[PATCH 04/37] qemuDomainAttachNetDevice: Use 'qemuFDPass' for the vdpa file descriptor

Peter Krempa pkrempa at redhat.com
Tue May 10 15:19:40 UTC 2022


We use the qemuFDPass infrastructure when building the command line,
refactor the monitor too.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_hotplug.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 274f47c25d..62cfc29a16 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1184,8 +1184,8 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
     virErrorPtr originalError = NULL;
     g_autofree char *slirpfdName = NULL;
     int slirpfd = -1;
-    g_autofree char *vdpafdName = NULL;
     int vdpafd = -1;
+    g_autoptr(qemuFDPass) vdpa = NULL;
     char **tapfdName = NULL;
     int *tapfd = NULL;
     size_t tapfdSize = 0;
@@ -1394,6 +1394,10 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,

         if ((vdpafd = qemuInterfaceVDPAConnect(net)) < 0)
             goto cleanup;
+
+        vdpa = qemuFDPassNew(net->info.alias, priv);
+
+        qemuFDPassAddFD(vdpa, &vdpafd, "-vdpa");
         break;

     case VIR_DOMAIN_NET_TYPE_SERVER:
@@ -1455,24 +1459,15 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,

     qemuDomainObjEnterMonitor(driver, vm);

-    if (vdpafd > 0) {
-        /* vhost-vdpa only accepts a filename. We can pass an open fd by
-         * filename if we add the fd to an fdset and then pass a filename of
-         * /dev/fdset/$FDSETID. */
-        qemuMonitorAddFdInfo fdinfo;
-        if (qemuMonitorAddFileHandleToSet(priv->mon, vdpafd, -1,
-                                          net->data.vdpa.devicepath,
-                                          &fdinfo) < 0) {
-            qemuDomainObjExitMonitor(vm);
-            goto cleanup;
-        }
-        vdpafdName = g_strdup_printf("/dev/fdset/%d", fdinfo.fdset);
+    if (qemuFDPassTransferMonitor(vdpa, priv->mon) < 0) {
+        qemuDomainObjExitMonitor(vm);
+        goto cleanup;
     }

     if (!(netprops = qemuBuildHostNetProps(net,
                                            tapfdName, tapfdSize,
                                            vhostfdName, vhostfdSize,
-                                           slirpfdName, vdpafdName))) {
+                                           slirpfdName, qemuFDPassGetPath(vdpa)))) {
         qemuDomainObjExitMonitor(vm);
         goto cleanup;
     }
-- 
2.35.1



More information about the libvir-list mailing list