remote generator, client: Handle functions with optional return values

This commit is contained in:
Matthias Bolte 2011-04-23 23:03:44 +02:00
parent abd05a07ae
commit 58b6a5c49e
3 changed files with 151 additions and 148 deletions

View File

@ -476,9 +476,7 @@ elsif ($opt_b) {
push(@ret_list, "ret->$1 = $1;"); push(@ret_list, "ret->$1 = $1;");
$single_ret_var = $1; $single_ret_var = $1;
if ($calls{$_}->{ProcName} eq "DomainGetAutostart" or if ($calls{$_}->{ProcName} =~ m/GetAutostart$/) {
$calls{$_}->{ProcName} eq "NetworkGetAutostart" or
$calls{$_}->{ProcName} eq "StoragePoolGetAutostart") {
$single_ret_by_ref = 1; $single_ret_by_ref = 1;
} else { } else {
$single_ret_by_ref = 0; $single_ret_by_ref = 0;
@ -756,15 +754,12 @@ elsif ($opt_k) {
"CPUBaseline", "CPUBaseline",
"DomainCreate", "DomainCreate",
"DomainDestroy", "DomainDestroy",
"DomainGetAutostart",
"DomainMigrateFinish", "DomainMigrateFinish",
"NWFilterDefineXML", # public API and XDR protocol mismatch "NWFilterDefineXML", # public API and XDR protocol mismatch
"DomainMigratePerform", "DomainMigratePerform",
"DomainMigrateFinish2", "DomainMigrateFinish2",
"DomainSnapshotListNames", "DomainSnapshotListNames",
"GetLibVersion",
"FindStoragePoolSources", "FindStoragePoolSources",
"GetVersion",
"IsSecure", "IsSecure",
"ListDefinedDomains", "ListDefinedDomains",
"ListDefinedInterfaces", "ListDefinedInterfaces",
@ -776,8 +771,6 @@ elsif ($opt_k) {
"StoragePoolListVolumes", "StoragePoolListVolumes",
"ListDomains", "ListDomains",
"ListStoragePools", "ListStoragePools",
"NetworkGetAutostart",
"StoragePoolGetAutostart",
"SecretSetValue", "SecretSetValue",
"GetURI", "GetURI",
"ListInterfaces", "ListInterfaces",
@ -998,18 +991,37 @@ elsif ($opt_k) {
$single_ret_var = "vir${type_name}Ptr rv = NULL"; $single_ret_var = "vir${type_name}Ptr rv = NULL";
$single_ret_type = "vir${type_name}Ptr"; $single_ret_type = "vir${type_name}Ptr";
} elsif ($ret_member =~ m/^int (\S+);/) { } elsif ($ret_member =~ m/^int (\S+);/) {
push(@ret_list, "rv = ret.$1;"); my $arg_name = $1;
if ($call->{ProcName} =~ m/GetAutostart$/) {
push(@args_list, "int *$arg_name");
push(@ret_list, "if ($arg_name) *$arg_name = ret.$arg_name;");
push(@ret_list, "rv = 0;");
} else {
push(@ret_list, "rv = ret.$arg_name;");
}
$single_ret_var = "int rv = -1"; $single_ret_var = "int rv = -1";
$single_ret_type = "int"; $single_ret_type = "int";
} elsif ($ret_member =~ m/hyper (\S+);/) { } elsif ($ret_member =~ m/hyper (\S+);/) {
push(@ret_list, "rv = ret.$1;"); my $arg_name = $1;
if ($call->{ProcName} eq "NodeGetFreeMemory") { if ($call->{ProcName} =~ m/Get(Lib)?Version/) {
$single_ret_var = "unsigned long long rv = 0"; push(@args_list, "unsigned long *$arg_name");
$single_ret_type = "unsigned long long"; push(@ret_list, "if ($arg_name) *$arg_name = ret.$arg_name;");
push(@ret_list, "rv = 0;");
$single_ret_var = "int rv = -1";
$single_ret_type = "int";
} else { } else {
$single_ret_var = "unsigned long rv = 0"; push(@ret_list, "rv = ret.$arg_name;");
$single_ret_type = "unsigned long";
if ($call->{ProcName} eq "NodeGetFreeMemory") {
$single_ret_var = "unsigned long long rv = 0";
$single_ret_type = "unsigned long long";
} else {
$single_ret_var = "unsigned long rv = 0";
$single_ret_type = "unsigned long";
}
} }
} else { } else {
die "unhandled type for return value: $ret_member"; die "unhandled type for return value: $ret_member";

View File

@ -319,7 +319,32 @@ done:
/* remoteDispatchDomainEventsRegisterAny has to be implemented manually */ /* remoteDispatchDomainEventsRegisterAny has to be implemented manually */
/* remoteDispatchDomainGetAutostart has to be implemented manually */ static int
remoteDomainGetAutostart(virDomainPtr dom, int *autostart)
{
int rv = -1;
struct private_data *priv = dom->conn->privateData;
remote_domain_get_autostart_args args;
remote_domain_get_autostart_ret ret;
remoteDriverLock(priv);
make_nonnull_domain(&args.dom, dom);
memset(&ret, 0, sizeof ret);
if (call(dom->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_AUTOSTART,
(xdrproc_t)xdr_remote_domain_get_autostart_args, (char *)&args,
(xdrproc_t)xdr_remote_domain_get_autostart_ret, (char *)&ret) == -1)
goto done;
if (autostart) *autostart = ret.autostart;
rv = 0;
done:
remoteDriverUnlock(priv);
return rv;
}
/* remoteDispatchDomainGetBlkioParameters has to be implemented manually */ /* remoteDispatchDomainGetBlkioParameters has to be implemented manually */
@ -1538,7 +1563,29 @@ done:
return rv; return rv;
} }
/* remoteDispatchGetLibVersion has to be implemented manually */ static int
remoteGetLibVersion(virConnectPtr conn, unsigned long *lib_ver)
{
int rv = -1;
struct private_data *priv = conn->privateData;
remote_get_lib_version_ret ret;
remoteDriverLock(priv);
memset(&ret, 0, sizeof ret);
if (call(conn, priv, 0, REMOTE_PROC_GET_LIB_VERSION,
(xdrproc_t)xdr_void, (char *)NULL,
(xdrproc_t)xdr_remote_get_lib_version_ret, (char *)&ret) == -1)
goto done;
if (lib_ver) *lib_ver = ret.lib_ver;
rv = 0;
done:
remoteDriverUnlock(priv);
return rv;
}
static int static int
remoteGetMaxVcpus(virConnectPtr conn, const char *type) remoteGetMaxVcpus(virConnectPtr conn, const char *type)
@ -1596,7 +1643,29 @@ done:
/* remoteDispatchGetURI has to be implemented manually */ /* remoteDispatchGetURI has to be implemented manually */
/* remoteDispatchGetVersion has to be implemented manually */ static int
remoteGetVersion(virConnectPtr conn, unsigned long *hv_ver)
{
int rv = -1;
struct private_data *priv = conn->privateData;
remote_get_version_ret ret;
remoteDriverLock(priv);
memset(&ret, 0, sizeof ret);
if (call(conn, priv, 0, REMOTE_PROC_GET_VERSION,
(xdrproc_t)xdr_void, (char *)NULL,
(xdrproc_t)xdr_remote_get_version_ret, (char *)&ret) == -1)
goto done;
if (hv_ver) *hv_ver = ret.hv_ver;
rv = 0;
done:
remoteDriverUnlock(priv);
return rv;
}
static int static int
remoteInterfaceCreate(virInterfacePtr iface, unsigned int flags) remoteInterfaceCreate(virInterfacePtr iface, unsigned int flags)
@ -1953,7 +2022,32 @@ done:
return rv; return rv;
} }
/* remoteDispatchNetworkGetAutostart has to be implemented manually */ static int
remoteNetworkGetAutostart(virNetworkPtr net, int *autostart)
{
int rv = -1;
struct private_data *priv = net->conn->networkPrivateData;
remote_network_get_autostart_args args;
remote_network_get_autostart_ret ret;
remoteDriverLock(priv);
make_nonnull_network(&args.net, net);
memset(&ret, 0, sizeof ret);
if (call(net->conn, priv, 0, REMOTE_PROC_NETWORK_GET_AUTOSTART,
(xdrproc_t)xdr_remote_network_get_autostart_args, (char *)&args,
(xdrproc_t)xdr_remote_network_get_autostart_ret, (char *)&ret) == -1)
goto done;
if (autostart) *autostart = ret.autostart;
rv = 0;
done:
remoteDriverUnlock(priv);
return rv;
}
static char * static char *
remoteNetworkGetBridgeName(virNetworkPtr net) remoteNetworkGetBridgeName(virNetworkPtr net)
@ -3015,7 +3109,32 @@ done:
return rv; return rv;
} }
/* remoteDispatchStoragePoolGetAutostart has to be implemented manually */ static int
remoteStoragePoolGetAutostart(virStoragePoolPtr pool, int *autostart)
{
int rv = -1;
struct private_data *priv = pool->conn->storagePrivateData;
remote_storage_pool_get_autostart_args args;
remote_storage_pool_get_autostart_ret ret;
remoteDriverLock(priv);
make_nonnull_storage_pool(&args.pool, pool);
memset(&ret, 0, sizeof ret);
if (call(pool->conn, priv, 0, REMOTE_PROC_STORAGE_POOL_GET_AUTOSTART,
(xdrproc_t)xdr_remote_storage_pool_get_autostart_args, (char *)&args,
(xdrproc_t)xdr_remote_storage_pool_get_autostart_ret, (char *)&ret) == -1)
goto done;
if (autostart) *autostart = ret.autostart;
rv = 0;
done:
remoteDriverUnlock(priv);
return rv;
}
static int static int
remoteStoragePoolGetInfo(virStoragePoolPtr pool, virStoragePoolInfoPtr result) remoteStoragePoolGetInfo(virStoragePoolPtr pool, virStoragePoolInfoPtr result)

View File

@ -1698,53 +1698,6 @@ done:
return rv; return rv;
} }
static int
remoteGetVersion (virConnectPtr conn, unsigned long *hvVer)
{
int rv = -1;
remote_get_version_ret ret;
struct private_data *priv = conn->privateData;
remoteDriverLock(priv);
memset (&ret, 0, sizeof ret);
if (call (conn, priv, 0, REMOTE_PROC_GET_VERSION,
(xdrproc_t) xdr_void, (char *) NULL,
(xdrproc_t) xdr_remote_get_version_ret, (char *) &ret) == -1)
goto done;
if (hvVer) *hvVer = ret.hv_ver;
rv = 0;
done:
remoteDriverUnlock(priv);
return rv;
}
static int
remoteGetLibVersion (virConnectPtr conn, unsigned long *libVer)
{
int rv = -1;
remote_get_lib_version_ret ret;
struct private_data *priv = conn->privateData;
remoteDriverLock(priv);
memset (&ret, 0, sizeof ret);
if (call (conn, priv, 0, REMOTE_PROC_GET_LIB_VERSION,
(xdrproc_t) xdr_void, (char *) NULL,
(xdrproc_t) xdr_remote_get_lib_version_ret,
(char *) &ret) == -1)
goto done;
if (libVer) *libVer = ret.lib_ver;
rv = 0;
done:
remoteDriverUnlock(priv);
return rv;
}
static int remoteIsSecure(virConnectPtr conn) static int remoteIsSecure(virConnectPtr conn)
{ {
int rv = -1; int rv = -1;
@ -2783,32 +2736,6 @@ done:
return rv; return rv;
} }
static int
remoteDomainGetAutostart (virDomainPtr domain, int *autostart)
{
int rv = -1;
remote_domain_get_autostart_args args;
remote_domain_get_autostart_ret ret;
struct private_data *priv = domain->conn->privateData;
remoteDriverLock(priv);
make_nonnull_domain (&args.dom, domain);
memset (&ret, 0, sizeof ret);
if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_AUTOSTART,
(xdrproc_t) xdr_remote_domain_get_autostart_args, (char *) &args,
(xdrproc_t) xdr_remote_domain_get_autostart_ret, (char *) &ret) == -1)
goto done;
if (autostart) *autostart = ret.autostart;
rv = 0;
done:
remoteDriverUnlock(priv);
return rv;
}
static char * static char *
remoteDomainGetSchedulerType (virDomainPtr domain, int *nparams) remoteDomainGetSchedulerType (virDomainPtr domain, int *nparams)
{ {
@ -3300,33 +3227,6 @@ done:
return rv; return rv;
} }
static int
remoteNetworkGetAutostart (virNetworkPtr network, int *autostart)
{
int rv = -1;
remote_network_get_autostart_args args;
remote_network_get_autostart_ret ret;
struct private_data *priv = network->conn->networkPrivateData;
remoteDriverLock(priv);
make_nonnull_network (&args.net, network);
memset (&ret, 0, sizeof ret);
if (call (network->conn, priv, 0, REMOTE_PROC_NETWORK_GET_AUTOSTART,
(xdrproc_t) xdr_remote_network_get_autostart_args, (char *) &args,
(xdrproc_t) xdr_remote_network_get_autostart_ret, (char *) &ret) == -1)
goto done;
if (autostart) *autostart = ret.autostart;
rv = 0;
done:
remoteDriverUnlock(priv);
return rv;
}
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
static virDrvOpenStatus ATTRIBUTE_NONNULL (1) static virDrvOpenStatus ATTRIBUTE_NONNULL (1)
@ -3732,34 +3632,6 @@ done:
return rv; return rv;
} }
static int
remoteStoragePoolGetAutostart (virStoragePoolPtr pool, int *autostart)
{
int rv = -1;
remote_storage_pool_get_autostart_args args;
remote_storage_pool_get_autostart_ret ret;
struct private_data *priv = pool->conn->storagePrivateData;
remoteDriverLock(priv);
make_nonnull_storage_pool (&args.pool, pool);
memset (&ret, 0, sizeof ret);
if (call (pool->conn, priv, 0, REMOTE_PROC_STORAGE_POOL_GET_AUTOSTART,
(xdrproc_t) xdr_remote_storage_pool_get_autostart_args, (char *) &args,
(xdrproc_t) xdr_remote_storage_pool_get_autostart_ret, (char *) &ret) == -1)
goto done;
if (autostart) *autostart = ret.autostart;
rv = 0;
done:
remoteDriverUnlock(priv);
return rv;
}
static int static int
remoteStoragePoolListVolumes (virStoragePoolPtr pool, char **const names, int maxnames) remoteStoragePoolListVolumes (virStoragePoolPtr pool, char **const names, int maxnames)
{ {