[PATCH] qemuMigrationSrcBeginPhase: Don't call 'qemuBlockNodesEnsureActive' with offline VM

Peter Krempa via Devel posted 1 patch 5 days, 8 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/0377a659f2d245aabc24896da7494caed680119d.1773838823.git.pkrempa@redhat.com
src/qemu/qemu_migration.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] qemuMigrationSrcBeginPhase: Don't call 'qemuBlockNodesEnsureActive' with offline VM
Posted by Peter Krempa via Devel 5 days, 8 hours ago
From: Peter Krempa <pkrempa@redhat.com>

Commits 7b5566ce67b18a and f879d5f40385358 ( v11.8.0-92-gf879d5f403 )
moved around code for re-activating block backends after migration.
While previously it was done when migration failed now we do it when we
need qemu to do some block operations.

Commit 7b5566ce67b18a introduced a bug where 'qemuBlockNodesEnsureActive'
is called also when the VM is offline (for migration with
'VIR_MIGRATE_OFFLINE'). That doesn't work though as attempting to enter
the monitor of an inactive VM returns failure.

Address it by calling 'qemuBlockNodesEnsureActive' only on active VMs
during migration.

Fixes: 7b5566ce67b18a2bebe68fdb07e046f25185f8d3
Resolves: https://redhat.atlassian.net/browse/RHEL-156800
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_migration.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index fec808ccfb..3141018a78 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2870,7 +2870,8 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver,
          vm->newDef && !qemuDomainVcpuHotplugIsInOrder(vm->newDef)))
         cookieFlags |= QEMU_MIGRATION_COOKIE_CPU_HOTPLUG;

-    if (qemuBlockNodesEnsureActive(vm, vm->job->asyncJob) < 0)
+    if (virDomainObjIsActive(vm) &&
+        qemuBlockNodesEnsureActive(vm, vm->job->asyncJob) < 0)
         return NULL;

     return qemuMigrationSrcBeginXML(vm, xmlin,
-- 
2.53.0
Re: [PATCH] qemuMigrationSrcBeginPhase: Don't call 'qemuBlockNodesEnsureActive' with offline VM
Posted by Michal Prívozník via Devel 5 days, 6 hours ago
On 3/18/26 14:00, Peter Krempa via Devel wrote:
> From: Peter Krempa <pkrempa@redhat.com>
> 
> Commits 7b5566ce67b18a and f879d5f40385358 ( v11.8.0-92-gf879d5f403 )
> moved around code for re-activating block backends after migration.
> While previously it was done when migration failed now we do it when we
> need qemu to do some block operations.
> 
> Commit 7b5566ce67b18a introduced a bug where 'qemuBlockNodesEnsureActive'
> is called also when the VM is offline (for migration with
> 'VIR_MIGRATE_OFFLINE'). That doesn't work though as attempting to enter
> the monitor of an inactive VM returns failure.
> 
> Address it by calling 'qemuBlockNodesEnsureActive' only on active VMs
> during migration.
> 
> Fixes: 7b5566ce67b18a2bebe68fdb07e046f25185f8d3
> Resolves: https://redhat.atlassian.net/browse/RHEL-156800
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>  src/qemu/qemu_migration.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Michal