all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: "Kağan Cengiz" <kagancengiz@kgncengiz.com>
To: pve-devel@lists.proxmox.com
Cc: "Kağan Cengiz" <kagancengiz@kgncengiz.com>
Subject: [PATCH qemu-server] net: add initial vhost-user support
Date: Mon, 13 Apr 2026 10:34:50 +0300	[thread overview]
Message-ID: <20260413073450.503199-1-kagancengiz@kgncengiz.com> (raw)

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




                 reply	other threads:[~2026-04-13  8:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260413073450.503199-1-kagancengiz@kgncengiz.com \
    --to=kagancengiz@kgncengiz.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal