提交 58b6a5c4 编写于 作者: M Matthias Bolte

remote generator, client: Handle functions with optional return values

上级 abd05a07
......@@ -476,9 +476,7 @@ elsif ($opt_b) {
push(@ret_list, "ret->$1 = $1;");
$single_ret_var = $1;
if ($calls{$_}->{ProcName} eq "DomainGetAutostart" or
$calls{$_}->{ProcName} eq "NetworkGetAutostart" or
$calls{$_}->{ProcName} eq "StoragePoolGetAutostart") {
if ($calls{$_}->{ProcName} =~ m/GetAutostart$/) {
$single_ret_by_ref = 1;
} else {
$single_ret_by_ref = 0;
......@@ -756,15 +754,12 @@ elsif ($opt_k) {
"CPUBaseline",
"DomainCreate",
"DomainDestroy",
"DomainGetAutostart",
"DomainMigrateFinish",
"NWFilterDefineXML", # public API and XDR protocol mismatch
"DomainMigratePerform",
"DomainMigrateFinish2",
"DomainSnapshotListNames",
"GetLibVersion",
"FindStoragePoolSources",
"GetVersion",
"IsSecure",
"ListDefinedDomains",
"ListDefinedInterfaces",
......@@ -776,8 +771,6 @@ elsif ($opt_k) {
"StoragePoolListVolumes",
"ListDomains",
"ListStoragePools",
"NetworkGetAutostart",
"StoragePoolGetAutostart",
"SecretSetValue",
"GetURI",
"ListInterfaces",
......@@ -998,18 +991,37 @@ elsif ($opt_k) {
$single_ret_var = "vir${type_name}Ptr rv = NULL";
$single_ret_type = "vir${type_name}Ptr";
} 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_type = "int";
} elsif ($ret_member =~ m/hyper (\S+);/) {
push(@ret_list, "rv = ret.$1;");
if ($call->{ProcName} eq "NodeGetFreeMemory") {
$single_ret_var = "unsigned long long rv = 0";
$single_ret_type = "unsigned long long";
my $arg_name = $1;
if ($call->{ProcName} =~ m/Get(Lib)?Version/) {
push(@args_list, "unsigned long *$arg_name");
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 {
$single_ret_var = "unsigned long rv = 0";
$single_ret_type = "unsigned long";
push(@ret_list, "rv = ret.$arg_name;");
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 {
die "unhandled type for return value: $ret_member";
......
......@@ -319,7 +319,32 @@ done:
/* 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 */
......@@ -1538,7 +1563,29 @@ done:
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
remoteGetMaxVcpus(virConnectPtr conn, const char *type)
......@@ -1596,7 +1643,29 @@ done:
/* 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
remoteInterfaceCreate(virInterfacePtr iface, unsigned int flags)
......@@ -1953,7 +2022,32 @@ done:
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 *
remoteNetworkGetBridgeName(virNetworkPtr net)
......@@ -3015,7 +3109,32 @@ done:
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
remoteStoragePoolGetInfo(virStoragePoolPtr pool, virStoragePoolInfoPtr result)
......
......@@ -1698,53 +1698,6 @@ done:
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)
{
int rv = -1;
......@@ -2783,32 +2736,6 @@ done:
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 *
remoteDomainGetSchedulerType (virDomainPtr domain, int *nparams)
{
......@@ -3300,33 +3227,6 @@ done:
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)
......@@ -3732,34 +3632,6 @@ done:
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
remoteStoragePoolListVolumes (virStoragePoolPtr pool, char **const names, int maxnames)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册