[PATCH 08/55] qemu: monitor: Allow using 'id' instead of 'device' for 'block_set_io_throttle'

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

 



The 'device' argument matches only the legacy drive alias. For blockdev
we need to set the throttling for a QOM id and thus we'll need to use
the 'id' field.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c       |  2 +-
 src/qemu/qemu_monitor.c      |  8 +++++---
 src/qemu/qemu_monitor.h      |  3 ++-
 src/qemu/qemu_monitor_json.c | 14 ++++++++++----
 src/qemu/qemu_monitor_json.h |  3 ++-
 tests/qemumonitorjsontest.c  |  2 +-
 6 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 5a4357d7a1..99fd3bebf5 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -18488,7 +18488,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
           * via the JSON error code from the block_set_io_throttle call */

         qemuDomainObjEnterMonitor(driver, vm);
-        ret = qemuMonitorSetBlockIoThrottle(priv->mon, device,
+        ret = qemuMonitorSetBlockIoThrottle(priv->mon, device, NULL,
                                             &info, supportMaxOptions,
                                             set_fields & QEMU_BLOCK_IOTUNE_SET_GROUP_NAME,
                                             supportMaxLengthOptions);
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 4f0bbc147d..2902c3b246 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3444,17 +3444,19 @@ qemuMonitorGetBlockJobInfo(qemuMonitorPtr mon,

 int
 qemuMonitorSetBlockIoThrottle(qemuMonitorPtr mon,
-                              const char *device,
+                              const char *drivealias,
+                              const char *qomid,
                               virDomainBlockIoTuneInfoPtr info,
                               bool supportMaxOptions,
                               bool supportGroupNameOption,
                               bool supportMaxLengthOptions)
 {
-    VIR_DEBUG("device=%p, info=%p", device, info);
+    VIR_DEBUG("drivealias=%s, qomid=%s, info=%p",
+              NULLSTR(drivealias), NULLSTR(qomid), info);

     QEMU_CHECK_MONITOR(mon);

-    return qemuMonitorJSONSetBlockIoThrottle(mon, device, info,
+    return qemuMonitorJSONSetBlockIoThrottle(mon, drivealias, qomid, info,
                                              supportMaxOptions,
                                              supportGroupNameOption,
                                              supportMaxLengthOptions);
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index b8e3ca2ce1..16fc75819f 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -932,7 +932,8 @@ int qemuMonitorOpenGraphics(qemuMonitorPtr mon,
                             bool skipauth);

 int qemuMonitorSetBlockIoThrottle(qemuMonitorPtr mon,
-                                  const char *device,
+                                  const char *drivealias,
+                                  const char *qomid,
                                   virDomainBlockIoTuneInfoPtr info,
                                   bool supportMaxOptions,
                                   bool supportGroupNameOption,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 48439ccae1..3a1dfb8563 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -4897,7 +4897,8 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr io_throttle,
 #undef GET_THROTTLE_STATS_OPTIONAL

 int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr mon,
-                                      const char *device,
+                                      const char *drivealias,
+                                      const char *qomid,
                                       virDomainBlockIoTuneInfoPtr info,
                                       bool supportMaxOptions,
                                       bool supportGroupNameOption,
@@ -4907,12 +4908,17 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr mon,
     virJSONValuePtr cmd = NULL;
     virJSONValuePtr result = NULL;
     virJSONValuePtr args = NULL;
+    const char *errdev = drivealias;
+
+    if (!errdev)
+        errdev = qomid;

     if (!(cmd = qemuMonitorJSONMakeCommand("block_set_io_throttle", NULL)))
         return -1;

     if (virJSONValueObjectCreate(&args,
-                                 "s:device", device,
+                                 "S:device", drivealias,
+                                 "S:id", qomid,
                                  "U:bps", info->total_bytes_sec,
                                  "U:bps_rd", info->read_bytes_sec,
                                  "U:bps_wr", info->write_bytes_sec,
@@ -4967,10 +4973,10 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr mon,
     if (virJSONValueObjectHasKey(result, "error")) {
         if (qemuMonitorJSONHasError(result, "DeviceNotActive")) {
             virReportError(VIR_ERR_OPERATION_INVALID,
-                           _("No active operation on device: %s"), device);
+                           _("No active operation on device: %s"), errdev);
         } else if (qemuMonitorJSONHasError(result, "NotSupported")) {
             virReportError(VIR_ERR_OPERATION_INVALID,
-                           _("Operation is not supported for device: %s"), device);
+                           _("Operation is not supported for device: %s"), errdev);
         } else {
             virJSONValuePtr error = virJSONValueObjectGet(result, "error");
             virReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 0458d81c0d..47635f14b1 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -327,7 +327,8 @@ int qemuMonitorJSONOpenGraphics(qemuMonitorPtr mon,
                                 bool skipauth);

 int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr mon,
-                                      const char *device,
+                                      const char *drivealias,
+                                      const char *qomid,
                                       virDomainBlockIoTuneInfoPtr info,
                                       bool supportMaxOptions,
                                       bool supportGroupNameOption,
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 863fa440a3..01e35cee04 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -2146,7 +2146,7 @@ testQemuMonitorJSONqemuMonitorJSONSetBlockIoThrottle(const void *data)
         goto cleanup;

     if (qemuMonitorJSONSetBlockIoThrottle(qemuMonitorTestGetMonitor(test),
-                                          "drive-virtio-disk1", &info, true,
+                                          "drive-virtio-disk1", NULL, &info, true,
                                           true, true) < 0)
         goto cleanup;

-- 
2.16.2

--
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