[PATCH 4/5] qemuBuildHostNetProps: Use 'fds', 'vhostfds' with QEMU_CAPS_NETDEV_TAP_FD_VHOSTFD_PLURAL

Peter Krempa via Devel posted 5 patches 2 days, 18 hours ago
[PATCH 4/5] qemuBuildHostNetProps: Use 'fds', 'vhostfds' with QEMU_CAPS_NETDEV_TAP_FD_VHOSTFD_PLURAL
Posted by Peter Krempa via Devel 2 days, 18 hours ago
From: Peter Krempa <pkrempa@redhat.com>

QEMU is going to deprecate the singular spelling for single FDs soon
with the guidance to use the plural. Since we can't/are unsure about
using that with older QEMUs do the change based on the capability.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_command.c | 11 +++++++----
 src/qemu/qemu_command.h |  3 ++-
 src/qemu/qemu_hotplug.c |  2 +-
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index ca6779a6ea..e6ce9492a3 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3925,7 +3925,8 @@ qemuBuildHostNetSocketAddr(virDomainNetDef *net)

 virJSONValue *
 qemuBuildHostNetProps(virDomainObj *vm,
-                      virDomainNetDef *net)
+                      virDomainNetDef *net,
+                      virQEMUCaps *qemuCaps)
 {
     virDomainNetType netType = virDomainNetGetActualType(net);
     size_t i;
@@ -3967,7 +3968,8 @@ qemuBuildHostNetProps(virDomainObj *vm,
                 nfds++;
             }

-            if (nfds > 1)
+            if (nfds > 1 ||
+                virQEMUCapsGet(qemuCaps, QEMU_CAPS_NETDEV_TAP_FD_VHOSTFD_PLURAL))
                 tapfd_field = "s:fds";
         }

@@ -3983,7 +3985,8 @@ qemuBuildHostNetProps(virDomainObj *vm,
                 nfds++;
             }

-            if (nfds > 1)
+            if (nfds > 1 ||
+                virQEMUCapsGet(qemuCaps, QEMU_CAPS_NETDEV_TAP_FD_VHOSTFD_PLURAL))
                 vhostfd_field = "s:vhostfds";
         }

@@ -9147,7 +9150,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver,
     qemuFDPassDirectTransferCommand(netpriv->slirpfd, cmd);
     qemuFDPassTransferCommand(netpriv->vdpafd, cmd);

-    if (!(hostnetprops = qemuBuildHostNetProps(vm, net)))
+    if (!(hostnetprops = qemuBuildHostNetProps(vm, net, qemuCaps)))
         goto cleanup;

     if (qemuBuildNetdevCommandlineFromJSON(cmd, hostnetprops, qemuCaps) < 0)
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index ad068f1f16..12e70bf180 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -87,7 +87,8 @@ qemuBuildChannelGuestfwdNetdevProps(virDomainChrDef *chr);

 virJSONValue *
 qemuBuildHostNetProps(virDomainObj *vm,
-                      virDomainNetDef *net);
+                      virDomainNetDef *net,
+                      virQEMUCaps *qemuCaps);

 int
 qemuBuildInterfaceConnect(virDomainObj *vm,
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index f786248e70..2ed7a3b163 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1388,7 +1388,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
         virNetDevSetMTU(net->ifname, net->mtu) < 0)
         goto cleanup;

-    if (!(netprops = qemuBuildHostNetProps(vm, net)))
+    if (!(netprops = qemuBuildHostNetProps(vm, net, priv->qemuCaps)))
         goto cleanup;

     qemuDomainObjEnterMonitor(vm);
-- 
2.53.0