[libvirt] [PATCH v4 01/13] qemu: Introduce qemuDomainDeviceDefValidateControllerAttributes
Marc Hartmayer
mhartmay at linux.vnet.ibm.com
Thu Jan 4 10:23:48 UTC 2018
On Tue, Dec 12, 2017 at 04:06 PM +0100, John Ferlan <jferlan at redhat.com> wrote:
> 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.
You not only move the checks, but also add the call
'qemuDomainSetSCSIControllerModel'.
>
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
> src/qemu/qemu_command.c | 24 ------------------------
> src/qemu/qemu_domain.c | 41 +++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 41 insertions(+), 24 deletions(-)
>
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 2dd50a214..d9cbdff83 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -2667,30 +2667,6 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
> return -1;
> }
>
> - if (!(def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI &&
> - 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 (model) {
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 347fc0742..120c013bd 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -3893,6 +3893,38 @@ qemuDomainDeviceDefValidateDisk(const virDomainDiskDef *disk)
>
>
> static int
> +qemuDomainDeviceDefValidateControllerAttributes(const virDomainControllerDef *controller,
> + int model)
> +{
> + if (!(controller->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI &&
> + 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)
> {
> @@ -3924,11 +3956,20 @@ qemuDomainDeviceDefValidateController(const virDomainControllerDef *controller,
> virQEMUCapsPtr qemuCaps)
> {
> int ret = 0;
> + int model = controller->model;
>
> if (!qemuDomainCheckCCWS390AddressSupport(def, controller->info, qemuCaps,
> "controller"))
> return -1;
>
> + if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) {
> + if ((qemuDomainSetSCSIControllerModel(def, qemuCaps, &model)) < 0)
> + return -1;
> + }
Didn't take a closer look, but is it the right place for this? (in a
validation function)
> +
> + if (qemuDomainDeviceDefValidateControllerAttributes(controller, model) < 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 at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
>
--
Beste Grüße / Kind regards
Marc Hartmayer
IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
More information about the libvir-list
mailing list