[PATCH 3/3] qemu: hotplug: Setup disk throttling with blockdev

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

 



With blockdev we must issue the block_set_io_throttle QMP command to
setup disk throttling as we currently can't do it with the 'throttle'
layer.

Unfortunately there's nothing we can do if it fails.

https://bugzilla.redhat.com/show_bug.cgi?id=1733163

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_hotplug.c | 18 +++++++++++++++++-
 src/qemu/qemu_process.c |  1 +
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 30aa6d2344..a7034fd298 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -617,6 +617,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
     VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
     VIR_AUTOPTR(virJSONValue) corProps = NULL;
     VIR_AUTOFREE(char *) corAlias = NULL;
+    bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);

     if (qemuDomainStorageSourceChainAccessAllow(driver, vm, disk->src) < 0)
         goto cleanup;
@@ -627,7 +628,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
     if (qemuDomainPrepareDiskSource(disk, priv, cfg) < 0)
         goto error;

-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) {
+    if (blockdev) {
         if (disk->copy_on_read == VIR_TRISTATE_SWITCH_ON &&
             !(corProps = qemuBlockStorageGetCopyOnReadProps(disk)))
         goto cleanup;
@@ -667,6 +668,21 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
         goto exit_monitor;
     }

+    /* Setup throttling of disk via block_set_io_throttle QMP command. This
+     * is a hack until the 'throttle' blockdev driver will support modification
+     * of the trhottle group. See also qemuProcessSetupDiskThrottlingBlockdev.
+     * As there isn't anything sane to do if this fails, let's just return
+     * success.
+     */
+    if (blockdev &&
+        qemuDiskConfigBlkdeviotuneEnabled(disk)) {
+        qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
+        if (qemuMonitorSetBlockIoThrottle(priv->mon, NULL, diskPriv->qomName,
+                                          &disk->blkdeviotune,
+                                          true, true, true) < 0)
+            VIR_WARN("failed to set blkdeviotune for '%s' of '%s'", disk->dst, vm->def->name);
+    }
+
     if (qemuDomainObjExitMonitor(driver, vm) < 0) {
         ret = -2;
         goto error;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index c9921646e9..61b03c8a2d 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -6671,6 +6671,7 @@ qemuProcessGenID(virDomainObjPtr vm,
  * Sets up disk trottling for -blockdev via block_set_io_throttle monitor
  * command. This hack should be replaced by proper use of the 'throttle'
  * blockdev driver in qemu once it will support changing of the throttle group.
+ * Same hack is done in qemuDomainAttachDiskGeneric.
  */
 static int
 qemuProcessSetupDiskThrottlingBlockdev(virQEMUDriverPtr driver,
-- 
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