]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuDomainPrepareHostdevPCI: Fix return values after conversion from bool to int
authorPeter Krempa <pkrempa@redhat.com>
Mon, 12 May 2025 13:06:32 +0000 (15:06 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 14 May 2025 14:38:38 +0000 (16:38 +0200)
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 <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_domain.c

index 52da2343436b4f255457bea6f0e96de5dee29d68..73869fcfac4d40b6cedfc4b75bf8254940591e9e 100644 (file)
@@ -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;
 }