From nobody Sun Jun 7 22:19:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1780603862; cv=none; d=zohomail.com; s=zohoarc; b=fmKNC/jpO4+qz9EO5c7WG4BD3E7FDeesMExEtcWlQtV6JlBGZlHIzYXttER6IapDjVUv0bzoLDxANFHsbnhPzzkPTyZS9LUSW6DRAiQYMuVAQVLKvKhFMcETriSc04g1rGUk3qgY8wphKtvOuaADlABLfZKCpOrtC67nX6sLvl8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780603862; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Xyq8h8hqTv71FOssirA1M3dj1o6Kf0mKh1rpcCehnLQ=; b=iG9E017iuBQ3WCwEw4FS33l1eKmLFMi/UaaCPRLrmPjFRABvRHr7GonL/AHLADyWMAxKnGS34/gA5DLR+E/Dht/gHDoCd8J6EQ295MJwjDMC9pJxvTg0ropP4IU1Bj3zdGVvyF19sSM/FuJ/HOS2CilBOkPRWhAnz9GszFlXQK4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780603862746706.4523189625295; Thu, 4 Jun 2026 13:11:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wVEOt-00023Z-AU; Thu, 04 Jun 2026 16:10:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVEOl-00022C-Bd for qemu-devel@nongnu.org; Thu, 04 Jun 2026 16:10:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVEOj-0006Jx-QE for qemu-devel@nongnu.org; Thu, 04 Jun 2026 16:10:39 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-642-vX3H2CpJN-yTYBDycnLyWA-1; Thu, 04 Jun 2026 16:10:34 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BF0DD1944D1B; Thu, 4 Jun 2026 20:10:33 +0000 (UTC) Received: from localhost (unknown [10.2.17.68]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9C8DF180049F; Thu, 4 Jun 2026 20:10:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780603836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xyq8h8hqTv71FOssirA1M3dj1o6Kf0mKh1rpcCehnLQ=; b=FDifHlJqATppUUbdtmuKZTbCihUZJMzcMfQeQZ4Gegqty2a+aiJJZQbJrwcnypI3jGo+fo z/SNJUDicsqRe+hT2La29f/+9So9UmrB6GSOSqtV3kCNcljyZOZ7zrgx6ko9rJVmP4xlU+ lSYDxsYiVxZiOHFHJ1QmMSAAxYzeYKc= X-MC-Unique: vX3H2CpJN-yTYBDycnLyWA-1 X-Mimecast-MFC-AGG-ID: vX3H2CpJN-yTYBDycnLyWA_1780603834 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Stefano Garzarella , gmaglione@redhat.com, "Michael S. Tsirkin" , hreitz@redhat.com, Pierrick Bouvier , Stefan Hajnoczi , Jorge Moreira Subject: [PATCH v3 1/3] vhost-user.rst: clarify when rings are started Date: Thu, 4 Jun 2026 16:10:27 -0400 Message-ID: <20260604201029.250450-2-stefanha@redhat.com> In-Reply-To: <20260604201029.250450-1-stefanha@redhat.com> References: <20260604201029.250450-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1780603864008158500 Content-Type: text/plain; charset="utf-8" Jorge Moreira pointed out that the ring state machine is underspecified. In the discussion that followed, we discovered that the spec says one thing and implementations do something else. This patch updates the spec to reflect how things are actually implemented across widely-used front-ends and back-ends including QEMU, crosvm, rust-vmm, and DPDK. Do this while taking care not to make any other existing implementations non-compliant by changing the spec. The spec says rings are started when a kick is received but the implementations actually start rings when VHOST_USER_SET_VRING_KICK is received. Reconcile this as follows: - Clarify that a ring can be stopped and then started again. The back-end must resume processing available requests when the ring is restarted. - Update the spec to say rings are started when VHOST_USER_SET_VRING_KICK is received. - Ensure compatibility by saying front-ends SHOULD inject a kick in case the back-end strictly implemented the old spec. - Avoid future back-end dependencies on injected kicks by saying that back-ends SHOULD NOT expect a kick to start rings. This way implementors have clarity on how things work while still allowing compatibility for existing implementations. Reported-by: Jorge Moreira Cc: "Michael S . Tsirkin" Signed-off-by: Stefan Hajnoczi Reviewed-by: Stefano Garzarella --- docs/interop/vhost-user.rst | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index 137c9f3669..6ced95e080 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -462,12 +462,26 @@ Rings have two independent states: started/stopped, a= nd enabled/disabled. * started and enabled: The back-end must process the ring normally, i.e. process all requests and execute them. =20 -Each ring is initialized in a stopped and disabled state. The back-end -must start a ring upon receiving a kick (that is, detecting that file -descriptor is readable) on the descriptor specified by -``VHOST_USER_SET_VRING_KICK`` or receiving the in-band message -``VHOST_USER_VRING_KICK`` if negotiated, and stop a ring upon receiving -``VHOST_USER_GET_VRING_BASE``. +Each ring is initialized in a stopped and disabled state. Rings are start= ed +with ``VHOST_USER_SET_VRING_KICK`` (or ``VHOST_USER_VRING_KICK`` if +``VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS`` is negotiated) and stopped = with +``VHOST_USER_GET_VRING_BASE``. A stopped ring enters the started state ag= ain +with ``VHOST_USER_SET_VRING_KICK`` (or ``VHOST_USER_VRING_KICK`` if +``VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS`` is negotiated) and the back= -end +resumes processing requests. + +Note that previous versions of this specification stated that rings start = when +the back-end receives a kick (that is, detecting that file descriptor is +readable) on the descriptor specified by ``VHOST_USER_SET_VRING_KICK`` or +receiving the in-band message ``VHOST_USER_VRING_KICK`` if negotiated. +Widely-used front-ends and back-ends did not implement this behavior and it +complicates poll mode back-ends that do not rely on the kick file descript= or. + +For compatibility with back-ends that implemented the start on kick behavi= or, +front-ends SHOULD inject a kick after ``VHOST_USER_SET_VRING_KICK``. This +ensures that the back-end processes any available requests in the ring. +Back-ends SHOULD NOT rely on receiving a kick after +``VHOST_USER_SET_VRING_KICK``. =20 Rings can be enabled or disabled by ``VHOST_USER_SET_VRING_ENABLE``. =20 --=20 2.54.0 From nobody Sun Jun 7 22:19:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1780603874; cv=none; d=zohomail.com; s=zohoarc; b=KUt0dvW+CQcP2Y6WKhXY98b3BGohVpjqPxrXdWuSQuMRkHanlE7kWsSwXcItd6s91+d5FK8Veo6Q5+ad6H2m0ve24sy1ztGZVuWJGVjBRB7+aC3kWlteklftViv3NS6koRV/0Mh1MghrB39f5AeLqswmqRUv6cl4G1Ovrqg0cjg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780603874; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=g8mnVozSEd48w7MhwSCFQ2rPIgSu70ABgHTMrQP/zQY=; b=HnRX3dzqG8iZXzFqA8wLQtRJQFsHkehq28tot1PeV/BwCEu6idGH3XZuvHFlzvHMD49Y/T/JVhLrBNkUevtlZoAbGPmkGMC/6dRPX4qg7Ogw/6NUiLvoH7E54LlXZ4nKL8VGkAZ7tFh2u3GSclMhQjTRAnlv9j1hNAECgl10MxM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780603874737260.25466864408475; Thu, 4 Jun 2026 13:11:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wVEOx-0002Ap-UY; Thu, 04 Jun 2026 16:10:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVEOm-00022D-DX for qemu-devel@nongnu.org; Thu, 04 Jun 2026 16:10:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVEOk-0006KW-Kz for qemu-devel@nongnu.org; Thu, 04 Jun 2026 16:10:40 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-336-WF3WYCn8Pji5veX5wWIOEA-1; Thu, 04 Jun 2026 16:10:36 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CCD131956094; Thu, 4 Jun 2026 20:10:35 +0000 (UTC) Received: from localhost (unknown [10.2.17.68]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DB640763; Thu, 4 Jun 2026 20:10:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780603838; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g8mnVozSEd48w7MhwSCFQ2rPIgSu70ABgHTMrQP/zQY=; b=Q6vCBealIekqd/lv4a9h5BLA5LTEeLd5GaUy9zxkgg3r/1L0Q+EKKPEWBn5hT1995KvUFh 1rcY1fixHfAIAOiwuIr26T+8fgNEiOhChBAj2BbW0HJbSdCfWWNIwLRc/OohgxIKmdNJPY 2ZjTE9wLzncGHKW26xrYkwmk2gb6BDM= X-MC-Unique: WF3WYCn8Pji5veX5wWIOEA-1 X-Mimecast-MFC-AGG-ID: WF3WYCn8Pji5veX5wWIOEA_1780603835 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Stefano Garzarella , gmaglione@redhat.com, "Michael S. Tsirkin" , hreitz@redhat.com, Pierrick Bouvier , Stefan Hajnoczi Subject: [PATCH v3 2/3] libvhost-user: look for available vq buffers upon SET_VRING_KICK Date: Thu, 4 Jun 2026 16:10:28 -0400 Message-ID: <20260604201029.250450-3-stefanha@redhat.com> In-Reply-To: <20260604201029.250450-1-stefanha@redhat.com> References: <20260604201029.250450-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1780603875725158500 Content-Type: text/plain; charset="utf-8" When a vring is started the back-end must look for available vq buffers and process them. This scenario can happen if the back-end is stopped with unprocessed available buffers and then started again. The inflight I/O tracking code already did this, but it should also be done when inflight I/O tracking is not enabled. Move the code and make it robust in case of EINTR or EAGAIN. Signed-off-by: Stefan Hajnoczi Reviewed-by: Stefano Garzarella --- subprojects/libvhost-user/libvhost-user.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index 9c630c2170..1dbb774a76 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -1390,11 +1390,6 @@ vu_check_queue_inflights(VuDev *dev, VuVirtq *vq) vq->counter =3D vq->resubmit_list[0].counter + 1; } =20 - /* in case of I/O hang after reconnecting */ - if (eventfd_write(vq->kick_fd, 1)) { - return -1; - } - return 0; } =20 @@ -1436,6 +1431,20 @@ vu_set_vring_kick_exec(VuDev *dev, VhostUserMsg *vms= g) vu_panic(dev, "Failed to check inflights for vq: %d\n", index); } =20 + /* Inject a kick to look for available vq buffers */ + if (dev->vq[index].kick_fd !=3D -1) { + int ret; + + do { + ret =3D eventfd_write(dev->vq[index].kick_fd, 1); + } while (ret !=3D 0 && errno =3D=3D EINTR); + + if (ret !=3D 0 && errno !=3D EAGAIN /* already readable */) { + vu_panic(dev, "Failed to inject kick during SET_VRING_KICK " + "on vq: %d with error: %m\n", index); + } + } + return false; } =20 --=20 2.54.0 From nobody Sun Jun 7 22:19:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1780603875; cv=none; d=zohomail.com; s=zohoarc; b=DWKNMB8ROxJBAbAsM4xd2WqDssblQGB79FmV7Hn0mCGLROsRRDPTXAzohTk8tPsk05nvuBN5LXTD7GUpZSed83yagX08yPEtoF+Xw9vCF9V2XwK4dpCSbXaRYayftAnh6Lvp7tJ16pM6lXq/K+GmyvQD8pCE+76jTbh8hwfuTIo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780603875; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ePVVFhkYD8+HulndPgvP6eAiy10i4SRM0NiVpgFSZTg=; b=SRbASO3lDoRPXrHl/tP+sV9qif1M/gbUcR2VwiROt636j4vy7vA/cpmHgNOxJ5ENHNierxzubMmcTKLtaEp87DlNMFAAiV/zPglaUz9Wymi03OQ51a16wOqTzMUvrHfPmjdDFETYvoi/IIxy2xk1YFtfBKaTyqs6FKOJkVXEvUo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780603875113639.1936414728401; Thu, 4 Jun 2026 13:11:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wVEOx-0002AM-Ok; Thu, 04 Jun 2026 16:10:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVEOq-00023Y-Uz for qemu-devel@nongnu.org; Thu, 04 Jun 2026 16:10:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVEOo-0006Lo-Gx for qemu-devel@nongnu.org; Thu, 04 Jun 2026 16:10:43 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-529-j4pQ7VSqNlynWtfLYW8klQ-1; Thu, 04 Jun 2026 16:10:38 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6FF321956059; Thu, 4 Jun 2026 20:10:37 +0000 (UTC) Received: from localhost (unknown [10.2.17.68]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 21169180049F; Thu, 4 Jun 2026 20:10:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780603841; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ePVVFhkYD8+HulndPgvP6eAiy10i4SRM0NiVpgFSZTg=; b=PAo/hCaBY322VIx7p03sA7UmRqqEinuzWSGtZ4xpU1NePxq9vreXhN4smxXlS6Y4P+2wna whA4lQUT89Q0UTs2oiyqghhiz00AyiR9NbZTP8jTljdKk1Z/Ee2Dck/JkgcG0cqZrbJrld 1/hLTC6gwmcOhveAMOuc/dcGxxLkWwI= X-MC-Unique: j4pQ7VSqNlynWtfLYW8klQ-1 X-Mimecast-MFC-AGG-ID: j4pQ7VSqNlynWtfLYW8klQ_1780603837 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Stefano Garzarella , gmaglione@redhat.com, "Michael S. Tsirkin" , hreitz@redhat.com, Pierrick Bouvier , Stefan Hajnoczi Subject: [PATCH v3 3/3] vhost-user: inject kick after SET_VRING_KICK Date: Thu, 4 Jun 2026 16:10:29 -0400 Message-ID: <20260604201029.250450-4-stefanha@redhat.com> In-Reply-To: <20260604201029.250450-1-stefanha@redhat.com> References: <20260604201029.250450-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1780603875771158500 Content-Type: text/plain; charset="utf-8" The vhost-user specification was updated to say that front-ends should inject a kick after SET_VRING_KICK in case the back-end implements the old spec wording which said vrings start when a kick is received. Do this in QEMU's front-end. An example scenario where this behavior helps: the back-end fails to check if the vring has available buffers when SET_VRING_KICK is received and the front-end stopped and then restarted the vring. In the case the back-end may not notice the available buffers unless the front-end injects a kick. Signed-off-by: Stefan Hajnoczi Reviewed-by: Stefano Garzarella --- hw/virtio/vhost-user.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index a8907cca74..7ef4105473 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1365,7 +1365,29 @@ static int vhost_set_vring_file(struct vhost_dev *de= v, static int vhost_user_set_vring_kick(struct vhost_dev *dev, struct vhost_vring_file *file) { - return vhost_set_vring_file(dev, VHOST_USER_SET_VRING_KICK, file); + int ret =3D vhost_set_vring_file(dev, VHOST_USER_SET_VRING_KICK, file); + if (ret < 0) { + return ret; + } + + /* + * Inject a kick in case the back-end only starts vring processing upon + * receiving a kick. The spec suggests this to improve compatibility. + */ + if (file->fd !=3D -1) { + uint64_t val =3D 1; + ssize_t nwritten; + + do { + nwritten =3D write(file->fd, &val, sizeof(val)); + } while (nwritten < 0 && errno =3D=3D EINTR); + + if (nwritten < 0 && errno !=3D EAGAIN /* back-end can already read= */) { + return -errno; + } + } + + return 0; } =20 static int vhost_user_set_vring_call(struct vhost_dev *dev, --=20 2.54.0