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 <fabian@ldsoft.dev>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Fabian Leditzky 2025-01-21 14:33:25 +00:00 committed by Peter Krempa
parent fce24e433b
commit 00f9f2ca1f

View File

@ -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);