[PATCH] qemu_passt: Format portForward device even without address

Michal Privoznik posted 1 patch 10 months, 4 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/479ccd4230d23ff03f9f40cb9c76774bc7569d60.1685620076.git.mprivozn@redhat.com
src/qemu/qemu_passt.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
[PATCH] qemu_passt: Format portForward device even without address
Posted by Michal Privoznik 10 months, 4 weeks ago
It's almost like we've anticipated this. Our XML parser and
formatter handles @address and @dev attributes of <portForward/>
element completely independent of each other. And as of commit
2023_03_29.b10b983~3 passt allows handling these two separately
too. All that's left is generate the cmd line according to this
new fact.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2210287
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_passt.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_passt.c b/src/qemu/qemu_passt.c
index 0712ca0b16..99636a3a49 100644
--- a/src/qemu/qemu_passt.c
+++ b/src/qemu/qemu_passt.c
@@ -221,6 +221,7 @@ qemuPasstStart(virDomainObj *vm,
     for (i = 0; i < net->nPortForwards; i++) {
         virDomainNetPortForward *pf = net->portForwards[i];
         g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
+        bool emitsep = false;
 
         if (pf->proto == VIR_DOMAIN_NET_PROTO_TCP) {
             virCommandAddArg(cmd, "--tcp-ports");
@@ -240,12 +241,16 @@ qemuPasstStart(virDomainObj *vm,
                 return -1;
 
             virBufferAddStr(&buf, addr);
+            emitsep = true;
+        }
 
-            if (pf->dev)
-                virBufferAsprintf(&buf, "%%%s", pf->dev);
+        if (pf->dev) {
+            virBufferAsprintf(&buf, "%%%s", pf->dev);
+            emitsep = true;
+        }
 
+        if (emitsep)
             virBufferAddChar(&buf, '/');
-        }
 
         if (!pf->nRanges) {
             virBufferAddLit(&buf, "all");
-- 
2.39.3
Re: [PATCH] qemu_passt: Format portForward device even without address
Posted by Ján Tomko 10 months, 4 weeks ago
On a Thursday in 2023, Michal Privoznik wrote:
>It's almost like we've anticipated this. Our XML parser and
>formatter handles @address and @dev attributes of <portForward/>
>element completely independent of each other. And as of commit
>2023_03_29.b10b983~3 passt allows handling these two separately
>too. All that's left is generate the cmd line according to this
>new fact.
>
>Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2210287
>Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>---
> src/qemu/qemu_passt.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano