1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

remote generator: Handle virDomainCreateWithFlags

Add special case code for updating a given domain object instead of
returning a new one.
This commit is contained in:
Matthias Bolte 2011-05-20 17:58:34 +02:00
parent 6df05081cb
commit a125f82ff4
4 changed files with 40 additions and 79 deletions

View File

@ -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,

View File

@ -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;

View File

@ -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)
{

View File

@ -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 */