[libvirt PATCH 1/3] conf: remove <backend upstream='xxx'/> attribute

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This attribute was added to support setting the --interface option for
passt, but in a post-push/pre-9.0-release review, danpb pointed out
that it would be better to use the existing <source dev='xxx'/>
attribute to set --interface rather than creating a new attribute (in
the wrong place). So we remove backend/upstream, and change the passt
commandline creation to grab the name for --interface from source/dev.

Signed-off-by: Laine Stump <laine@xxxxxxxxxx>
---
 docs/formatdomain.rst                     |  9 +++++----
 src/conf/domain_conf.c                    | 15 +++++++++++++--
 src/conf/domain_conf.h                    |  1 +
 src/conf/schemas/domaincommon.rng         | 13 ++++++++-----
 src/qemu/qemu_passt.c                     |  4 ++--
 tests/qemuxml2argvdata/net-user-passt.xml |  3 ++-
 6 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index 2c44f77ab6..490a954745 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -4821,9 +4821,9 @@ destined for the host toward the guest instead.
 
 When the passt backend is used, the ``<backend>`` attribute
 ``logFile`` can be used to tell the passt process for this interface
-where to write its message log, and the ``<backend>`` attribute
-``upstream`` can tell it to restrict upstream traffic to a particular
-host interface.
+where to write its message log, and the ``<source>`` attribute ``dev``
+can tell it to use a particular host interface to derive the routes
+given to the guest for forwarding traffic upstream.
 
 Additionally, when passt is used, multiple ``<portForward>`` elements
 can be added to forward incoming network traffic for the host to this
@@ -4855,8 +4855,9 @@ ports **with the exception of some subset**.
    <devices>
      ...
      <interface type='user'>
-       <backend type='passt' logFile='/var/log/passt.log' upstream='eth0'/>
+       <backend type='passt' logFile='/var/log/passt.log'/>
        <mac address="00:11:22:33:44:55"/>
+       <source dev='eth0'/>
        <ip family='ipv4' address='172.17.2.0' prefix='24'/>
        <ip family='ipv6' address='2001:db8:ac10:fd01::' prefix='64'/>
        <portForward proto='tcp' address='2001:db8:ac10:fd01::1:10' start='2022'>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e43dee1a60..5379204f89 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9038,7 +9038,6 @@ virDomainNetBackendParseXML(xmlNodePtr node,
     }
 
     def->backend.logFile = virXMLPropString(node, "logFile");
-    def->backend.upstream = virXMLPropString(node, "upstream");
 
     if (tap)
         def->backend.tap = virFileSanitizePath(tap);
@@ -9464,6 +9463,9 @@ 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;
@@ -23277,6 +23279,9 @@ virDomainActualNetDefContentsFormat(virBuffer *buf,
                 return -1;
             }
             virBufferAsprintf(buf, " mode='%s'", mode);
+        } else if (actualType == VIR_DOMAIN_NET_TYPE_USER) {
+
+            virBufferEscapeString(buf, " dev='%s'", def->sourceDev);
         }
 
         virBufferAddLit(buf, "/>\n");
@@ -23487,7 +23492,6 @@ virDomainNetBackendFormat(virBuffer *buf,
     virBufferEscapeString(&attrBuf, " tap='%s'", backend->tap);
     virBufferEscapeString(&attrBuf, " vhost='%s'", backend->vhost);
     virBufferEscapeString(&attrBuf, " logFile='%s'", backend->logFile);
-    virBufferEscapeString(&attrBuf, " upstream='%s'", backend->upstream);
     virXMLFormatElement(buf, "backend", &attrBuf, NULL);
 }
 
@@ -23752,6 +23756,13 @@ virDomainNetDefFormat(virBuffer *buf,
         }
 
         case VIR_DOMAIN_NET_TYPE_USER:
+            if (def->backend.type == VIR_DOMAIN_NET_BACKEND_PASST &&
+                def->sourceDev) {
+                virBufferEscapeString(buf, "<source dev='%s'", def->sourceDev);
+                sourceLines++;
+            }
+            break;
+
         case VIR_DOMAIN_NET_TYPE_NULL:
         case VIR_DOMAIN_NET_TYPE_LAST:
             break;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 60fc7c4eb2..3e4985a67d 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1192,6 +1192,7 @@ struct _virDomainNetDef {
     virNetDevIPInfo hostIP;
     char *ifname_guest_actual;
     char *ifname_guest;
+    char *sourceDev;
     virNetDevIPInfo guestIP;
     size_t nPortForwards;
     virDomainNetPortForward **portForwards;
diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng
index bd2e789327..6cb0a20e1e 100644
--- a/src/conf/schemas/domaincommon.rng
+++ b/src/conf/schemas/domaincommon.rng
@@ -3318,6 +3318,14 @@
             <value>user</value>
           </attribute>
           <interleave>
+            <optional>
+              <element name="source">
+                <attribute name="dev">
+                  <ref name="deviceName"/>
+                </attribute>
+                <empty/>
+              </element>
+            </optional>
             <ref name="interface-options"/>
           </interleave>
         </group>
@@ -3643,11 +3651,6 @@
               <ref name="absFilePath"/>
             </attribute>
           </optional>
-          <optional>
-            <attribute name="upstream">
-              <ref name="deviceName"/>
-            </attribute>
-          </optional>
         </element>
       </optional>
       <optional>
diff --git a/src/qemu/qemu_passt.c b/src/qemu/qemu_passt.c
index a7ee841af7..b1215a1bba 100644
--- a/src/qemu/qemu_passt.c
+++ b/src/qemu/qemu_passt.c
@@ -167,8 +167,8 @@ qemuPasstStart(virDomainObj *vm,
         virCommandAddArgFormat(cmd, "%u", net->mtu);
     }
 
-    if (net->backend.upstream)
-        virCommandAddArgList(cmd, "--interface", net->backend.upstream, NULL);
+    if (net->sourceDev)
+        virCommandAddArgList(cmd, "--interface", net->sourceDev, NULL);
 
     if (net->backend.logFile)
         virCommandAddArgList(cmd, "--log-file", net->backend.logFile, NULL);
diff --git a/tests/qemuxml2argvdata/net-user-passt.xml b/tests/qemuxml2argvdata/net-user-passt.xml
index b82eebd089..20c9f50542 100644
--- a/tests/qemuxml2argvdata/net-user-passt.xml
+++ b/tests/qemuxml2argvdata/net-user-passt.xml
@@ -27,6 +27,7 @@
     <controller type='pci' index='0' model='pci-root'/>
     <interface type='user'>
       <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'>
@@ -46,7 +47,7 @@
         <range start='443' to='344'/>
       </portForward>
       <model type='rtl8139'/>
-      <backend type='passt' logFile='/var/log/loglaw.blog' upstream='eth42'/>
+      <backend type='passt' logFile='/var/log/loglaw.blog'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
     </interface>
     <input type='mouse' bus='ps2'/>
-- 
2.38.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux