mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
remote generator, daemon: Handle functions with optional arguments
This commit is contained in:
parent
0411030665
commit
9a74649cd2
130
daemon/remote.c
130
daemon/remote.c
@ -493,35 +493,6 @@ cleanup:
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
remoteDispatchGetMaxVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
||||||
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
||||||
virConnectPtr conn,
|
|
||||||
remote_message_header *hdr ATTRIBUTE_UNUSED,
|
|
||||||
remote_error *rerr,
|
|
||||||
remote_get_max_vcpus_args *args,
|
|
||||||
remote_get_max_vcpus_ret *ret)
|
|
||||||
{
|
|
||||||
char *type;
|
|
||||||
int rv = -1;
|
|
||||||
|
|
||||||
if (!conn) {
|
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
type = args->type ? *args->type : NULL;
|
|
||||||
if ((ret->max_vcpus = virConnectGetMaxVcpus(conn, type)) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
rv = 0;
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
if (rv < 0)
|
|
||||||
remoteDispatchError(rerr);
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
remoteDispatchNodeGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
|
remoteDispatchNodeGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
|
||||||
struct qemud_client *client ATTRIBUTE_UNUSED,
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
||||||
@ -1359,46 +1330,6 @@ cleanup:
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
remoteDispatchDomainMigratePerform(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_migrate_perform_args *args,
|
|
||||||
void *ret ATTRIBUTE_UNUSED)
|
|
||||||
{
|
|
||||||
virDomainPtr dom = NULL;
|
|
||||||
char *dname;
|
|
||||||
int rv = -1;
|
|
||||||
|
|
||||||
if (!conn) {
|
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(dom = get_nonnull_domain(conn, args->dom)))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
dname = args->dname == NULL ? NULL : *args->dname;
|
|
||||||
|
|
||||||
if (virDomainMigratePerform(dom,
|
|
||||||
args->cookie.cookie_val,
|
|
||||||
args->cookie.cookie_len,
|
|
||||||
args->uri,
|
|
||||||
args->flags, dname, args->resource) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
rv = 0;
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
if (rv < 0)
|
|
||||||
remoteDispatchError(rerr);
|
|
||||||
if (dom)
|
|
||||||
virDomainFree(dom);
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED,
|
remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED,
|
||||||
struct qemud_client *client ATTRIBUTE_UNUSED,
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
||||||
@ -3139,37 +3070,6 @@ cleanup:
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
remoteDispatchFindStoragePoolSources(struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
||||||
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
||||||
virConnectPtr conn,
|
|
||||||
remote_message_header *hdr ATTRIBUTE_UNUSED,
|
|
||||||
remote_error *rerr,
|
|
||||||
remote_find_storage_pool_sources_args *args,
|
|
||||||
remote_find_storage_pool_sources_ret *ret)
|
|
||||||
{
|
|
||||||
int rv = -1;
|
|
||||||
|
|
||||||
if (!conn) {
|
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(ret->xml =
|
|
||||||
virConnectFindStoragePoolSources(conn,
|
|
||||||
args->type,
|
|
||||||
args->srcSpec ? *args->srcSpec : NULL,
|
|
||||||
args->flags)))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
rv = 0;
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
if (rv < 0)
|
|
||||||
remoteDispatchError(rerr);
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
remoteDispatchStoragePoolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
|
remoteDispatchStoragePoolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
|
||||||
struct qemud_client *client ATTRIBUTE_UNUSED,
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
||||||
@ -3307,36 +3207,6 @@ cleanup:
|
|||||||
* NODE INFO APIS
|
* NODE INFO APIS
|
||||||
**************************************************************/
|
**************************************************************/
|
||||||
|
|
||||||
static int
|
|
||||||
remoteDispatchNodeNumOfDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
||||||
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
||||||
virConnectPtr conn,
|
|
||||||
remote_message_header *hdr ATTRIBUTE_UNUSED,
|
|
||||||
remote_error *rerr,
|
|
||||||
remote_node_num_of_devices_args *args,
|
|
||||||
remote_node_num_of_devices_ret *ret)
|
|
||||||
{
|
|
||||||
int rv = -1;
|
|
||||||
|
|
||||||
if (!conn) {
|
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ret->num = virNodeNumOfDevices(conn,
|
|
||||||
args->cap ? *args->cap : NULL,
|
|
||||||
args->flags)) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
rv = 0;
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
if (rv < 0)
|
|
||||||
remoteDispatchError(rerr);
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
remoteDispatchNodeListDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
|
remoteDispatchNodeListDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
|
||||||
struct qemud_client *client ATTRIBUTE_UNUSED,
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
||||||
|
@ -1017,7 +1017,42 @@ cleanup:
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remoteDispatchDomainMigratePerform has to be implemented manually */
|
static int
|
||||||
|
remoteDispatchDomainMigratePerform(
|
||||||
|
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_migrate_perform_args *args,
|
||||||
|
void *ret ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
int rv = -1;
|
||||||
|
virDomainPtr dom = NULL;
|
||||||
|
char *dname;
|
||||||
|
|
||||||
|
if (!conn) {
|
||||||
|
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(dom = get_nonnull_domain(conn, args->dom)))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
dname = args->dname ? *args->dname : NULL;
|
||||||
|
|
||||||
|
if (virDomainMigratePerform(dom, args->cookie.cookie_val, args->cookie.cookie_len, args->uri, args->flags, dname, args->resource) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
rv = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
if (rv < 0)
|
||||||
|
remoteDispatchError(rerr);
|
||||||
|
if (dom)
|
||||||
|
virDomainFree(dom);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
/* remoteDispatchDomainMigratePrepare has to be implemented manually */
|
/* remoteDispatchDomainMigratePrepare has to be implemented manually */
|
||||||
|
|
||||||
@ -1907,7 +1942,38 @@ cleanup:
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remoteDispatchFindStoragePoolSources has to be implemented manually */
|
static int
|
||||||
|
remoteDispatchFindStoragePoolSources(
|
||||||
|
struct qemud_server *server ATTRIBUTE_UNUSED,
|
||||||
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
||||||
|
virConnectPtr conn,
|
||||||
|
remote_message_header *hdr ATTRIBUTE_UNUSED,
|
||||||
|
remote_error *rerr,
|
||||||
|
remote_find_storage_pool_sources_args *args,
|
||||||
|
remote_find_storage_pool_sources_ret *ret)
|
||||||
|
{
|
||||||
|
int rv = -1;
|
||||||
|
char *srcSpec;
|
||||||
|
char *xml;
|
||||||
|
|
||||||
|
if (!conn) {
|
||||||
|
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
srcSpec = args->srcSpec ? *args->srcSpec : NULL;
|
||||||
|
|
||||||
|
if ((xml = virConnectFindStoragePoolSources(conn, args->type, srcSpec, args->flags)) == NULL)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
ret->xml = xml;
|
||||||
|
rv = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
if (rv < 0)
|
||||||
|
remoteDispatchError(rerr);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
remoteDispatchGetCapabilities(
|
remoteDispatchGetCapabilities(
|
||||||
@ -1999,7 +2065,38 @@ cleanup:
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remoteDispatchGetMaxVcpus has to be implemented manually */
|
static int
|
||||||
|
remoteDispatchGetMaxVcpus(
|
||||||
|
struct qemud_server *server ATTRIBUTE_UNUSED,
|
||||||
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
||||||
|
virConnectPtr conn,
|
||||||
|
remote_message_header *hdr ATTRIBUTE_UNUSED,
|
||||||
|
remote_error *rerr,
|
||||||
|
remote_get_max_vcpus_args *args,
|
||||||
|
remote_get_max_vcpus_ret *ret)
|
||||||
|
{
|
||||||
|
int rv = -1;
|
||||||
|
char *type;
|
||||||
|
int max_vcpus;
|
||||||
|
|
||||||
|
if (!conn) {
|
||||||
|
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
type = args->type ? *args->type : NULL;
|
||||||
|
|
||||||
|
if ((max_vcpus = virConnectGetMaxVcpus(conn, type)) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
ret->max_vcpus = max_vcpus;
|
||||||
|
rv = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
if (rv < 0)
|
||||||
|
remoteDispatchError(rerr);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
remoteDispatchGetSysinfo(
|
remoteDispatchGetSysinfo(
|
||||||
@ -3171,7 +3268,38 @@ cleanup:
|
|||||||
|
|
||||||
/* remoteDispatchNodeListDevices has to be implemented manually */
|
/* remoteDispatchNodeListDevices has to be implemented manually */
|
||||||
|
|
||||||
/* remoteDispatchNodeNumOfDevices has to be implemented manually */
|
static int
|
||||||
|
remoteDispatchNodeNumOfDevices(
|
||||||
|
struct qemud_server *server ATTRIBUTE_UNUSED,
|
||||||
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
||||||
|
virConnectPtr conn,
|
||||||
|
remote_message_header *hdr ATTRIBUTE_UNUSED,
|
||||||
|
remote_error *rerr,
|
||||||
|
remote_node_num_of_devices_args *args,
|
||||||
|
remote_node_num_of_devices_ret *ret)
|
||||||
|
{
|
||||||
|
int rv = -1;
|
||||||
|
char *cap;
|
||||||
|
int num;
|
||||||
|
|
||||||
|
if (!conn) {
|
||||||
|
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
cap = args->cap ? *args->cap : NULL;
|
||||||
|
|
||||||
|
if ((num = virNodeNumOfDevices(conn, cap, args->flags)) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
ret->num = num;
|
||||||
|
rv = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
if (rv < 0)
|
||||||
|
remoteDispatchError(rerr);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
remoteDispatchNumOfDefinedDomains(
|
remoteDispatchNumOfDefinedDomains(
|
||||||
|
@ -241,7 +241,6 @@ elsif ($opt_b) {
|
|||||||
@ungeneratable = ("Close",
|
@ungeneratable = ("Close",
|
||||||
"DomainEventsDeregisterAny",
|
"DomainEventsDeregisterAny",
|
||||||
"DomainEventsRegisterAny",
|
"DomainEventsRegisterAny",
|
||||||
"DomainMigratePerform",
|
|
||||||
"DomainMigratePrepareTunnel",
|
"DomainMigratePrepareTunnel",
|
||||||
"DomainOpenConsole",
|
"DomainOpenConsole",
|
||||||
"DomainPinVcpu",
|
"DomainPinVcpu",
|
||||||
@ -280,8 +279,6 @@ elsif ($opt_b) {
|
|||||||
"DomainMigratePrepare",
|
"DomainMigratePrepare",
|
||||||
"DomainMigratePrepare2",
|
"DomainMigratePrepare2",
|
||||||
"DomainSnapshotListNames",
|
"DomainSnapshotListNames",
|
||||||
"FindStoragePoolSources",
|
|
||||||
"GetMaxVcpus",
|
|
||||||
"GetType",
|
"GetType",
|
||||||
"ListDefinedDomains",
|
"ListDefinedDomains",
|
||||||
"ListDefinedInterfaces",
|
"ListDefinedInterfaces",
|
||||||
@ -299,7 +296,6 @@ elsif ($opt_b) {
|
|||||||
"NodeGetInfo",
|
"NodeGetInfo",
|
||||||
"NodeGetSecurityModel",
|
"NodeGetSecurityModel",
|
||||||
"NodeListDevices",
|
"NodeListDevices",
|
||||||
"NodeNumOfDevices",
|
|
||||||
"SecretGetValue",
|
"SecretGetValue",
|
||||||
"StoragePoolGetInfo",
|
"StoragePoolGetInfo",
|
||||||
"StoragePoolListVolumes",
|
"StoragePoolListVolumes",
|
||||||
@ -348,6 +344,7 @@ elsif ($opt_b) {
|
|||||||
|
|
||||||
my $has_node_device = 0;
|
my $has_node_device = 0;
|
||||||
my @vars_list = ();
|
my @vars_list = ();
|
||||||
|
my @optionals_list = ();
|
||||||
my @getters_list = ();
|
my @getters_list = ();
|
||||||
my @args_list = ();
|
my @args_list = ();
|
||||||
my @ret_list = ();
|
my @ret_list = ();
|
||||||
@ -470,6 +467,10 @@ elsif ($opt_b) {
|
|||||||
|
|
||||||
if ($1 eq "remote_uuid") {
|
if ($1 eq "remote_uuid") {
|
||||||
push(@args_list, "(unsigned char *) args->$2");
|
push(@args_list, "(unsigned char *) args->$2");
|
||||||
|
} elsif ($1 eq "remote_string") {
|
||||||
|
push(@vars_list, "char *$2");
|
||||||
|
push(@optionals_list, "$2");
|
||||||
|
push(@args_list, "$2");
|
||||||
} else {
|
} else {
|
||||||
push(@args_list, "args->$2");
|
push(@args_list, "args->$2");
|
||||||
}
|
}
|
||||||
@ -619,6 +620,14 @@ elsif ($opt_b) {
|
|||||||
print "\n";
|
print "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach my $optional (@optionals_list) {
|
||||||
|
print " $optional = args->$optional ? *args->$optional : NULL;\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (@optionals_list) {
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
|
||||||
if ($calls{$_}->{ret} eq "void") {
|
if ($calls{$_}->{ret} eq "void") {
|
||||||
print " if (vir$calls{$_}->{ProcName}(";
|
print " if (vir$calls{$_}->{ProcName}(";
|
||||||
print join(', ', @args_list);
|
print join(', ', @args_list);
|
||||||
@ -638,8 +647,10 @@ elsif ($opt_b) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($calls{$_}->{ProcName} eq "GetSysinfo" or
|
if ($calls{$_}->{ProcName} eq "GetSysinfo" or
|
||||||
|
$calls{$_}->{ProcName} eq "GetMaxVcpus" or
|
||||||
$calls{$_}->{ProcName} eq "DomainXMLFromNative" or
|
$calls{$_}->{ProcName} eq "DomainXMLFromNative" or
|
||||||
$calls{$_}->{ProcName} eq "DomainXMLToNative") {
|
$calls{$_}->{ProcName} eq "DomainXMLToNative" or
|
||||||
|
$calls{$_}->{ProcName} eq "FindStoragePoolSources") {
|
||||||
$prefix = "Connect"
|
$prefix = "Connect"
|
||||||
} elsif ($calls{$_}->{ProcName} eq "SupportsFeature") {
|
} elsif ($calls{$_}->{ProcName} eq "SupportsFeature") {
|
||||||
$prefix = "Drv"
|
$prefix = "Drv"
|
||||||
|
Loading…
Reference in New Issue
Block a user