qemu_hotplug: Properly assign USB address to hotplugged usb-net device

Previously, the network device hotplug logic would try to ensure only CCW or
PCI addresses. With recent support for the usb-net model, this patch will
ensure USB addresses for usb-net network devices.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/14
Signed-off-by: Rayhan Faizel <rayhan.faizel@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Rayhan Faizel 2024-05-13 19:25:03 +05:30 committed by Michal Privoznik
parent 2482801608
commit ffebb557f1

View File

@ -1159,8 +1159,11 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
goto cleanup; goto cleanup;
} }
if (qemuDomainIsS390CCW(vm->def) && if (net->model == VIR_DOMAIN_NET_MODEL_USB_NET) {
net->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { if (virDomainUSBAddressEnsure(priv->usbaddrs, &net->info) < 0)
goto cleanup;
} else if (qemuDomainIsS390CCW(vm->def) &&
net->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW; net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
if (!(ccwaddrs = virDomainCCWAddressSetCreateFromDomain(vm->def))) if (!(ccwaddrs = virDomainCCWAddressSetCreateFromDomain(vm->def)))
goto cleanup; goto cleanup;