migrate_cancel QMP command cannot be used for cancelling memory-only
dumps and priv->job.dump_memory_only is used for reporting an error if
someone calls virDomainAbortJob when memory-only dump job is running.

Since commit 150930e3098 the dump_memory_only flag is set only
dump-guest-memory command was called without the detach parameter. This
would incorrectly allow libvirt to send migrate_cancel while the
detached memory-only dump is running.

Signed-off-by: Jiri Denemark <jdene...@redhat.com>
---
 src/qemu/qemu_driver.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 198020a0e4..4af6d58fb1 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3794,12 +3794,12 @@ qemuDumpToFd(virQEMUDriverPtr driver,
     if (qemuSecuritySetImageFDLabel(driver->securityManager, vm->def, fd) < 0)
         return -1;
 
-    if (detach) {
+    priv->job.dump_memory_only = true;
+
+    if (detach)
         priv->job.current->statsType = QEMU_DOMAIN_JOB_STATS_TYPE_MEMDUMP;
-    } else {
+    else
         VIR_FREE(priv->job.current);
-        priv->job.dump_memory_only = true;
-    }
 
     if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
         return -1;
@@ -13472,7 +13472,7 @@ static int qemuDomainAbortJob(virDomainPtr dom)
 
     priv = vm->privateData;
 
-    if (!priv->job.asyncJob || priv->job.dump_memory_only) {
+    if (!priv->job.asyncJob) {
         virReportError(VIR_ERR_OPERATION_INVALID,
                        "%s", _("no job is active on the domain"));
         goto endjob;
@@ -13485,6 +13485,13 @@ static int qemuDomainAbortJob(virDomainPtr dom)
         goto endjob;
     }
 
+    if (priv->job.asyncJob == QEMU_ASYNC_JOB_DUMP &&
+        priv->job.dump_memory_only) {
+        virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                       _("cannot abort memory-only dump"));
+        goto endjob;
+    }
+
     if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT &&
         (priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY ||
          (virDomainObjGetState(vm, &reason) == VIR_DOMAIN_PAUSED &&
-- 
2.17.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to