mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
conf: check port range even for USB hubs
Move the range check introduced by commit 2650d5e
into
virDomainUSBAddressFindPort. That way both virDomainUSBAddressRelease
and virDomainUSBAddressSetAddHub can benefit from it.
Reported-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
384504f7ba
commit
4a7773f7ea
@ -1785,7 +1785,7 @@ virDomainUSBAddressFindPort(virDomainUSBAddressSetPtr addrs,
|
|||||||
const char *portStr)
|
const char *portStr)
|
||||||
{
|
{
|
||||||
virDomainUSBAddressHubPtr hub = NULL;
|
virDomainUSBAddressHubPtr hub = NULL;
|
||||||
ssize_t i, lastIdx;
|
ssize_t i, lastIdx, targetPort;
|
||||||
|
|
||||||
if (info->addr.usb.bus >= addrs->nbuses ||
|
if (info->addr.usb.bus >= addrs->nbuses ||
|
||||||
!addrs->buses[info->addr.usb.bus]) {
|
!addrs->buses[info->addr.usb.bus]) {
|
||||||
@ -1820,7 +1820,15 @@ virDomainUSBAddressFindPort(virDomainUSBAddressSetPtr addrs,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*targetIdx = info->addr.usb.port[lastIdx] - 1;
|
targetPort = info->addr.usb.port[lastIdx] - 1;
|
||||||
|
if (targetPort >= virBitmapSize(hub->portmap)) {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
|
_("requested USB port %s not present on USB bus %u"),
|
||||||
|
portStr, info->addr.usb.bus);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
*targetIdx = targetPort;
|
||||||
return hub;
|
return hub;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2070,13 +2078,6 @@ virDomainUSBAddressReserve(virDomainDeviceInfoPtr info,
|
|||||||
portStr)))
|
portStr)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (targetPort >= virBitmapSize(targetHub->portmap)) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("requested USB port %s not present on USB bus %u"),
|
|
||||||
portStr, info->addr.usb.bus);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virBitmapIsBitSet(targetHub->portmap, targetPort)) {
|
if (virBitmapIsBitSet(targetHub->portmap, targetPort)) {
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
_("Duplicate USB address bus %u port %s"),
|
_("Duplicate USB address bus %u port %s"),
|
||||||
|
Loading…
Reference in New Issue
Block a user