]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virDomainInputDefValidate: Validate model
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 26 May 2022 11:48:56 +0000 (13:48 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 30 May 2022 14:30:21 +0000 (16:30 +0200)
If input device has one of virtio* models set then it has to go
onto virtio bus. Introduce such check into the validator.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2081981
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/conf/domain_validate.c

index 1feb7a8f9c37dc0828aa5ad8eb155e592d1033e9..f3910f08a4b187caa5004d6be51cc5259364ee47 100644 (file)
@@ -2306,6 +2306,27 @@ virDomainInputDefValidate(const virDomainInputDef *input,
         return -1;
     }
 
+    switch ((virDomainInputModel)input->model) {
+    case VIR_DOMAIN_INPUT_MODEL_VIRTIO:
+    case VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL:
+    case VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL:
+        if (input->bus != VIR_DOMAIN_INPUT_BUS_VIRTIO) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("only bus 'virtio' is supported for input model '%s'"),
+                           virDomainInputModelTypeToString(input->model));
+            return -1;
+        }
+        break;
+
+    case VIR_DOMAIN_INPUT_MODEL_DEFAULT:
+        break;
+
+    case VIR_DOMAIN_INPUT_MODEL_LAST:
+    default:
+        virReportEnumRangeError(virDomainInputModel, input->model);
+        return -1;
+    }
+
     return 0;
 }