storage: Use virStoragePoolObjGetDef accessor for Sheepdog backend

In preparation for privatizing the object, use the accessor.
This commit is contained in:
John Ferlan 2017-07-26 14:17:22 -04:00
parent 7920d97ab9
commit 2bbb66c4b7

View File

@ -96,13 +96,14 @@ void
virStorageBackendSheepdogAddHostArg(virCommandPtr cmd, virStorageBackendSheepdogAddHostArg(virCommandPtr cmd,
virStoragePoolObjPtr pool) virStoragePoolObjPtr pool)
{ {
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
const char *address = "localhost"; const char *address = "localhost";
int port = 7000; int port = 7000;
if (pool->def->source.nhost > 0) { if (def->source.nhost > 0) {
if (pool->def->source.hosts[0].name != NULL) if (def->source.hosts[0].name != NULL)
address = pool->def->source.hosts[0].name; address = def->source.hosts[0].name;
if (pool->def->source.hosts[0].port) if (def->source.hosts[0].port)
port = pool->def->source.hosts[0].port; port = def->source.hosts[0].port;
} }
virCommandAddArg(cmd, "-a"); virCommandAddArg(cmd, "-a");
virCommandAddArgFormat(cmd, "%s", address); virCommandAddArgFormat(cmd, "%s", address);
@ -202,7 +203,8 @@ virStorageBackendSheepdogRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
if (virCommandRun(cmd, NULL) < 0) if (virCommandRun(cmd, NULL) < 0)
goto cleanup; goto cleanup;
if (virStorageBackendSheepdogParseNodeInfo(pool->def, output) < 0) if (virStorageBackendSheepdogParseNodeInfo(virStoragePoolObjGetDef(pool),
output) < 0)
goto cleanup; goto cleanup;
ret = virStorageBackendSheepdogRefreshAllVol(conn, pool); ret = virStorageBackendSheepdogRefreshAllVol(conn, pool);
@ -236,6 +238,8 @@ virStorageBackendSheepdogCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
virStoragePoolObjPtr pool, virStoragePoolObjPtr pool,
virStorageVolDefPtr vol) virStorageVolDefPtr vol)
{ {
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
if (vol->target.encryption != NULL) { if (vol->target.encryption != NULL) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
"%s", _("storage pool does not support encrypted " "%s", _("storage pool does not support encrypted "
@ -247,7 +251,7 @@ virStorageBackendSheepdogCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
VIR_FREE(vol->key); VIR_FREE(vol->key);
if (virAsprintf(&vol->key, "%s/%s", if (virAsprintf(&vol->key, "%s/%s",
pool->def->source.name, vol->name) < 0) def->source.name, vol->name) < 0)
return -1; return -1;
VIR_FREE(vol->target.path); VIR_FREE(vol->target.path);
@ -356,8 +360,9 @@ virStorageBackendSheepdogRefreshVol(virConnectPtr conn ATTRIBUTE_UNUSED,
{ {
int ret; int ret;
char *output = NULL; char *output = NULL;
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
virCommandPtr cmd = virCommandNewArgList(SHEEPDOGCLI, "vdi", "list", vol->name, "-r", NULL); virCommandPtr cmd = virCommandNewArgList(SHEEPDOGCLI, "vdi", "list", vol->name, "-r", NULL);
virStorageBackendSheepdogAddHostArg(cmd, pool); virStorageBackendSheepdogAddHostArg(cmd, pool);
virCommandSetOutputBuffer(cmd, &output); virCommandSetOutputBuffer(cmd, &output);
ret = virCommandRun(cmd, NULL); ret = virCommandRun(cmd, NULL);
@ -372,7 +377,7 @@ virStorageBackendSheepdogRefreshVol(virConnectPtr conn ATTRIBUTE_UNUSED,
VIR_FREE(vol->key); VIR_FREE(vol->key);
if (virAsprintf(&vol->key, "%s/%s", if (virAsprintf(&vol->key, "%s/%s",
pool->def->source.name, vol->name) < 0) def->source.name, vol->name) < 0)
goto cleanup; goto cleanup;
VIR_FREE(vol->target.path); VIR_FREE(vol->target.path);