--- daemon/remote_generator.pl | 63 +++++++--- src/remote/remote_client_bodies.c | 257 ++++++++++++++++++++++++++++++++++- src/remote/remote_driver.c | 266 ------------------------------------- 3 files changed, 296 insertions(+), 290 deletions(-) diff --git a/daemon/remote_generator.pl b/daemon/remote_generator.pl index 5045b7f..b0e9a4c 100755 --- a/daemon/remote_generator.pl +++ b/daemon/remote_generator.pl @@ -751,14 +751,9 @@ elsif ($opt_k) { "AuthPolkit", "CPUBaseline", - "DomainBlockStats", "DomainCreate", "DomainDestroy", "DomainGetAutostart", - "DomainGetBlockInfo", - "DomainGetInfo", - "DomainGetJobInfo", - "DomainInterfaceStats", "DomainMigrateFinish", "NWFilterDefineXML", # public API and XDR protocol mismatch "DomainMigratePerform", @@ -772,8 +767,6 @@ elsif ($opt_k) { "ListDefinedInterfaces", "ListNWFilters", "SupportsFeature", - "StorageVolGetInfo", - "StoragePoolGetInfo", "NodeListDevices", "NodeGetCellsFreeMemory", "ListDefinedNetworks", @@ -783,7 +776,6 @@ elsif ($opt_k) { "NetworkGetAutostart", "StoragePoolGetAutostart", "SecretSetValue", - "NodeGetInfo", "GetURI", "ListInterfaces", "ListDefinedStoragePools", @@ -831,16 +823,13 @@ elsif ($opt_k) { next; } + # handle arguments to the function my @args_list = (); my @vars_list = (); my @setters_list = (); - my @ret_list = (); my $priv_src = "conn"; my $priv_name = "privateData"; my $call_args = "&args"; - my $call_ret = "&ret"; - my $single_ret_var = "int rv = -1"; - my $single_ret_type = "int"; if ($call->{args} eq "void") { $call_args = "NULL"; @@ -937,6 +926,10 @@ elsif ($opt_k) { } } + if (! @args_list) { + push(@args_list, "virConnectPtr conn"); + } + # fix priv_name for the NumOf* functions if ($priv_name eq "privateData" and !($call->{ProcName} =~ m/Domains/) and @@ -946,13 +939,36 @@ elsif ($opt_k) { $priv_name = "${prefix}PrivateData"; } + # handle return values of the function + my @ret_list = (); + my $call_ret = "&ret"; + my $single_ret_var = "int rv = -1"; + my $single_ret_type = "int"; + my $multi_ret = 0; + + if ($call->{ret} ne "void" and + scalar(@{$call->{ret_members}}) > 1) { + $multi_ret = 1; + } + if ($call->{ret} eq "void") { $call_ret = "NULL"; } else { push(@vars_list, "$call->{ret} ret"); foreach my $ret_member (@{$call->{ret_members}}) { - if ($ret_member =~ m/remote_nonnull_string (\S+);/) { + if ($multi_ret) { + if ($ret_member =~ m/(char|short|int|hyper) (\S+)\[\S+\];/) { + push(@ret_list, "memcpy(result->$2, ret.$2, sizeof result->$2);"); + } elsif ($ret_member =~ m/char (\S+);/ or + $ret_member =~ m/short (\S+);/ or + $ret_member =~ m/int (\S+);/ or + $ret_member =~ m/hyper (\S+);/) { + push(@ret_list, "result->$1 = ret.$1;"); + } else { + die "unhandled type for multi-return-value: $ret_member"; + } + } elsif ($ret_member =~ m/remote_nonnull_string (\S+);/) { push(@ret_list, "rv = ret.$1;"); $single_ret_var = "char *rv = NULL"; $single_ret_type = "char *"; @@ -998,8 +1014,21 @@ elsif ($opt_k) { } } - if (! @args_list) { - push(@args_list, "virConnectPtr conn"); + # select struct type for multi-return-value functions + if ($multi_ret) { + my $last_arg; + my $struct_name = $call->{ProcName}; + $struct_name =~ s/Get//; + + if ($call->{ProcName} eq "DomainGetBlockInfo") { + $last_arg = pop(@args_list); + } + + push(@args_list, "vir${struct_name}Ptr result"); + + if (defined $last_arg) { + push(@args_list, $last_arg); + } } # print function @@ -1047,7 +1076,9 @@ elsif ($opt_k) { print " "; print join("\n ", @ret_list); print "\n"; - } else { + } + + if ($multi_ret or !@ret_list) { print " rv = 0;\n"; } diff --git a/src/remote/remote_client_bodies.c b/src/remote/remote_client_bodies.c index 5471c1b..334b963 100644 --- a/src/remote/remote_client_bodies.c +++ b/src/remote/remote_client_bodies.c @@ -117,7 +117,37 @@ done: /* remoteDispatchDomainBlockPeek has to be implemented manually */ -/* remoteDispatchDomainBlockStats has to be implemented manually */ +static int +remoteDomainBlockStats(virDomainPtr dom, const char *path, virDomainBlockStatsPtr result) +{ + int rv = -1; + struct private_data *priv = dom->conn->privateData; + remote_domain_block_stats_args args; + remote_domain_block_stats_ret ret; + + remoteDriverLock(priv); + + make_nonnull_domain(&args.dom, dom); + args.path = (char *)path; + + memset(&ret, 0, sizeof ret); + + if (call(dom->conn, priv, 0, REMOTE_PROC_DOMAIN_BLOCK_STATS, + (xdrproc_t)xdr_remote_domain_block_stats_args, (char *)&args, + (xdrproc_t)xdr_remote_domain_block_stats_ret, (char *)&ret) == -1) + goto done; + + result->rd_req = ret.rd_req; + result->rd_bytes = ret.rd_bytes; + result->wr_req = ret.wr_req; + result->wr_bytes = ret.wr_bytes; + result->errs = ret.errs; + rv = 0; + +done: + remoteDriverUnlock(priv); + return rv; +} static int remoteDomainCoreDump(virDomainPtr dom, const char *to, int flags) @@ -293,11 +323,105 @@ done: /* remoteDispatchDomainGetBlkioParameters has to be implemented manually */ -/* remoteDispatchDomainGetBlockInfo has to be implemented manually */ +static int +remoteDomainGetBlockInfo(virDomainPtr dom, const char *path, virDomainBlockInfoPtr result, unsigned int flags) +{ + int rv = -1; + struct private_data *priv = dom->conn->privateData; + remote_domain_get_block_info_args args; + remote_domain_get_block_info_ret ret; + + remoteDriverLock(priv); + + make_nonnull_domain(&args.dom, dom); + args.path = (char *)path; + args.flags = flags; + + memset(&ret, 0, sizeof ret); + + if (call(dom->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_BLOCK_INFO, + (xdrproc_t)xdr_remote_domain_get_block_info_args, (char *)&args, + (xdrproc_t)xdr_remote_domain_get_block_info_ret, (char *)&ret) == -1) + goto done; + + result->allocation = ret.allocation; + result->capacity = ret.capacity; + result->physical = ret.physical; + rv = 0; + +done: + remoteDriverUnlock(priv); + return rv; +} + +static int +remoteDomainGetInfo(virDomainPtr dom, virDomainInfoPtr result) +{ + int rv = -1; + struct private_data *priv = dom->conn->privateData; + remote_domain_get_info_args args; + remote_domain_get_info_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_INFO, + (xdrproc_t)xdr_remote_domain_get_info_args, (char *)&args, + (xdrproc_t)xdr_remote_domain_get_info_ret, (char *)&ret) == -1) + goto done; -/* remoteDispatchDomainGetInfo has to be implemented manually */ + result->state = ret.state; + result->maxMem = ret.maxMem; + result->memory = ret.memory; + result->nrVirtCpu = ret.nrVirtCpu; + result->cpuTime = ret.cpuTime; + rv = 0; -/* remoteDispatchDomainGetJobInfo has to be implemented manually */ +done: + remoteDriverUnlock(priv); + return rv; +} + +static int +remoteDomainGetJobInfo(virDomainPtr dom, virDomainJobInfoPtr result) +{ + int rv = -1; + struct private_data *priv = dom->conn->privateData; + remote_domain_get_job_info_args args; + remote_domain_get_job_info_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_JOB_INFO, + (xdrproc_t)xdr_remote_domain_get_job_info_args, (char *)&args, + (xdrproc_t)xdr_remote_domain_get_job_info_ret, (char *)&ret) == -1) + goto done; + + result->type = ret.type; + result->timeElapsed = ret.timeElapsed; + result->timeRemaining = ret.timeRemaining; + result->dataTotal = ret.dataTotal; + result->dataProcessed = ret.dataProcessed; + result->dataRemaining = ret.dataRemaining; + result->memTotal = ret.memTotal; + result->memProcessed = ret.memProcessed; + result->memRemaining = ret.memRemaining; + result->fileTotal = ret.fileTotal; + result->fileProcessed = ret.fileProcessed; + result->fileRemaining = ret.fileRemaining; + rv = 0; + +done: + remoteDriverUnlock(priv); + return rv; +} static unsigned long remoteDomainGetMaxMemory(virDomainPtr dom) @@ -468,7 +592,40 @@ done: return rv; } -/* remoteDispatchDomainInterfaceStats has to be implemented manually */ +static int +remoteDomainInterfaceStats(virDomainPtr dom, const char *path, virDomainInterfaceStatsPtr result) +{ + int rv = -1; + struct private_data *priv = dom->conn->privateData; + remote_domain_interface_stats_args args; + remote_domain_interface_stats_ret ret; + + remoteDriverLock(priv); + + make_nonnull_domain(&args.dom, dom); + args.path = (char *)path; + + memset(&ret, 0, sizeof ret); + + if (call(dom->conn, priv, 0, REMOTE_PROC_DOMAIN_INTERFACE_STATS, + (xdrproc_t)xdr_remote_domain_interface_stats_args, (char *)&args, + (xdrproc_t)xdr_remote_domain_interface_stats_ret, (char *)&ret) == -1) + goto done; + + result->rx_bytes = ret.rx_bytes; + result->rx_packets = ret.rx_packets; + result->rx_errs = ret.rx_errs; + result->rx_drop = ret.rx_drop; + result->tx_bytes = ret.tx_bytes; + result->tx_packets = ret.tx_packets; + result->tx_errs = ret.tx_errs; + result->tx_drop = ret.tx_drop; + rv = 0; + +done: + remoteDriverUnlock(priv); + return rv; +} static int remoteDomainIsActive(virDomainPtr dom) @@ -2143,7 +2300,36 @@ done: return rv; } -/* remoteDispatchNodeGetInfo has to be implemented manually */ +static int +remoteNodeGetInfo(virConnectPtr conn, virNodeInfoPtr result) +{ + int rv = -1; + struct private_data *priv = conn->privateData; + remote_node_get_info_ret ret; + + remoteDriverLock(priv); + + memset(&ret, 0, sizeof ret); + + if (call(conn, priv, 0, REMOTE_PROC_NODE_GET_INFO, + (xdrproc_t)xdr_void, (char *)NULL, + (xdrproc_t)xdr_remote_node_get_info_ret, (char *)&ret) == -1) + goto done; + + memcpy(result->model, ret.model, sizeof result->model); + result->memory = ret.memory; + result->cpus = ret.cpus; + result->mhz = ret.mhz; + result->nodes = ret.nodes; + result->sockets = ret.sockets; + result->cores = ret.cores; + result->threads = ret.threads; + rv = 0; + +done: + remoteDriverUnlock(priv); + return rv; +} /* remoteDispatchNodeGetSecurityModel has to be implemented manually */ @@ -2831,7 +3017,35 @@ done: /* remoteDispatchStoragePoolGetAutostart has to be implemented manually */ -/* remoteDispatchStoragePoolGetInfo has to be implemented manually */ +static int +remoteStoragePoolGetInfo(virStoragePoolPtr pool, virStoragePoolInfoPtr result) +{ + int rv = -1; + struct private_data *priv = pool->conn->storagePrivateData; + remote_storage_pool_get_info_args args; + remote_storage_pool_get_info_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_INFO, + (xdrproc_t)xdr_remote_storage_pool_get_info_args, (char *)&args, + (xdrproc_t)xdr_remote_storage_pool_get_info_ret, (char *)&ret) == -1) + goto done; + + result->state = ret.state; + result->capacity = ret.capacity; + result->allocation = ret.allocation; + result->available = ret.available; + rv = 0; + +done: + remoteDriverUnlock(priv); + return rv; +} static int remoteStoragePoolIsActive(virStoragePoolPtr pool) @@ -3177,7 +3391,34 @@ done: return rv; } -/* remoteDispatchStorageVolGetInfo has to be implemented manually */ +static int +remoteStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr result) +{ + int rv = -1; + struct private_data *priv = vol->conn->storagePrivateData; + remote_storage_vol_get_info_args args; + remote_storage_vol_get_info_ret ret; + + remoteDriverLock(priv); + + make_nonnull_storage_vol(&args.vol, vol); + + memset(&ret, 0, sizeof ret); + + if (call(vol->conn, priv, 0, REMOTE_PROC_STORAGE_VOL_GET_INFO, + (xdrproc_t)xdr_remote_storage_vol_get_info_args, (char *)&args, + (xdrproc_t)xdr_remote_storage_vol_get_info_ret, (char *)&ret) == -1) + goto done; + + result->type = ret.type; + result->capacity = ret.capacity; + result->allocation = ret.allocation; + rv = 0; + +done: + remoteDriverUnlock(priv); + return rv; +} static char * remoteStorageVolGetPath(virStorageVolPtr vol) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 79ebfb3..6cbcc35 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -1811,37 +1811,6 @@ done: } static int -remoteNodeGetInfo (virConnectPtr conn, virNodeInfoPtr info) -{ - int rv = -1; - remote_node_get_info_ret ret; - struct private_data *priv = conn->privateData; - - remoteDriverLock(priv); - - memset (&ret, 0, sizeof ret); - if (call (conn, priv, 0, REMOTE_PROC_NODE_GET_INFO, - (xdrproc_t) xdr_void, (char *) NULL, - (xdrproc_t) xdr_remote_node_get_info_ret, (char *) &ret) == -1) - goto done; - - if (virStrcpyStatic(info->model, ret.model) == NULL) - goto done; - info->memory = ret.memory; - info->cpus = ret.cpus; - info->mhz = ret.mhz; - info->nodes = ret.nodes; - info->sockets = ret.sockets; - info->cores = ret.cores; - info->threads = ret.threads; - rv = 0; - -done: - remoteDriverUnlock(priv); - return rv; -} - -static int remoteNodeGetCellsFreeMemory(virConnectPtr conn, unsigned long long *freeMems, int startCell, @@ -2291,37 +2260,6 @@ done: } static int -remoteDomainGetInfo (virDomainPtr domain, virDomainInfoPtr info) -{ - int rv = -1; - remote_domain_get_info_args args; - remote_domain_get_info_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_INFO, - (xdrproc_t) xdr_remote_domain_get_info_args, (char *) &args, - (xdrproc_t) xdr_remote_domain_get_info_ret, (char *) &ret) == -1) - goto done; - - info->state = ret.state; - info->maxMem = ret.maxMem; - info->memory = ret.memory; - info->nrVirtCpu = ret.nrVirtCpu; - info->cpuTime = ret.cpuTime; - - rv = 0; - -done: - remoteDriverUnlock(priv); - return rv; -} - -static int remoteDomainPinVcpu (virDomainPtr domain, unsigned int vcpu, unsigned char *cpumap, @@ -3035,78 +2973,6 @@ done: } static int -remoteDomainBlockStats (virDomainPtr domain, const char *path, - struct _virDomainBlockStats *stats) -{ - int rv = -1; - remote_domain_block_stats_args args; - remote_domain_block_stats_ret ret; - struct private_data *priv = domain->conn->privateData; - - remoteDriverLock(priv); - - make_nonnull_domain (&args.dom, domain); - args.path = (char *) path; - - memset (&ret, 0, sizeof ret); - if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_BLOCK_STATS, - (xdrproc_t) xdr_remote_domain_block_stats_args, (char *) &args, - (xdrproc_t) xdr_remote_domain_block_stats_ret, (char *) &ret) - == -1) - goto done; - - stats->rd_req = ret.rd_req; - stats->rd_bytes = ret.rd_bytes; - stats->wr_req = ret.wr_req; - stats->wr_bytes = ret.wr_bytes; - stats->errs = ret.errs; - - rv = 0; - -done: - remoteDriverUnlock(priv); - return rv; -} - -static int -remoteDomainInterfaceStats (virDomainPtr domain, const char *path, - struct _virDomainInterfaceStats *stats) -{ - int rv = -1; - remote_domain_interface_stats_args args; - remote_domain_interface_stats_ret ret; - struct private_data *priv = domain->conn->privateData; - - remoteDriverLock(priv); - - make_nonnull_domain (&args.dom, domain); - args.path = (char *) path; - - memset (&ret, 0, sizeof ret); - if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_INTERFACE_STATS, - (xdrproc_t) xdr_remote_domain_interface_stats_args, - (char *) &args, - (xdrproc_t) xdr_remote_domain_interface_stats_ret, - (char *) &ret) == -1) - goto done; - - stats->rx_bytes = ret.rx_bytes; - stats->rx_packets = ret.rx_packets; - stats->rx_errs = ret.rx_errs; - stats->rx_drop = ret.rx_drop; - stats->tx_bytes = ret.tx_bytes; - stats->tx_packets = ret.tx_packets; - stats->tx_errs = ret.tx_errs; - stats->tx_drop = ret.tx_drop; - - rv = 0; - -done: - remoteDriverUnlock(priv); - return rv; -} - -static int remoteDomainMemoryStats (virDomainPtr domain, struct _virDomainMemoryStat *stats, unsigned int nr_stats) @@ -3253,40 +3119,6 @@ done: return rv; } -static int -remoteDomainGetBlockInfo (virDomainPtr domain, - const char *path, - virDomainBlockInfoPtr info, - unsigned int flags) -{ - int rv = -1; - remote_domain_get_block_info_args args; - remote_domain_get_block_info_ret ret; - struct private_data *priv = domain->conn->privateData; - - remoteDriverLock(priv); - - make_nonnull_domain (&args.dom, domain); - args.path = (char*)path; - args.flags = flags; - - memset (&ret, 0, sizeof ret); - if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_BLOCK_INFO, - (xdrproc_t) xdr_remote_domain_get_block_info_args, (char *) &args, - (xdrproc_t) xdr_remote_domain_get_block_info_ret, (char *) &ret) == -1) - goto done; - - info->allocation = ret.allocation; - info->capacity = ret.capacity; - info->physical = ret.physical; - - rv = 0; - -done: - remoteDriverUnlock(priv); - return rv; -} - /*----------------------------------------------------------------------*/ static virDrvOpenStatus ATTRIBUTE_NONNULL (1) @@ -3901,36 +3733,6 @@ done: } static int -remoteStoragePoolGetInfo (virStoragePoolPtr pool, virStoragePoolInfoPtr info) -{ - int rv = -1; - remote_storage_pool_get_info_args args; - remote_storage_pool_get_info_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_INFO, - (xdrproc_t) xdr_remote_storage_pool_get_info_args, (char *) &args, - (xdrproc_t) xdr_remote_storage_pool_get_info_ret, (char *) &ret) == -1) - goto done; - - info->state = ret.state; - info->capacity = ret.capacity; - info->allocation = ret.allocation; - info->available = ret.available; - - rv = 0; - -done: - remoteDriverUnlock(priv); - return rv; -} - -static int remoteStoragePoolGetAutostart (virStoragePoolPtr pool, int *autostart) { int rv = -1; @@ -4014,35 +3816,6 @@ done: return rv; } -static int -remoteStorageVolGetInfo (virStorageVolPtr vol, virStorageVolInfoPtr info) -{ - int rv = -1; - remote_storage_vol_get_info_args args; - remote_storage_vol_get_info_ret ret; - struct private_data *priv = vol->conn->storagePrivateData; - - remoteDriverLock(priv); - - make_nonnull_storage_vol (&args.vol, vol); - - memset (&ret, 0, sizeof ret); - if (call (vol->conn, priv, 0, REMOTE_PROC_STORAGE_VOL_GET_INFO, - (xdrproc_t) xdr_remote_storage_vol_get_info_args, (char *) &args, - (xdrproc_t) xdr_remote_storage_vol_get_info_ret, (char *) &ret) == -1) - goto done; - - info->type = ret.type; - info->capacity = ret.capacity; - info->allocation = ret.allocation; - - rv = 0; - -done: - remoteDriverUnlock(priv); - return rv; -} - /*----------------------------------------------------------------------*/ static virDrvOpenStatus ATTRIBUTE_NONNULL (1) @@ -6226,45 +5999,6 @@ done: return cpu; } - -static int -remoteDomainGetJobInfo (virDomainPtr domain, virDomainJobInfoPtr info) -{ - int rv = -1; - remote_domain_get_job_info_args args; - remote_domain_get_job_info_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_JOB_INFO, - (xdrproc_t) xdr_remote_domain_get_job_info_args, (char *) &args, - (xdrproc_t) xdr_remote_domain_get_job_info_ret, (char *) &ret) == -1) - goto done; - - info->type = ret.type; - info->timeElapsed = ret.timeElapsed; - info->timeRemaining = ret.timeRemaining; - info->dataTotal = ret.dataTotal; - info->dataProcessed = ret.dataProcessed; - info->dataRemaining = ret.dataRemaining; - info->memTotal = ret.memTotal; - info->memProcessed = ret.memProcessed; - info->memRemaining = ret.memRemaining; - info->fileTotal = ret.fileTotal; - info->fileProcessed = ret.fileProcessed; - info->fileRemaining = ret.fileRemaining; - - rv = 0; - -done: - remoteDriverUnlock(priv); - return rv; -} - static int remoteDomainSnapshotListNames (virDomainPtr domain, char **const names, int maxnames, unsigned int flags) -- 1.7.0.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list