]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: put vhost-user code that's special for passt in a helper function
authorLaine Stump <laine@redhat.com>
Fri, 4 Apr 2025 23:38:28 +0000 (19:38 -0400)
committerLaine Stump <laine@redhat.com>
Fri, 11 Apr 2025 03:47:34 +0000 (23:47 -0400)
Rather than duplicating these two lines of chr device object setup for
hotplug and domain start, put them in a helper function that's called
from both places. That way when we need to setup *more* stuff specific
to passt+vhostuser, we can just add it in that one place.

Signed-off-by: Laine Stump <laine@redhat.com>
Tested-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_hotplug.c
src/qemu/qemu_passt.c
src/qemu/qemu_passt.h
src/qemu/qemu_process.c

index 9977662a2c645f9f4f7b922cac34086d1c54d08b..4562a75d2a76a5b357cd84181dc2def7027c38b1 100644 (file)
@@ -1268,12 +1268,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
 
         if (net->backend.type == VIR_DOMAIN_NET_BACKEND_PASST) {
 
-            /* vhostuser needs socket path in this location, and when
-             * backend is passt, the path is derived from other info,
-             * not taken from config.
-             */
-            g_free(net->data.vhostuser->data.nix.path);
-            net->data.vhostuser->data.nix.path = qemuPasstCreateSocketPath(vm, net);
+            qemuPasstPrepareVhostUser(vm, net);
 
             if (qemuPasstStart(vm, net) < 0)
                 goto cleanup;
index b9616d1c635d1b168db2929e62f4d3b2102db148..bc495eca1ec53feb0ea1fcae24ec8b3b4511b3bb 100644 (file)
@@ -165,6 +165,25 @@ qemuPasstSetupCgroup(virDomainObj *vm,
 }
 
 
+void
+qemuPasstPrepareVhostUser(virDomainObj *vm,
+                          virDomainNetDef *net)
+{
+    /* There are some options on the QEMU commandline for a vhost-user
+     * chr device that are normally configurable, but when it is passt
+     * speaking to the vhost-user device those things are
+     * derived/fixed. This function, which is called prior to
+     * generating the QEMU commandline, sets thos derived/fixed things
+     * in the chr device object.
+     */
+
+    /* The socket path is not user-configurable for passt - it is
+     * derived from other info
+     */
+    g_free(net->data.vhostuser->data.nix.path);
+    net->data.vhostuser->data.nix.path = qemuPasstCreateSocketPath(vm, net);
+}
+
 int
 qemuPasstStart(virDomainObj *vm,
                virDomainNetDef *net)
index e0b9aaac8dfabfc11c044a2c7ef1eec1666bee81..ea545ccf38ecb48839bff7435031983bf2fbcfb5 100644 (file)
@@ -37,5 +37,8 @@ int qemuPasstSetupCgroup(virDomainObj *vm,
                          virDomainNetDef *net,
                          virCgroup *cgroup);
 
+void qemuPasstPrepareVhostUser(virDomainObj *vm,
+                               virDomainNetDef *net);
+
 char *qemuPasstCreateSocketPath(virDomainObj *vm,
                                 virDomainNetDef *net);
index 8a758f78adcc3dfc63ddadf172bdb0a1c2528a86..1af91c5909a6c0294c584f6812b441a7d2ec0a3e 100644 (file)
@@ -6022,13 +6022,8 @@ qemuProcessPrepareDomainNetwork(virDomainObj *vm)
 
         case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
             if (net->backend.type == VIR_DOMAIN_NET_BACKEND_PASST) {
-                /* when using the passt backend, the path of the
-                 * unix socket is always derived from other info
-                 * *not* manually given in the config, but all the
-                 * vhostuser code looks for it there.
-                 */
-                g_free(net->data.vhostuser->data.nix.path);
-                net->data.vhostuser->data.nix.path = qemuPasstCreateSocketPath(vm, net);
+                /* some extra setup of internal data for passt vhostuser mode */
+                qemuPasstPrepareVhostUser(vm, net);
             }
             break;