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,