public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH qemu-server] net: add initial vhost-user support
@ 2026-04-13  7:34 Kağan Cengiz
  0 siblings, 0 replies; only message in thread
From: Kağan Cengiz @ 2026-04-13  7:34 UTC (permalink / raw)
  To: pve-devel; +Cc: Kağan Cengiz

Add support for vhost-user network backends to qemu-server. It expects unix sockets
to be present at /run/vhost-user/{bridge}.sock.

This is the initial backend implementation. API and GUI support
will be added in follow-up patches.

Signed-off-by: Kağan Cengiz <kagancengiz@kgncengiz.com>
---
 src/PVE/QemuServer.pm         | 18 +++++++++++++++++-
 src/PVE/QemuServer/Network.pm |  8 ++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 2a469fff..27c88379 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -1358,7 +1358,7 @@ sub print_netdevice_full {
     print "netdev $netid: not adding 'host_mtu' parameter for migration compat\n"
         if $migration_skip_host_mtu;
 
-    if ($net->{model} eq 'virtio' && $net->{bridge} && !$migration_skip_host_mtu) {
+    if ($net->{model} eq 'virtio' && $net->{bridge} && !$migration_skip_host_mtu && !$net->{vhostuser}) {
         my $bridge_mtu = PVE::Network::read_bridge_mtu($net->{bridge});
 
         if ($host_mtu_migration) {
@@ -1446,6 +1446,11 @@ sub print_netdev_full {
     my $netdev = "";
     my $script = $hotplug ? "pve-bridge-hotplug" : "pve-bridge";
 
+    if ($net->{vhostuser}) {
+        my $queues = $net->{queues} || 1;
+        return "type=vhost-user,id=$netid,chardev=char$netid,vhostforce=on,queues=$queues";
+    }
+
     if ($net->{bridge}) {
         $netdev = "type=tap,id=$netid,ifname=${ifname},script=/usr/libexec/qemu-server/$script"
             . ",downscript=/usr/libexec/qemu-server/pve-bridgedown$vhostparam";
@@ -3664,6 +3669,17 @@ sub config_to_command {
 
         $d->{bootindex} = $bootorder->{$netname} if $bootorder->{$netname};
 
+        if ($d->{vhostuser}) {
+            my $vhost_user_dir = "/run/vhost-user";
+            my $socket_path = "$vhost_user_dir/$d->{bridge}.sock";
+
+            if (! -e $socket_path) {
+                die "network device '$netname' - vhost-user socket not found: $socket_path\n";
+            }
+
+            push @$devices, '-chardev', "socket,id=char$netname,path=$socket_path";
+        }
+
         my $netdevfull = print_netdev_full($vmid, $conf, $arch, $d, $netname);
         push @$devices, '-netdev', $netdevfull;
 
diff --git a/src/PVE/QemuServer/Network.pm b/src/PVE/QemuServer/Network.pm
index eb8222e8..cf889f0c 100644
--- a/src/PVE/QemuServer/Network.pm
+++ b/src/PVE/QemuServer/Network.pm
@@ -71,6 +71,12 @@ my $net_fmt = {
             optional => 1,
         },
     ),
+    vhostuser => {
+        type => 'boolean',
+        description => "Use vhost-user for networking. Requires a vhost-user compatible bridge.",
+        optional => 1,
+        default => 0,
+    },
     queues => {
         type => 'integer',
         minimum => 0,
@@ -258,6 +264,8 @@ sub add_nets_bridge_fdb {
         # NOTE: expect setups with learning off to *not* use auto-random-generation of MAC on start
         my $net = parse_net($conf->{$opt}, 1) or next;
 
+        next if $net->{vhostuser};
+
         my $mac = $net->{macaddr};
         if (!$mac) {
             log_warn(
-- 
2.53.0




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-04-13  8:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-13  7:34 [PATCH qemu-server] net: add initial vhost-user support Kağan Cengiz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal