[PATCH 2/2] qemuDomainSetBlockIoTune: Skip monitor call for empty cdrom

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

 



Similarly to startup of the VM qemu doesn't like setting throttling for
an empty drive. Just skip it since we do the correct thing once new
media is inserted.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/117
Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
CC: Han Han <hhan@xxxxxxxxxx>

Please test this commit since you have the environment prepared.

 src/qemu/qemu_driver.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1283e61785..027617deef 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16301,16 +16301,23 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,

 #undef CHECK_MAX

-        qemuDomainObjEnterMonitor(driver, vm);
-        ret = qemuMonitorSetBlockIoThrottle(priv->mon, drivealias, qdevid,
-                                            &info, supportMaxOptions,
-                                            set_fields & QEMU_BLOCK_IOTUNE_SET_GROUP_NAME,
-                                            supportMaxLengthOptions);
-        if (qemuDomainObjExitMonitor(driver, vm) < 0)
+        /* blockdev-based qemu doesn't want to set the throttling when a cdrom
+         * is empty. Skip the monitor call here since we will set the throttling
+         * once new media is inserted */
+        if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV) ||
+            !virStorageSourceIsEmpty(disk->src)) {
+
+            qemuDomainObjEnterMonitor(driver, vm);
+            ret = qemuMonitorSetBlockIoThrottle(priv->mon, drivealias, qdevid,
+                                                &info, supportMaxOptions,
+                                                set_fields & QEMU_BLOCK_IOTUNE_SET_GROUP_NAME,
+                                                supportMaxLengthOptions);
+            if (qemuDomainObjExitMonitor(driver, vm) < 0)
+                ret = -1;
+            if (ret < 0)
+                goto endjob;
             ret = -1;
-        if (ret < 0)
-            goto endjob;
-        ret = -1;
+        }

         virDomainDiskSetBlockIOTune(disk, &info);

-- 
2.29.2




[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