list: Implement RPC calls for virStoragePoolListAllVolumes

The RPC generator doesn't returning support list of object, this
patch do the work manually.

  * daemon/remote.c:
    Implemente the server side handler remoteDispatchStoragePoolListAllVolumes

  * src/remote/remote_driver.c:
    Add remote driver handler remoteStoragePoolListAllVolumes

  * src/remote/remote_protocol.x:
    New RPC procedure REMOTE_PROC_STORAGE_POOL_LIST_ALL_VOLUMES and
    structs to represent the args and ret for it.

  * src/remote_protocol-structs: Likewise.
This commit is contained in:
Osier Yang 2012-09-04 23:32:54 +08:00
parent a42eac601e
commit a8bac1c0f3
4 changed files with 150 additions and 1 deletions

View File

@ -4155,6 +4155,64 @@ cleanup:
return rv; return rv;
} }
static int
remoteDispatchStoragePoolListAllVolumes(virNetServerPtr server ATTRIBUTE_UNUSED,
virNetServerClientPtr client,
virNetMessagePtr msg ATTRIBUTE_UNUSED,
virNetMessageErrorPtr rerr,
remote_storage_pool_list_all_volumes_args *args,
remote_storage_pool_list_all_volumes_ret *ret)
{
virStorageVolPtr *vols = NULL;
virStoragePoolPtr pool = NULL;
int nvols = 0;
int i;
int rv = -1;
struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
if (!priv->conn) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
goto cleanup;
}
if (!(pool = get_nonnull_storage_pool(priv->conn, args->pool)))
goto cleanup;
if ((nvols = virStoragePoolListAllVolumes(pool,
args->need_results ? &vols : NULL,
args->flags)) < 0)
goto cleanup;
if (vols && nvols) {
if (VIR_ALLOC_N(ret->vols.vols_val, nvols) < 0) {
virReportOOMError();
goto cleanup;
}
ret->vols.vols_len = nvols;
for (i = 0; i < nvols; i++)
make_nonnull_storage_vol(ret->vols.vols_val + i, vols[i]);
} else {
ret->vols.vols_len = 0;
ret->vols.vols_val = NULL;
}
ret->ret = nvols;
rv = 0;
cleanup:
if (rv < 0)
virNetMessageSaveError(rerr);
if (vols) {
for (i = 0; i < nvols; i++)
virStorageVolFree(vols[i]);
VIR_FREE(vols);
}
return rv;
}
/*----- Helpers. -----*/ /*----- Helpers. -----*/
/* get_nonnull_domain and get_nonnull_network turn an on-wire /* get_nonnull_domain and get_nonnull_network turn an on-wire

View File

@ -2920,6 +2920,71 @@ done:
return rv; return rv;
} }
static int
remoteStoragePoolListAllVolumes(virStoragePoolPtr pool,
virStorageVolPtr **vols,
unsigned int flags)
{
int rv = -1;
int i;
virStorageVolPtr *tmp_vols = NULL;
remote_storage_pool_list_all_volumes_args args;
remote_storage_pool_list_all_volumes_ret ret;
struct private_data *priv = pool->conn->privateData;
remoteDriverLock(priv);
make_nonnull_storage_pool(&args.pool, pool);
args.need_results = !!vols;
args.flags = flags;
memset(&ret, 0, sizeof(ret));
if (call(pool->conn,
priv,
0,
REMOTE_PROC_STORAGE_POOL_LIST_ALL_VOLUMES,
(xdrproc_t) xdr_remote_storage_pool_list_all_volumes_args,
(char *) &args,
(xdrproc_t) xdr_remote_storage_pool_list_all_volumes_ret,
(char *) &ret) == -1)
goto done;
if (vols) {
if (VIR_ALLOC_N(tmp_vols, ret.vols.vols_len + 1) < 0) {
virReportOOMError();
goto cleanup;
}
for (i = 0; i < ret.vols.vols_len; i++) {
tmp_vols[i] = get_nonnull_storage_vol(pool->conn, ret.vols.vols_val[i]);
if (!tmp_vols[i]) {
virReportOOMError();
goto cleanup;
}
}
*vols = tmp_vols;
tmp_vols = NULL;
}
rv = ret.ret;
cleanup:
if (tmp_vols) {
for (i = 0; i < ret.vols.vols_len; i++)
if (tmp_vols[i])
virStorageVolFree(tmp_vols[i]);
VIR_FREE(tmp_vols);
}
xdr_free((xdrproc_t) xdr_remote_storage_pool_list_all_volumes_ret, (char *) &ret);
done:
remoteDriverUnlock(priv);
return rv;
}
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
static virDrvOpenStatus ATTRIBUTE_NONNULL (1) static virDrvOpenStatus ATTRIBUTE_NONNULL (1)
@ -5694,6 +5759,7 @@ static virStorageDriver storage_driver = {
.poolSetAutostart = remoteStoragePoolSetAutostart, /* 0.4.1 */ .poolSetAutostart = remoteStoragePoolSetAutostart, /* 0.4.1 */
.poolNumOfVolumes = remoteStoragePoolNumOfVolumes, /* 0.4.1 */ .poolNumOfVolumes = remoteStoragePoolNumOfVolumes, /* 0.4.1 */
.poolListVolumes = remoteStoragePoolListVolumes, /* 0.4.1 */ .poolListVolumes = remoteStoragePoolListVolumes, /* 0.4.1 */
.poolListAllVolumes = remoteStoragePoolListAllVolumes, /* 0.10.0 */
.volLookupByName = remoteStorageVolLookupByName, /* 0.4.1 */ .volLookupByName = remoteStorageVolLookupByName, /* 0.4.1 */
.volLookupByKey = remoteStorageVolLookupByKey, /* 0.4.1 */ .volLookupByKey = remoteStorageVolLookupByKey, /* 0.4.1 */

