mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 04:55:18 +00:00
qemuMigrationSrcRun: Sanitize setting of cookieFlags and migrate_flags on storage migration
Base the decision on the main API flags (VIR_MIGRATE_NON_SHARED_DISK, QEMU_MONITOR_MIGRATE_NON_SHARED_INC) via a boolean 'storageMigration' rather than juggling everything trhough 'migration_flags'. After this patch 'migration_flags' is updated to contain the legacy storage migration flags only when we'll be about to use it rather than setting it and then resetting it. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Tested-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
a9c1d5657d
commit
da69f4b208
@ -3995,6 +3995,7 @@ qemuMigrationSrcRun(virQEMUDriver *driver,
|
|||||||
bool abort_on_error = !!(flags & VIR_MIGRATE_ABORT_ON_ERROR);
|
bool abort_on_error = !!(flags & VIR_MIGRATE_ABORT_ON_ERROR);
|
||||||
bool events = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT);
|
bool events = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT);
|
||||||
bool bwParam = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_PARAM_BANDWIDTH);
|
bool bwParam = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_PARAM_BANDWIDTH);
|
||||||
|
bool storageMigration = flags & (VIR_MIGRATE_NON_SHARED_DISK | QEMU_MONITOR_MIGRATE_NON_SHARED_INC);
|
||||||
bool cancel = false;
|
bool cancel = false;
|
||||||
unsigned int waitFlags;
|
unsigned int waitFlags;
|
||||||
g_autoptr(virDomainDef) persistDef = NULL;
|
g_autoptr(virDomainDef) persistDef = NULL;
|
||||||
@ -4010,19 +4011,13 @@ qemuMigrationSrcRun(virQEMUDriver *driver,
|
|||||||
spec, spec->destType, spec->fwdType, dconn,
|
spec, spec->destType, spec->fwdType, dconn,
|
||||||
NULLSTR(graphicsuri), nmigrate_disks, migrate_disks);
|
NULLSTR(graphicsuri), nmigrate_disks, migrate_disks);
|
||||||
|
|
||||||
if (flags & VIR_MIGRATE_NON_SHARED_DISK) {
|
if (storageMigration) {
|
||||||
migrate_flags |= QEMU_MONITOR_MIGRATE_NON_SHARED_DISK;
|
|
||||||
cookieFlags |= QEMU_MIGRATION_COOKIE_NBD;
|
cookieFlags |= QEMU_MIGRATION_COOKIE_NBD;
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & VIR_MIGRATE_NON_SHARED_INC) {
|
if (virQEMUCapsGet(priv->qemuCaps,
|
||||||
migrate_flags |= QEMU_MONITOR_MIGRATE_NON_SHARED_INC;
|
QEMU_CAPS_MIGRATION_PARAM_BLOCK_BITMAP_MAPPING))
|
||||||
cookieFlags |= QEMU_MIGRATION_COOKIE_NBD;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cookieFlags & QEMU_MIGRATION_COOKIE_NBD &&
|
|
||||||
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_PARAM_BLOCK_BITMAP_MAPPING))
|
|
||||||
cookieFlags |= QEMU_MIGRATION_COOKIE_BLOCK_DIRTY_BITMAPS;
|
cookieFlags |= QEMU_MIGRATION_COOKIE_BLOCK_DIRTY_BITMAPS;
|
||||||
|
}
|
||||||
|
|
||||||
if (virLockManagerPluginUsesState(driver->lockManager) &&
|
if (virLockManagerPluginUsesState(driver->lockManager) &&
|
||||||
!cookieout) {
|
!cookieout) {
|
||||||
@ -4100,8 +4095,8 @@ qemuMigrationSrcRun(virQEMUDriver *driver,
|
|||||||
migParams) < 0)
|
migParams) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (migrate_flags & (QEMU_MONITOR_MIGRATE_NON_SHARED_DISK |
|
|
||||||
QEMU_MONITOR_MIGRATE_NON_SHARED_INC)) {
|
if (storageMigration) {
|
||||||
if (mig->nbd) {
|
if (mig->nbd) {
|
||||||
const char *host = "";
|
const char *host = "";
|
||||||
|
|
||||||
@ -4130,16 +4125,17 @@ qemuMigrationSrcRun(virQEMUDriver *driver,
|
|||||||
nbdURI, flags) < 0) {
|
nbdURI, flags) < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mask out the legacy migration flags if we are using NBD */
|
|
||||||
migrate_flags &= ~(QEMU_MONITOR_MIGRATE_NON_SHARED_DISK |
|
|
||||||
QEMU_MONITOR_MIGRATE_NON_SHARED_INC);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* Destination doesn't support NBD server.
|
/* Destination doesn't support NBD server.
|
||||||
* Fall back to previous implementation. */
|
* Fall back to previous implementation. */
|
||||||
VIR_DEBUG("Destination doesn't support NBD server "
|
VIR_DEBUG("Destination doesn't support NBD server "
|
||||||
"Falling back to previous implementation.");
|
"Falling back to previous implementation.");
|
||||||
|
|
||||||
|
if (flags & VIR_MIGRATE_NON_SHARED_DISK)
|
||||||
|
migrate_flags |= QEMU_MONITOR_MIGRATE_NON_SHARED_DISK;
|
||||||
|
|
||||||
|
if (flags & VIR_MIGRATE_NON_SHARED_INC)
|
||||||
|
migrate_flags |= QEMU_MONITOR_MIGRATE_NON_SHARED_INC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user