Move the block guarded by 'is_tap' boolean to the only place where
'is_tap' is set to true.
This causes few arguments to change places.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_command.c | 55 +++++++++----------
.../net-eth-unmanaged-tap.args | 2 +-
tests/qemuxml2argvdata/user-aliases.args | 2 +-
3 files changed, 27 insertions(+), 32 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c86ab3f438..19afad22a1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4194,7 +4194,6 @@ qemuBuildHostNetProps(virDomainNetDef *net,
size_t vhostfdSize,
const char *slirpfd)
{
- bool is_tap = false;
virDomainNetType netType = virDomainNetGetActualType(net);
size_t i;
qemuDomainNetworkPrivate *netpriv = QEMU_DOMAIN_NETWORK_PRIVATE(net);
@@ -4239,7 +4238,31 @@ qemuBuildHostNetProps(virDomainNetDef *net,
return NULL;
}
- is_tap = true;
+ if (vhostfdSize) {
+ if (virJSONValueObjectAppendBoolean(netprops, "vhost", true) <
0)
+ return NULL;
+
+ if (vhostfdSize == 1) {
+ if (virJSONValueObjectAdd(&netprops, "s:vhostfd",
vhostfd[0], NULL) < 0)
+ return NULL;
+ } else {
+ g_auto(virBuffer) fdsbuf = VIR_BUFFER_INITIALIZER;
+
+ for (i = 0; i < vhostfdSize; i++)
+ virBufferAsprintf(&fdsbuf, "%s:", vhostfd[i]);
+
+ virBufferTrim(&fdsbuf, ":");
+
+ if (virJSONValueObjectAdd(&netprops,
+ "s:vhostfds",
virBufferCurrentContent(&fdsbuf),
+ NULL) < 0)
+ return NULL;
+ }
+ }
+
+ if (net->tune.sndbuf_specified &&
+ virJSONValueObjectAppendNumberUlong(netprops, "sndbuf",
net->tune.sndbuf) < 0)
+ return NULL;
break;
case VIR_DOMAIN_NET_TYPE_CLIENT:
@@ -4352,34 +4375,6 @@ qemuBuildHostNetProps(virDomainNetDef *net,
if (virJSONValueObjectAppendStringPrintf(netprops, "id",
"host%s", net->info.alias) < 0)
return NULL;
- if (is_tap) {
- if (vhostfdSize) {
- if (virJSONValueObjectAppendBoolean(netprops, "vhost", true) <
0)
- return NULL;
-
- if (vhostfdSize == 1) {
- if (virJSONValueObjectAdd(&netprops, "s:vhostfd",
vhostfd[0], NULL) < 0)
- return NULL;
- } else {
- g_auto(virBuffer) fdsbuf = VIR_BUFFER_INITIALIZER;
-
- for (i = 0; i < vhostfdSize; i++)
- virBufferAsprintf(&fdsbuf, "%s:", vhostfd[i]);
-
- virBufferTrim(&fdsbuf, ":");
-
- if (virJSONValueObjectAdd(&netprops,
- "s:vhostfds",
virBufferCurrentContent(&fdsbuf),
- NULL) < 0)
- return NULL;
- }
- }
-
- if (net->tune.sndbuf_specified &&
- virJSONValueObjectAppendNumberUlong(netprops, "sndbuf",
net->tune.sndbuf) < 0)
- return NULL;
- }
-
return g_steal_pointer(&netprops);
}
diff --git a/tests/qemuxml2argvdata/net-eth-unmanaged-tap.args
b/tests/qemuxml2argvdata/net-eth-unmanaged-tap.args
index 8722f27207..5909d60490 100644
--- a/tests/qemuxml2argvdata/net-eth-unmanaged-tap.args
+++ b/tests/qemuxml2argvdata/net-eth-unmanaged-tap.args
@@ -29,6 +29,6 @@ QEMU_AUDIO_DRV=none \
-usb \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
--netdev tap,fd=3,id=hostnet0,vhost=on,vhostfd=44 \
+-netdev tap,fd=3,vhost=on,vhostfd=44,id=hostnet0 \
-device virtio-net-pci,netdev=hostnet0,id=net0,mac=fe:11:22:33:44:55,bus=pci.0,addr=0x2
\
-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/user-aliases.args
b/tests/qemuxml2argvdata/user-aliases.args
index f88ebbf11d..c80be4b439 100644
--- a/tests/qemuxml2argvdata/user-aliases.args
+++ b/tests/qemuxml2argvdata/user-aliases.args
@@ -47,7 +47,7 @@ QEMU_AUDIO_DRV=none \
-drive
file=/home/zippy/tmp/install-amd64-minimal-20140619.iso,format=raw,if=none,id=drive-ua-WhatAnAwesomeCDROM,readonly=on,cache=none
\
-device
ide-cd,bus=ide.1,unit=0,drive=drive-ua-WhatAnAwesomeCDROM,id=ua-WhatAnAwesomeCDROM,bootindex=2
\
-global isa-fdc.driveA=drive-ua-myDisk1 \
--netdev tap,fd=3,id=hostua-CheckoutThisNIC,vhost=on,vhostfd=44 \
+-netdev tap,fd=3,vhost=on,vhostfd=44,id=hostua-CheckoutThisNIC \
-device
virtio-net-pci,netdev=hostua-CheckoutThisNIC,id=ua-CheckoutThisNIC,mac=52:54:00:d6:c0:0b,bus=pci.0,addr=0x3
\
-netdev socket,listen=127.0.0.1:1234,id=hostua-WeCanAlsoDoServerMode \
-device
rtl8139,netdev=hostua-WeCanAlsoDoServerMode,id=ua-WeCanAlsoDoServerMode,mac=52:54:00:22:c9:42,bus=pci.0,addr=0x9
\
--
2.35.1