qemuDomainAttachHostPCIDevice: Handle hostevs with unassigned type of address

A <hostdev/> can have <address type='unassigned'/> which means
libvirt manages the device detach from/reattach to the host but
the device is never exposed to the guest. This means that we have
to take a shortcut during hotplug, similar to the one we are
taking when constructing the command line (see
qemuBuildHostdevCommandLine()).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2040548
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Michal Privoznik 2022-01-25 08:51:26 +01:00
parent 89f9346791
commit f5de3af7f4

View File

@ -1668,6 +1668,12 @@ qemuDomainAttachHostPCIDevice(virQEMUDriver *driver,
qemuDomainFillDeviceIsolationGroup(vm->def, &dev); qemuDomainFillDeviceIsolationGroup(vm->def, &dev);
} }
if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED) {
/* Unassigned devices are not exposed to QEMU. Our job is done here. */
ret = 0;
goto done;
}
if (qemuDomainEnsurePCIAddress(vm, &dev) < 0) if (qemuDomainEnsurePCIAddress(vm, &dev) < 0)
goto error; goto error;
releaseaddr = true; releaseaddr = true;
@ -1692,6 +1698,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDriver *driver,
exit_monitor: exit_monitor:
qemuDomainObjExitMonitor(driver, vm); qemuDomainObjExitMonitor(driver, vm);
done:
virDomainAuditHostdev(vm, hostdev, "attach", ret == 0); virDomainAuditHostdev(vm, hostdev, "attach", ret == 0);
if (ret < 0) if (ret < 0)
goto error; goto error;