mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
Recreate the USB address cache at reconnect
When starting a new domain, we allocate the USB addresses and keep an address cache in the domain object's private data. However this data is lost on libvirtd restart. Also generate the address cache if all the addresses have been specified, so that devices hotplugged after libvirtd restart also get theirs assigned. https://bugzilla.redhat.com/show_bug.cgi?id=1387666
This commit is contained in:
parent
244ebb8f2b
commit
dc67d00cd2
@ -1830,6 +1830,18 @@ virDomainUSBAddressAssign(virDomainUSBAddressSetPtr addrs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
virDomainUSBAddressPresent(virDomainDeviceInfoPtr info,
|
||||||
|
void *data ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB &&
|
||||||
|
virDomainUSBAddressPortIsValid(info->addr.usb.port))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
virDomainUSBAddressReserve(virDomainDeviceInfoPtr info,
|
virDomainUSBAddressReserve(virDomainDeviceInfoPtr info,
|
||||||
void *data)
|
void *data)
|
||||||
|
@ -300,6 +300,10 @@ size_t
|
|||||||
virDomainUSBAddressCountAllPorts(virDomainDefPtr def);
|
virDomainUSBAddressCountAllPorts(virDomainDefPtr def);
|
||||||
void virDomainUSBAddressSetFree(virDomainUSBAddressSetPtr addrs);
|
void virDomainUSBAddressSetFree(virDomainUSBAddressSetPtr addrs);
|
||||||
|
|
||||||
|
int
|
||||||
|
virDomainUSBAddressPresent(virDomainDeviceInfoPtr info,
|
||||||
|
void *data)
|
||||||
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
||||||
int
|
int
|
||||||
virDomainUSBAddressReserve(virDomainDeviceInfoPtr info,
|
virDomainUSBAddressReserve(virDomainDeviceInfoPtr info,
|
||||||
void *data)
|
void *data)
|
||||||
|
@ -116,6 +116,7 @@ virDomainUSBAddressEnsure;
|
|||||||
virDomainUSBAddressPortFormat;
|
virDomainUSBAddressPortFormat;
|
||||||
virDomainUSBAddressPortFormatBuf;
|
virDomainUSBAddressPortFormatBuf;
|
||||||
virDomainUSBAddressPortIsValid;
|
virDomainUSBAddressPortIsValid;
|
||||||
|
virDomainUSBAddressPresent;
|
||||||
virDomainUSBAddressRelease;
|
virDomainUSBAddressRelease;
|
||||||
virDomainUSBAddressReserve;
|
virDomainUSBAddressReserve;
|
||||||
virDomainUSBAddressSetAddControllers;
|
virDomainUSBAddressSetAddControllers;
|
||||||
|
@ -1750,12 +1750,24 @@ qemuDomainUSBAddressAddHubs(virDomainDefPtr def)
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainAssignUSBAddresses(virDomainDefPtr def,
|
qemuDomainAssignUSBAddresses(virDomainDefPtr def,
|
||||||
virDomainObjPtr obj)
|
virDomainObjPtr obj,
|
||||||
|
bool newDomain)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virDomainUSBAddressSetPtr addrs = NULL;
|
virDomainUSBAddressSetPtr addrs = NULL;
|
||||||
qemuDomainObjPrivatePtr priv = NULL;
|
qemuDomainObjPrivatePtr priv = NULL;
|
||||||
|
|
||||||
|
if (!newDomain) {
|
||||||
|
/* only create the address cache for:
|
||||||
|
* new domains
|
||||||
|
* domains that already have all the addresses specified
|
||||||
|
* otherwise libvirt's attempt to recreate the USB topology via
|
||||||
|
* QEMU command line might fail */
|
||||||
|
if (virDomainUSBDeviceDefForeach(def, virDomainUSBAddressPresent, NULL,
|
||||||
|
false) < 0)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(addrs = virDomainUSBAddressSetCreate()))
|
if (!(addrs = virDomainUSBAddressSetCreate()))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -1812,7 +1824,7 @@ qemuDomainAssignAddresses(virDomainDefPtr def,
|
|||||||
if (qemuDomainAssignPCIAddresses(def, qemuCaps, obj) < 0)
|
if (qemuDomainAssignPCIAddresses(def, qemuCaps, obj) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (newDomain && qemuDomainAssignUSBAddresses(def, obj) < 0)
|
if (qemuDomainAssignUSBAddresses(def, obj, newDomain) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user