Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx>
---
src/qemu/qemu_command.c | 24 -----------------------
src/qemu/qemu_validate.c | 41 +++++++++++++++++++++++++++++++++++++++-
2 files changed, 40 insertions(+), 25 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index b8b5ac1246..9ec5ace1c7 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1616,35 +1616,11 @@ qemuBuildDiskDeviceStr(const virDomainDef *def,
return NULL;
if (controllerModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC) {
- if (disk->info.addr.drive.target != 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("target must be 0 for controller "
- "model 'lsilogic'"));
- return NULL;
- }
-
virBufferAsprintf(&opt, ",bus=%s.%d,scsi-id=%d",
contAlias,
disk->info.addr.drive.bus,
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"));
- return NULL;
- }
-
- if (disk->info.addr.drive.bus != 0 &&
- disk->info.addr.drive.unit != 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("This QEMU only supports both bus and "
- "unit equal to 0"));
- return NULL;
- }
- }
-
virBufferAsprintf(&opt, ",bus=%s.0,channel=%d,scsi-id=%d,lun=%d",
contAlias,
disk->info.addr.drive.bus,
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 10c770d318..5ad13d9fd6 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -2004,8 +2004,12 @@ qemuValidateDomainDeviceDefDiskSerial(const char *value)
static int
qemuValidateDomainDeviceDefDiskFrontend(const virDomainDiskDef *disk,
+ const virDomainDef *def,
virQEMUCapsPtr qemuCaps)
{
+ virDomainDeviceInfoPtr diskInfo;
+ int cModel;
+
if (disk->geometry.cylinders > 0 &&
disk->geometry.heads > 0 &&
disk->geometry.sectors > 0) {
@@ -2146,6 +2150,9 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDomainDiskDef *disk,
switch (disk->bus) {
case VIR_DOMAIN_DISK_BUS_SCSI:
+ diskInfo = (virDomainDeviceInfoPtr)&disk->info;
+ cModel = qemuDomainFindSCSIControllerModel(def, diskInfo);
+
if (disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("unexpected address type for scsi disk"));
@@ -2160,6 +2167,38 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDomainDiskDef *disk,
"%s", _("SCSI controller only supports 1 bus"));
return -1;
}
+
+ /* We allow hotplug/hotunplug disks without a controller,
+ * hence we don't error out if cModel is < 0. These
+ * validations were originally made under the assumption of
+ * a controller being found though. */
+ if (cModel > 0) {
+ if (cModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC) {
+ if (disk->info.addr.drive.target != 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("target must be 0 for controller "
+ "model 'lsilogic'"));
+ return -1;
+ }
+ } else {
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_DISK_CHANNEL)) {