From 3592b81c4c717f01f34362e0b578989f9f93676f Mon Sep 17 00:00:00 2001 From: Laine Stump Date: Thu, 12 Jan 2023 23:42:16 -0500 Subject: [PATCH] conf: remove 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 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 Reviewed-by: Jiri Denemark --- 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 ```` attribute ``logFile`` can be used to tell the passt process for this interface -where to write its message log, and the ```` attribute -``upstream`` can tell it to restrict upstream traffic to a particular -host interface. +where to write its message log, and the ```` 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 ```` 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**. ... - + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e43dee1a60..45965fa0fa 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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, "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 @@ user + + + + + + + + @@ -3643,11 +3651,6 @@ - - - - - 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 @@ + @@ -46,7 +47,7 @@ - +
-- 2.47.2