]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: parse interface/source/@dev for all interface types (with backend type='passt')
authorLaine Stump <laine@redhat.com>
Fri, 7 Mar 2025 00:19:12 +0000 (19:19 -0500)
committerLaine Stump <laine@redhat.com>
Fri, 14 Mar 2025 17:43:44 +0000 (13:43 -0400)
The original implementation of the passt backend for vhost-user
interfaces erroneously forgot to parse:

  <source dev='blah'/>

for interface type='vhostuser', so it wasn't being added to the passt
commandline, and also wasn't being saved to the domain config. Now we
parse it whenever the <backend> type='passt', no matter what the
interface type, and then throw an error during validation if
source/@dev was specified for interface type = 'user|vhostuser' and
backend type != 'passt'.

Fixes: 1e9054b9c79d721a55f413c2983c5370044f8f60
Resolves: https://issues.redhat.com/browse/RHEL-82539
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/conf/domain_conf.c
src/conf/domain_validate.c
tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.xml

index b94cf99236d21bc97f44c1a5239bb27ace32368d..dedcf76511ffea51960deb43b73ec5f5e94dd6cf 100644 (file)
@@ -9940,9 +9940,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt,
         break;
 
     case VIR_DOMAIN_NET_TYPE_USER:
-        def->sourceDev = virXMLPropString(source_node, "dev");
-        break;
-
     case VIR_DOMAIN_NET_TYPE_NULL:
     case VIR_DOMAIN_NET_TYPE_LAST:
         break;
@@ -10057,6 +10054,11 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt,
         return NULL;
     }
 
+    if (def->backend.type == VIR_DOMAIN_NET_BACKEND_PASST) {
+        def->sourceDev = virXMLPropString(source_node, "dev");
+    }
+
+
     def->linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DEFAULT;
     if (linkstate != NULL) {
         if ((def->linkstate = virDomainNetInterfaceLinkStateTypeFromString(linkstate)) <= 0) {
index f2a98f143df95a8de798861ca368e25486423042..7b901da593c8a0ad6a47cbc3157d0bfd2358d879 100644 (file)
@@ -2190,12 +2190,18 @@ virDomainNetDefValidate(const virDomainNetDef *net)
     if (net->type != VIR_DOMAIN_NET_TYPE_USER &&
         net->type != VIR_DOMAIN_NET_TYPE_VHOSTUSER) {
         if (net->backend.type == VIR_DOMAIN_NET_BACKEND_PASST) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("The 'passt' backend can only be used with interface type='user' or type='vhostuser'"));
             return -1;
         }
     }
 
+    if (net->sourceDev && net->backend.type != VIR_DOMAIN_NET_BACKEND_PASST) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("The 'dev' attribute of the <source> element can only be used with <interface> type='user' or type='vhostuser' if the <backend> type='passt'"));
+        return -1;
+    }
+
     if (net->nPortForwards > 0) {
         size_t p;
 
index a1f9366722bb55e318fd2ae773a8d305b0318f2f..529aff11f82c88bd7ef56d70e252ee2cb4f781b5 100644 (file)
@@ -33,6 +33,7 @@
     <controller type='pci' index='0' model='pci-root'/>
     <interface type='vhostuser'>
       <mac address='00:11:22:33:44:55'/>
+      <source dev='eth42'/>
       <ip address='172.17.2.0' family='ipv4' prefix='24'/>
       <ip address='2001:db8:ac10:fd01::feed' family='ipv6'/>
       <portForward proto='tcp' address='2001:db8:ac10:fd01::1:10'>
@@ -63,6 +64,7 @@
     </interface>
     <interface type='vhostuser'>
       <mac address='00:11:22:33:44:11'/>
+      <source dev='eth43'/>
       <model type='virtio'/>
       <backend type='passt'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>