From 00f9f2ca1f01d864297edc5618410127685e552d Mon Sep 17 00:00:00 2001 From: Fabian Leditzky Date: Tue, 21 Jan 2025 14:33:25 +0000 Subject: [PATCH] qemu: Check empty drives in block I/O throttle API Provide a proper user facing error when attempting to query block I/O throttling settings for an empty drive. Without this patch, a less meaningful internal error produced by qemuMonitorJSONBlockIoThrottleInfo would be propagated to the user. Signed-off-by: Fabian Leditzky Reviewed-by: Peter Krempa --- src/qemu/qemu_driver.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a1fc61bae2..da714f1975 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15368,6 +15368,14 @@ qemuDomainGetBlockIoTune(virDomainPtr dom, if (!qemuDomainDiskBlockIoTuneIsSupported(disk)) goto endjob; + /* qemu won't return block IO throttle settings for an empty cd-rom drive */ + if (virStorageSourceIsEmpty(disk->src)) { + virReportError(VIR_ERR_INVALID_ARG, + _("disk '%1$s' does not currently have a source assigned"), + path); + goto endjob; + } + qemuDomainObjEnterMonitor(vm); rc = qemuMonitorGetBlockIoThrottle(priv->mon, QEMU_DOMAIN_DISK_PRIVATE(disk)->qomName, &reply); qemuDomainObjExitMonitor(vm); -- 2.47.3