]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Added capability checking for block <iotune> setting.
authorMartin Kletzander <mkletzan@redhat.com>
Wed, 18 Jan 2012 16:42:33 +0000 (17:42 +0100)
committerEric Blake <eblake@redhat.com>
Wed, 18 Jan 2012 16:56:00 +0000 (09:56 -0700)
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. The support
for blkiotune setting was added in upstream qemu repo under commit
0563e191516289c9d2f282a8c50f2eecef2fa773.

src/qemu/qemu_capabilities.c
src/qemu/qemu_capabilities.h
src/qemu/qemu_command.c
tests/qemuxml2argvtest.c

index 0a1c9aa3841b79a4938e0e9b2f9431afd55263ba..54757fcd26b3dc1cfc7e6af3b182738bf59a2e22 100644 (file)
@@ -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,8 @@ 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="))
+            qemuCapsSet(flags, QEMU_CAPS_DRIVE_IOTUNE);
     }
     if ((p = strstr(help, "-vga")) && !strstr(help, "-std-vga")) {
         const char *nl = strstr(p, "\n");
index 1d4d10e59d0f99b5be69a5a63781e45782feb160..6a5389e4f5036ba25c721894d1ad2442bd1043ee 100644 (file)
@@ -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 */
 };
 
index 3bbe9cf6393378d2bb5816f2a99341f10e2bd82c..aaccf62b6e799c7f746ff8e55a0c5300a0816bae 100644 (file)
@@ -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);
index 5cec86bed496be480222f3fc0c67d80f7f8bbda2..d40b37e5d765408740eb3f29447308ec8cbef7fc 100644 (file)
@@ -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,