mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
conf: stop passing virConnectPtr into virDomainDiskTranslateSourcePool
Rather than expecting callers to pass a virConnectPtr into the virDomainDiskTranslateSourcePool() method, just acquire a connection to the storage driver when needed. Reviewed-by: John Ferlan <jferlan@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
aed679da85
commit
2d43f0a2dc
@ -29171,9 +29171,9 @@ virDomainDiskTranslateSourcePoolAuth(virDomainDiskDefPtr def,
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
virDomainDiskTranslateSourcePool(virConnectPtr conn,
|
virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def)
|
||||||
virDomainDiskDefPtr def)
|
|
||||||
{
|
{
|
||||||
|
virConnectPtr conn = NULL;
|
||||||
virStoragePoolDefPtr pooldef = NULL;
|
virStoragePoolDefPtr pooldef = NULL;
|
||||||
virStoragePoolPtr pool = NULL;
|
virStoragePoolPtr pool = NULL;
|
||||||
virStorageVolPtr vol = NULL;
|
virStorageVolPtr vol = NULL;
|
||||||
@ -29187,9 +29187,12 @@ virDomainDiskTranslateSourcePool(virConnectPtr conn,
|
|||||||
if (!def->src->srcpool)
|
if (!def->src->srcpool)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!(pool = virStoragePoolLookupByName(conn, def->src->srcpool->pool)))
|
if (!(conn = virGetConnectStorage()))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (!(pool = virStoragePoolLookupByName(conn, def->src->srcpool->pool)))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (virStoragePoolIsActive(pool) != 1) {
|
if (virStoragePoolIsActive(pool) != 1) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("storage pool '%s' containing volume '%s' "
|
_("storage pool '%s' containing volume '%s' "
|
||||||
@ -29333,6 +29336,7 @@ virDomainDiskTranslateSourcePool(virConnectPtr conn,
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
|
virObjectUnref(conn);
|
||||||
virObjectUnref(pool);
|
virObjectUnref(pool);
|
||||||
virObjectUnref(vol);
|
virObjectUnref(vol);
|
||||||
VIR_FREE(poolxml);
|
VIR_FREE(poolxml);
|
||||||
|
@ -3512,8 +3512,7 @@ virDomainNetResolveActualType(virDomainNetDefPtr iface)
|
|||||||
ATTRIBUTE_NONNULL(1);
|
ATTRIBUTE_NONNULL(1);
|
||||||
|
|
||||||
|
|
||||||
int virDomainDiskTranslateSourcePool(virConnectPtr conn,
|
int virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def);
|
||||||
virDomainDiskDefPtr def);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __DOMAIN_CONF_H */
|
#endif /* __DOMAIN_CONF_H */
|
||||||
|
@ -1631,8 +1631,7 @@ int qemuDriverAllocateID(virQEMUDriverPtr driver)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
qemuTranslateSnapshotDiskSourcePool(virConnectPtr conn ATTRIBUTE_UNUSED,
|
qemuTranslateSnapshotDiskSourcePool(virDomainSnapshotDiskDefPtr def)
|
||||||
virDomainSnapshotDiskDefPtr def)
|
|
||||||
{
|
{
|
||||||
if (def->src->type != VIR_STORAGE_TYPE_VOLUME)
|
if (def->src->type != VIR_STORAGE_TYPE_VOLUME)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -349,8 +349,7 @@ int qemuSetUnprivSGIO(virDomainDeviceDefPtr dev);
|
|||||||
int qemuDriverAllocateID(virQEMUDriverPtr driver);
|
int qemuDriverAllocateID(virQEMUDriverPtr driver);
|
||||||
virDomainXMLOptionPtr virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver);
|
virDomainXMLOptionPtr virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver);
|
||||||
|
|
||||||
int qemuTranslateSnapshotDiskSourcePool(virConnectPtr conn,
|
int qemuTranslateSnapshotDiskSourcePool(virDomainSnapshotDiskDefPtr def);
|
||||||
virDomainSnapshotDiskDefPtr def);
|
|
||||||
|
|
||||||
char * qemuGetBaseHugepagePath(virHugeTLBFSPtr hugepage);
|
char * qemuGetBaseHugepagePath(virHugeTLBFSPtr hugepage);
|
||||||
char * qemuGetDomainHugepagePath(const virDomainDef *def,
|
char * qemuGetDomainHugepagePath(const virDomainDef *def,
|
||||||
|
@ -7871,8 +7871,7 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainChangeDiskLive(virConnectPtr conn,
|
qemuDomainChangeDiskLive(virDomainObjPtr vm,
|
||||||
virDomainObjPtr vm,
|
|
||||||
virDomainDeviceDefPtr dev,
|
virDomainDeviceDefPtr dev,
|
||||||
virQEMUDriverPtr driver,
|
virQEMUDriverPtr driver,
|
||||||
bool force)
|
bool force)
|
||||||
@ -7881,7 +7880,7 @@ qemuDomainChangeDiskLive(virConnectPtr conn,
|
|||||||
virDomainDiskDefPtr orig_disk = NULL;
|
virDomainDiskDefPtr orig_disk = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (virDomainDiskTranslateSourcePool(conn, disk) < 0)
|
if (virDomainDiskTranslateSourcePool(disk) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (qemuDomainDetermineDiskChain(driver, vm, disk, false, true) < 0)
|
if (qemuDomainDetermineDiskChain(driver, vm, disk, false, true) < 0)
|
||||||
@ -7932,8 +7931,7 @@ qemuDomainChangeDiskLive(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainUpdateDeviceLive(virConnectPtr conn,
|
qemuDomainUpdateDeviceLive(virDomainObjPtr vm,
|
||||||
virDomainObjPtr vm,
|
|
||||||
virDomainDeviceDefPtr dev,
|
virDomainDeviceDefPtr dev,
|
||||||
virDomainPtr dom,
|
virDomainPtr dom,
|
||||||
bool force)
|
bool force)
|
||||||
@ -7944,7 +7942,7 @@ qemuDomainUpdateDeviceLive(virConnectPtr conn,
|
|||||||
switch ((virDomainDeviceType) dev->type) {
|
switch ((virDomainDeviceType) dev->type) {
|
||||||
case VIR_DOMAIN_DEVICE_DISK:
|
case VIR_DOMAIN_DEVICE_DISK:
|
||||||
qemuDomainObjCheckDiskTaint(driver, vm, dev->data.disk, NULL);
|
qemuDomainObjCheckDiskTaint(driver, vm, dev->data.disk, NULL);
|
||||||
ret = qemuDomainChangeDiskLive(conn, vm, dev, driver, force);
|
ret = qemuDomainChangeDiskLive(vm, dev, driver, force);
|
||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_DEVICE_GRAPHICS:
|
case VIR_DOMAIN_DEVICE_GRAPHICS:
|
||||||
ret = qemuDomainChangeGraphics(driver, vm, dev->data.graphics);
|
ret = qemuDomainChangeGraphics(driver, vm, dev->data.graphics);
|
||||||
@ -7986,7 +7984,6 @@ qemuDomainUpdateDeviceLive(virConnectPtr conn,
|
|||||||
static int
|
static int
|
||||||
qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
|
qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
|
||||||
virDomainDeviceDefPtr dev,
|
virDomainDeviceDefPtr dev,
|
||||||
virConnectPtr conn,
|
|
||||||
virCapsPtr caps,
|
virCapsPtr caps,
|
||||||
unsigned int parse_flags,
|
unsigned int parse_flags,
|
||||||
virDomainXMLOptionPtr xmlopt)
|
virDomainXMLOptionPtr xmlopt)
|
||||||
@ -8008,7 +8005,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
|
|||||||
_("target %s already exists"), disk->dst);
|
_("target %s already exists"), disk->dst);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (virDomainDiskTranslateSourcePool(conn, disk) < 0)
|
if (virDomainDiskTranslateSourcePool(disk) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (qemuCheckDiskConfig(disk, NULL) < 0)
|
if (qemuCheckDiskConfig(disk, NULL) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -8494,7 +8491,7 @@ qemuDomainAttachDeviceLiveAndConfig(virConnectPtr conn,
|
|||||||
|
|
||||||
if (virDomainDefCompatibleDevice(vmdef, dev) < 0)
|
if (virDomainDefCompatibleDevice(vmdef, dev) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if ((ret = qemuDomainAttachDeviceConfig(vmdef, dev, conn, caps,
|
if ((ret = qemuDomainAttachDeviceConfig(vmdef, dev, caps,
|
||||||
parse_flags,
|
parse_flags,
|
||||||
driver->xmlopt)) < 0)
|
driver->xmlopt)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -8654,7 +8651,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
|
|||||||
if (virDomainDefCompatibleDevice(vm->def, dev_copy) < 0)
|
if (virDomainDefCompatibleDevice(vm->def, dev_copy) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if ((ret = qemuDomainUpdateDeviceLive(dom->conn, vm, dev_copy, dom, force)) < 0)
|
if ((ret = qemuDomainUpdateDeviceLive(vm, dev_copy, dom, force)) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
/*
|
/*
|
||||||
* update domain status forcibly because the domain status may be
|
* update domain status forcibly because the domain status may be
|
||||||
@ -14229,8 +14226,7 @@ qemuDomainSnapshotPrepareDiskExternalActive(virDomainSnapshotDiskDefPtr snapdisk
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainSnapshotPrepareDiskExternal(virConnectPtr conn,
|
qemuDomainSnapshotPrepareDiskExternal(virDomainDiskDefPtr disk,
|
||||||
virDomainDiskDefPtr disk,
|
|
||||||
virDomainSnapshotDiskDefPtr snapdisk,
|
virDomainSnapshotDiskDefPtr snapdisk,
|
||||||
bool active,
|
bool active,
|
||||||
bool reuse)
|
bool reuse)
|
||||||
@ -14238,11 +14234,11 @@ qemuDomainSnapshotPrepareDiskExternal(virConnectPtr conn,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
if (qemuTranslateSnapshotDiskSourcePool(conn, snapdisk) < 0)
|
if (qemuTranslateSnapshotDiskSourcePool(snapdisk) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!active) {
|
if (!active) {
|
||||||
if (virDomainDiskTranslateSourcePool(conn, disk) < 0)
|
if (virDomainDiskTranslateSourcePool(disk) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (qemuDomainSnapshotPrepareDiskExternalInactive(snapdisk, disk) < 0)
|
if (qemuDomainSnapshotPrepareDiskExternalInactive(snapdisk, disk) < 0)
|
||||||
@ -14284,8 +14280,7 @@ qemuDomainSnapshotPrepareDiskExternal(virConnectPtr conn,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainSnapshotPrepareDiskInternal(virConnectPtr conn,
|
qemuDomainSnapshotPrepareDiskInternal(virDomainDiskDefPtr disk,
|
||||||
virDomainDiskDefPtr disk,
|
|
||||||
bool active)
|
bool active)
|
||||||
{
|
{
|
||||||
int actualType;
|
int actualType;
|
||||||
@ -14294,7 +14289,7 @@ qemuDomainSnapshotPrepareDiskInternal(virConnectPtr conn,
|
|||||||
if (active)
|
if (active)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (virDomainDiskTranslateSourcePool(conn, disk) < 0)
|
if (virDomainDiskTranslateSourcePool(disk) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
actualType = virStorageSourceGetActualType(disk->src);
|
actualType = virStorageSourceGetActualType(disk->src);
|
||||||
@ -14343,8 +14338,7 @@ qemuDomainSnapshotPrepareDiskInternal(virConnectPtr conn,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainSnapshotPrepare(virConnectPtr conn,
|
qemuDomainSnapshotPrepare(virDomainObjPtr vm,
|
||||||
virDomainObjPtr vm,
|
|
||||||
virDomainSnapshotDefPtr def,
|
virDomainSnapshotDefPtr def,
|
||||||
unsigned int *flags)
|
unsigned int *flags)
|
||||||
{
|
{
|
||||||
@ -14385,7 +14379,7 @@ qemuDomainSnapshotPrepare(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuDomainSnapshotPrepareDiskInternal(conn, dom_disk,
|
if (qemuDomainSnapshotPrepareDiskInternal(dom_disk,
|
||||||
active) < 0)
|
active) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -14414,7 +14408,7 @@ qemuDomainSnapshotPrepare(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuDomainSnapshotPrepareDiskExternal(conn, dom_disk, disk,
|
if (qemuDomainSnapshotPrepareDiskExternal(dom_disk, disk,
|
||||||
active, reuse) < 0)
|
active, reuse) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -15062,7 +15056,6 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
|||||||
const char *xmlDesc,
|
const char *xmlDesc,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
virConnectPtr conn = domain->conn;
|
|
||||||
virQEMUDriverPtr driver = domain->conn->privateData;
|
virQEMUDriverPtr driver = domain->conn->privateData;
|
||||||
virDomainObjPtr vm = NULL;
|
virDomainObjPtr vm = NULL;
|
||||||
char *xml = NULL;
|
char *xml = NULL;
|
||||||
@ -15241,7 +15234,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
|||||||
}
|
}
|
||||||
if (virDomainSnapshotAlignDisks(def, align_location,
|
if (virDomainSnapshotAlignDisks(def, align_location,
|
||||||
align_match) < 0 ||
|
align_match) < 0 ||
|
||||||
qemuDomainSnapshotPrepare(conn, vm, def, &flags) < 0)
|
qemuDomainSnapshotPrepare(vm, def, &flags) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -713,7 +713,7 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainDiskTranslateSourcePool(conn, disk) < 0)
|
if (virDomainDiskTranslateSourcePool(disk) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (qemuAddSharedDevice(driver, dev, vm->def->name) < 0)
|
if (qemuAddSharedDevice(driver, dev, vm->def->name) < 0)
|
||||||
|
@ -5603,7 +5603,7 @@ qemuProcessPrepareDomainStorage(virConnectPtr conn,
|
|||||||
size_t idx = i - 1;
|
size_t idx = i - 1;
|
||||||
virDomainDiskDefPtr disk = vm->def->disks[idx];
|
virDomainDiskDefPtr disk = vm->def->disks[idx];
|
||||||
|
|
||||||
if (virDomainDiskTranslateSourcePool(conn, disk) < 0) {
|
if (virDomainDiskTranslateSourcePool(disk) < 0) {
|
||||||
if (qemuDomainCheckDiskStartupPolicy(driver, vm, idx, cold_boot) < 0)
|
if (qemuDomainCheckDiskStartupPolicy(driver, vm, idx, cold_boot) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -7362,7 +7362,7 @@ qemuProcessReconnect(void *opaque)
|
|||||||
virDomainDiskDefPtr disk = obj->def->disks[i];
|
virDomainDiskDefPtr disk = obj->def->disks[i];
|
||||||
virDomainDeviceDef dev;
|
virDomainDeviceDef dev;
|
||||||
|
|
||||||
if (virDomainDiskTranslateSourcePool(conn, disk) < 0)
|
if (virDomainDiskTranslateSourcePool(disk) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* backing chains need to be refreshed only if they could change */
|
/* backing chains need to be refreshed only if they could change */
|
||||||
|
@ -429,6 +429,9 @@ testCompareXMLToArgv(const void *data)
|
|||||||
conn->secretDriver = &fakeSecretDriver;
|
conn->secretDriver = &fakeSecretDriver;
|
||||||
conn->storageDriver = &fakeStorageDriver;
|
conn->storageDriver = &fakeStorageDriver;
|
||||||
|
|
||||||
|
virSetConnectSecret(conn);
|
||||||
|
virSetConnectStorage(conn);
|
||||||
|
|
||||||
if (virQEMUCapsGet(info->qemuCaps, QEMU_CAPS_MONITOR_JSON))
|
if (virQEMUCapsGet(info->qemuCaps, QEMU_CAPS_MONITOR_JSON))
|
||||||
flags |= FLAG_JSON;
|
flags |= FLAG_JSON;
|
||||||
|
|
||||||
@ -536,6 +539,8 @@ testCompareXMLToArgv(const void *data)
|
|||||||
virDomainChrSourceDefClear(&monitor_chr);
|
virDomainChrSourceDefClear(&monitor_chr);
|
||||||
virCommandFree(cmd);
|
virCommandFree(cmd);
|
||||||
virObjectUnref(vm);
|
virObjectUnref(vm);
|
||||||
|
virSetConnectSecret(NULL);
|
||||||
|
virSetConnectStorage(NULL);
|
||||||
virObjectUnref(conn);
|
virObjectUnref(conn);
|
||||||
VIR_FREE(migrateURI);
|
VIR_FREE(migrateURI);
|
||||||
VIR_FREE(xml);
|
VIR_FREE(xml);
|
||||||
|
Loading…
Reference in New Issue
Block a user