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

[libvirt] [PATCHv2 38/62] qemu: driver: Use QOM backend name for disk IO throttling APIs



With -blockdev the drive alias can't be used any more so we need to
switch to the QOM name.

Signed-off-by: Peter Krempa <pkrempa redhat com>
---
 src/qemu/qemu_driver.c | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 7b9c19087e..fb09278112 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -18202,7 +18202,8 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
     virDomainDefPtr def = NULL;
     virDomainDefPtr persistentDef = NULL;
     virDomainBlockIoTuneInfo info;
-    char *device = NULL;
+    char *drivealias = NULL;
+    const char *qdevid = NULL;
     int ret = -1;
     size_t i;
     virDomainDiskDefPtr conf_disk = NULL;
@@ -18427,8 +18428,12 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
         if (!(disk = qemuDomainDiskByName(def, path)))
             goto endjob;

-        if (!(device = qemuAliasDiskDriveFromDisk(disk)))
-            goto endjob;
+        if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) {
+            qdevid = QEMU_DOMAIN_DISK_PRIVATE(disk)->backendQomName;
+        } else {
+            if (!(drivealias = qemuAliasDiskDriveFromDisk(disk)))
+                goto endjob;
+        }

         if (qemuDomainSetBlockIoTuneDefaults(&info, &disk->blkdeviotune,
                                              set_fields) < 0)
@@ -18474,7 +18479,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
           * via the JSON error code from the block_set_io_throttle call */

         qemuDomainObjEnterMonitor(driver, vm);
-        ret = qemuMonitorSetBlockIoThrottle(priv->mon, device, NULL,
+        ret = qemuMonitorSetBlockIoThrottle(priv->mon, drivealias, qdevid,
                                             &info, supportMaxOptions,
                                             set_fields & QEMU_BLOCK_IOTUNE_SET_GROUP_NAME,
                                             supportMaxLengthOptions);
@@ -18524,7 +18529,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,

  cleanup:
     VIR_FREE(info.group_name);
-    VIR_FREE(device);
+    VIR_FREE(drivealias);
     virDomainObjEndAPI(&vm);
     if (eventNparams)
         virTypedParamsFree(eventParams, eventNparams);
@@ -18546,7 +18551,8 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
     virDomainDefPtr def = NULL;
     virDomainDefPtr persistentDef = NULL;
     virDomainBlockIoTuneInfo reply = {0};
-    char *device = NULL;
+    char *drivealias = NULL;
+    const char *qdevid = NULL;
     int ret = -1;
     int maxparams;

@@ -18600,10 +18606,14 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
         if (!(disk = qemuDomainDiskByName(def, path)))
             goto endjob;

-        if (!(device = qemuAliasDiskDriveFromDisk(disk)))
-            goto endjob;
+        if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) {
+            qdevid = QEMU_DOMAIN_DISK_PRIVATE(disk)->backendQomName;
+        } else {
+            if (!(drivealias = qemuAliasDiskDriveFromDisk(disk)))
+                goto endjob;
+        }
         qemuDomainObjEnterMonitor(driver, vm);
-        ret = qemuMonitorGetBlockIoThrottle(priv->mon, device, NULL, &reply);
+        ret = qemuMonitorGetBlockIoThrottle(priv->mon, drivealias, qdevid, &reply);
         if (qemuDomainObjExitMonitor(driver, vm) < 0)
             goto endjob;
         if (ret < 0)
@@ -18678,7 +18688,7 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,

  cleanup:
     VIR_FREE(reply.group_name);
-    VIR_FREE(device);
+    VIR_FREE(drivealias);
     virDomainObjEndAPI(&vm);
     return ret;
 }
-- 
2.16.2


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