mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
qemuDomainAttachDeviceDiskLiveInternal: Absorb qemuDomainAttachSCSIDisk
Move the validation of the SCSI device address and the attachment of the controller into qemuDomainAttachDeviceDiskLiveInternal as there's no specific need for a special helper. 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
f60135d37a
commit
d5a204ef91
@ -932,47 +932,6 @@ qemuDomainFindOrCreateSCSIDiskController(virQEMUDriver *driver,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuDomainAttachSCSIDisk(virQEMUDriver *driver,
|
||||
virDomainObj *vm,
|
||||
virDomainDiskDef *disk)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
/* We should have an address already, so make sure */
|
||||
if (disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unexpected disk address type %s"),
|
||||
virDomainDeviceAddressTypeToString(disk->info.type));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virDomainSCSIDriveAddressIsUsed(vm->def, &disk->info.addr.drive)) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("Domain already contains a disk with that address"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Let's make sure the disk has a controller defined and loaded before
|
||||
* trying to add it. The controller used by the disk must exist before a
|
||||
* qemu command line string is generated.
|
||||
*
|
||||
* Ensure that the given controller and all controllers with a smaller index
|
||||
* exist; there must not be any missing index in between.
|
||||
*/
|
||||
for (i = 0; i <= disk->info.addr.drive.controller; i++) {
|
||||
if (!qemuDomainFindOrCreateSCSIDiskController(driver, vm, i))
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (qemuDomainAttachDiskGeneric(driver, vm, disk) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int
|
||||
qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver,
|
||||
virDomainObj *vm,
|
||||
@ -1039,7 +998,33 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver,
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DISK_BUS_SCSI:
|
||||
ret = qemuDomainAttachSCSIDisk(driver, vm, disk);
|
||||
/* We should have an address already, so make sure */
|
||||
if (disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unexpected disk address type %s"),
|
||||
virDomainDeviceAddressTypeToString(disk->info.type));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virDomainSCSIDriveAddressIsUsed(vm->def, &disk->info.addr.drive)) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("Domain already contains a disk with that address"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Let's make sure the disk has a controller defined and loaded before
|
||||
* trying to add it. The controller used by the disk must exist before a
|
||||
* qemu command line string is generated.
|
||||
*
|
||||
* Ensure that the given controller and all controllers with a smaller index
|
||||
* exist; there must not be any missing index in between.
|
||||
*/
|
||||
for (i = 0; i <= disk->info.addr.drive.controller; i++) {
|
||||
if (!qemuDomainFindOrCreateSCSIDiskController(driver, vm, i))
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret = qemuDomainAttachDiskGeneric(driver, vm, disk);
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DISK_BUS_IDE:
|
||||
|
Loading…
Reference in New Issue
Block a user