---
src/qemu/qemu_command.c | 124 +++++++++++++++++++-----------------------------
1 file changed, 48 insertions(+), 76 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f38e98f..e46baaf 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4094,6 +4094,40 @@ error:
return NULL;
}
+static int
+qemuBuildSCSIDriveDevStr(int controllerModel,
+ virDomainDiskDefPtr disk,
+ virQEMUCapsPtr qemuCaps,
+ virBufferPtr opt)
+{
+ 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");
+ }
+
+
+ if (controllerModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC)
+ virBufferAsprintf(opt, ",bus=scsi%d.%d,scsi-id=%d",
+ disk->info.addr.drive.controller,
+ disk->info.addr.drive.bus,
+ disk->info.addr.drive.unit);
+ else
+ virBufferAsprintf(opt, ",bus=scsi%d.0,channel=%d,scsi-id=%d,lun=%d",
+ disk->info.addr.drive.controller,
+ disk->info.addr.drive.bus,
+ disk->info.addr.drive.target,
+ disk->info.addr.drive.unit);
+ return 0;
+}
+
char *
qemuBuildDriveDevStr(virDomainDefPtr def,
virDomainDiskDefPtr disk,
@@ -4232,94 +4266,32 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
if ((qemuSetScsiControllerModel(def, qemuCaps, &controllerModel)) < 0)
goto error;
- if (controllerModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC) {
+ if (controllerModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC ||
+ controllerModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_USB_BOT) {
if (disk->info.addr.drive.target != 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("target must be 0 for controller "
"model 'lsilogic'"));
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,
- disk->info.addr.drive.unit);
- } else if (controllerModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_USB_BOT) {
- if (disk->info.addr.drive.target != 0) {
+ } else if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_DISK_CHANNEL)) {
+ if (disk->info.addr.drive.target > 7) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("target must be 0 for controller "
- "model 'usb-bot'"));
+ _("This QEMU doesn't support target "
+ "greater than 7"));
goto error;
}
- 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,
- disk->info.addr.drive.target,
- disk->info.addr.drive.unit);
- } else {
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_DISK_CHANNEL)) {
- if (disk->info.addr.drive.target > 7) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("This QEMU doesn't support target "
- "greater than 7"));
- goto error;
- }
-
- if ((disk->info.addr.drive.bus != disk->info.addr.drive.unit)
&&
- (disk->info.addr.drive.bus != 0)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("This QEMU only supports both bus and "
- "unit equal to 0"));
- goto error;
- }
- }
-
- 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");
+ if ((disk->info.addr.drive.bus != disk->info.addr.drive.unit)
&&
+ (disk->info.addr.drive.bus != 0)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("This QEMU only supports both bus and "
+ "unit equal to 0"));
+ goto error;
}
-
- virBufferAsprintf(&opt,
",bus=scsi%d.0,channel=%d,scsi-id=%d,lun=%d",
- disk->info.addr.drive.controller,
- disk->info.addr.drive.bus,
- disk->info.addr.drive.target,
- disk->info.addr.drive.unit);
}
+
+ qemuBuildSCSIDriveDevStr(controllerModel, disk, qemuCaps, &opt);
break;
case VIR_DOMAIN_DISK_BUS_SATA:
if (disk->info.addr.drive.bus != 0) {
--
1.8.3.1