There is no point in iterating over all devices if none of them
could possibly match.
---
src/qemu/qemu_hotplug.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 0288986d8..aebd00598 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -3752,6 +3752,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;
@@ -4828,8 +4831,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);
--
2.13.0