[PATCH 16/18] qemuMonitorGetBlockIoThrottle: Drop 'diskalias' argument

Peter Krempa pkrempa at redhat.com
Thu May 25 15:13:43 UTC 2023


Every caller will pass 'qdevid' as it's populated in the data madatorily
with qemu-4.2 and onwards due to mandatory -blockdev use. Thus we can
drop compatibility with the old way of matching the disk via alias.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_driver.c       | 10 +---------
 src/qemu/qemu_monitor.c      |  6 ++----
 src/qemu/qemu_monitor.h      |  1 -
 src/qemu/qemu_monitor_json.c | 10 ++++------
 src/qemu/qemu_monitor_json.h |  1 -
 tests/qemumonitorjsontest.c  |  2 +-
 6 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d3b37486c3..430b75880b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15240,8 +15240,6 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
     virDomainDef *def = NULL;
     virDomainDef *persistentDef = NULL;
     virDomainBlockIoTuneInfo reply = {0};
-    g_autofree char *drivealias = NULL;
-    const char *qdevid = NULL;
     int ret = -1;
     int maxparams;

@@ -15288,14 +15286,8 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
         if (!qemuDomainDiskBlockIoTuneIsSupported(disk))
             goto endjob;

-        if (QEMU_DOMAIN_DISK_PRIVATE(disk)->qomName) {
-            qdevid = QEMU_DOMAIN_DISK_PRIVATE(disk)->qomName;
-        } else {
-            if (!(drivealias = qemuAliasDiskDriveFromDisk(disk)))
-                goto endjob;
-        }
         qemuDomainObjEnterMonitor(vm);
-        rc = qemuMonitorGetBlockIoThrottle(priv->mon, drivealias, qdevid, &reply);
+        rc = qemuMonitorGetBlockIoThrottle(priv->mon, QEMU_DOMAIN_DISK_PRIVATE(disk)->qomName, &reply);
         qemuDomainObjExitMonitor(vm);

         if (rc < 0)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index dacf161971..5faf64a4ec 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2988,16 +2988,14 @@ qemuMonitorSetBlockIoThrottle(qemuMonitor *mon,

 int
 qemuMonitorGetBlockIoThrottle(qemuMonitor *mon,
-                              const char *drivealias,
                               const char *qdevid,
                               virDomainBlockIoTuneInfo *reply)
 {
-    VIR_DEBUG("drivealias=%s, qdevid=%s, reply=%p",
-              NULLSTR(drivealias), NULLSTR(qdevid), reply);
+    VIR_DEBUG("qdevid=%s, reply=%p", NULLSTR(qdevid), reply);

     QEMU_CHECK_MONITOR(mon);

-    return qemuMonitorJSONGetBlockIoThrottle(mon, drivealias, qdevid, reply);
+    return qemuMonitorJSONGetBlockIoThrottle(mon, qdevid, reply);
 }


diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 09f22f2328..6006a451a3 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1057,7 +1057,6 @@ int qemuMonitorSetBlockIoThrottle(qemuMonitor *mon,
                                   virDomainBlockIoTuneInfo *info);

 int qemuMonitorGetBlockIoThrottle(qemuMonitor *mon,
-                                  const char *drivealias,
                                   const char *qdevid,
                                   virDomainBlockIoTuneInfo *reply);

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 745d83e2b6..af7649f8b0 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -4517,7 +4517,6 @@ int qemuMonitorJSONOpenGraphics(qemuMonitor *mon,
     }
 static int
 qemuMonitorJSONBlockIoThrottleInfo(virJSONValue *io_throttle,
-                                   const char *drivealias,
                                    const char *qdevid,
                                    virDomainBlockIoTuneInfo *reply)
 {
@@ -4547,8 +4546,8 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValue *io_throttle,
             return -1;
         }

-        if ((drivealias && current_drive && STRNEQ(current_drive, drivealias)) ||
-            (qdevid && current_qdev && STRNEQ(current_qdev, qdevid)))
+        if (STRNEQ_NULLABLE(current_qdev, qdevid) &&
+            STRNEQ_NULLABLE(current_drive, qdevid))
             continue;

         found = true;
@@ -4587,7 +4586,7 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValue *io_throttle,
     if (!found) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("cannot find throttling info for device '%1$s'"),
-                       drivealias ? drivealias : qdevid);
+                       qdevid);
         return -1;
     }

@@ -4640,7 +4639,6 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitor *mon,
 }

 int qemuMonitorJSONGetBlockIoThrottle(qemuMonitor *mon,
-                                      const char *drivealias,
                                       const char *qdevid,
                                       virDomainBlockIoTuneInfo *reply)
 {
@@ -4649,7 +4647,7 @@ int qemuMonitorJSONGetBlockIoThrottle(qemuMonitor *mon,
     if (!(devices = qemuMonitorJSONQueryBlock(mon)))
         return -1;

-    return qemuMonitorJSONBlockIoThrottleInfo(devices, drivealias, qdevid, reply);
+    return qemuMonitorJSONBlockIoThrottleInfo(devices, qdevid, reply);
 }

 int qemuMonitorJSONSystemWakeup(qemuMonitor *mon)
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 6f376cf9b7..3f77ab0ab3 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -407,7 +407,6 @@ qemuMonitorJSONSetBlockIoThrottle(qemuMonitor *mon,

 int
 qemuMonitorJSONGetBlockIoThrottle(qemuMonitor *mon,
-                                  const char *drivealias,
                                   const char *qdevid,
                                   virDomainBlockIoTuneInfo *reply);

diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 5c05669280..ba12aae5b7 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -1897,7 +1897,7 @@ testQemuMonitorJSONqemuMonitorJSONSetBlockIoThrottle(const void *opaque)
         return -1;

     if (qemuMonitorJSONGetBlockIoThrottle(qemuMonitorTestGetMonitor(test),
-                                          "drive-virtio-disk0", NULL, &info) < 0)
+                                          "drive-virtio-disk0", &info) < 0)
         goto cleanup;

     if (testValidateGetBlockIoThrottle(&info, &expectedInfo) < 0)
-- 
2.40.1



More information about the libvir-list mailing list