Move the checks that various attributes are not set on any controller other than SCSI controller using virtio-scsi model into the common controller validate checks. Need to also add a qemuDomainResetSCSIControllerModel call in order to ensure we get the "right" SCSI model if it's not set by default since it wouldn't be set during post parse processing. Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- src/qemu/qemu_command.c | 24 ------------------------ src/qemu/qemu_domain.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 899f0cbbb..7b2f4cd13 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2725,30 +2725,6 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, return -1; } - if (!(def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI && - def->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI)) { - if (def->queues) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("'queues' is only supported by virtio-scsi controller")); - return -1; - } - if (def->cmd_per_lun) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("'cmd_per_lun' is only supported by virtio-scsi controller")); - return -1; - } - if (def->max_sectors) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("'max_sectors' is only supported by virtio-scsi controller")); - return -1; - } - if (def->ioeventfd) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("'ioeventfd' is only supported by virtio-scsi controller")); - return -1; - } - } - switch ((virDomainControllerType) def->type) { case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: switch (def->model) { diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c8123ce59..324805282 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3923,6 +3923,37 @@ qemuDomainDeviceDefValidateDisk(const virDomainDiskDef *disk) static int +qemuDomainDeviceDefValidateControllerAttributes(const virDomainControllerDef *controller) +{ + if (!(controller->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI && + controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI)) { + if (controller->queues) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'queues' is only supported by virtio-scsi controller")); + return -1; + } + if (controller->cmd_per_lun) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'cmd_per_lun' is only supported by virtio-scsi controller")); + return -1; + } + if (controller->max_sectors) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'max_sectors' is only supported by virtio-scsi controller")); + return -1; + } + if (controller->ioeventfd) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'ioeventfd' is only supported by virtio-scsi controller")); + return -1; + } + } + + return 0; +} + + +static int qemuDomainDeviceDefValidateControllerIDE(const virDomainControllerDef *controller, const virDomainDef *def) { @@ -3959,6 +3990,9 @@ qemuDomainDeviceDefValidateController(const virDomainControllerDef *controller, "controller")) return -1; + if (qemuDomainDeviceDefValidateControllerAttributes(controller) < 0) + return -1; + switch ((virDomainControllerType) controller->type) { case VIR_DOMAIN_CONTROLLER_TYPE_IDE: ret = qemuDomainDeviceDefValidateControllerIDE(controller, def); -- 2.13.6 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list