From: David Gibson <david@gibson.dropbear.id.au>
To: Ammar Yasser <aerosound161@gmail.com>
Cc: passt-dev@passt.top, eperezma@redhat.com
Subject: Re: [RFC v3 3/8] conf: Add context fields, epoll types and the --vhost flag to pasta
Date: Mon, 10 Aug 2026 11:11:53 +1000 [thread overview]
Message-ID: <anklTWjo_1L-rgIJ@zatzit> (raw)
In-Reply-To: <20260802132155.870796-4-aerosound161@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 7247 bytes --]
On Sun, Aug 02, 2026 at 01:21:50PM +0000, Ammar Yasser wrote:
> The --vhost controls whether or no to use vhost acceleration for pasta.
> The EPOLL_TYPE_VHOST_CALL means that kernel wants to notify us about
> data it has written. EPOLL_TYPE_VHOST_ERROR means the kernel encountered
> an internal error on vhost and wants to notify us that something went
> wrong.
>
> Add the fd_vhost field on the context which will carry the file
> descriptor of the device and will indicate that the setup was
> successful. The vq field contains the kick, call and err file
> descriptors for both queues.
>
> Also add vhost (mark if vhost acceleration was requested) and
> virtio_features field.
A couple of concerns about the command line interface. IIUC, once
this is all ready the difference between vhost-kernel and regular
tuntap should be neither guest-visible nor user-visible. So, assuming
it does perform better, we'll probably want to make it the default.
So, making this explicitly an opt-in probably isn't what we want.
Maybe --vhost on|off|auto would be a better idea, defaulting to off
now, but auto (use if available) in future. "on" would be if the user
definitely wants vhost, and would rather we exit than fall back if
it's not available.
A more minor concern is that there's the potential confusion between
this and --vhost-user. Not immediately sure what we can do about
this, since that's just reflecting the confusingly similar names of
the underlying features.
> Signed-off-by: Ammar Yasser <aerosound161@gmail.com>
> ---
> conf.c | 6 ++++++
> epoll_type.h | 4 ++++
> passt.c | 3 +++
> passt.h | 15 +++++++++++++++
> 4 files changed, 28 insertions(+)
>
> diff --git a/conf.c b/conf.c
> index faf2681..c31546e 100644
> --- a/conf.c
> +++ b/conf.c
> @@ -736,6 +736,7 @@ pasta_opts:
> " default: auto\n"
> " --host-lo-to-ns-lo Translate host-loopback forwards to\n"
> " namespace loopback\n"
> + " --vhost\t\tUse vhost-kernel acceleration\n"
> " --userns NSPATH Target user namespace to join\n"
> " --netns PATH|NAME Target network namespace to join\n"
> " --netns-only Don't join existing user namespace\n"
> @@ -766,6 +767,7 @@ enum passt_modes conf_mode(int argc, char *argv[])
> int vhost_user = 0;
> const struct option optvu[] = {
> {"vhost-user", no_argument, &vhost_user, 1 },
> + {"vhost", no_argument, NULL, 0 },
> { 0 },
> };
> char argv0[PATH_MAX], *basearg0;
> @@ -1309,6 +1311,7 @@ void conf(struct ctx *c, int argc, char **argv)
> {"ipv4-only", no_argument, NULL, '4' },
> {"ipv6-only", no_argument, NULL, '6' },
> {"one-off", no_argument, NULL, '1' },
> + {"vhost", no_argument, &c->vhost, 1 },
> {"tcp-ports", required_argument, NULL, 't' },
> {"udp-ports", required_argument, NULL, 'u' },
> {"tcp-ns", required_argument, NULL, 'T' },
> @@ -1838,6 +1841,9 @@ void conf(struct ctx *c, int argc, char **argv)
> die("--no-copy-addrs needs --config-net");
> }
>
> + if (c->vhost && c->mode != MODE_PASTA)
> + die("--vhost is only available in pasta mode");
> +
> if (c->mode == MODE_PASTA && c->splice_only) {
> if (c->no_splice)
> die("--splice-only is incompatible with --no-splice");
> diff --git a/epoll_type.h b/epoll_type.h
> index 061325a..e3206d1 100644
> --- a/epoll_type.h
> +++ b/epoll_type.h
> @@ -50,6 +50,10 @@ enum epoll_type {
> EPOLL_TYPE_CONF_LISTEN,
> /* Configuration socket */
> EPOLL_TYPE_CONF,
> + /* vhost-kernel call socket */
> + EPOLL_TYPE_VHOST_CALL,
> + /* vhost-kernel error socket */
> + EPOLL_TYPE_VHOST_ERROR,
>
> EPOLL_NUM_TYPES,
> };
> diff --git a/passt.c b/passt.c
> index 5054551..865b331 100644
> --- a/passt.c
> +++ b/passt.c
> @@ -65,6 +65,7 @@ char pkt_buf[PKT_BUF_BYTES] __attribute__ ((aligned(PAGE_SIZE)));
> struct ctx passt_ctx = {
> .pidfile_fd = -1,
> .fd_tap = -1,
> + .fd_vhost = -1,
> .fd_tap_listen = -1,
> .fd_control_listen = -1,
> .fd_repair_listen = -1,
> @@ -92,6 +93,8 @@ char *epoll_type_str[] = {
> [EPOLL_TYPE_NL_NEIGH] = "netlink neighbour notifier socket",
> [EPOLL_TYPE_CONF_LISTEN] = "configuration listening socket",
> [EPOLL_TYPE_CONF] = "configuration socket",
> + [EPOLL_TYPE_VHOST_CALL] = "vhost-kernel call socket",
> + [EPOLL_TYPE_VHOST_ERROR] = "vhost-kernel error socket",
> };
> static_assert(ARRAY_SIZE(epoll_type_str) == EPOLL_NUM_TYPES,
> "epoll_type_str[] doesn't match enum epoll_type");
> diff --git a/passt.h b/passt.h
> index 51ccd4f..c729316 100644
> --- a/passt.h
> +++ b/passt.h
> @@ -183,8 +183,11 @@ struct ip6_ctx {
> * @fd_repair_listen: File descriptor for listening TCP_REPAIR socket, if any
> * @fd_repair: Connected AF_UNIX socket for TCP_REPAIR helper
> * @our_tap_mac: Pasta/passt's MAC on the tap link
> + * @fd_vhost: File descriptor for /dev/vhost-net, set on vhost setup
> * @guest_mac: MAC address of guest or namespace, seen or configured
> * @hash_secret: 128-bit secret for siphash functions
> + * @virtio_features: Negotiated virtio feature bits
> + * @vhost: Enable vhost-kernel acceleration for pasta
> * @ifi4: Template interface for IPv4, -1: none, 0: IPv4 disabled
> * @ip4: IPv4 configuration
> * @dns_search: DNS search list
> @@ -202,6 +205,8 @@ struct ip6_ctx {
> * @no_udp: Disable UDP operation
> * @udp: Context for UDP protocol handler
> * @no_icmp: Disable ICMP operation
> + * @vq: Per-virtqueue eventfd descriptors for vhost-kernel
> + * ([0] is RX, [1] is TX; each holds kick_fd, call_fd, err_fd)
> * @mtu: MTU passed via DHCP/NDP
> * @no_dns: Do not source/use DNS servers for any purpose
> * @no_dns_search: Do not source/use domain search lists for any purpose
> @@ -258,11 +263,14 @@ struct ctx {
> int fd_control;
> int fd_repair_listen;
> int fd_repair;
> +
> + int fd_vhost;
> unsigned char our_tap_mac[ETH_ALEN];
> unsigned char guest_mac[ETH_ALEN];
> uint16_t mtu;
>
> uint64_t hash_secret[2];
> + uint64_t virtio_features;
>
> int ifi4;
> struct ip4_ctx ip4;
> @@ -288,6 +296,12 @@ struct ctx {
> struct udp_ctx udp;
> int no_icmp;
>
> + struct {
> + int kick_fd;
> + int call_fd;
> + int err_fd;
> + } vq[2];
> +
> int no_dns;
> int no_dns_search;
> int no_dhcp_dns;
> @@ -300,6 +314,7 @@ struct ctx {
> int splice_only;
> int host_lo_to_ns_lo;
> int freebind;
> + int vhost;
> bool chroot_fallback;
>
> int low_wmem;
It might be a bit neater to put the new vhost-kernel related fields
into a substructure, rather than spreading them across struct ctx. At
some point it would be nice to make the various tap backends a bit
more pluggable / independent from each other. Doing that's obviously
not in scope for this series, but keeping it's internal data all
together will at least not make that job harder in the future.
> --
> 2.34.1
>
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-08-10 1:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-02 13:21 [RFC v3 0/8] Add vhost-net kernel support " Ammar Yasser
2026-08-02 13:21 ` [RFC v3 1/8] tap: Move the tap_hdr file to a separate file Ammar Yasser
2026-08-07 5:40 ` David Gibson
2026-08-02 13:21 ` [RFC v3 2/8] udp,tcp: Make protocol specific buffers public Ammar Yasser
2026-08-07 5:56 ` David Gibson
2026-08-02 13:21 ` [RFC v3 3/8] conf: Add context fields, epoll types and the --vhost flag to pasta Ammar Yasser
2026-08-10 1:11 ` David Gibson [this message]
2026-08-02 13:21 ` [RFC v3 4/8] virtio: Define the pasta vhost interface Ammar Yasser
2026-08-10 2:06 ` David Gibson
2026-08-02 13:21 ` [RFC v3 5/8] virtio: Implement the pasta vhost functions Ammar Yasser
2026-08-02 13:21 ` [RFC v3 6/8] virtio: Implement pasta vhost acceleration guest->pasta path Ammar Yasser
2026-08-02 13:21 ` [RFC v3 7/8] pasta: Implement pasta vhost TX (pasta->guest) prerequisites Ammar Yasser
2026-08-02 13:21 ` [RFC v3 8/8] tap: Implement pasta vhost TX Ammar Yasser
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=anklTWjo_1L-rgIJ@zatzit \
--to=david@gibson.dropbear.id.au \
--cc=aerosound161@gmail.com \
--cc=eperezma@redhat.com \
--cc=passt-dev@passt.top \
/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.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).