]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuIsMultiFunctionDevice: return early for non-PCI addresses
authorJán Tomko <jtomko@redhat.com>
Wed, 18 Oct 2017 13:33:45 +0000 (15:33 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 19 Oct 2017 12:45:15 +0000 (14:45 +0200)
There is no point in iterating over all devices if none of them
could possibly match.

src/qemu/qemu_hotplug.c

index 85faa2a46edb79f3c816f5827183d29c52ebf543..be5fa8648455682f791483104564589b978e9166 100644 (file)
@@ -3751,6 +3751,9 @@ static int qemuComparePCIDevice(virDomainDefPtr def ATTRIBUTE_UNUSED,
 static bool qemuIsMultiFunctionDevice(virDomainDefPtr def,
                                       virDomainDeviceInfoPtr dev)
 {
+    if (dev->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)
+        return false;
+
     if (virDomainDeviceInfoIterate(def, qemuComparePCIDevice, dev) < 0)
         return true;
     return false;
@@ -4852,8 +4855,7 @@ int qemuDomainDetachControllerDevice(virQEMUDriverPtr driver,
         goto cleanup;
     }
 
-    if (detach->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
-        qemuIsMultiFunctionDevice(vm->def, &detach->info)) {
+    if (qemuIsMultiFunctionDevice(vm->def, &detach->info)) {
         virReportError(VIR_ERR_OPERATION_FAILED,
                        _("cannot hot unplug multifunction PCI device: %s"),
                        dev->data.disk->dst);