From nobody Mon Sep 28 01:21:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1786070694494529.0714284514952; Thu, 6 Aug 2026 19:44:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wsAZC-00066z-9Y; Thu, 06 Aug 2026 22:44:14 -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 1wsAZA-000660-8R for qemu-devel@nongnu.org; Thu, 06 Aug 2026 22:44:12 -0400 Received: from mailgw.kylinos.cn ([124.126.103.232]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wsAZ7-0001Dx-1B for qemu-devel@nongnu.org; Thu, 06 Aug 2026 22:44:12 -0400 Received: from xwm-tianyi510pro-14imb.. [(10.44.16.150)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 556373050; Fri, 07 Aug 2026 10:44:01 +0800 X-UUID: d8eaf7b0920911f1aa26b74ffac11d73-20260807 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.12, REQID:4106178b-6c22-443f-8b85-3b8bdbf4ae82, IP:0, U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:e7bac3a, CLOUDID:8a9c9a87391082d94948f77bd7939082, BulkI D:nil,BulkQuantity:0,Recheck:0,SF:102|136|865|898,TC:nil,Content:0|15|50,E DM:-3|-100,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI: 0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: d8eaf7b0920911f1aa26b74ffac11d73-20260807 X-User: xiongweimin@kylinos.cn From: Xiong Weimin To: qemu-devel@nongnu.org Cc: "Michael S . Tsirkin" , Jason Wang , virtualization@lists.linux.dev Subject: [PATCH] hw/virtio: Propagate vhost_virtqueue_mask errors Date: Fri, 7 Aug 2026 10:43:59 +0800 Message-ID: <20260807024359.2157914-1-xiongweimin@kylinos.cn> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=124.126.103.232; envelope-from=xiongweimin@kylinos.cn; helo=mailgw.kylinos.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=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: 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-ZM-MESSAGEID: 1786070697832158501 Content-Type: text/plain; charset="utf-8" vhost_virtqueue_mask() currently reports failures from vhost_set_vring_call() but always returns void, so callers cannot react. In particular, vhost_virtqueue_start() has a TODO next to the unmask call when !use_guest_notifier_mask. Make vhost_virtqueue_mask() return the underlying errno, and on failure in vhost_virtqueue_start() jump to the existing fail path which unmaps the vring and propagates the error to the device start caller. Other call sites keep today's behavior by ignoring the return value. Signed-off-by: Xiong Weimin --- hw/virtio/vhost.c | 10 +++++++--- include/hw/virtio/vhost.h | 9 ++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index af41841b52..b02d831d3a 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1470,8 +1470,10 @@ int vhost_virtqueue_start(struct vhost_dev *dev, * will do it later. */ if (!vdev->use_guest_notifier_mask) { - /* TODO: check and handle errors. */ - vhost_virtqueue_mask(dev, vdev, idx, false); + r =3D vhost_virtqueue_mask(dev, vdev, idx, false); + if (r < 0) { + goto fail; + } } =20 if (k->query_guest_notifiers && @@ -1918,7 +1920,7 @@ bool vhost_virtqueue_pending(struct vhost_dev *hdev, = int n) } =20 /* Mask/unmask events from this vq. */ -void vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int = n, +int vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int n, bool mask) { struct VirtQueue *vvq =3D virtio_get_queue(vdev, n); @@ -1939,7 +1941,9 @@ void vhost_virtqueue_mask(struct vhost_dev *hdev, Vir= tIODevice *vdev, int n, r =3D hdev->vhost_ops->vhost_set_vring_call(hdev, &file); if (r < 0) { error_report("vhost_set_vring_call failed %d", -r); + return r; } + return 0; } =20 bool vhost_config_pending(struct vhost_dev *hdev) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 684bafcaad..3db56433b6 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -310,10 +310,13 @@ void vhost_dev_set_config_notifier(struct vhost_dev *= dev, */ bool vhost_virtqueue_pending(struct vhost_dev *hdev, int n); =20 -/* Mask/unmask events from this vq. +/** + * vhost_virtqueue_mask(): mask/unmask events from this vq. + * + * Returns: 0 on success, a negative errno on failure. */ -void vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int = n, - bool mask); +int vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int n, + bool mask); =20 /** * vhost_get_features_ex() - sanitize the extended features set