mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu: migration: don't open storage driver too early
If storage migration is requested, and the destination storage does not exist on the remote host, qemu's migration support will call into the libvirt storage driver to precreate the destination storage. The storage driver virConnectPtr is opened too early though, adding an unnecessary dependency on the storage driver for several cases that don't require it. This currently requires kubevirt to install the storage driver even though they aren't actually using it. Push the virGetConnectStorage calls to right before the cases they are actually needed. Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
6ad23525e4
commit
accdc0e773
@ -169,7 +169,7 @@ qemuMigrationSrcRestoreDomainState(virQEMUDriverPtr driver, virDomainObjPtr vm)
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuMigrationDstPrecreateDisk(virConnectPtr conn,
|
qemuMigrationDstPrecreateDisk(virConnectPtr *conn,
|
||||||
virDomainDiskDefPtr disk,
|
virDomainDiskDefPtr disk,
|
||||||
unsigned long long capacity)
|
unsigned long long capacity)
|
||||||
{
|
{
|
||||||
@ -204,7 +204,12 @@ qemuMigrationDstPrecreateDisk(virConnectPtr conn,
|
|||||||
*volName = '\0';
|
*volName = '\0';
|
||||||
volName++;
|
volName++;
|
||||||
|
|
||||||
if (!(pool = virStoragePoolLookupByTargetPath(conn, basePath)))
|
if (!*conn) {
|
||||||
|
if (!(*conn = virGetConnectStorage()))
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(pool = virStoragePoolLookupByTargetPath(*conn, basePath)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
format = virStorageFileFormatTypeToString(disk->src->format);
|
format = virStorageFileFormatTypeToString(disk->src->format);
|
||||||
if (disk->src->format == VIR_STORAGE_FILE_QCOW2)
|
if (disk->src->format == VIR_STORAGE_FILE_QCOW2)
|
||||||
@ -212,7 +217,12 @@ qemuMigrationDstPrecreateDisk(virConnectPtr conn,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_STORAGE_TYPE_VOLUME:
|
case VIR_STORAGE_TYPE_VOLUME:
|
||||||
if (!(pool = virStoragePoolLookupByName(conn, disk->src->srcpool->pool)))
|
if (!*conn) {
|
||||||
|
if (!(*conn = virGetConnectStorage()))
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(pool = virStoragePoolLookupByName(*conn, disk->src->srcpool->pool)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
format = virStorageFileFormatTypeToString(disk->src->format);
|
format = virStorageFileFormatTypeToString(disk->src->format);
|
||||||
volName = disk->src->srcpool->volume;
|
volName = disk->src->srcpool->volume;
|
||||||
@ -304,14 +314,11 @@ qemuMigrationDstPrecreateStorage(virDomainObjPtr vm,
|
|||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
virConnectPtr conn;
|
virConnectPtr conn = NULL;
|
||||||
|
|
||||||
if (!nbd || !nbd->ndisks)
|
if (!nbd || !nbd->ndisks)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!(conn = virGetConnectStorage()))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (i = 0; i < nbd->ndisks; i++) {
|
for (i = 0; i < nbd->ndisks; i++) {
|
||||||
virDomainDiskDefPtr disk;
|
virDomainDiskDefPtr disk;
|
||||||
const char *diskSrcPath;
|
const char *diskSrcPath;
|
||||||
@ -349,7 +356,8 @@ qemuMigrationDstPrecreateStorage(virDomainObjPtr vm,
|
|||||||
|
|
||||||
VIR_DEBUG("Proceeding with disk source %s", NULLSTR(diskSrcPath));
|
VIR_DEBUG("Proceeding with disk source %s", NULLSTR(diskSrcPath));
|
||||||
|
|
||||||
if (qemuMigrationDstPrecreateDisk(conn, disk, nbd->disks[i].capacity) < 0)
|
if (qemuMigrationDstPrecreateDisk(&conn,
|
||||||
|
disk, nbd->disks[i].capacity) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user