diff --git a/daemon/remote.c b/daemon/remote.c index 35129aacd2c57f50caffc8b631a351204b701262..cda602f967fb3a6a4572bcc31854f75847de710b 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -893,36 +893,6 @@ cleanup: return rv; } -static int -remoteDispatchDomainCreateWithFlags(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_create_with_flags_args *args, - remote_domain_create_with_flags_ret *ret) -{ - int rv = -1; - virDomainPtr dom = NULL; - - if (!(dom = get_nonnull_domain(conn, args->dom))) - goto cleanup; - - if (virDomainCreateWithFlags(dom, args->flags) < 0) - goto cleanup; - - make_nonnull_domain(&ret->dom, dom); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (dom) - virDomainFree(dom); - return rv; -} - static int remoteDispatchDomainGetSecurityLabel(struct qemud_server *server ATTRIBUTE_UNUSED, struct qemud_client *client ATTRIBUTE_UNUSED, diff --git a/daemon/remote_generator.pl b/daemon/remote_generator.pl index d21f959fc59bab52f41ea51d6c8e309453ae18cf..b23e3b1909e169650719775d41e744138c06da7e 100755 --- a/daemon/remote_generator.pl +++ b/daemon/remote_generator.pl @@ -450,14 +450,22 @@ elsif ($opt_b) { } elsif ($ret_member =~ m/^remote_nonnull_(domain|network|storage_pool|storage_vol|interface|node_device|secret|nwfilter|domain_snapshot) (\S+);/) { my $type_name = name_to_ProcName($1); - push(@vars_list, "vir${type_name}Ptr $2 = NULL"); - push(@ret_list, "make_nonnull_$1(&ret->$2, $2);"); - push(@free_list, - " if ($2)\n" . - " vir${type_name}Free($2);"); - $single_ret_var = $2; - $single_ret_by_ref = 0; - $single_ret_check = " == NULL"; + if ($call->{ProcName} eq "DomainCreateWithFlags") { + # SPECIAL: virDomainCreateWithFlags updates the given + # domain object instead of returning a new one + push(@ret_list, "make_nonnull_$1(&ret->$2, $2);"); + $single_ret_var = undef; + $single_ret_by_ref = 1; + } else { + push(@vars_list, "vir${type_name}Ptr $2 = NULL"); + push(@ret_list, "make_nonnull_$1(&ret->$2, $2);"); + push(@free_list, + " if ($2)\n" . + " vir${type_name}Free($2);"); + $single_ret_var = $2; + $single_ret_by_ref = 0; + $single_ret_check = " == NULL"; + } } elsif ($ret_member =~ m/^int (\S+)<(\S+)>;/) { push(@vars_list, "int len"); push(@ret_list, "ret->$1.$1_len = len;"); @@ -679,7 +687,12 @@ elsif ($opt_b) { if ($single_ret_by_ref) { print " if (vir$prefix$proc_name("; print join(', ', @args_list); - print ", &$single_ret_var) < 0)\n"; + + if (defined $single_ret_var) { + print ", &$single_ret_var"; + } + + print ") < 0)\n"; } else { print " if (($single_ret_var = vir$prefix$proc_name("; print join(', ', @args_list); @@ -979,15 +992,25 @@ elsif ($opt_k) { $priv_name = "${name}PrivateData"; } - if ($name eq "domain_snapshot") { - push(@ret_list, "rv = get_nonnull_$name(dom, ret.$arg_name);"); + if ($call->{ProcName} eq "DomainCreateWithFlags") { + # SPECIAL: virDomainCreateWithFlags updates the given + # domain object instead of returning a new one + push(@ret_list, "dom->id = ret.dom.id;"); + push(@ret_list, "xdr_free((xdrproc_t)xdr_$call->{ret}, (char *)&ret);"); + push(@ret_list, "rv = 0;"); + $single_ret_var = "int rv = -1"; + $single_ret_type = "int"; } else { - push(@ret_list, "rv = get_nonnull_$name($priv_src, ret.$arg_name);"); - } + if ($name eq "domain_snapshot") { + push(@ret_list, "rv = get_nonnull_$name(dom, ret.$arg_name);"); + } else { + push(@ret_list, "rv = get_nonnull_$name($priv_src, ret.$arg_name);"); + } - push(@ret_list, "xdr_free((xdrproc_t)xdr_$call->{ret}, (char *)&ret);"); - $single_ret_var = "vir${type_name}Ptr rv = NULL"; - $single_ret_type = "vir${type_name}Ptr"; + push(@ret_list, "xdr_free((xdrproc_t)xdr_$call->{ret}, (char *)&ret);"); + $single_ret_var = "vir${type_name}Ptr rv = NULL"; + $single_ret_type = "vir${type_name}Ptr"; + } } elsif ($ret_member =~ m/^int (\S+);/) { my $arg_name = $1; diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 14f99082708a9b65be1392f95bf25fed9761bdb7..9c2fccb938f5370726ab4cf223ecf3dd6cf2ce7d 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -2440,38 +2440,6 @@ done: return rv; } -static int -remoteDomainCreateWithFlags (virDomainPtr domain, unsigned int flags) -{ - int rv = -1; - remote_domain_create_with_flags_args args; - remote_domain_create_with_flags_ret ret; - struct private_data *priv = domain->conn->privateData; - - remoteDriverLock(priv); - - make_nonnull_domain (&args.dom, domain); - args.flags = flags; - - memset (&ret, 0, sizeof ret); - if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS, - (xdrproc_t) xdr_remote_domain_create_with_flags_args, - (char *) &args, - (xdrproc_t) xdr_remote_domain_create_with_flags_ret, - (char *) &ret) == -1) - goto done; - - domain->id = ret.dom.id; - xdr_free ((xdrproc_t) &xdr_remote_domain_create_with_flags_ret, - (char *) &ret); - - rv = 0; - -done: - remoteDriverUnlock(priv); - return rv; -} - static char * remoteDomainGetSchedulerType (virDomainPtr domain, int *nparams) { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index d8c0e532d1791c88e3b0b267946d983be435f38c..9e2c42034650ca78116778431997815afbec7e70 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -2270,7 +2270,7 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_SNAPSHOT_DELETE = 193, /* autogen autogen */ 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, /* skipgen skipgen */ + REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS = 196, /* autogen autogen */ REMOTE_PROC_DOMAIN_SET_MEMORY_PARAMETERS = 197, /* skipgen skipgen */ REMOTE_PROC_DOMAIN_GET_MEMORY_PARAMETERS = 198, /* skipgen skipgen */ REMOTE_PROC_DOMAIN_SET_VCPUS_FLAGS = 199, /* autogen autogen */