From: Peter Krempa Date: Mon, 12 May 2025 13:06:32 +0000 (+0200) Subject: qemuDomainPrepareHostdevPCI: Fix return values after conversion from bool to int X-Git-Tag: v11.4.0-rc1~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fced1da27937cfefc5b83ce69fd244f5b4724e54;p=thirdparty%2Flibvirt.git qemuDomainPrepareHostdevPCI: Fix return values after conversion from bool to int Historically when the code was in 'qemuHostdevPreparePCIDevicesCheckSupport' the function returned bools. Later it was refactored and moved to 'qemuDomainPrepareHostdevPCI' the return values were not changed. Thus the function now returned '-1', 'false', and 'true'. Callers checked for '-1' only so the few cases forbidding legacy device passthrough were no longer causing fatal errors. Fixes: 3b87709c768480e085556e06bd8d08f62270d42d Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 52da234343..73869fcfac 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9945,28 +9945,28 @@ qemuDomainPrepareHostdevPCI(virDomainHostdevDef *hostdev, if (!supportsPassthroughVFIO) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("host doesn't support VFIO PCI passthrough")); - return false; + return -1; } break; case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_KVM: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("host doesn't support legacy PCI passthrough")); - return false; + return -1; case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("QEMU does not support device assignment mode '%1$s'"), virDeviceHostdevPCIDriverNameTypeToString(*driverName)); - return false; + return -1; default: case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_LAST: virReportEnumRangeError(virDeviceHostdevPCIDriverName, *driverName); - break; + return -1; } - return true; + return 0; }