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=202502 header.b=auYtTzvh; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 5CCAC5A026F for ; Thu, 03 Apr 2025 03:51:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202502; t=1743645057; bh=FH0IKVnD6HpYJqkjuFYu8UGks06uRV4tWkIv2/9SK7E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=auYtTzvhi5sgSGiCb0s7C6mcaL9+a3TuCchSXWQvWbDWIPxoLx/5/WiOKCuMq280l O5C0N8n3px4XRFfGqiwX5FRovldJXMPPffFy0Lt5AfPn4DCqyHAifQPBgPw+zGcKcg lcd6YwTR2PUkJH3V3xKksocLYWbrNswC70es7ke728AqtP9EMZIzNsuVhFwW4GKyNO KVQAgv+WzlgNzMO3+EEaewddrkYBCUzDO5CTEBdjD6lWcUSfH0n2ce94NQDSiltFRM dtcXEUcv4W0cfuroXuQqnZBO/x1aexZ+jchQlGj7kNwotpJh4ec+D6o5AndrL1uDiW 7Tde4DobT5UUg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4ZSl7j35Gtz4xN1; Thu, 3 Apr 2025 12:50:57 +1100 (AEDT) Date: Thu, 3 Apr 2025 12:50:51 +1100 From: David Gibson To: Eugenio =?iso-8859-1?Q?P=E9rez?= Subject: Re: [PATCH 3/3] tap: add die() on vhost error Message-ID: References: <20250401113809.1765282-4-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="tEknmh+zSZjxr+sQ" Content-Disposition: inline In-Reply-To: <20250401113809.1765282-4-eperezma@redhat.com> Message-ID-Hash: 2ZA63MIJSAQRIUFKUL3NLBLGYE7FDJQI X-Message-ID-Hash: 2ZA63MIJSAQRIUFKUL3NLBLGYE7FDJQI 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, jmaloy@redhat.com, sbrivio@redhat.com, lvivier@redhat.com, dgibson@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: --tEknmh+zSZjxr+sQ Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 01, 2025 at 01:38:09PM +0200, Eugenio P=E9rez wrote: > In case the kernel needs to signal an error. >=20 > Signed-off-by: Eugenio P=E9rez > --- > epoll_type.h | 2 ++ > passt.c | 4 ++++ > passt.h | 1 + > tap.c | 16 ++++++++++++++++ > 4 files changed, 23 insertions(+) >=20 > diff --git a/epoll_type.h b/epoll_type.h > index 6284c79..6b320db 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 19c5d5f..2779e0b 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"); > @@ -361,6 +362,9 @@ loop: > case EPOLL_TYPE_VHOST_CALL: > vhost_call_cb(&c, ref, &now); > break; > + case EPOLL_TYPE_VHOST_ERROR: > + die("Error on vhost-kernel socket"); > + break; > default: > /* Can't happen */ > ASSERT(0); > diff --git a/passt.h b/passt.h > index eb5aa03..9e42f3b 100644 > --- a/passt.h > +++ b/passt.h > @@ -307,6 +307,7 @@ struct ctx { >=20 > int kick_fd; > int call_fd; > + int err_fd; > } vq[2]; >=20 > int no_dns; > diff --git a/tap.c b/tap.c > index fbe83aa..b02d3da 100644 > --- a/tap.c > +++ b/tap.c > @@ -1552,6 +1552,22 @@ static int tap_ns_tun(void *arg) > if (rc < 0) > 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; If it's possible to re-initialize vhost, eventually it would be nice to do so eventually, but for now die()ing is perfectly reasonable. > } >=20 > /* 1:1 translation */ --=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 --tEknmh+zSZjxr+sQ Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmft6XoACgkQzQJF27ox 2GeNrQ/9EUsX5VCCJ2Xy/uzGKRXCPNUKPc3OkISaUnNfbS99DThv/LAY7qQXgVc5 HCXyJkyUjrdNw5FrSgHrSsrr+KzW0tPBXyEjKc9yBw8/VAvzCTVx0RM1NxSko5I3 nv1U2ffDbIFSAluLu0IZ/4ZorDPld0c7GTrf4TM1xh6vjJ+1FsFvw7czOlkq0lZM C9ONptou1irIBMtIBA3UKobB7pZJp47wL0fZtatrzI5w8IZjLmEUv8eZfUiVcVYH r1nOU3A6wA+YNvboxfocbQd8Jx/y7qHd02lIC7zk6Bn9Ofgly4lIIPjTA6h//Ibp hTn6dVIhtnCxf9fp5cnhIeYfLwVlg0KKuejjfQFFN8LRMJOgSojEZZVUGrwr+HnD o7pMIlowpAnfLC1hA3bnQgsm+ltzHXv2FR2FP1A4y1ivvPbI5i6f+99VKmxZK9YQ B3/QjualJlcT7kkvrgdNS4dwanY4TQ8sbs74VDdlgqNGmfR9KPDugwUYcT0scV9J B98FXmgFXr24TZZH84bJ4rJ8aj1+YyEDqipS+5fery4RLXcQ2ju3kvr9GCx6LHO9 gUKkUrcB/linJ5IT/1PHVaaoDEEon0f4/cscnnMBAGBydyFCySdNyOzhVdxfp1js E1qNhxLXT2HKkFehukb9ziuFWBvvAmOJxVh7PBoVyOkKtn3tWnE= =f/bn -----END PGP SIGNATURE----- --tEknmh+zSZjxr+sQ--