mirror of https://gitee.com/openkylin/libvirt.git
qemu: eliminate duplicated code in qemuBuildDriveDevStr()
The code to add device type to the commandline was identical for lsi and other models of SCSI controllers, but was duplicated (with the exception of a minor ordering difference of the if-else clauses) for the two cases. This patch replaces those two with a single instance of the code just before the if().
This commit is contained in:
parent
da558e72c4
commit
e27c5c8fcb
|
@ -4070,6 +4070,19 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
|
|||
if ((qemuSetSCSIControllerModel(def, qemuCaps, &controllerModel)) < 0)
|
||||
goto error;
|
||||
|
||||
if (disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) {
|
||||
virBufferAddLit(&opt, "scsi-block");
|
||||
} else {
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_CD)) {
|
||||
if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
|
||||
virBufferAddLit(&opt, "scsi-cd");
|
||||
else
|
||||
virBufferAddLit(&opt, "scsi-hd");
|
||||
} else {
|
||||
virBufferAddLit(&opt, "scsi-disk");
|
||||
}
|
||||
}
|
||||
|
||||
if (controllerModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC) {
|
||||
if (disk->info.addr.drive.target != 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
|
@ -4078,19 +4091,6 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
|
|||
goto error;
|
||||
}
|
||||
|
||||
if (disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) {
|
||||
virBufferAddLit(&opt, "scsi-block");
|
||||
} else {
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_CD)) {
|
||||
if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
|
||||
virBufferAddLit(&opt, "scsi-cd");
|
||||
else
|
||||
virBufferAddLit(&opt, "scsi-hd");
|
||||
} else {
|
||||
virBufferAddLit(&opt, "scsi-disk");
|
||||
}
|
||||
}
|
||||
|
||||
virBufferAsprintf(&opt, ",bus=scsi%d.%d,scsi-id=%d",
|
||||
disk->info.addr.drive.controller,
|
||||
disk->info.addr.drive.bus,
|
||||
|
@ -4113,19 +4113,6 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
|
|||
}
|
||||
}
|
||||
|
||||
if (disk->device != VIR_DOMAIN_DISK_DEVICE_LUN) {
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_CD)) {
|
||||
if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
|
||||
virBufferAddLit(&opt, "scsi-cd");
|
||||
else
|
||||
virBufferAddLit(&opt, "scsi-hd");
|
||||
} else {
|
||||
virBufferAddLit(&opt, "scsi-disk");
|
||||
}
|
||||
} else {
|
||||
virBufferAddLit(&opt, "scsi-block");
|
||||
}
|
||||
|
||||
virBufferAsprintf(&opt, ",bus=scsi%d.0,channel=%d,scsi-id=%d,lun=%d",
|
||||
disk->info.addr.drive.controller,
|
||||
disk->info.addr.drive.bus,
|
||||
|
|
Loading…
Reference in New Issue