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=202506 header.b=T2pwHVvj; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 49D935A0280 for ; Wed, 23 Jul 2025 08:58:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202506; t=1753253743; bh=s6FmrLOJlVGsb5P84bKhS+3n3L4/HUEeqmxyAxXIWXY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=T2pwHVvjia1iiiZWBz1NBe/OqJBRuhr0FUNizIueYpG8sKptwPT2G/NhzrCK8qj2T DZXP/6or17OuJA9QN8pIENasB8K3KiS4CTBFiCCJ3+nhxQAv/nv0jDwm3fJ2Nzm4vw SFNoAp1QvL9nMgmkk+hs9y9hggMYuHvrgasOY6uOM+/HeoSm14Gm77bFRbQ7jDshng aOEpuodxiolYBISSyq1/ycRBXU4xYmHXay/XE1y2yk2cTghq3zpe8V1lc6cGZWVGIH 7LwFUwgomrXsrYB3PDgmdwdhmFeRZJzy8I+jna2Bgbs16bcwizfvKOwEPJ64bJHYi6 cdbyk09QPjACw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4bn4f71FQ7z4xPf; Wed, 23 Jul 2025 16:55:43 +1000 (AEST) Date: Wed, 23 Jul 2025 16:58:25 +1000 From: David Gibson To: Eugenio =?iso-8859-1?Q?P=E9rez?= Subject: Re: [RFC v2 02/11] tap: add die() on vhost error Message-ID: References: <20250709174748.3514693-1-eperezma@redhat.com> <20250709174748.3514693-3-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="cm7Shf4ma/xOLK0y" Content-Disposition: inline In-Reply-To: <20250709174748.3514693-3-eperezma@redhat.com> Message-ID-Hash: 5R6QO3KNE7XCC2TOQXKNT7GVWBU4FBHS X-Message-ID-Hash: 5R6QO3KNE7XCC2TOQXKNT7GVWBU4FBHS 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, jasowang@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: --cm7Shf4ma/xOLK0y Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 09, 2025 at 07:47:39PM +0200, Eugenio P=E9rez wrote: > In case the kernel needs to signal an error. >=20 > Signed-off-by: Eugenio P=E9rez Reviewed-by: David Gibson > --- > RFC v2: Add TODO (David) >=20 > Signed-off-by: Eugenio P=E9rez > --- > epoll_type.h | 2 ++ > passt.c | 5 +++++ > passt.h | 1 + > tap.c | 16 ++++++++++++++++ > 4 files changed, 24 insertions(+) >=20 > diff --git a/epoll_type.h b/epoll_type.h > index 0371c14..93c4701 100644 > --- a/epoll_type.h > +++ b/epoll_type.h > @@ -46,6 +46,8 @@ enum epoll_type { > EPOLL_TYPE_REPAIR, > /* 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 0f2659c..d839f5a 100644 > --- a/passt.c > +++ b/passt.c > @@ -80,6 +80,7 @@ char *epoll_type_str[] =3D { > [EPOLL_TYPE_REPAIR_LISTEN] =3D "TCP_REPAIR helper listening socket", > [EPOLL_TYPE_REPAIR] =3D "TCP_REPAIR helper 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"); > @@ -362,6 +363,10 @@ loop: > case EPOLL_TYPE_VHOST_CALL: > tap_vhost_input(&c, ref, &now); > break; > + case EPOLL_TYPE_VHOST_ERROR: > + /* TODO re-initialize vhost */ > + die("Error on vhost-kernel socket"); > + break; > default: > /* Can't happen */ > ASSERT(0); > diff --git a/passt.h b/passt.h > index 7bb86c4..0066145 100644 > --- a/passt.h > +++ b/passt.h > @@ -303,6 +303,7 @@ struct ctx { > struct { > int kick_fd; > int call_fd; > + int err_fd; > } vq[2]; > =20 > int no_dns; > diff --git a/tap.c b/tap.c > index e4a3822..0c49e6d 100644 > --- a/tap.c > +++ b/tap.c > @@ -1598,6 +1598,22 @@ static int tap_ns_tun(void *arg) > die_perror("Failed to add call eventfd to epoll"); > } > c->vq[i].call_fd =3D file.fd; > + > + file.fd =3D eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); > + if (file.fd < 0) > + die_perror("Failed to create error eventfd"); > + > + rc =3D ioctl(vhost_fd, VHOST_SET_VRING_ERR, &file); > + if (rc < 0) > + die_perror( > + "VHOST_SET_VRING_ERR ioctl on /dev/vhost-net failed"); > + > + ref.type =3D EPOLL_TYPE_VHOST_ERROR, ref.fd =3D file.fd; > + ev.data.u64 =3D ref.u64; > + rc =3D epoll_ctl(c->epollfd, EPOLL_CTL_ADD, ref.fd, &ev); > + if (rc < 0) > + die_perror("Failed to add error eventfd to epoll"); > + c->vq[i].err_fd =3D file.fd; > } > =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 --cm7Shf4ma/xOLK0y Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmiAiBAACgkQzQJF27ox 2Gd3ahAAmR+Yv2k8lUv5utZyfQfLOvFMwzm9BciqNfkOawno21cR3pP4lw4Rc3sn +mrgxLzU1Yc0BEAqaTSf3R6CcayB/thyw2lLm8/q98nmFHYO+0SqDECyopqlT9Sh 8BTjPIeLQC8F9FSbu1/n9ZOUbjICAHRiw9JNK6VF0lepTtAURZST7G3Hj88FZvrO 6WUqpDe3UApDNHuv/g0lJedA9ovidvEOqDp2IWq0ZRq7KRvl2DDMbn6FTcmRhjnV wacBxrcrFAlJ9JMikGPBV7SXNhEeVZRGuevEFdsaDeT5cX1+9Ws/lgG9FsTDcMpu 2iY4EnotFotXvl0ImtBrH1cnXj5ciB+2kswg5kveZcsrcyZKocqrc5pPZLMYt3OA Lcdfe9Wdrxvsh53qSC1AB39xaE3Wnw7SPCfjziN+bZq9QKLGxzZS+SjTm656LitG ORg62PdOxITbJnB71h5ueby8QtObuUdqTvoU9+8LidQEVF9nsI9zX/v1gMr01hIj 0P8iS2VO+O0p6o5qges2ij33tmitGQN+Jas5wedS7v375ZF+MwzFsj+Uaky/cAN6 nrzwjLcp5VUfE+aiI2mvFWu1c6mmIYbkWPVO/kDW2NrZdTsrwRe8s5FxSjBS8eX0 wd/dmTxtNIetURUsmyvbVH5U9gC8eqb85x9ByKqoxF2Tv6VwmiM= =FOxO -----END PGP SIGNATURE----- --cm7Shf4ma/xOLK0y--