From 4c82f09ef08674be77f461600195d0a646105306 Mon Sep 17 00:00:00 2001 From: Martin Kletzander Date: Wed, 18 Jan 2012 17:42:33 +0100 Subject: [PATCH] Added capability checking for block 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. The support for blkiotune setting was added in upstream qemu repo under commit 0563e191516289c9d2f282a8c50f2eecef2fa773. --- src/qemu/qemu_capabilities.c | 4 ++++ src/qemu/qemu_capabilities.h | 2 ++ src/qemu/qemu_command.c | 13 +++++++++++++ tests/qemuxml2argvtest.c | 2 +- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 0a1c9aa384..54757fcd26 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,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"); diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 1d4d10e59d..6a5389e4f5 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 3bbe9cf639..aaccf62b6e 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 5cec86bed4..d40b37e5d7 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,