From nobody Sun Sep 28 15:29:09 2025 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=1758578567; cv=none; d=zohomail.com; s=zohoarc; b=AUedmL9haUNURf8lfoB4oS3yscW2NQoy3UV58mUP4MvMYcf1D+z1bDUegzcZyPuJfR+zLJUu2YnGynahmAVhOXLlOmOi04C3fvkYUw7mpz6mvoLk5eXwNLg1ldt7TzTCshr4JRm+0zj3lrF5wgTmTSuysYE8axyXOlPqduI69iI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758578567; 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=x+xonViXNrhX+Y2vsLPFiHj9moTtLnBh7lb0zW5gpSs=; b=HZQw/QiNcYpyhW8DLZEwsCAm9cAU3+0HS5pMJFswljPn4BpDdmKeJhr2IoCY5DFDh6Xb4mj4seTBWhWwK7Dn5fa1mO46WwPiUqlrv1qvwURdLENZ3LC3I1PQk3Jm9jIA3iON40mO/tgGEzE/ILStNMVU8qou/jynarSQJZHGBMc= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758578567131190.65873643798568; Mon, 22 Sep 2025 15:02:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0obp-0005ns-Ou; Mon, 22 Sep 2025 18:02:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0obk-0005jS-7R for qemu-devel@nongnu.org; Mon, 22 Sep 2025 18:02:05 -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 1v0obi-0001st-4U for qemu-devel@nongnu.org; Mon, 22 Sep 2025 18:02:03 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-646-8LiljfrPMYOFHj6hPTKjOg-1; Mon, 22 Sep 2025 18:01:56 -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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A33421800452; Mon, 22 Sep 2025 22:01:54 +0000 (UTC) Received: from localhost (unknown [10.2.17.92]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E88211800452; Mon, 22 Sep 2025 22:01:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758578520; 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=x+xonViXNrhX+Y2vsLPFiHj9moTtLnBh7lb0zW5gpSs=; b=NU70kbxSLbwhorBf3aznZUZfKoQYhQzQdbPhE+uaOE2MNwoY9ZR42z22Fr++fZVm93kXWB Y0M5qBjy5Kp0kIn1JiiPf5zhMwbo8y8n+shaM4YWY2Lz7yFwl2/fJY3NrZ3x2v199k6Tss UXO9E6vHzbXyVQzievYe0BbiiZiJGpY= X-MC-Unique: 8LiljfrPMYOFHj6hPTKjOg-1 X-Mimecast-MFC-AGG-ID: 8LiljfrPMYOFHj6hPTKjOg_1758578515 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Kevin Wolf , "Michael S. Tsirkin" , , Hanna Reitz , Laurent Vivier , Fam Zheng , Fabiano Rosas , Paolo Bonzini , Stefan Hajnoczi , Stefano Garzarella Subject: [PATCH 1/5] vhost: use virtio_config_get_guest_notifier() Date: Mon, 22 Sep 2025 18:01:45 -0400 Message-ID: <20250922220149.498967-2-stefanha@redhat.com> In-Reply-To: <20250922220149.498967-1-stefanha@redhat.com> References: <20250922220149.498967-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=lists.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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1758578569885116600 Content-Type: text/plain; charset="utf-8" There is a getter function so avoid accessing the ->config_notifier field directly. Signed-off-by: Stefan Hajnoczi Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/virtio/vhost.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 6557c58d12..37b39aa0c2 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1817,7 +1817,7 @@ void vhost_config_mask(struct vhost_dev *hdev, VirtIO= Device *vdev, bool mask) int r; EventNotifier *notifier =3D &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier; - EventNotifier *config_notifier =3D &vdev->config_notifier; + EventNotifier *config_notifier =3D virtio_config_get_guest_notifier(vd= ev); assert(hdev->vhost_ops); =20 if ((hdev->started =3D=3D false) || @@ -1848,13 +1848,15 @@ static void vhost_stop_config_intr(struct vhost_dev= *dev) static void vhost_start_config_intr(struct vhost_dev *dev) { int r; + EventNotifier *config_notifier =3D + virtio_config_get_guest_notifier(dev->vdev); =20 assert(dev->vhost_ops); - int fd =3D event_notifier_get_fd(&dev->vdev->config_notifier); + int fd =3D event_notifier_get_fd(config_notifier); if (dev->vhost_ops->vhost_set_config_call) { r =3D dev->vhost_ops->vhost_set_config_call(dev, fd); if (!r) { - event_notifier_set(&dev->vdev->config_notifier); + event_notifier_set(config_notifier); } } } @@ -2139,12 +2141,13 @@ static int do_vhost_dev_stop(struct vhost_dev *hdev= , VirtIODevice *vdev, { int i; int rc =3D 0; + EventNotifier *config_notifier =3D virtio_config_get_guest_notifier(vd= ev); =20 /* should only be called after backend is connected */ assert(hdev->vhost_ops); event_notifier_test_and_clear( &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier); - event_notifier_test_and_clear(&vdev->config_notifier); + event_notifier_test_and_clear(config_notifier); event_notifier_cleanup( &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier); =20 --=20 2.51.0 From nobody Sun Sep 28 15:29:09 2025 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=1758578568; cv=none; d=zohomail.com; s=zohoarc; b=gHyWBbAwTi2nvS6xHi7hrgMnsrLK9qPusbxbqeUyt4KcQHMUqBjbgL0tnxnwVIQ4FJCCZQMVPF/DPD9JByl/vXfx6y1fhTFzhmG3qduf3bI1B5EVwUNTsgKYpyaCGVWZp4Yo2mJgdHZqv9SliJS6ncUkyooAMr1irnOjmxSeimA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758578568; 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=4f/lDoSl2tEdm0Pamz1TmV3fUjMmmFhYe5iOa04hOPg=; b=E/f8kxe/gXBdxC4ExVVgRCoKzgd/RE0dr/BFT2P4bAeWK1xo9nMfKVJBrW3yyymoakofCjUXGe5Kg2YOmaQtWdNycyIFluENy94vQFrTMZRJt4OxeJlVZME/XUSS8jRNu9vH0Js3EAcjYN04IErBOhxarH7r8Xg3/ph3FGxiYU4= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758578568259820.0447850913686; Mon, 22 Sep 2025 15:02:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0obp-0005n6-2j; Mon, 22 Sep 2025 18:02:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0obj-0005hj-KS for qemu-devel@nongnu.org; Mon, 22 Sep 2025 18:02:04 -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 1v0obg-0001sr-VK for qemu-devel@nongnu.org; Mon, 22 Sep 2025 18:02:03 -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-650-uu8aiVpGOwWuYfGSkUtXkw-1; Mon, 22 Sep 2025 18:01:58 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 2C63A19560B4; Mon, 22 Sep 2025 22:01:57 +0000 (UTC) Received: from localhost (unknown [10.2.17.92]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3994A19560BB; Mon, 22 Sep 2025 22:01:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758578520; 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=4f/lDoSl2tEdm0Pamz1TmV3fUjMmmFhYe5iOa04hOPg=; b=RGb+M0+f3y3O25QkQuJujJQlVyS3imNckoymD/u9ETb5x36U3ra29SQjynlDvsVuNYEHPO cIhzvdbIRDgE0MAvrrouUfzE3IdRl/tXDtJmQRBv//c6i1wimOULG3b35G2+c225aA2oT7 szYZeei2cHiVUtvF/J47KZK/cN6Razc= X-MC-Unique: uu8aiVpGOwWuYfGSkUtXkw-1 X-Mimecast-MFC-AGG-ID: uu8aiVpGOwWuYfGSkUtXkw_1758578517 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Kevin Wolf , "Michael S. Tsirkin" , , Hanna Reitz , Laurent Vivier , Fam Zheng , Fabiano Rosas , Paolo Bonzini , Stefan Hajnoczi , Stefano Garzarella Subject: [PATCH 2/5] virtio: unify virtio_notify_irqfd() and virtio_notify() Date: Mon, 22 Sep 2025 18:01:46 -0400 Message-ID: <20250922220149.498967-3-stefanha@redhat.com> In-Reply-To: <20250922220149.498967-1-stefanha@redhat.com> References: <20250922220149.498967-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=lists.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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1758578569895116600 Content-Type: text/plain; charset="utf-8" The difference between these two functions: - virtio_notify() uses the interrupt code path (MSI or classic IRQs) - virtio_notify_irqfd() uses guest notifiers (irqfds) virtio_notify() can only be called with the BQL held because the interrupt code path requires the BQL. Device models use virtio_notify_irqfd() from IOThreads since the BQL is not held. The two functions can be unified by pushing down the if (qemu_in_iothread()) check from virtio-blk and virtio-scsi into core virtio code. This is in preparation for the next commit that will add irqfd support to virtio_notify_config() and where it's unattractive to introduce another irqfd-only API for device model callers. Signed-off-by: Stefan Hajnoczi Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/virtio/virtio.h | 1 - hw/block/virtio-blk.c | 6 +----- hw/scsi/virtio-scsi.c | 6 +----- hw/virtio/virtio.c | 28 +++++++++++++--------------- hw/virtio/trace-events | 1 - 5 files changed, 15 insertions(+), 27 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index c594764f23..8435f5e8fc 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -290,7 +290,6 @@ int virtqueue_get_avail_bytes(VirtQueue *vq, unsigned i= nt *in_bytes, unsigned int *out_bytes, unsigned max_in_byt= es, unsigned max_out_bytes); =20 -void virtio_notify_irqfd(VirtIODevice *vdev, VirtQueue *vq); void virtio_notify(VirtIODevice *vdev, VirtQueue *vq); =20 int virtio_save(VirtIODevice *vdev, QEMUFile *f); diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 9bab2716c1..64efce4846 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -62,11 +62,7 @@ void virtio_blk_req_complete(VirtIOBlockReq *req, unsign= ed char status) iov_discard_undo(&req->inhdr_undo); iov_discard_undo(&req->outhdr_undo); virtqueue_push(req->vq, &req->elem, req->in_len); - if (qemu_in_iothread()) { - virtio_notify_irqfd(vdev, req->vq); - } else { - virtio_notify(vdev, req->vq); - } + virtio_notify(vdev, req->vq); } =20 static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error, diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 34ae14f7bf..d817fc42b4 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -116,11 +116,7 @@ static void virtio_scsi_complete_req(VirtIOSCSIReq *re= q, QemuMutex *vq_lock) } =20 virtqueue_push(vq, &req->elem, req->qsgl.size + req->resp_iov.size); - if (s->dataplane_started && !s->dataplane_fenced) { - virtio_notify_irqfd(vdev, vq); - } else { - virtio_notify(vdev, vq); - } + virtio_notify(vdev, vq); =20 if (vq_lock) { qemu_mutex_unlock(vq_lock); diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 9a81ad912e..13830debfd 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -31,6 +31,7 @@ #include "hw/qdev-properties.h" #include "hw/virtio/virtio-access.h" #include "system/dma.h" +#include "system/iothread.h" #include "system/runstate.h" #include "virtio-qmp.h" =20 @@ -2654,16 +2655,8 @@ static void virtio_notify_irqfd_deferred_fn(void *op= aque) event_notifier_set(notifier); } =20 -void virtio_notify_irqfd(VirtIODevice *vdev, VirtQueue *vq) +static void virtio_irq(VirtQueue *vq) { - WITH_RCU_READ_LOCK_GUARD() { - if (!virtio_should_notify(vdev, vq)) { - return; - } - } - - trace_virtio_notify_irqfd(vdev, vq); - /* * virtio spec 1.0 says ISR bit 0 should be ignored with MSI, but * windows drivers included in virtio-win 1.8.0 (circa 2015) are @@ -2680,13 +2673,18 @@ void virtio_notify_irqfd(VirtIODevice *vdev, VirtQu= eue *vq) * to an atomic operation. */ virtio_set_isr(vq->vdev, 0x1); - defer_call(virtio_notify_irqfd_deferred_fn, &vq->guest_notifier); -} =20 -static void virtio_irq(VirtQueue *vq) -{ - virtio_set_isr(vq->vdev, 0x1); - virtio_notify_vector(vq->vdev, vq->vector); + /* + * The interrupt code path requires the Big QEMU Lock (BQL), so use the + * notifier instead when in an IOThread. This assumes that device mode= ls + * have already called ->set_guest_notifiers() sometime before calling= this + * function. + */ + if (qemu_in_iothread()) { + defer_call(virtio_notify_irqfd_deferred_fn, &vq->guest_notifier); + } else { + virtio_notify_vector(vq->vdev, vq->vector); + } } =20 void virtio_notify(VirtIODevice *vdev, VirtQueue *vq) diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 76f0d458b2..658cc365e7 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -75,7 +75,6 @@ virtqueue_flush(void *vq, unsigned int count) "vq %p coun= t %u" virtqueue_pop(void *vq, void *elem, unsigned int in_num, unsigned int out_= num) "vq %p elem %p in_num %u out_num %u" virtio_queue_notify(void *vdev, int n, void *vq) "vdev %p n %d vq %p" virtio_notify_irqfd_deferred_fn(void *vdev, void *vq) "vdev %p vq %p" -virtio_notify_irqfd(void *vdev, void *vq) "vdev %p vq %p" virtio_notify(void *vdev, void *vq) "vdev %p vq %p" virtio_set_status(void *vdev, uint8_t val) "vdev %p val %u" =20 --=20 2.51.0 From nobody Sun Sep 28 15:29:09 2025 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=1758578587; cv=none; d=zohomail.com; s=zohoarc; b=Y0MIIE2+nzNMZsSoSGXunAPbNg+pMbI31O8YPOI5IqdYFOzHu2K+BNBh5x91LWy0B7J4Hvmnxok5cJ6QYRe3utULLIoGe6B288+dxQ6QdTh8r9e3K/9AZPbq11EjTsUQ3dfhw2/4Evi/rsX67VWXChbz46RBk60F6uBGw9EA2Bg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758578587; 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=MOkyRXBewUgAC0oUKh3r+fGvQty4Mx2Cj2IYFAhox1c=; b=QYn5Q/iWOVAACcanCINuOOkEP5Fx9GD2AKVbOK+IV5nVuoZJ4Xt1NHsXsHTxOnzGRsOXbmIoiN/R5lRZQnAYJLnCdyAwpJEwHOyyUtCM67KOQYkN2zDng8LPvJUYKEud0tFkV06jYRf8+WeQxP23DbQgzuqfXgBJLEwIPImFizY= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758578587230839.2098921321364; Mon, 22 Sep 2025 15:03:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0obr-0005qY-Lw; Mon, 22 Sep 2025 18:02:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0obo-0005mR-Ge for qemu-devel@nongnu.org; Mon, 22 Sep 2025 18:02:08 -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 1v0obm-0001tj-7Y for qemu-devel@nongnu.org; Mon, 22 Sep 2025 18:02:08 -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-663-DdMBUD2iOkes0pMCUY64cg-1; Mon, 22 Sep 2025 18:02:01 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 A347D19560A7; Mon, 22 Sep 2025 22:02:00 +0000 (UTC) Received: from localhost (unknown [10.2.17.92]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AF08E1955F21; Mon, 22 Sep 2025 22:01:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758578524; 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=MOkyRXBewUgAC0oUKh3r+fGvQty4Mx2Cj2IYFAhox1c=; b=O1WUkDcZ47i3r2mufRkYiXFQPJ0U1DCydT9hLD9fsXrN3oOTtjoS9HH4nhuqomvWkw/nyh 5YFrzWDqC1iOfUhArFIfon7Z4sAPwmDUfGd/4tcnFBizj2RRm/dy7h2QIrF6tzQLaViayd EqgMt8TPNmHvZqM7kfPDxPZ6o+POu+Q= X-MC-Unique: DdMBUD2iOkes0pMCUY64cg-1 X-Mimecast-MFC-AGG-ID: DdMBUD2iOkes0pMCUY64cg_1758578520 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Kevin Wolf , "Michael S. Tsirkin" , , Hanna Reitz , Laurent Vivier , Fam Zheng , Fabiano Rosas , Paolo Bonzini , Stefan Hajnoczi , Stefano Garzarella Subject: [PATCH 3/5] virtio: support irqfd in virtio_notify_config() Date: Mon, 22 Sep 2025 18:01:47 -0400 Message-ID: <20250922220149.498967-4-stefanha@redhat.com> In-Reply-To: <20250922220149.498967-1-stefanha@redhat.com> References: <20250922220149.498967-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=lists.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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1758578588309116600 Content-Type: text/plain; charset="utf-8" virtio_error() calls virtio_notify_config() to inject a VIRTIO Configuration Change Notification. This doesn't work from IOThreads because the BQL is not held and the interrupt code path requires the BQL. Follow the same approach as virtio_notify() and use ->config_notifier (an irqfd) when called from the IOThread. Signed-off-by: Stefan Hajnoczi --- hw/virtio/virtio.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 13830debfd..ced0fea4fc 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2706,7 +2706,12 @@ void virtio_notify_config(VirtIODevice *vdev) =20 virtio_set_isr(vdev, 0x3); vdev->generation++; - virtio_notify_vector(vdev, vdev->config_vector); + + if (qemu_in_iothread()) { + defer_call(virtio_notify_irqfd_deferred_fn, &vdev->config_notifier= ); + } else { + virtio_notify_vector(vdev, vdev->config_vector); + } } =20 static bool virtio_device_endian_needed(void *opaque) --=20 2.51.0 From nobody Sun Sep 28 15:29:09 2025 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=1758578651; cv=none; d=zohomail.com; s=zohoarc; b=Uhbpx77PvG1EqHUCcUud4kor6M/OvDNf3nT+fGBmXQedqb1unibAYt1+UTnc0OlQMBXEzdtub414hiAEYGuEZRHcCs5sZCDbjfvkFnOw+2BPlFMOc4/VLdUj4GBJSBL2I3/ey/kWMgi3ged9YhRmZqdOkie4LlP++hRgviSjv+c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758578651; 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=r8pxt9v6z846eVxTQNs696Qb0T/nfnbXitLcSBp+icI=; b=iRyuyLIMqCCYxix3C9kJB3E1XdvdW7OXLoAh4dkmnetffji2E9f44HXfizQnoX7o6i5FObWvitteia/3K1SpLgx66DfX9V0qwuSXp0jCiR1VK7OqLwtMpOPYf/ni9tmX9E3FkV4SdrLEXjsy9yzPn2yz22ITMfDCsBk6EX9DNHA= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758578651692839.8054385862491; Mon, 22 Sep 2025 15:04:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0obs-0005r4-9b; Mon, 22 Sep 2025 18:02:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0obp-0005nl-CI for qemu-devel@nongnu.org; Mon, 22 Sep 2025 18:02:09 -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 1v0obn-0001u8-Gj for qemu-devel@nongnu.org; Mon, 22 Sep 2025 18:02:09 -0400 Received: from mx-prod-mc-04.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-629-nw7VmPm1Pcm-hl9yFnE2Lw-1; Mon, 22 Sep 2025 18:02:03 -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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7CD481955F26; Mon, 22 Sep 2025 22:02:02 +0000 (UTC) Received: from localhost (unknown [10.2.17.92]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1077D1800452; Mon, 22 Sep 2025 22:02:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758578526; 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=r8pxt9v6z846eVxTQNs696Qb0T/nfnbXitLcSBp+icI=; b=LKs7MATkZ89O8/QK3+8vknNrDwvXScOJ9uoIJV2iu9qgbFpFFoMNLwVG6+/9qbW1uruSWE 1RAOskgRkQB7I2MdXQEJmp3mTe+uZQlfPVwg5Jind5ZqrVh9eGwN4aJqZ+7A9cOJnQxdOm 2EyC64Q0gMgCsP9TKj73WaofkvKIrC0= X-MC-Unique: nw7VmPm1Pcm-hl9yFnE2Lw-1 X-Mimecast-MFC-AGG-ID: nw7VmPm1Pcm-hl9yFnE2Lw_1758578522 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Kevin Wolf , "Michael S. Tsirkin" , , Hanna Reitz , Laurent Vivier , Fam Zheng , Fabiano Rosas , Paolo Bonzini , Stefan Hajnoczi , Stefano Garzarella Subject: [PATCH 4/5] tests/libqos: extract qvirtqueue_set_avail_idx() Date: Mon, 22 Sep 2025 18:01:48 -0400 Message-ID: <20250922220149.498967-5-stefanha@redhat.com> In-Reply-To: <20250922220149.498967-1-stefanha@redhat.com> References: <20250922220149.498967-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=lists.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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1758578657495116600 Content-Type: text/plain; charset="utf-8" Setting the vring's avail.idx can be useful for low-level VIRTIO tests, especially for testing error scenarios with invalid vrings. Extract it into a new function so that the next commit can add a test that uses this new test API. Signed-off-by: Stefan Hajnoczi Acked-by: Fabiano Rosas Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tests/qtest/libqos/virtio.h | 2 ++ tests/qtest/libqos/virtio.c | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/qtest/libqos/virtio.h b/tests/qtest/libqos/virtio.h index 7adc7cbd10..e238f1726f 100644 --- a/tests/qtest/libqos/virtio.h +++ b/tests/qtest/libqos/virtio.h @@ -143,6 +143,8 @@ uint32_t qvirtqueue_add(QTestState *qts, QVirtQueue *vq= , uint64_t data, uint32_t len, bool write, bool next); uint32_t qvirtqueue_add_indirect(QTestState *qts, QVirtQueue *vq, QVRingIndirectDesc *indirect); +void qvirtqueue_set_avail_idx(QTestState *qts, QVirtioDevice *d, + QVirtQueue *vq, uint16_t idx); void qvirtqueue_kick(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq, uint32_t free_head); bool qvirtqueue_get_buf(QTestState *qts, QVirtQueue *vq, uint32_t *desc_id= x, diff --git a/tests/qtest/libqos/virtio.c b/tests/qtest/libqos/virtio.c index 5a709d0bc5..010ff40834 100644 --- a/tests/qtest/libqos/virtio.c +++ b/tests/qtest/libqos/virtio.c @@ -265,8 +265,9 @@ void qvring_init(QTestState *qts, const QGuestAllocator= *alloc, QVirtQueue *vq, =20 /* vq->avail->flags */ qvirtio_writew(vq->vdev, qts, vq->avail, 0); - /* vq->avail->idx */ - qvirtio_writew(vq->vdev, qts, vq->avail + 2, 0); + + qvirtqueue_set_avail_idx(qts, vq->vdev, vq, 0); + /* vq->avail->used_event */ qvirtio_writew(vq->vdev, qts, vq->avail + 4 + (2 * vq->size), 0); =20 @@ -388,6 +389,13 @@ uint32_t qvirtqueue_add_indirect(QTestState *qts, QVir= tQueue *vq, return vq->free_head++; /* Return and increase, in this order */ } =20 +void qvirtqueue_set_avail_idx(QTestState *qts, QVirtioDevice *d, + QVirtQueue *vq, uint16_t idx) +{ + /* vq->avail->idx */ + qvirtio_writew(d, qts, vq->avail + 2, idx); +} + void qvirtqueue_kick(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq, uint32_t free_head) { @@ -400,8 +408,8 @@ void qvirtqueue_kick(QTestState *qts, QVirtioDevice *d,= QVirtQueue *vq, =20 /* vq->avail->ring[idx % vq->size] */ qvirtio_writew(d, qts, vq->avail + 4 + (2 * (idx % vq->size)), free_he= ad); - /* vq->avail->idx */ - qvirtio_writew(d, qts, vq->avail + 2, idx + 1); + + qvirtqueue_set_avail_idx(qts, d, vq, idx + 1); =20 /* Must read after idx is updated */ flags =3D qvirtio_readw(d, qts, vq->used); --=20 2.51.0 From nobody Sun Sep 28 15:29:09 2025 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=1758578597; cv=none; d=zohomail.com; s=zohoarc; b=IzReb874CgIJxWPDQuHZVRZ9gaWBpx+MsVevhJj/NBchWTPKjzBvlVtplY2VK+7viFQHVbuz3mW8VYn6ak96+SXgkMSmpVQYAlyMtIxi9fwuHf9dGTo/2Y5r1IxmCIX2gQxcmH9TqkKuMPLU6W0WHz3fe7a9+6UZYlbmp06Tf0U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758578597; 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=+TfaxV/wez/uLDfuf+bd3G0/itM6OL3XKa9FRn6eFIw=; b=N2480gPzqnmzZoJSnxpa6bWRYzrgZmJP9n3vPIHM94I1zgMbA0rVphygOb2EaafcgAFDDDX702O/FnEoDsGFn1noKt+71D7TUnnOgNWcFh7Krx6dRYbGhO2+XlZB5Vrny5Fb7DDuV8qH6tKpdAq3E6va557Mn3w2qaYOLQVFmQc= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175857859706434.35512576568601; Mon, 22 Sep 2025 15:03:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0obx-0005tq-ID; Mon, 22 Sep 2025 18:02:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0obv-0005sl-LT for qemu-devel@nongnu.org; Mon, 22 Sep 2025 18:02:15 -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 1v0obu-0001vD-0X for qemu-devel@nongnu.org; Mon, 22 Sep 2025 18:02:15 -0400 Received: from mx-prod-mc-02.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-264-fZKruXZkP26S0qWOuoTnYA-1; Mon, 22 Sep 2025 18:02:08 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8AB3E19560AF; Mon, 22 Sep 2025 22:02:04 +0000 (UTC) Received: from localhost (unknown [10.2.17.92]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C6571195608E; Mon, 22 Sep 2025 22:02:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758578533; 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=+TfaxV/wez/uLDfuf+bd3G0/itM6OL3XKa9FRn6eFIw=; b=cc+xaHpPp9U0tarIhqb3Hz0o1hChaSuuLMduNyCaOOd8lx5/98f3sAyxKR3H2So80QipKm 5NYLXOl3tG5XJnQEbAZ5il93GIcGiOLcxISmprnZRcnA1bbVVB9oFtQSk6LScORl+WlqeN 7AwADeJLw7aCHqmadYcyfc5iLZeUIWU= X-MC-Unique: fZKruXZkP26S0qWOuoTnYA-1 X-Mimecast-MFC-AGG-ID: fZKruXZkP26S0qWOuoTnYA_1758578524 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Kevin Wolf , "Michael S. Tsirkin" , , Hanna Reitz , Laurent Vivier , Fam Zheng , Fabiano Rosas , Paolo Bonzini , Stefan Hajnoczi , Stefano Garzarella Subject: [PATCH 5/5] tests/virtio-scsi: add a virtio_error() IOThread test Date: Mon, 22 Sep 2025 18:01:49 -0400 Message-ID: <20250922220149.498967-6-stefanha@redhat.com> In-Reply-To: <20250922220149.498967-1-stefanha@redhat.com> References: <20250922220149.498967-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=lists.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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1758578597885116600 Content-Type: text/plain; charset="utf-8" Now that virtio_error() calls should work in an IOThread, add a virtio-scsi IOThread test cases that triggers virtio_error(). Signed-off-by: Stefan Hajnoczi --- tests/qtest/virtio-scsi-test.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/qtest/virtio-scsi-test.c b/tests/qtest/virtio-scsi-test.c index db10d572d0..e2350c52f6 100644 --- a/tests/qtest/virtio-scsi-test.c +++ b/tests/qtest/virtio-scsi-test.c @@ -311,6 +311,31 @@ fail: unlink(tmp_path); } =20 +static void test_iothread_virtio_error(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + QVirtioSCSIPCI *scsi_pci =3D obj; + QVirtioSCSI *scsi =3D &scsi_pci->scsi; + QVirtioSCSIQueues *vs; + QVirtQueue *vq; + + alloc =3D t_alloc; + vs =3D qvirtio_scsi_init(scsi->vdev); + vq =3D vs->vq[2]; + + /* Move avail.idx out of bounds to trigger virtio_error() */ + qvirtqueue_set_avail_idx(global_qtest, scsi->vdev, vq, vq->size * 2); + scsi->vdev->bus->virtqueue_kick(scsi->vdev, vq); + + /* + * Reset the device out of the error state. If QEMU hangs or crashes t= hen + * this will fail. + */ + qvirtio_reset(scsi->vdev); + + qvirtio_scsi_pci_free(vs); +} + static void *virtio_scsi_hotplug_setup(GString *cmd_line, void *arg) { g_string_append(cmd_line, @@ -383,6 +408,13 @@ static void register_virtio_scsi_test(void) }; qos_add_test("iothread-attach-node", "virtio-scsi-pci", test_iothread_attach_node, &opts); + + opts.before =3D virtio_scsi_setup_iothread; + opts.edge =3D (QOSGraphEdgeOptions) { + .extra_device_opts =3D "iothread=3Dthread0", + }; + qos_add_test("iothread-virtio-error", "virtio-scsi-pci", + test_iothread_virtio_error, &opts); } =20 libqos_init(register_virtio_scsi_test); --=20 2.51.0