conf: remove <backend upstream='xxx'/> attribute

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@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Laine Stump 2023-01-12 23:42:16 -05:00 committed by Jiri Denemark
parent 8ff8fe3f8a
commit 3592b81c4c
6 changed files with 31 additions and 14 deletions

View File

@ -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'>

View File

@ -2715,6 +2715,7 @@ virDomainNetDefFree(virDomainNetDef *def)
g_free(def->ifname_guest_actual);
g_free(def->virtio);
g_free(def->coalesce);
g_free(def->sourceDev);
virNetDevIPInfoClear(&def->guestIP);
virNetDevIPInfoClear(&def->hostIP);
@ -9038,7 +9039,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 +9464,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 +23280,8 @@ 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;

View File

@ -1192,6 +1192,7 @@ struct _virDomainNetDef {
virNetDevIPInfo hostIP;
char *ifname_guest_actual;
char *ifname_guest;
char *sourceDev;
virNetDevIPInfo guestIP;
size_t nPortForwards;
virDomainNetPortForward **portForwards;

View File

@ -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>

View File

@ -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);

View File

@ -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'/>