diff --git a/daemon/remote.c b/daemon/remote.c index 64478cc7a2..2a32ee8291 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -784,92 +784,6 @@ no_memory: goto cleanup; } -static int -remoteDispatchDomainSetSchedulerParameters(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_domain_set_scheduler_parameters_args *args, - void *ret ATTRIBUTE_UNUSED) -{ - virDomainPtr dom = NULL; - virTypedParameterPtr params = NULL; - int nparams; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - nparams = args->params.params_len; - - if ((params = remoteDeserializeTypedParameters(args->params.params_val, - args->params.params_len, - REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX, - &nparams)) == NULL) - goto cleanup; - - if (!(dom = get_nonnull_domain(conn, args->dom))) - goto cleanup; - - if (virDomainSetSchedulerParameters(dom, params, nparams) < 0) - goto cleanup; - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (dom) - virDomainFree(dom); - VIR_FREE(params); - return rv; -} - -static int -remoteDispatchDomainSetSchedulerParametersFlags(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_domain_set_scheduler_parameters_flags_args *args, - void *ret ATTRIBUTE_UNUSED) -{ - virDomainPtr dom = NULL; - virTypedParameterPtr params = NULL; - int nparams; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if ((params = remoteDeserializeTypedParameters(args->params.params_val, - args->params.params_len, - REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX, - &nparams)) == NULL) - goto cleanup; - - if (!(dom = get_nonnull_domain(conn, args->dom))) - goto cleanup; - - if (virDomainSetSchedulerParametersFlags(dom, params, nparams, args->flags) < 0) - goto cleanup; - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (dom) - virDomainFree(dom); - VIR_FREE(params); - return rv; -} - static int remoteDispatchDomainMemoryStats(struct qemud_server *server ATTRIBUTE_UNUSED, struct qemud_client *client ATTRIBUTE_UNUSED, @@ -1362,54 +1276,6 @@ cleanup: return rv; } -static int -remoteDispatchDomainSetMemoryParameters(struct qemud_server *server - ATTRIBUTE_UNUSED, - struct qemud_client *client - ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header * - hdr ATTRIBUTE_UNUSED, - remote_error * rerr, - remote_domain_set_memory_parameters_args - * args, void *ret ATTRIBUTE_UNUSED) -{ - virDomainPtr dom = NULL; - virTypedParameterPtr params = NULL; - int nparams; - unsigned int flags; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - flags = args->flags; - - if ((params = remoteDeserializeTypedParameters(args->params.params_val, - args->params.params_len, - REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX, - &nparams)) == NULL) - goto cleanup; - - if (!(dom = get_nonnull_domain(conn, args->dom))) - goto cleanup; - - if (virDomainSetMemoryParameters(dom, params, nparams, flags) < 0) - goto cleanup; - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - VIR_FREE(params); - if (dom) - virDomainFree(dom); - return rv; -} - static int remoteDispatchDomainGetMemoryParameters(struct qemud_server *server ATTRIBUTE_UNUSED, @@ -1477,54 +1343,6 @@ cleanup: return rv; } -static int -remoteDispatchDomainSetBlkioParameters(struct qemud_server *server - ATTRIBUTE_UNUSED, - struct qemud_client *client - ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header * - hdr ATTRIBUTE_UNUSED, - remote_error * rerr, - remote_domain_set_blkio_parameters_args - * args, void *ret ATTRIBUTE_UNUSED) -{ - virDomainPtr dom = NULL; - virTypedParameterPtr params = NULL; - int nparams; - unsigned int flags; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - flags = args->flags; - - if ((params = remoteDeserializeTypedParameters(args->params.params_val, - args->params.params_len, - REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX, - &nparams)) == NULL) - goto cleanup; - - if (!(dom = get_nonnull_domain(conn, args->dom))) - goto cleanup; - - if (virDomainSetBlkioParameters(dom, params, nparams, flags) < 0) - goto cleanup; - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - VIR_FREE(params); - if (dom) - virDomainFree(dom); - return rv; -} - static int remoteDispatchDomainGetBlkioParameters(struct qemud_server *server ATTRIBUTE_UNUSED, diff --git a/daemon/remote_generator.pl b/daemon/remote_generator.pl index f85cc6b04b..e204b76699 100755 --- a/daemon/remote_generator.pl +++ b/daemon/remote_generator.pl @@ -407,6 +407,17 @@ elsif ($opt_b) { } push(@args_list, "args->$2.$2_len"); + } elsif ($args_member =~ m/^remote_typed_param (\S+)<(\S+)>;/) { + push(@vars_list, "virTypedParameterPtr $1 = NULL"); + push(@vars_list, "int n$1"); + push(@args_list, "$1"); + push(@args_list, "n$1"); + push(@getters_list, " if (($1 = remoteDeserializeTypedParameters(args->$1.$1_val,\n" . + " args->$1.$1_len,\n" . + " $2,\n" . + " &n$1)) == NULL)\n" . + " goto cleanup;\n"); + push(@free_list, " VIR_FREE(params);"); } elsif ($args_member =~ m/<\S+>;/ or $args_member =~ m/\[\S+\];/) { # just make all other array types fail die "unhandled type for argument value: $args_member"; @@ -893,6 +904,7 @@ elsif ($opt_k) { my @vars_list = (); my @args_check_list = (); my @setters_list = (); + my @setters_list2 = (); my $priv_src = "conn"; my $priv_name = "privateData"; my $call_args = "&args"; @@ -973,6 +985,19 @@ elsif ($opt_k) { push(@setters_list, "args.$arg_name.${arg_name}_val = (char *)$arg_name;"); push(@setters_list, "args.$arg_name.${arg_name}_len = ${arg_name}len;"); push(@args_check_list, { name => "\"$arg_name\"", arg => "${arg_name}len", limit => $limit }); + } elsif ($args_member =~ m/^remote_typed_param (\S+)<(\S+)>;/) { + push(@args_list, "virTypedParameterPtr $1"); + push(@args_list, "int n$1"); + push(@setters_list2, "if (remoteSerializeTypedParameters($1, n$1, &args.$1.$1_val, &args.$1.$1_len) < 0) {\n" . + " xdr_free((xdrproc_t)xdr_$call->{args}, (char *)&args);\n" . + " goto done;\n" . + " }"); + } elsif ($args_member =~ m/^(unsigned )?int (\S+);\s*\/\*\s*call-by-reference\s*\*\//) { + my $type_name = $1; $type_name .= "int *"; + my $arg_name = $2; + + push(@args_list, "$type_name $arg_name"); + push(@setters_list, "args.$arg_name = *$arg_name;"); } elsif ($args_member =~ m/^(unsigned )?int (\S+);/) { my $type_name = $1; $type_name .= "int"; my $arg_name = $2; @@ -1021,6 +1046,7 @@ elsif ($opt_k) { # handle return values of the function my @ret_list = (); + my @ret_list2 = (); my $call_ret = "&ret"; my $single_ret_var = "int rv = -1"; my $single_ret_type = "int"; @@ -1029,6 +1055,7 @@ elsif ($opt_k) { my $single_ret_list_name = "undefined"; my $single_ret_list_max_var = "undefined"; my $single_ret_list_max_define = "undefined"; + my $single_ret_cleanup = 0; my $multi_ret = 0; if ($call->{ret} ne "void" and @@ -1118,6 +1145,18 @@ elsif ($opt_k) { $single_ret_var = "vir${type_name}Ptr rv = NULL"; $single_ret_type = "vir${type_name}Ptr"; } + } elsif ($ret_member =~ m/^remote_typed_param (\S+)<(\S+)>;\s*\/\*\s*insert@(\d+)\s*\*\//) { + splice(@args_list, int($3), 0, ("virTypedParameterPtr $1")); + push(@ret_list2, "if (remoteDeserializeTypedParameters(ret.$1.$1_val,\n" . + " ret.$1.$1_len,\n" . + " $2,\n" . + " $1,\n" . + " n$1) < 0)\n" . + " goto cleanup;\n"); + $single_ret_cleanup = 1; + } elsif ($ret_member =~ m/^remote_typed_param (\S+)<\S+>;/) { + # error out on unannotated arrays + die "remote_typed_param array without insert@ annotation: $ret_member"; } elsif ($ret_member =~ m/^int (\S+);/) { my $arg_name = $1; @@ -1257,6 +1296,17 @@ elsif ($opt_k) { print "\n"; } + if (@setters_list2) { + print "\n"; + print " "; + } + + print join("\n ", @setters_list2); + + if (@setters_list2) { + print "\n"; + } + if ($call->{ret} ne "void") { print "\n"; print " memset(&ret, 0, sizeof ret);\n"; @@ -1301,6 +1351,12 @@ elsif ($opt_k) { print "\n"; } + if (@ret_list2) { + print " "; + print join("\n ", @ret_list2); + print "\n"; + } + if (@ret_list) { print " "; print join("\n ", @ret_list); @@ -1316,7 +1372,7 @@ elsif ($opt_k) { print " rv = 0;\n"; } - if ($single_ret_as_list) { + if ($single_ret_as_list or $single_ret_cleanup) { print "\n"; print "cleanup:\n"; print " xdr_free((xdrproc_t)xdr_remote_$call->{name}_ret, (char *)&ret);\n"; diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index ac0c6f7aef..14c3d2414c 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -1915,42 +1915,6 @@ cleanup: return rv; } -static int -remoteDomainSetMemoryParameters (virDomainPtr domain, - virTypedParameterPtr params, - int nparams, - unsigned int flags) -{ - int rv = -1; - remote_domain_set_memory_parameters_args args; - struct private_data *priv = domain->conn->privateData; - - remoteDriverLock(priv); - - make_nonnull_domain (&args.dom, domain); - - args.flags = flags; - - if (remoteSerializeTypedParameters(params, nparams, - &args.params.params_val, - &args.params.params_len) < 0) { - xdr_free ((xdrproc_t) xdr_remote_domain_set_memory_parameters_args, - (char *) &args); - goto done; - } - - if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_SET_MEMORY_PARAMETERS, - (xdrproc_t) xdr_remote_domain_set_memory_parameters_args, - (char *) &args, (xdrproc_t) xdr_void, (char *) NULL) == -1) - goto done; - - rv = 0; - -done: - remoteDriverUnlock(priv); - return rv; -} - static int remoteDomainGetMemoryParameters (virDomainPtr domain, virTypedParameterPtr params, int *nparams, @@ -1999,42 +1963,6 @@ done: return rv; } -static int -remoteDomainSetBlkioParameters (virDomainPtr domain, - virTypedParameterPtr params, - int nparams, - unsigned int flags) -{ - int rv = -1; - remote_domain_set_blkio_parameters_args args; - struct private_data *priv = domain->conn->privateData; - - remoteDriverLock(priv); - - make_nonnull_domain (&args.dom, domain); - - args.flags = flags; - - if (remoteSerializeTypedParameters(params, nparams, - &args.params.params_val, - &args.params.params_len) < 0) { - xdr_free ((xdrproc_t) xdr_remote_domain_set_blkio_parameters_args, - (char *) &args); - goto done; - } - - if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_SET_BLKIO_PARAMETERS, - (xdrproc_t) xdr_remote_domain_set_blkio_parameters_args, - (char *) &args, (xdrproc_t) xdr_void, (char *) NULL) == -1) - goto done; - - rv = 0; - -done: - remoteDriverUnlock(priv); - return rv; -} - static int remoteDomainGetBlkioParameters (virDomainPtr domain, virTypedParameterPtr params, int *nparams, @@ -2434,149 +2362,6 @@ done: return rv; } -static int -remoteDomainGetSchedulerParameters (virDomainPtr domain, - virTypedParameterPtr params, int *nparams) -{ - int rv = -1; - remote_domain_get_scheduler_parameters_args args; - remote_domain_get_scheduler_parameters_ret ret; - struct private_data *priv = domain->conn->privateData; - - remoteDriverLock(priv); - - make_nonnull_domain (&args.dom, domain); - args.nparams = *nparams; - - memset (&ret, 0, sizeof ret); - if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_SCHEDULER_PARAMETERS, - (xdrproc_t) xdr_remote_domain_get_scheduler_parameters_args, (char *) &args, - (xdrproc_t) xdr_remote_domain_get_scheduler_parameters_ret, (char *) &ret) == -1) - goto done; - - if (remoteDeserializeTypedParameters(ret.params.params_val, - ret.params.params_len, - REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX, - params, - nparams) < 0) - goto cleanup; - - rv = 0; - -cleanup: - xdr_free ((xdrproc_t) xdr_remote_domain_get_scheduler_parameters_ret, (char *) &ret); -done: - remoteDriverUnlock(priv); - return rv; -} - -static int -remoteDomainGetSchedulerParametersFlags (virDomainPtr domain, - virTypedParameterPtr params, - int *nparams, - unsigned int flags) -{ - int rv = -1; - remote_domain_get_scheduler_parameters_flags_args args; - remote_domain_get_scheduler_parameters_flags_ret ret; - struct private_data *priv = domain->conn->privateData; - - remoteDriverLock(priv); - - make_nonnull_domain (&args.dom, domain); - args.nparams = *nparams; - args.flags = flags; - - memset (&ret, 0, sizeof ret); - if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_SCHEDULER_PARAMETERS_FLAGS, - (xdrproc_t) xdr_remote_domain_get_scheduler_parameters_flags_args, (char *) &args, - (xdrproc_t) xdr_remote_domain_get_scheduler_parameters_flags_ret, (char *) &ret) == -1) - goto done; - - if (remoteDeserializeTypedParameters(ret.params.params_val, - ret.params.params_len, - REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX, - params, - nparams) < 0) - goto cleanup; - - rv = 0; - -cleanup: - xdr_free ((xdrproc_t) xdr_remote_domain_get_scheduler_parameters_flags_ret, (char *) &ret); -done: - remoteDriverUnlock(priv); - return rv; -} - -static int -remoteDomainSetSchedulerParameters (virDomainPtr domain, - virTypedParameterPtr params, int nparams) -{ - int rv = -1; - remote_domain_set_scheduler_parameters_args args; - struct private_data *priv = domain->conn->privateData; - - remoteDriverLock(priv); - - make_nonnull_domain (&args.dom, domain); - - if (remoteSerializeTypedParameters(params, nparams, - &args.params.params_val, - &args.params.params_len) < 0) { - xdr_free ((xdrproc_t) xdr_remote_domain_set_scheduler_parameters_args, - (char *) &args); - goto done; - } - - if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_SET_SCHEDULER_PARAMETERS, - (xdrproc_t) xdr_remote_domain_set_scheduler_parameters_args, (char *) &args, - (xdrproc_t) xdr_void, (char *) NULL) == -1) - goto done; - - rv = 0; - -done: - remoteDriverUnlock(priv); - return rv; -} - -static int -remoteDomainSetSchedulerParametersFlags(virDomainPtr domain, - virTypedParameterPtr params, - int nparams, - unsigned int flags) -{ - int rv = -1; - remote_domain_set_scheduler_parameters_flags_args args; - struct private_data *priv = domain->conn->privateData; - - remoteDriverLock(priv); - - make_nonnull_domain (&args.dom, domain); - - args.flags = flags; - - if (remoteSerializeTypedParameters(params, nparams, - &args.params.params_val, - &args.params.params_len) < 0) { - xdr_free ((xdrproc_t) xdr_remote_domain_set_scheduler_parameters_flags_args, - (char *) &args); - goto done; - } - - if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_SET_SCHEDULER_PARAMETERS_FLAGS, - (xdrproc_t) xdr_remote_domain_set_scheduler_parameters_flags_args, (char *) &args, - (xdrproc_t) xdr_void, (char *) NULL) == -1) - goto done; - - rv = 0; - -done: - remoteDriverUnlock(priv); - return rv; -} - static int remoteDomainMemoryStats (virDomainPtr domain, struct _virDomainMemoryStat *stats, diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 0602c2766f..c9b8cff6ff 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -427,21 +427,21 @@ struct remote_domain_get_scheduler_type_ret { struct remote_domain_get_scheduler_parameters_args { remote_nonnull_domain dom; - int nparams; + int nparams; /* call-by-reference */ }; struct remote_domain_get_scheduler_parameters_ret { - remote_typed_param params; + remote_typed_param params; /* insert@1 */ }; struct remote_domain_get_scheduler_parameters_flags_args { remote_nonnull_domain dom; - int nparams; + int nparams; /* call-by-reference */ unsigned int flags; }; struct remote_domain_get_scheduler_parameters_flags_ret { - remote_typed_param params; + remote_typed_param params; /* insert@1 */ }; struct remote_domain_set_scheduler_parameters_args { @@ -2113,8 +2113,8 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_RESTORE = 54, /* autogen autogen */ REMOTE_PROC_DOMAIN_SAVE = 55, /* autogen autogen */ REMOTE_PROC_DOMAIN_GET_SCHEDULER_TYPE = 56, /* skipgen skipgen */ - REMOTE_PROC_DOMAIN_GET_SCHEDULER_PARAMETERS = 57, /* skipgen skipgen */ - REMOTE_PROC_DOMAIN_SET_SCHEDULER_PARAMETERS = 58, /* skipgen skipgen */ + REMOTE_PROC_DOMAIN_GET_SCHEDULER_PARAMETERS = 57, /* skipgen autogen */ + REMOTE_PROC_DOMAIN_SET_SCHEDULER_PARAMETERS = 58, /* autogen autogen */ REMOTE_PROC_GET_HOSTNAME = 59, /* autogen autogen */ REMOTE_PROC_SUPPORTS_FEATURE = 60, /* autogen autogen */ @@ -2267,7 +2267,7 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_GET_BLOCK_INFO = 194, /* autogen autogen */ REMOTE_PROC_DOMAIN_EVENT_IO_ERROR_REASON = 195, /* autogen autogen */ REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS = 196, /* autogen autogen */ - REMOTE_PROC_DOMAIN_SET_MEMORY_PARAMETERS = 197, /* skipgen skipgen */ + REMOTE_PROC_DOMAIN_SET_MEMORY_PARAMETERS = 197, /* autogen autogen */ REMOTE_PROC_DOMAIN_GET_MEMORY_PARAMETERS = 198, /* skipgen skipgen */ REMOTE_PROC_DOMAIN_SET_VCPUS_FLAGS = 199, /* autogen autogen */ REMOTE_PROC_DOMAIN_GET_VCPUS_FLAGS = 200, /* autogen autogen */ @@ -2276,7 +2276,7 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_IS_UPDATED = 202, /* autogen autogen */ REMOTE_PROC_GET_SYSINFO = 203, /* autogen autogen */ REMOTE_PROC_DOMAIN_SET_MEMORY_FLAGS = 204, /* autogen autogen */ - REMOTE_PROC_DOMAIN_SET_BLKIO_PARAMETERS = 205, /* skipgen skipgen */ + REMOTE_PROC_DOMAIN_SET_BLKIO_PARAMETERS = 205, /* autogen autogen */ REMOTE_PROC_DOMAIN_GET_BLKIO_PARAMETERS = 206, /* skipgen skipgen */ REMOTE_PROC_DOMAIN_MIGRATE_SET_MAX_SPEED = 207, /* autogen autogen */ REMOTE_PROC_STORAGE_VOL_UPLOAD = 208, /* autogen autogen | writestream@1 */ @@ -2291,12 +2291,12 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_MIGRATE_PERFORM3 = 216, /* skipgen skipgen */ REMOTE_PROC_DOMAIN_MIGRATE_FINISH3 = 217, /* skipgen skipgen */ REMOTE_PROC_DOMAIN_MIGRATE_CONFIRM3 = 218, /* skipgen skipgen */ - REMOTE_PROC_DOMAIN_SET_SCHEDULER_PARAMETERS_FLAGS = 219, /* skipgen skipgen */ + REMOTE_PROC_DOMAIN_SET_SCHEDULER_PARAMETERS_FLAGS = 219, /* autogen autogen */ REMOTE_PROC_INTERFACE_CHANGE_BEGIN = 220, /* autogen autogen */ REMOTE_PROC_INTERFACE_CHANGE_COMMIT = 221, /* autogen autogen */ REMOTE_PROC_INTERFACE_CHANGE_ROLLBACK = 222, /* autogen autogen */ - REMOTE_PROC_DOMAIN_GET_SCHEDULER_PARAMETERS_FLAGS = 223, /* skipgen skipgen */ + REMOTE_PROC_DOMAIN_GET_SCHEDULER_PARAMETERS_FLAGS = 223, /* skipgen autogen */ REMOTE_PROC_DOMAIN_EVENT_CONTROL_ERROR = 224 /* skipgen skipgen */ /*