[PATCH 0/2] A couple of migration blocker query patches

Five minutes after pushing eperezma's patches that query QEMU for migration blockers, I realized that the query would be called during "offline migration" (when there is no QEMU process running). So the 1st patch moves the query down so it will only be called during live migration. The 2nd patch takes advantage of this new query to skip the hardcoded check the makes any vfio assigned device a migration blocker. Once QEMU and the kernel get migration of (some) vfio devices sorted out, libvirt will allow migration of domains with those devices. Laine Stump (2): qemu: don't try to query QEMU about migration blockers during offline migration qemu: skip hardcoded hostdev migration check if QEMU can do it for us src/qemu/qemu_migration.c | 45 ++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 19 deletions(-) -- 2.35.3

The new code that queries QEMU about migration blockers was put at the top of qemuMigrationSrcIsAllowed(), but that function can also be called in the case of offline migration (ie when the domain is inactive / QEMU isn't running). This check should have been put inside the "if (!(flags & VIR_MIGRATE_OFFLINE))" conditional, so let's move it there. Fixes: 156e99f686690855be4e45d9b8b3194191a8bc31 Signed-off-by: Laine Stump <laine@redhat.com> --- src/qemu/qemu_migration.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 5d1e5f987b..6fc5791f61 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1455,22 +1455,6 @@ qemuMigrationSrcIsAllowed(virQEMUDriver *driver, int nsnapshots; int pauseReason; size_t i; - bool blockedReasonsCap = virQEMUCapsGet(priv->qemuCaps, - QEMU_CAPS_MIGRATION_BLOCKED_REASONS); - - /* Ask qemu if it have a migration blocker */ - if (blockedReasonsCap) { - g_auto(GStrv) blockers = NULL; - if (qemuDomainGetMigrationBlockers(driver, vm, &blockers) < 0) - return false; - - if (blockers && blockers[0]) { - g_autofree char *reasons = g_strjoinv("; ", blockers); - virReportError(VIR_ERR_OPERATION_INVALID, - _("cannot migrate domain: %s"), reasons); - return false; - } - } /* perform these checks only when migrating to remote hosts */ if (remote) { @@ -1488,6 +1472,24 @@ qemuMigrationSrcIsAllowed(virQEMUDriver *driver, /* following checks don't make sense for offline migration */ if (!(flags & VIR_MIGRATE_OFFLINE)) { + bool blockedReasonsCap = virQEMUCapsGet(priv->qemuCaps, + QEMU_CAPS_MIGRATION_BLOCKED_REASONS); + + /* Ask qemu if it has a migration blocker */ + if (blockedReasonsCap) { + g_auto(GStrv) blockers = NULL; + + if (qemuDomainGetMigrationBlockers(driver, vm, &blockers) < 0) + return false; + + if (blockers && blockers[0]) { + g_autofree char *reasons = g_strjoinv("; ", blockers); + virReportError(VIR_ERR_OPERATION_INVALID, + _("cannot migrate domain: %s"), reasons); + return false; + } + } + if (remote) { /* cancel migration if disk I/O error is emitted while migrating */ if (flags & VIR_MIGRATE_ABORT_ON_ERROR && -- 2.35.3

libvirt currently will block migration for any vfio-assigned device unless it is a network device that is associated with a virtio-net failover device (ie. if the hostdev object has a teaming->type == VIR_DOMAIN_NET_TEAMING_TYPE_TRANSIENT). In the future there will be other vfio devices that can be migrated, so we don't want to rely on this hardcoded block. QEMU 6.0+ will anyway inform us of any devices that will block migration (as a part of qemuDomainGetMigrationBlockers()), so we only need to do the hardcoded check in the case of old QEMU that can't provide that information. Signed-off-by: Laine Stump <laine@redhat.com> --- src/qemu/qemu_migration.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 6fc5791f61..4ad5b7af39 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1488,6 +1488,14 @@ qemuMigrationSrcIsAllowed(virQEMUDriver *driver, _("cannot migrate domain: %s"), reasons); return false; } + } else { + /* checks here are for anything that doesn't need to be + * checked by libvirt if running QEMU that can be queried + * about migration blockers. + */ + + if (!qemuMigrationSrcIsAllowedHostdev(vm->def)) + return false; } if (remote) { @@ -1514,9 +1522,6 @@ qemuMigrationSrcIsAllowed(virQEMUDriver *driver, return false; } - if (!qemuMigrationSrcIsAllowedHostdev(vm->def)) - return false; - if (vm->def->cpu) { /* QEMU blocks migration and save with invariant TSC enabled * unless TSC frequency is explicitly set. -- 2.35.3

On Thu, Jul 21, 2022 at 02:21:11 -0400, Laine Stump wrote:
Five minutes after pushing eperezma's patches that query QEMU for migration blockers, I realized that the query would be called during "offline migration" (when there is no QEMU process running). So the 1st patch moves the query down so it will only be called during live migration.
The 2nd patch takes advantage of this new query to skip the hardcoded check the makes any vfio assigned device a migration blocker. Once QEMU and the kernel get migration of (some) vfio devices sorted out, libvirt will allow migration of domains with those devices.
Laine Stump (2): qemu: don't try to query QEMU about migration blockers during offline migration qemu: skip hardcoded hostdev migration check if QEMU can do it for us
src/qemu/qemu_migration.c | 45 ++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 19 deletions(-)
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
participants (2)
-
Jiri Denemark
-
Laine Stump