]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Introduce qemuDomainDeviceDefValidateControllerAttributes
authorJohn Ferlan <jferlan@redhat.com>
Fri, 8 Dec 2017 18:21:05 +0000 (13:21 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Fri, 2 Feb 2018 19:35:26 +0000 (14:35 -0500)
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.

src/qemu/qemu_command.c
src/qemu/qemu_domain.c

index 543270028754ba5c0d0e330cb9193f95b63491db..980ed1870572375a72da945bc3fa7d6393960575 100644 (file)
@@ -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) {
index c8123ce59bc433235b70eed725b38761bfe23881..3248052821d0fbb8a403de709f1c14c5c8e71476 100644 (file)
@@ -3922,6 +3922,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);