[PATCH 3/3] qemu: Use proper block job name when reconnecting to VM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The hash table returned by qemuMonitorGetAllBlockJobInfo is organized by
the frontend name (which skipps the 'drive-' prefix). While our code
properly matches the jobs to the disk, qemu needs the full job name
including the 'drive-' prefix to be able to identify jobs.

Fix this by adding an argument to qemuMonitorGetAllBlockJobInfo which
does not modify the job name before filling the hash.

This fixes a regression where users would not be able to cancel/pivot
block jobs after restarting libvirtd while a blockjob is running.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_migration.c    |  2 +-
 src/qemu/qemu_monitor.c      |  7 ++++---
 src/qemu/qemu_monitor.h      |  3 ++-
 src/qemu/qemu_monitor_json.c | 12 ++++++++----
 src/qemu/qemu_monitor_json.h |  3 ++-
 src/qemu/qemu_process.c      |  2 +-
 6 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 32b3040473..1ea817004d 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -5545,7 +5545,7 @@ qemuMigrationSrcFetchMirrorStats(virQEMUDriverPtr driver,
     if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
         return -1;

-    blockinfo = qemuMonitorGetAllBlockJobInfo(priv->mon);
+    blockinfo = qemuMonitorGetAllBlockJobInfo(priv->mon, false);

     if (qemuDomainObjExitMonitor(driver, vm) < 0 || !blockinfo)
         return -1;
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 6b731cd91a..9826426b29 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3442,10 +3442,11 @@ qemuMonitorBlockJobSetSpeed(qemuMonitorPtr mon,


 virHashTablePtr
-qemuMonitorGetAllBlockJobInfo(qemuMonitorPtr mon)
+qemuMonitorGetAllBlockJobInfo(qemuMonitorPtr mon,
+                              bool rawjobname)
 {
     QEMU_CHECK_MONITOR_NULL(mon);
-    return qemuMonitorJSONGetAllBlockJobInfo(mon);
+    return qemuMonitorJSONGetAllBlockJobInfo(mon, rawjobname);
 }


@@ -3465,7 +3466,7 @@ qemuMonitorGetBlockJobInfo(qemuMonitorPtr mon,

     VIR_DEBUG("alias=%s, info=%p", alias, info);

-    if (!(all = qemuMonitorGetAllBlockJobInfo(mon)))
+    if (!(all = qemuMonitorGetAllBlockJobInfo(mon, false)))
         return -1;

     if ((data = virHashLookup(all, alias))) {
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index dee594fa66..cf4d567667 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -956,7 +956,8 @@ struct _qemuMonitorBlockJobInfo {
     int ready; /* -1 if unknown, 0 if not ready, 1 if ready */
 };

-virHashTablePtr qemuMonitorGetAllBlockJobInfo(qemuMonitorPtr mon);
+virHashTablePtr qemuMonitorGetAllBlockJobInfo(qemuMonitorPtr mon,
+                                              bool rawjobname);
 int qemuMonitorGetBlockJobInfo(qemuMonitorPtr mon,
                                const char *device,
                                qemuMonitorBlockJobInfoPtr info)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 53a7de8b77..2873399dc3 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -4662,7 +4662,8 @@ int qemuMonitorJSONScreendump(qemuMonitorPtr mon,

 static int
 qemuMonitorJSONParseBlockJobInfo(virHashTablePtr blockJobs,
-                                 virJSONValuePtr entry)
+                                 virJSONValuePtr entry,
+                                 bool rawjobname)
 {
     qemuMonitorBlockJobInfoPtr info = NULL;
     const char *device;
@@ -4674,7 +4675,9 @@ qemuMonitorJSONParseBlockJobInfo(virHashTablePtr blockJobs,
                        _("entry was missing 'device'"));
         return -1;
     }
-    device = qemuAliasDiskDriveSkipPrefix(device);
+
+    if (!rawjobname)
+        device = qemuAliasDiskDriveSkipPrefix(device);

     if (VIR_ALLOC(info) < 0 ||
         virHashAddEntry(blockJobs, device, info) < 0) {
@@ -4724,7 +4727,8 @@ qemuMonitorJSONParseBlockJobInfo(virHashTablePtr blockJobs,
 }

 virHashTablePtr
-qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon)
+qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon,
+                                  bool rawjobname)
 {
     virJSONValuePtr cmd = NULL;
     virJSONValuePtr reply = NULL;
@@ -4756,7 +4760,7 @@ qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon)
                            _("missing array element"));
             goto error;
         }
-        if (qemuMonitorJSONParseBlockJobInfo(blockJobs, entry) < 0)
+        if (qemuMonitorJSONParseBlockJobInfo(blockJobs, entry, rawjobname) < 0)
             goto error;
     }

diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index acef1a0a79..c8fde1d1b6 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -317,7 +317,8 @@ int qemuMonitorJSONBlockJobSetSpeed(qemuMonitorPtr mon,
                                     unsigned long long speed)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

-virHashTablePtr qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon)
+virHashTablePtr qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon,
+                                                  bool rawjobname)
     ATTRIBUTE_NONNULL(1);

 int qemuMonitorJSONSetLink(qemuMonitorPtr mon,
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 50a76aa0ed..f114611e02 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -8011,7 +8011,7 @@ qemuProcessRefreshLegacyBlockjobs(virQEMUDriverPtr driver,
     int ret = -1;

     qemuDomainObjEnterMonitor(driver, vm);
-    blockJobs = qemuMonitorGetAllBlockJobInfo(qemuDomainGetMonitor(vm));
+    blockJobs = qemuMonitorGetAllBlockJobInfo(qemuDomainGetMonitor(vm), true);
     if (qemuDomainObjExitMonitor(driver, vm) < 0 || !blockJobs)
         goto cleanup;

-- 
2.21.0

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux