mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-15 00:55:17 +00:00
qemuDomainAttachDeviceDiskLiveInternal: Absorb qemuDomainAttachUSBMassStorageDevice
Move the specific device setup and address reservation code into the main hotplug helper as it's just one extra function call. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
9514f0fba0
commit
f7fbdbb52f
@ -995,32 +995,16 @@ qemuDomainAttachSCSIDisk(virQEMUDriver *driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
qemuDomainAttachUSBMassStorageDevice(virQEMUDriver *driver,
|
|
||||||
virDomainObj *vm,
|
|
||||||
virDomainDiskDef *disk)
|
|
||||||
{
|
|
||||||
qemuDomainObjPrivate *priv = vm->privateData;
|
|
||||||
|
|
||||||
if (virDomainUSBAddressEnsure(priv->usbaddrs, &disk->info) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (qemuDomainAttachDiskGeneric(driver, vm, disk) < 0) {
|
|
||||||
virDomainUSBAddressRelease(priv->usbaddrs, &disk->info);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver,
|
qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver,
|
||||||
virDomainObj *vm,
|
virDomainObj *vm,
|
||||||
virDomainDeviceDef *dev)
|
virDomainDeviceDef *dev)
|
||||||
{
|
{
|
||||||
|
qemuDomainObjPrivate *priv = vm->privateData;
|
||||||
size_t i;
|
size_t i;
|
||||||
virDomainDiskDef *disk = dev->data.disk;
|
virDomainDiskDef *disk = dev->data.disk;
|
||||||
|
bool releaseUSB = false;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM ||
|
if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM ||
|
||||||
@ -1060,7 +1044,13 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver,
|
|||||||
_("disk device='lun' is not supported for usb bus"));
|
_("disk device='lun' is not supported for usb bus"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ret = qemuDomainAttachUSBMassStorageDevice(driver, vm, disk);
|
|
||||||
|
if (virDomainUSBAddressEnsure(priv->usbaddrs, &disk->info) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
releaseUSB = true;
|
||||||
|
|
||||||
|
ret = qemuDomainAttachDiskGeneric(driver, vm, disk);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_DISK_BUS_VIRTIO:
|
case VIR_DOMAIN_DISK_BUS_VIRTIO:
|
||||||
@ -1088,8 +1078,13 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (ret != 0)
|
if (ret < 0) {
|
||||||
ignore_value(qemuRemoveSharedDevice(driver, dev, vm->def->name));
|
ignore_value(qemuRemoveSharedDevice(driver, dev, vm->def->name));
|
||||||
|
|
||||||
|
if (releaseUSB)
|
||||||
|
virDomainUSBAddressRelease(priv->usbaddrs, &disk->info);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user