From nobody Sat May 30 18:35:06 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=1779218216; cv=none; d=zohomail.com; s=zohoarc; b=iYkLF/swbJ2lIgrBT5GevgWaYPsJBcR6KFPLNmGzgci7dX71s/gJbngotsD75qDok/3l/ELFBWz0QqOIDWS8MIdyRVV0kHYL4ogwoqZAhdwKrTakQJ9vMYvY46KxcIwfpOJse9hpwt8H3nA/Mf122rF0OKMbViYy2Elk8WBQrTM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779218216; 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=V+WRbViVVU5GV+Twv/WxD9BDGPz60bNZsrWBB4wRIAc=; b=FFUITyikK5ITDDd0zZX6h3/RFu1LxpQfgpetsgZs+7cI903+jY/ivLIwTNhVRDNKty7X0ojy4+RU5zrXaADmXFFaz4pJjrDEcnxpUe0PNwReZOBtUhGl19WTfhFars7VTGqJFVlnlAWLVP89C1c0LH0r1uVL5N/tUri1xyA2yuM= 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 1779218216056382.1978500571905; Tue, 19 May 2026 12:16:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wPPvJ-0004zs-09; Tue, 19 May 2026 15:16:13 -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 1wPPv9-0004sx-8r for qemu-devel@nongnu.org; Tue, 19 May 2026 15:16:04 -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 1wPPv5-0005tY-Em for qemu-devel@nongnu.org; Tue, 19 May 2026 15:16:02 -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-695-QK08oJOFMDienS63kFPLBw-1; Tue, 19 May 2026 15:15:53 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 A23C7195609E; Tue, 19 May 2026 19:15:52 +0000 (UTC) Received: from localhost (unknown [10.2.16.118]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C01BB18004A3; Tue, 19 May 2026 19:15:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779218155; 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=V+WRbViVVU5GV+Twv/WxD9BDGPz60bNZsrWBB4wRIAc=; b=If+w+qQFyHufLNoB0nwL1t0UjTmhA2/b+XLjpxc9Ew83uXS3dY/VzjBwMR/w2GZpyPL/Y9 JbY6G8+LjZJPmxg4uY1MsbYU7H1/M6Ru/9/JL+qmVu49b49VLWP9LwJdkHgXXi+GwyEz/V PBMceJp1ok9C7xuMm7xHE1cua2yZxo4= X-MC-Unique: QK08oJOFMDienS63kFPLBw-1 X-Mimecast-MFC-AGG-ID: QK08oJOFMDienS63kFPLBw_1779218153 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , hreitz@redhat.com, Stefano Garzarella , Pierrick Bouvier , gmaglione@redhat.com, Stefan Hajnoczi , Jorge Moreira Subject: [PATCH v2 1/3] vhost-user.rst: clarify when rings are started Date: Tue, 19 May 2026 15:15:46 -0400 Message-ID: <20260519191548.335082-2-stefanha@redhat.com> In-Reply-To: <20260519191548.335082-1-stefanha@redhat.com> References: <20260519191548.335082-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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_H4=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: 1779218218427158500 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 sepc. 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" Cc: Stefano Garzarella Signed-off-by: Stefan Hajnoczi --- 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 Sat May 30 18:35:06 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=1779218237; cv=none; d=zohomail.com; s=zohoarc; b=linLKBL+4cp+eifddzhx79kx23Js1HAqBPCx4ee+7A2Uoz73c7fMjeUwg5Mh0xTNBDIo6ZMFcKVzACoSHRpP0RcVvXurqrfA0heevoHdU399vDOvbN42xU9EPAg+iUd/RdajlkoX8U1hbOfRF9JIeJ0jTeIWVPJb7GFT2XL60T8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779218237; 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=/PPKYPCBCgXpNSOInH4RnnHadB8txYUK1zR7KC28T9U=; b=c9OEJd7pW+DQNwx2+Gju29sY3eu0gMJnSfzsI9w6EKJPUHOemCCREm+vxsCitoX6IhZwsneaHLpZBHDteTXeZClhlb/19L5fUjss/DRFfPC3SsbNjTRMLpvT/88boVlIc964hDvRyzxGRUkA+kzybiO70wyjB32DV/nPwsIoerI= 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 1779218237389390.07357374126116; Tue, 19 May 2026 12:17:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wPPvE-0004wv-2D; Tue, 19 May 2026 15:16:08 -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 1wPPv9-0004sw-8i for qemu-devel@nongnu.org; Tue, 19 May 2026 15:16:04 -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 1wPPv5-0005tw-NI for qemu-devel@nongnu.org; Tue, 19 May 2026 15:16:01 -0400 Received: from mx-prod-mc-01.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-507-RIvE470GPPqtrgajzy1Ljw-1; Tue, 19 May 2026 15:15:55 -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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 59BEC19560A1; Tue, 19 May 2026 19:15:54 +0000 (UTC) Received: from localhost (unknown [10.2.16.118]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0F9061685; Tue, 19 May 2026 19:15:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779218158; 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=/PPKYPCBCgXpNSOInH4RnnHadB8txYUK1zR7KC28T9U=; b=fDFDOqDcJvr6MbRn/ZxqmOjugddIaKKsFv6y48x4a4iX5hSqH92coaptu6ePx8JZ9gVM/D AHfOYNtD3ewh1Sv3qebyeVD8IgNCz8wKeEhsgErwpXj8wdvD6KIX/VUsxOY2sgaBXbYEr8 ad8aJFSCKLh13QfuSWKRk3edXfn8PYY= X-MC-Unique: RIvE470GPPqtrgajzy1Ljw-1 X-Mimecast-MFC-AGG-ID: RIvE470GPPqtrgajzy1Ljw_1779218154 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , hreitz@redhat.com, Stefano Garzarella , Pierrick Bouvier , gmaglione@redhat.com, Stefan Hajnoczi Subject: [PATCH v2 2/3] libvhost-user: look for available vq buffers upon SET_VRING_KICK Date: Tue, 19 May 2026 15:15:47 -0400 Message-ID: <20260519191548.335082-3-stefanha@redhat.com> In-Reply-To: <20260519191548.335082-1-stefanha@redhat.com> References: <20260519191548.335082-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.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_H4=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: 1779218240944154100 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. Signed-off-by: Stefan Hajnoczi --- subprojects/libvhost-user/libvhost-user.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index 9c630c2170..2e286ea6d9 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,11 @@ 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 (eventfd_write(dev->vq[index].kick_fd, 1)) { + return -1; + } + return false; } =20 --=20 2.54.0 From nobody Sat May 30 18:35:06 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=1779218219; cv=none; d=zohomail.com; s=zohoarc; b=l6C7A6AoJFROqfnRRC253SvMpJ6tm6AniP+xcGtjd2UrhZbNVTo4xSZjfIjtqPbtvSkuDO6aUAN5Zi/KT5r8ta10QDaDPUf/+1HYFflufCduVNy0H16IrI+ef592VUfWyE3GbepN7ZDbJka6Qfh5/6sRzHh9GTZH8Uv7SswUpSs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779218219; 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=oTD0kvnL4/tBRdkBHdbKvd8RLIPg2VMcTJWY4PjZMzo=; b=KIjpepFJNhHlKUMZUUSKLvP3mn3C6U0dZuACRE8g0fUWNnnDM8RPSjS2ugimMF9sz5bsbyLIxNG0cU26/OuH+VY/XZyuW4yR8OFyWUdvALOWXFCWd2xVDmXxWMUlc39LiyM8I6KdQyzrXXfhfi4lL1yuYOimC6yt1edGAZl2mWk= 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 1779218219162452.3552070774956; Tue, 19 May 2026 12:16:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wPPvF-0004yG-AB; Tue, 19 May 2026 15:16:09 -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 1wPPvD-0004wS-7b for qemu-devel@nongnu.org; Tue, 19 May 2026 15:16:07 -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 1wPPvB-0005wg-8X for qemu-devel@nongnu.org; Tue, 19 May 2026 15:16:06 -0400 Received: from mx-prod-mc-01.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-611-QuCExxSiNE2pd3DGMJw_OA-1; Tue, 19 May 2026 15:15:57 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9B56419560AA; Tue, 19 May 2026 19:15:56 +0000 (UTC) Received: from localhost (unknown [10.2.16.118]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D6BE830002DC; Tue, 19 May 2026 19:15:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779218164; 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=oTD0kvnL4/tBRdkBHdbKvd8RLIPg2VMcTJWY4PjZMzo=; b=CxfICxsfdPNzMwmnZ1l/ndV77blYqg/sZaixCY3RbEbEiog79SPz2flRuxejSHo48/Fxr+ UJPZo+Xp2Yky7f3vjQUc0xw1pr3ogTkpoeUVcZXilSbWVtutW5PJ/amjnzGabCcXfU1A2B tFZtXCNVN9zmJ+35EMjv3xqy7U+bfK4= X-MC-Unique: QuCExxSiNE2pd3DGMJw_OA-1 X-Mimecast-MFC-AGG-ID: QuCExxSiNE2pd3DGMJw_OA_1779218156 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , hreitz@redhat.com, Stefano Garzarella , Pierrick Bouvier , gmaglione@redhat.com, Stefan Hajnoczi Subject: [PATCH v2 3/3] vhost-user: inject kick after SET_VRING_KICK Date: Tue, 19 May 2026 15:15:48 -0400 Message-ID: <20260519191548.335082-4-stefanha@redhat.com> In-Reply-To: <20260519191548.335082-1-stefanha@redhat.com> References: <20260519191548.335082-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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_H4=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: 1779218219868158500 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 --- 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