Blame SOURCES/libvirt-qemu_migration-Acquire-correct-job-in-qemuMigrationSrcIsAllowed.patch

032100
From d4c4660b097695916244307d1125a17c30c0c9ef Mon Sep 17 00:00:00 2001
032100
Message-Id: <d4c4660b097695916244307d1125a17c30c0c9ef@dist-git>
032100
From: Martin Kletzander <mkletzan@redhat.com>
032100
Date: Fri, 22 Jul 2022 12:20:04 +0200
032100
Subject: [PATCH] qemu_migration: Acquire correct job in
032100
 qemuMigrationSrcIsAllowed
032100
MIME-Version: 1.0
032100
Content-Type: text/plain; charset=UTF-8
032100
Content-Transfer-Encoding: 8bit
032100
032100
Commit 62627524607f added the acquiring of a job, but it is not always
032100
VIR_ASYNC_JOB_MIGRATION_OUT, so the code fails when doing save or anything else.
032100
Correct the async job by passing it from the caller as another parameter.
032100
032100
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
032100
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
032100
(cherry picked from commit 69e0e33873f1aec55df77f12fb0197d50dca3319)
032100
Resolves: https://bugzilla.redhat.com/2092833
032100
Signed-off-by: Eugenio PĂ©rez <eperezma@redhat.com>
032100
---
032100
 src/qemu/qemu_driver.c    | 8 ++++----
032100
 src/qemu/qemu_migration.c | 7 ++++---
032100
 src/qemu/qemu_migration.h | 1 +
032100
 src/qemu/qemu_snapshot.c  | 4 ++--
032100
 4 files changed, 11 insertions(+), 9 deletions(-)
032100
032100
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
032100
index 654b5d65e5..847c96639d 100644
032100
--- a/src/qemu/qemu_driver.c
032100
+++ b/src/qemu/qemu_driver.c
032100
@@ -2650,13 +2650,13 @@ qemuDomainSaveInternal(virQEMUDriver *driver,
032100
     virQEMUSaveData *data = NULL;
032100
     g_autoptr(qemuDomainSaveCookie) cookie = NULL;
032100
 
032100
-    if (!qemuMigrationSrcIsAllowed(driver, vm, false, 0))
032100
-        goto cleanup;
032100
-
032100
     if (qemuDomainObjBeginAsyncJob(driver, vm, VIR_ASYNC_JOB_SAVE,
032100
                                    VIR_DOMAIN_JOB_OPERATION_SAVE, flags) < 0)
032100
         goto cleanup;
032100
 
032100
+    if (!qemuMigrationSrcIsAllowed(driver, vm, false, VIR_ASYNC_JOB_SAVE, 0))
032100
+        goto cleanup;
032100
+
032100
     if (!virDomainObjIsActive(vm)) {
032100
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
032100
                        _("guest unexpectedly quit"));
032100
@@ -3176,7 +3176,7 @@ doCoreDump(virQEMUDriver *driver,
032100
             goto cleanup;
032100
         }
032100
 
032100
-        if (!qemuMigrationSrcIsAllowed(driver, vm, false, 0))
032100
+        if (!qemuMigrationSrcIsAllowed(driver, vm, false, VIR_ASYNC_JOB_DUMP, 0))
032100
             goto cleanup;
032100
 
032100
         if (qemuMigrationSrcToFile(driver, vm, fd, compressor,
032100
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
032100
index 96c4c0f1da..f571c9eb27 100644
032100
--- a/src/qemu/qemu_migration.c
032100
+++ b/src/qemu/qemu_migration.c
032100
@@ -1452,6 +1452,7 @@ bool
032100
 qemuMigrationSrcIsAllowed(virQEMUDriver *driver,
032100
                           virDomainObj *vm,
032100
                           bool remote,
032100
+                          int asyncJob,
032100
                           unsigned int flags)
032100
 {
032100
     qemuDomainObjPrivate *priv = vm->privateData;
032100
@@ -1483,7 +1484,7 @@ qemuMigrationSrcIsAllowed(virQEMUDriver *driver,
032100
             g_auto(GStrv) blockers = NULL;
032100
 
032100
             if (qemuDomainGetMigrationBlockers(driver, vm,
032100
-                                               VIR_ASYNC_JOB_MIGRATION_OUT,
032100
+                                               asyncJob,
032100
                                                &blockers) < 0) {
032100
                 return false;
032100
             }
032100
@@ -2632,7 +2633,7 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver,
032100
         qemuMigrationJobStartPhase(vm, QEMU_MIGRATION_PHASE_BEGIN3) < 0)
032100
         return NULL;
032100
 
032100
-    if (!qemuMigrationSrcIsAllowed(driver, vm, true, flags))
032100
+    if (!qemuMigrationSrcIsAllowed(driver, vm, true, priv->job.asyncJob, flags))
032100
         return NULL;
032100
 
032100
     if (!(flags & (VIR_MIGRATE_UNSAFE | VIR_MIGRATE_OFFLINE)) &&
032100
@@ -6033,7 +6034,7 @@ qemuMigrationSrcPerformJob(virQEMUDriver *driver,
032100
         if (!(flags & VIR_MIGRATE_OFFLINE) && virDomainObjCheckActive(vm) < 0)
032100
             goto endjob;
032100
 
032100
-        if (!qemuMigrationSrcIsAllowed(driver, vm, true, flags))
032100
+        if (!qemuMigrationSrcIsAllowed(driver, vm, true, VIR_ASYNC_JOB_MIGRATION_OUT, flags))
032100
             goto endjob;
032100
 
032100
         if (!(flags & (VIR_MIGRATE_UNSAFE | VIR_MIGRATE_OFFLINE)) &&
032100
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
032100
index 81cc1e91c0..61d12d6eb1 100644
032100
--- a/src/qemu/qemu_migration.h
032100
+++ b/src/qemu/qemu_migration.h
032100
@@ -229,6 +229,7 @@ bool
032100
 qemuMigrationSrcIsAllowed(virQEMUDriver *driver,
032100
                           virDomainObj *vm,
032100
                           bool remote,
032100
+                          int asyncJob,
032100
                           unsigned int flags);
032100
 
032100
 int
032100
diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
032100
index 833f880252..0733d44faa 100644
032100
--- a/src/qemu/qemu_snapshot.c
032100
+++ b/src/qemu/qemu_snapshot.c
032100
@@ -291,7 +291,7 @@ qemuSnapshotCreateActiveInternal(virQEMUDriver *driver,
032100
     virDomainSnapshotDef *snapdef = virDomainSnapshotObjGetDef(snap);
032100
     int ret = -1;
032100
 
032100
-    if (!qemuMigrationSrcIsAllowed(driver, vm, false, 0))
032100
+    if (!qemuMigrationSrcIsAllowed(driver, vm, false, VIR_ASYNC_JOB_SNAPSHOT, 0))
032100
         goto cleanup;
032100
 
032100
     if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) {
032100
@@ -1422,7 +1422,7 @@ qemuSnapshotCreateActiveExternal(virQEMUDriver *driver,
032100
     /* do the memory snapshot if necessary */
032100
     if (memory) {
032100
         /* check if migration is possible */
032100
-        if (!qemuMigrationSrcIsAllowed(driver, vm, false, 0))
032100
+        if (!qemuMigrationSrcIsAllowed(driver, vm, false, VIR_ASYNC_JOB_SNAPSHOT, 0))
032100
             goto cleanup;
032100
 
032100
         qemuDomainJobSetStatsType(priv->job.current,
032100
-- 
032100
2.35.1
032100