View File

@ -2568,6 +2568,17 @@ struct remote_connect_list_all_storage_pools_ret {
unsigned int ret; unsigned int ret;
}; };
struct remote_storage_pool_list_all_volumes_args {
remote_nonnull_storage_pool pool;
int need_results;
unsigned int flags;
};
struct remote_storage_pool_list_all_volumes_ret {
remote_nonnull_storage_vol vols<>;
unsigned int ret;
};
/*----- Protocol. -----*/ /*----- Protocol. -----*/
/* Define the program number, protocol version and procedure numbers here. */ /* Define the program number, protocol version and procedure numbers here. */
@ -2899,7 +2910,8 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_PIN_EMULATOR = 279, /* skipgen skipgen */ REMOTE_PROC_DOMAIN_PIN_EMULATOR = 279, /* skipgen skipgen */
REMOTE_PROC_DOMAIN_GET_EMULATOR_PIN_INFO = 280, /* skipgen skipgen */ REMOTE_PROC_DOMAIN_GET_EMULATOR_PIN_INFO = 280, /* skipgen skipgen */
REMOTE_PROC_CONNECT_LIST_ALL_STORAGE_POOLS = 281 /* skipgen skipgen priority:high */ REMOTE_PROC_CONNECT_LIST_ALL_STORAGE_POOLS = 281, /* skipgen skipgen priority:high */
REMOTE_PROC_STORAGE_POOL_LIST_ALL_VOLUMES = 282 /* skipgen skipgen priority:high */
/* /*
* Notice how the entries are grouped in sets of 10 ? * Notice how the entries are grouped in sets of 10 ?

View File

@ -2022,6 +2022,18 @@ struct remote_connect_list_all_storage_pools_ret {
} pools; } pools;
u_int ret; u_int ret;
}; };
struct remote_storage_pool_list_all_volumes_args {
remote_nonnull_storage_pool pool;
int need_results;
u_int flags;
};
struct remote_storage_pool_list_all_volumes_ret {
struct {
u_int vols_len;
remote_nonnull_storage_vol * vols_val;
} vols;
u_int ret;
};
enum remote_procedure { enum remote_procedure {
REMOTE_PROC_OPEN = 1, REMOTE_PROC_OPEN = 1,
REMOTE_PROC_CLOSE = 2, REMOTE_PROC_CLOSE = 2,
@ -2304,4 +2316,5 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_PIN_EMULATOR = 279, REMOTE_PROC_DOMAIN_PIN_EMULATOR = 279,
REMOTE_PROC_DOMAIN_GET_EMULATOR_PIN_INFO = 280, REMOTE_PROC_DOMAIN_GET_EMULATOR_PIN_INFO = 280,
REMOTE_PROC_CONNECT_LIST_ALL_STORAGE_POOLS = 281, REMOTE_PROC_CONNECT_LIST_ALL_STORAGE_POOLS = 281,
REMOTE_PROC_STORAGE_POOL_LIST_ALL_VOLUMES = 282,
}; };