mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
conf,qemu: Check for NULL addrs in virDomainUSBAddressRelease
Rather than having the caller check, if the input @addrs is NULL (e.g. priv->usbaddrs), then just return 0. This also removes the need for ATTRIBUTE_NONNULL which only really helped if someone passed a NULL as a parameter not if the passed parameter is NULL. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
9c61c28081
commit
207cece6a3
@ -2175,7 +2175,7 @@ virDomainUSBAddressRelease(virDomainUSBAddressSetPtr addrs,
|
|||||||
int targetPort;
|
int targetPort;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB ||
|
if (!addrs || info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB ||
|
||||||
!virDomainUSBAddressPortIsValid(info->addr.usb.port))
|
!virDomainUSBAddressPortIsValid(info->addr.usb.port))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -330,5 +330,5 @@ virDomainUSBAddressEnsure(virDomainUSBAddressSetPtr addrs,
|
|||||||
int
|
int
|
||||||
virDomainUSBAddressRelease(virDomainUSBAddressSetPtr addrs,
|
virDomainUSBAddressRelease(virDomainUSBAddressSetPtr addrs,
|
||||||
virDomainDeviceInfoPtr info)
|
virDomainDeviceInfoPtr info)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
ATTRIBUTE_NONNULL(2);
|
||||||
#endif /* __DOMAIN_ADDR_H__ */
|
#endif /* __DOMAIN_ADDR_H__ */
|
||||||
|
@ -2943,11 +2943,8 @@ qemuDomainReleaseDeviceAddress(virDomainObjPtr vm,
|
|||||||
if (virDeviceInfoPCIAddressPresent(info))
|
if (virDeviceInfoPCIAddressPresent(info))
|
||||||
virDomainPCIAddressReleaseAddr(priv->pciaddrs, &info->addr.pci);
|
virDomainPCIAddressReleaseAddr(priv->pciaddrs, &info->addr.pci);
|
||||||
|
|
||||||
if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB &&
|
if (virDomainUSBAddressRelease(priv->usbaddrs, info) < 0)
|
||||||
priv->usbaddrs &&
|
VIR_WARN("Unable to release USB address on %s", NULLSTR(devstr));
|
||||||
virDomainUSBAddressRelease(priv->usbaddrs, info) < 0)
|
|
||||||
VIR_WARN("Unable to release USB address on %s",
|
|
||||||
NULLSTR(devstr));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2241,7 +2241,6 @@ qemuDomainAttachHostUSBDevice(virQEMUDriverPtr driver,
|
|||||||
{
|
{
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
char *devstr = NULL;
|
char *devstr = NULL;
|
||||||
bool releaseaddr = false;
|
|
||||||
bool added = false;
|
bool added = false;
|
||||||
bool teardowncgroup = false;
|
bool teardowncgroup = false;
|
||||||
bool teardownlabel = false;
|
bool teardownlabel = false;
|
||||||
@ -2250,8 +2249,7 @@ qemuDomainAttachHostUSBDevice(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
if (priv->usbaddrs) {
|
if (priv->usbaddrs) {
|
||||||
if (virDomainUSBAddressEnsure(priv->usbaddrs, hostdev->info) < 0)
|
if (virDomainUSBAddressEnsure(priv->usbaddrs, hostdev->info) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
releaseaddr = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuHostdevPrepareUSBDevices(driver, vm->def->name, &hostdev, 1, 0) < 0)
|
if (qemuHostdevPrepareUSBDevices(driver, vm->def->name, &hostdev, 1, 0) < 0)
|
||||||
@ -2304,8 +2302,7 @@ qemuDomainAttachHostUSBDevice(virQEMUDriverPtr driver,
|
|||||||
VIR_WARN("Unable to remove host device from /dev");
|
VIR_WARN("Unable to remove host device from /dev");
|
||||||
if (added)
|
if (added)
|
||||||
qemuHostdevReAttachUSBDevices(driver, vm->def->name, &hostdev, 1);
|
qemuHostdevReAttachUSBDevices(driver, vm->def->name, &hostdev, 1);
|
||||||
if (releaseaddr)
|
virDomainUSBAddressRelease(priv->usbaddrs, hostdev->info);
|
||||||
virDomainUSBAddressRelease(priv->usbaddrs, hostdev->info);
|
|
||||||
}
|
}
|
||||||
VIR_FREE(devstr);
|
VIR_FREE(devstr);
|
||||||
return ret;
|
return ret;
|
||||||
@ -3827,8 +3824,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
|
|||||||
dev.type = VIR_DOMAIN_DEVICE_DISK;
|
dev.type = VIR_DOMAIN_DEVICE_DISK;
|
||||||
dev.data.disk = disk;
|
dev.data.disk = disk;
|
||||||
ignore_value(qemuRemoveSharedDevice(driver, &dev, vm->def->name));
|
ignore_value(qemuRemoveSharedDevice(driver, &dev, vm->def->name));
|
||||||
if (priv->usbaddrs)
|
virDomainUSBAddressRelease(priv->usbaddrs, &disk->info);
|
||||||
virDomainUSBAddressRelease(priv->usbaddrs, &disk->info);
|
|
||||||
|
|
||||||
virDomainDiskDefFree(disk);
|
virDomainDiskDefFree(disk);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user