public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: "Eugenio Pérez" <eperezma@redhat.com>
Cc: passt-dev@passt.top, jasowang@redhat.com
Subject: Re: [RFC v2 02/11] tap: add die() on vhost error
Date: Wed, 23 Jul 2025 16:58:25 +1000	[thread overview]
Message-ID: <aICIEVP9KDrUc5mL@zatzit> (raw)
In-Reply-To: <20250709174748.3514693-3-eperezma@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2953 bytes --]

On Wed, Jul 09, 2025 at 07:47:39PM +0200, Eugenio Pérez wrote:
> In case the kernel needs to signal an error.
> 
> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
> RFC v2: Add TODO (David)
> 
> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> ---
>  epoll_type.h |  2 ++
>  passt.c      |  5 +++++
>  passt.h      |  1 +
>  tap.c        | 16 ++++++++++++++++
>  4 files changed, 24 insertions(+)
> 
> 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,
>  
>  	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[] = {
>  	[EPOLL_TYPE_REPAIR_LISTEN]	= "TCP_REPAIR helper listening socket",
>  	[EPOLL_TYPE_REPAIR]		= "TCP_REPAIR helper 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");
> @@ -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];
>  
>  	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 = file.fd;
> +
> +		file.fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
> +		if (file.fd < 0)
> +			die_perror("Failed to create error eventfd");
> +
> +		rc = 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 = EPOLL_TYPE_VHOST_ERROR, ref.fd = file.fd;
> +		ev.data.u64 = ref.u64;
> +		rc = 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 = file.fd;
>  	}
>  
>  	/*

-- 
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 --]

  reply	other threads:[~2025-07-23  6:58 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-09 17:47 [RFC v2 00/11] Add vhost-net kernel support Eugenio Pérez
2025-07-09 17:47 ` [RFC v2 01/11] tap: implement vhost_call_cb Eugenio Pérez
2025-07-23  6:56   ` David Gibson
2025-07-09 17:47 ` [RFC v2 02/11] tap: add die() on vhost error Eugenio Pérez
2025-07-23  6:58   ` David Gibson [this message]
2025-07-09 17:47 ` [RFC v2 03/11] tap: replace tx tap hdr with virtio_nethdr_mrg_rxbuf Eugenio Pérez
2025-07-24  0:17   ` David Gibson
2025-07-09 17:47 ` [RFC v2 04/11] tcp: export memory regions to vhost Eugenio Pérez
2025-07-23  7:06   ` David Gibson
2025-07-09 17:47 ` [RFC v2 05/11] virtio: Fill .next in tx queue Eugenio Pérez
2025-07-23  7:07   ` David Gibson
2025-07-09 17:47 ` [RFC v2 06/11] tap: move static iov_sock to tcp_buf_data_from_sock Eugenio Pérez
2025-07-23  7:09   ` David Gibson
2025-07-09 17:47 ` [RFC v2 07/11] tap: support tx through vhost Eugenio Pérez
2025-07-24  0:24   ` David Gibson
2025-07-24 14:30     ` Stefano Brivio
2025-07-25  0:23       ` David Gibson
2025-07-09 17:47 ` [RFC v2 08/11] tap: add tap_free_old_xmit Eugenio Pérez
2025-07-24  0:32   ` David Gibson
2025-07-09 17:47 ` [RFC v2 09/11] tcp: start conversion to circular buffer Eugenio Pérez
2025-07-24  1:03   ` David Gibson
2025-07-09 17:47 ` [RFC v2 10/11] tap: add poll(2) to used_idx Eugenio Pérez
2025-07-24  1:20   ` David Gibson
2025-07-09 17:47 ` [RFC v2 11/11] tcp_buf: adding TCP tx circular buffer Eugenio Pérez
2025-07-24  1:33   ` David Gibson
2025-07-10  9:46 ` [RFC v2 00/11] Add vhost-net kernel support Eugenio Perez Martin

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=aICIEVP9KDrUc5mL@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=eperezma@redhat.com \
    --cc=jasowang@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).