From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202608 header.b=gY1UiySn; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 672725A0262 for ; Mon, 10 Aug 2026 03:12:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202608; t=1786324318; bh=jm4O9c12dUjUBtUNHUj8jMr4YaJmPML5n0v2Ay0h3gw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gY1UiySnsxwe1sCQMmJPionUrf8R5rq5lTiVpE5F9MGiX4CfnI3/DRXXVI9HSOVGN G+58kuGJXJGO8IlSYUPuK/2T/fYgHlXdSQSlq60X12Dn33jnJVsptFuY9aPdefFKO2 XK3OJwYtjnlhRlaNSuEMpWHm5RWgEvD6MgA4jVxHPWTCpF6xq8JPPI2LxdLltMxit6 VS0jf+f+kYQH4w78mzIRlM8kWIxDk6wnVhVLU+8MR+TTPwLV4NflIx1wBztvoNfuHn oRReCZ3m9Gr4oeuZD3sIthg929GLtvwkiYwnTBfV6RZ4O27C+DVxFY5zdmVcm5NVxR CAMaBwshHHzQA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4hJGtk3ywsz4w9r; Mon, 10 Aug 2026 11:11:58 +1000 (AEST) Date: Mon, 10 Aug 2026 11:11:53 +1000 From: David Gibson To: Ammar Yasser Subject: Re: [RFC v3 3/8] conf: Add context fields, epoll types and the --vhost flag to pasta Message-ID: References: <20260802132155.870796-1-aerosound161@gmail.com> <20260802132155.870796-4-aerosound161@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="okOn8JAsn/gP7DcX" Content-Disposition: inline In-Reply-To: <20260802132155.870796-4-aerosound161@gmail.com> Message-ID-Hash: ZZY2NZKLUHLRXFO4FISIZ2O64HJPLIGV X-Message-ID-Hash: ZZY2NZKLUHLRXFO4FISIZ2O64HJPLIGV X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, eperezma@redhat.com X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --okOn8JAsn/gP7DcX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. >=20 > 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. >=20 > 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 > --- > conf.c | 6 ++++++ > epoll_type.h | 4 ++++ > passt.c | 3 +++ > passt.h | 15 +++++++++++++++ > 4 files changed, 28 insertions(+) >=20 > 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 =3D 0; > const struct option optvu[] =3D { > {"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"); > } > =20 > + if (c->vhost && c->mode !=3D MODE_PASTA) > + die("--vhost is only available in pasta mode"); > + > if (c->mode =3D=3D 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, > =20 > 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(PAG= E_SIZE))); > struct ctx passt_ctx =3D { > .pidfile_fd =3D -1, > .fd_tap =3D -1, > + .fd_vhost =3D -1, > .fd_tap_listen =3D -1, > .fd_control_listen =3D -1, > .fd_repair_listen =3D -1, > @@ -92,6 +93,8 @@ char *epoll_type_str[] =3D { > [EPOLL_TYPE_NL_NEIGH] =3D "netlink neighbour notifier socket", > [EPOLL_TYPE_CONF_LISTEN] =3D "configuration listening socket", > [EPOLL_TYPE_CONF] =3D "configuration socket", > + [EPOLL_TYPE_VHOST_CALL] =3D "vhost-kernel call socket", > + [EPOLL_TYPE_VHOST_ERROR] =3D "vhost-kernel error socket", > }; > static_assert(ARRAY_SIZE(epoll_type_str) =3D=3D 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, i= f 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; > =20 > uint64_t hash_secret[2]; > + uint64_t virtio_features; > =20 > int ifi4; > struct ip4_ctx ip4; > @@ -288,6 +296,12 @@ struct ctx { > struct udp_ctx udp; > int no_icmp; > =20 > + 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; > =20 > 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. > --=20 > 2.34.1 >=20 --=20 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 --okOn8JAsn/gP7DcX Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmp5JU4ACgkQzQJF27ox 2Ge4hxAApvhGbEfzRdECmuUK+ydRhNiVX0PMHuNaLuAkJ3vgeRP9XLU+p1dsZFR+ 7bkwUXdsMsCdkERVy7jdwumuqhNHlSHLnhdOznZSFhEdUG2cFdtVMZGUVFU3lswe INPVOCTHqfZcfYqQYjvmjRIYZXpnBonwAQTp6r+Xc9irnPAFJ4cvWTDMlMEHFpx1 1rSUDI44YOvx1RFuzHCWPmOZ4rWTEpEfZgfb/SgH/K2++50BF1RxcWMeH/JyV9zu SMUzauIGGmQdNs41n+Uc10uz8zn5hn3Q9+/SeLGfXaMEc+ySUTFU0H+cuMEiSXM/ rGpkMsKXHKXzRAfFitdq18sPNE02ttqT3wkDRYsFBI+0jvQgDa2UCWfy2WrdyT2z hYzm7ldlWZpY8CaJWdV6AQtX1AoQBRpXffWz6BQbZ+3xRDaBIZKwU4DcjgveL8jB tmqJaC7QN/gJux6k5EWvOA3ZzWQ4o+QSjbJlgqm2GjaqKk0K5h1sPMv6uuCTgQV7 CNgBoy3AEbJ/AO/C/6sJjzxNDRzSJAuioEUb1jKn7aXU4FTrkD2nvaC4XG2hq9cO hwvislZL3c1rQL3tW9m25nhlfYDoOMnQD7iJcKJ1mlCLxNOUnbCn6Hot4FZzJWJD hYkFYwDeVr3AKM+n4qyh89mj5arCBLah0MyhSGEvVx1IaRJt8wY= =mRDj -----END PGP SIGNATURE----- --okOn8JAsn/gP7DcX--