]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: validate that model is virtio for vhostuser and vdpa interfaces in the same...
authorLaine Stump <laine@redhat.com>
Sun, 9 Feb 2025 23:46:00 +0000 (18:46 -0500)
committerLaine Stump <laine@redhat.com>
Mon, 17 Feb 2025 04:58:35 +0000 (23:58 -0500)
Both vhostuser and vdpa interface types must use the virtio model in
the guest (because part of the functionality is implemented in the
guest virtio driver). Due to ["because that's the way it happened"]
this has been validated for vhostuser in the hypervisor-agnostic
validate function, but for vdpa it has been done in the QEMU-specific
validate. Since these interface models are only supported by QEMU
anyway, validate for both of them in the QEMU validation function.

Take advantage of this change to switch to using
virDomainNetIsVirtioModel(net) instead of "net->model ==
VIR_DOMAIN_NET_MODEL_VIRTIO" (the former also matches
...VIRTIO_TRANSITIONAL and ...VIRTIO_NON_TRANSITIONAL, so is more
correct).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/domain_validate.c
src/qemu/qemu_validate.c

index eb5e764c020cb44fc159722cb593d3a4710209a3..d0e2bcaccf58806fafefe2f4fd6439495ea024f1 100644 (file)
@@ -2186,12 +2186,6 @@ virDomainNetDefValidate(const virDomainNetDef *net)
 
     switch (net->type) {
     case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
-        if (!virDomainNetIsVirtioModel(net)) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("Wrong or no <model> 'type' attribute specified with <interface type='vhostuser'/>. vhostuser requires the virtio-net* frontend"));
-            return -1;
-        }
-
         if (net->data.vhostuser->data.nix.listen &&
             net->data.vhostuser->data.nix.reconnect.enabled == VIR_TRISTATE_BOOL_YES) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
index 06093bc42b4f7b5ad5b47fed72b77a76171848f7..243c499a337fdfa7ce4bc8a53d3c04330c5d3757 100644 (file)
@@ -1823,17 +1823,18 @@ qemuValidateDomainDeviceDefNetwork(const virDomainNetDef *net,
                            _("vDPA devices are not supported with this QEMU binary"));
             return -1;
         }
+    }
 
-        if (net->model != VIR_DOMAIN_NET_MODEL_VIRTIO) {
+    if (!virDomainNetIsVirtioModel(net)) {
+        if (net->type == VIR_DOMAIN_NET_TYPE_VDPA ||
+            net->type == VIR_DOMAIN_NET_TYPE_VHOSTUSER) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("invalid model for interface of type '%1$s': '%2$s'"),
+                           _("invalid model for interface of type '%1$s': '%2$s' - must be 'virtio'"),
                            virDomainNetTypeToString(net->type),
                            virDomainNetModelTypeToString(net->model));
             return -1;
         }
-    }
-
-    if (virDomainNetIsVirtioModel(net)) {
+    } else {
         if (net->driver.virtio.rx_queue_size) {
             if (!VIR_IS_POW2(net->driver.virtio.rx_queue_size)) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",