mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-04 20:15:19 +00:00
qemu: Build activeUsbHostdevs list on process reconnect
If the daemon is restarted it will lose list of active
USB devices assigned to active domains. Therefore we need
to rebuild this list on qemuProcessReconnect().
(cherry picked from commit ea3bc548ac
)
This commit is contained in:
parent
8fca254f5d
commit
8a98a23900
@ -157,6 +157,46 @@ int qemuUpdateActivePciHostdevs(struct qemud_driver *driver,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
qemuUpdateActiveUsbHostdevs(struct qemud_driver *driver,
|
||||
virDomainDefPtr def)
|
||||
{
|
||||
virDomainHostdevDefPtr hostdev = NULL;
|
||||
int i;
|
||||
|
||||
if (!def->nhostdevs)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < def->nhostdevs; i++) {
|
||||
usbDevice *usb = NULL;
|
||||
hostdev = def->hostdevs[i];
|
||||
|
||||
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
|
||||
continue;
|
||||
if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB)
|
||||
continue;
|
||||
|
||||
usb = usbGetDevice(hostdev->source.subsys.u.usb.bus,
|
||||
hostdev->source.subsys.u.usb.device);
|
||||
if (!usb) {
|
||||
VIR_WARN("Unable to reattach USB device %03d.%03d on domain %s",
|
||||
hostdev->source.subsys.u.usb.bus,
|
||||
hostdev->source.subsys.u.usb.device,
|
||||
def->name);
|
||||
continue;
|
||||
}
|
||||
|
||||
usbDeviceSetUsedBy(usb, def->name);
|
||||
|
||||
if (usbDeviceListAdd(driver->activeUsbHostdevs, usb) < 0) {
|
||||
usbFreeDevice(usb);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
qemuDomainHostdevPciSysfsPath(virDomainHostdevDefPtr hostdev, char **sysfs_path)
|
||||
{
|
||||
|
@ -29,6 +29,8 @@
|
||||
|
||||
int qemuUpdateActivePciHostdevs(struct qemud_driver *driver,
|
||||
virDomainDefPtr def);
|
||||
int qemuUpdateActiveUsbHostdevs(struct qemud_driver *driver,
|
||||
virDomainDefPtr def);
|
||||
int qemuPrepareHostdevPCIDevices(struct qemud_driver *driver,
|
||||
const char *name,
|
||||
const unsigned char *uuid,
|
||||
|
@ -3057,6 +3057,9 @@ qemuProcessReconnect(void *opaque)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (qemuUpdateActiveUsbHostdevs(driver, obj->def) < 0)
|
||||
goto error;
|
||||
|
||||
if (qemuProcessUpdateState(driver, obj) < 0)
|
||||
goto error;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user