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

[libvirt] [PATCH] Added capability checking for block <iotune> setting.



There was missing capability for blkiotune and thus specifying these
settings caused libvirt to run qemu with invalid parameters and then
reporting qemu error instead of the standard libvirt one.
---
 src/qemu/qemu_capabilities.c |    6 ++++++
 src/qemu/qemu_capabilities.h |    2 ++
 src/qemu/qemu_command.c      |   13 +++++++++++++
 tests/qemuxml2argvtest.c     |    2 +-
 4 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 0a1c9aa..f50e0b0 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -150,6 +150,8 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
               "drive-copy-on-read",
               "cpu-host",
               "fsdev-writeout",
+
+              "drive-iotune", /* 85 */
     );

 struct qemu_feature_flags {
@@ -1031,6 +1033,10 @@ qemuCapsComputeCmdFlags(const char *help,
             qemuCapsSet(flags, QEMU_CAPS_DRIVE_AIO);
         if (strstr(help, "copy-on-read=on|off"))
             qemuCapsSet(flags, QEMU_CAPS_DRIVE_COPY_ON_READ);
+        if (strstr(help, "bps=") && strstr(help, "iops=") &&
+            strstr(help, "bps_rd=") && strstr(help, "bps_wr=") &&
+            strstr(help, "iops_rd=") && strstr(help, "iops_wr="))
+            qemuCapsSet(flags, QEMU_CAPS_DRIVE_IOTUNE);
     }
     if ((p = strstr(help, "-vga")) && !strstr(help, "-std-vga")) {
         const char *nl = strstr(p, "\n");
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 1d4d10e..6a5389e 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -124,6 +124,8 @@ enum qemuCapsFlags {
     QEMU_CAPS_CPU_HOST          = 83, /* support for -cpu host */
     QEMU_CAPS_FSDEV_WRITEOUT     = 84, /* -fsdev writeout supported */

+    QEMU_CAPS_DRIVE_IOTUNE       = 85, /* -drive bps= and friends ({b,io}ps{_rd,_wr,}) */
+
     QEMU_CAPS_LAST,                   /* this must always be the last item */
 };

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 3bbe9cf..aaccf62 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1987,6 +1987,19 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
     }

     /* block I/O throttling */
+    if ((disk->blkdeviotune.total_bytes_sec ||
+         disk->blkdeviotune.read_bytes_sec ||
+         disk->blkdeviotune.write_bytes_sec ||
+         disk->blkdeviotune.total_iops_sec ||
+         disk->blkdeviotune.read_iops_sec ||
+         disk->blkdeviotune.write_iops_sec) &&
+        !qemuCapsGet(qemuCaps, QEMU_CAPS_DRIVE_IOTUNE)) {
+        qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                        _("block I/O throttling not supported with this "
+                          "QEMU binary"));
+        goto error;
+    }
+
     if (disk->blkdeviotune.total_bytes_sec) {
         virBufferAsprintf(&opt, ",bps=%llu",
                           disk->blkdeviotune.total_bytes_sec);
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 5cec86b..d40b37e 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -705,7 +705,7 @@ mymain(void)
     DO_TEST("cputune", false, QEMU_CAPS_NAME);
     DO_TEST("numatune-memory", false, NONE);
     DO_TEST("blkdeviotune", false, QEMU_CAPS_NAME, QEMU_CAPS_DEVICE,
-            QEMU_CAPS_DRIVE);
+            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_IOTUNE);

     DO_TEST("multifunction-pci-device", false,
             QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
--
1.7.3.4


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