From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Pl3uEC7S; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 3ED365A0008 for ; Thu, 03 Apr 2025 08:36:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1743662206; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PbGp7iPYUIxjqdHUrQVa2Ali9obsmDmzLxgtjGKL6p0=; b=Pl3uEC7Szryahb3J0HDXZUX67xiK2fWQW+qHU/2ivJPyL3jSlA7Ql9xpdAGF+RwVv+JOYn 6a4fL4xHAeiMjYEyWYAju/16wPnF08E6gCYl6bQOl2RNndwTFaoXkrBI8COFFLUWFDiuHX Yy1fEh2twk+RvCprZqSkJu4kEBRWtjA= Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-52-xG8slQ6YNveHXX8OzKUwwg-1; Thu, 03 Apr 2025 02:36:44 -0400 X-MC-Unique: xG8slQ6YNveHXX8OzKUwwg-1 X-Mimecast-MFC-AGG-ID: xG8slQ6YNveHXX8OzKUwwg_1743662203 Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-2ff799be8f5so555789a91.1 for ; Wed, 02 Apr 2025 23:36:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743662203; x=1744267003; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PbGp7iPYUIxjqdHUrQVa2Ali9obsmDmzLxgtjGKL6p0=; b=V+wKR+vL8Fv1DWWA92YyJsqZMNXbbDRgxI4lsdKTAK2Tn2ZUHRwiz3KcAdBLL0PJSU raS5wyHX6X7WA+1hzAGn8HYyD8mp/XldozKHCtBpPP5SzfZN5OJapZ0EQl/sqa72BGjk HvypgpPTXSyC0dT0P/sMxcrXw4/fJIjo26TpLnzexL3sBDiB5Ig3MrIxxsugQaBEvP2u bTWX3IF7BczhsV7A6Dbp3HlSsyH7uR0mmOjDxq6KdQSeDa46zS2L0fW3M8pr+ee+4G7F fCWGRpEGf/g+gjWwSAEAQpny+fiWw+1Bdndr5BY9mQXGUIkam8C1m9NezBIa4qSNPd9V QUiQ== X-Gm-Message-State: AOJu0Yy+0+b+kLEtW6ETzJv1C0ZzDHls732B705JP2CZnGrMFJ2QPIFK v+aTTPChC5LViZBbo3aQ1Ixkl36qBrPMjJD5UED4BWNeVxoGDkuygKhH1/uizF3Hfr9u/JUvZxR +htketYZXIuazgXYnLTLxdZrfsPrCa5aP+CFcISKHNiqfvWPp4D6/DAx6GlBTsNGLx+N6uzFGfS RrFmqaBzfn0rcHu593IXiBEvrWXoYemMJi X-Gm-Gg: ASbGncvpt4ZD5tpEZoP6LYg14RKpSIpV9mYqunSoe8uepKRf4vnnuJnoXT8tv77HyjL keT9JpFXPVzJQXKfh+DPtGzhcj51a4Ip/fZMYSoTKkXYwgtQQI3GSyvovqHTI2GEajsbJg5o= X-Received: by 2002:a17:90a:e706:b0:2fe:8282:cb9d with SMTP id 98e67ed59e1d1-30532154804mr29917370a91.28.1743662203259; Wed, 02 Apr 2025 23:36:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGNUnNPkP9gb+SRRDwd+Mhig/CMEDOqp9OHzkhvDy80qNvxovt3PoViBIzyMV5FI2ir2JrkvUi8yrSpT+w1AbE= X-Received: by 2002:a17:90a:e706:b0:2fe:8282:cb9d with SMTP id 98e67ed59e1d1-30532154804mr29917332a91.28.1743662202502; Wed, 02 Apr 2025 23:36:42 -0700 (PDT) MIME-Version: 1.0 References: <20250401113809.1765282-4-eperezma@redhat.com> In-Reply-To: From: Eugenio Perez Martin Date: Thu, 3 Apr 2025 08:36:06 +0200 X-Gm-Features: AQ5f1JpnXU6rW_5GAUazxRF9XXcokAl5bIcTHGi8V2dpfVmT1TyTDXo_KxeEahQ Message-ID: Subject: Re: [PATCH 3/3] tap: add die() on vhost error To: David Gibson X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: m0ZJlIHJX5N3FIDy355pQOXLfxSWzqLEpH-Q1aQIRTE_1743662203 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 6M7IA7JY4Y7KOA75ABNVL2EJKYMQ5ZRW X-Message-ID-Hash: 6M7IA7JY4Y7KOA75ABNVL2EJKYMQ5ZRW X-MailFrom: eperezma@redhat.com 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 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: On Thu, Apr 3, 2025 at 3:51=E2=80=AFAM David Gibson wrote: > > On Tue, Apr 01, 2025 at 01:38:09PM +0200, Eugenio P=C3=A9rez wrote: > > In case the kernel needs to signal an error. > > > > Signed-off-by: Eugenio P=C3=A9rez > > --- > > epoll_type.h | 2 ++ > > passt.c | 4 ++++ > > passt.h | 1 + > > tap.c | 16 ++++++++++++++++ > > 4 files changed, 23 insertions(+) > > > > 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, > > > > 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 { > > > > int kick_fd; > > int call_fd; > > + int err_fd; > > } vq[2]; > > > > 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. > That's a good point, adding TODO!