mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemuMigrationDstPrepareStorage: Move block device specific logic
Now that we have a switch statement, the code adding the 'slice' for block devices of non-equal sizes can be moved to appropriate location. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
e42a3935ac
commit
1e12394d3b
@ -452,8 +452,27 @@ qemuMigrationDstPrepareStorage(virDomainObj *vm,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
switch (virStorageSourceGetActualType(disk->src)) {
|
switch (virStorageSourceGetActualType(disk->src)) {
|
||||||
case VIR_STORAGE_TYPE_FILE:
|
|
||||||
case VIR_STORAGE_TYPE_BLOCK:
|
case VIR_STORAGE_TYPE_BLOCK:
|
||||||
|
/* In case the destination of the storage migration is a block
|
||||||
|
* device it might be possible that for various reasons the size
|
||||||
|
* will not be identical. Since qemu refuses to do a blockdev-mirror
|
||||||
|
* into an image which doesn't have the exact same size we need to
|
||||||
|
* install a slice on top of the top image */
|
||||||
|
if (disk->src->format == VIR_STORAGE_FILE_RAW &&
|
||||||
|
disk->src->sliceStorage == NULL) {
|
||||||
|
qemuDomainObjPrivate *priv = vm->privateData;
|
||||||
|
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(priv->driver);
|
||||||
|
qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
||||||
|
|
||||||
|
if (qemuDomainStorageUpdatePhysical(cfg, vm, disk->src) == 0 &&
|
||||||
|
disk->src->physical > nbd->disks[i].capacity) {
|
||||||
|
disk->src->sliceStorage = g_new0(virStorageSourceSlice, 1);
|
||||||
|
disk->src->sliceStorage->size = nbd->disks[i].capacity;
|
||||||
|
diskPriv->migrationslice = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
G_GNUC_FALLTHROUGH;
|
||||||
|
case VIR_STORAGE_TYPE_FILE:
|
||||||
case VIR_STORAGE_TYPE_DIR:
|
case VIR_STORAGE_TYPE_DIR:
|
||||||
diskSrcPath = virDomainDiskGetSource(disk);
|
diskSrcPath = virDomainDiskGetSource(disk);
|
||||||
break;
|
break;
|
||||||
@ -478,26 +497,6 @@ qemuMigrationDstPrepareStorage(virDomainObj *vm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (diskSrcPath) {
|
if (diskSrcPath) {
|
||||||
/* In case the destination of the storage migration is a block
|
|
||||||
* device it might be possible that for various reasons the size
|
|
||||||
* will not be identical. Since qemu refuses to do a blockdev-mirror
|
|
||||||
* into an image which doesn't have the exact same size we need to
|
|
||||||
* install a slice on top of the top image */
|
|
||||||
if (virStorageSourceIsBlockLocal(disk->src) &&
|
|
||||||
disk->src->format == VIR_STORAGE_FILE_RAW &&
|
|
||||||
disk->src->sliceStorage == NULL) {
|
|
||||||
qemuDomainObjPrivate *priv = vm->privateData;
|
|
||||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(priv->driver);
|
|
||||||
qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
|
||||||
|
|
||||||
if (qemuDomainStorageUpdatePhysical(cfg, vm, disk->src) == 0 &&
|
|
||||||
disk->src->physical > nbd->disks[i].capacity) {
|
|
||||||
disk->src->sliceStorage = g_new0(virStorageSourceSlice, 1);
|
|
||||||
disk->src->sliceStorage->size = nbd->disks[i].capacity;
|
|
||||||
diskPriv->migrationslice = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* don't pre-create existing disks */
|
/* don't pre-create existing disks */
|
||||||
if (virFileExists(diskSrcPath)) {
|
if (virFileExists(diskSrcPath)) {
|
||||||
VIR_DEBUG("Skipping pre-create of existing source for disk '%s'", disk->dst);
|
VIR_DEBUG("Skipping pre-create of existing source for disk '%s'", disk->dst);
|
||||||
|
Loading…
Reference in New Issue
Block a user