From nobody Sat Sep 26 20:52:33 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1789150200; cv=none; d=zohomail.com; s=zohoarc; b=Up5CHaUWmNyX2UuLW3SFrPept8DMiQlLb4uJax6ERGQyZAJgFjveb5CWJaH06+MVToP43vBz7Mea/jtL/Z8zVTqocz+xHtRyXMxUxk2TfRaFUFpN5Ir5Ua+5TnZqoRyUZibqNx5KOxYSBwWeRL/+GWSfWkTMtll2Cjr1/wvXsh4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789150200; 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=fbFSQh3QjfQiC+H+Nv8e1iQ1NC9bj9HmckG7oUuK69o=; b=Oid46pxkV4iQuadIKKALi/D3za6V/UiVry5lLiJECVjex2/ocvA0JjzUTaM84CG91ooMOPkI9DqtE10GH2JTqJihYnISkPVYZOwPUw2dIKrdMBF0YR2tJEHrdVYCMjdkqoiyZSfJKk3a9sgHIm2HfS/76v7qSMR8LttRPUzQ0jk= 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=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789150200095750.4258041106251; Fri, 11 Sep 2026 11:10:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x55ga-0005SH-Sa; Fri, 11 Sep 2026 14:09:16 -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 1x55gP-0005Oq-Al for qemu-devel@nongnu.org; Fri, 11 Sep 2026 14:09:05 -0400 Received: from forwardcorp1a.mail.yandex.net ([178.154.239.72]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x55gL-0000GX-ID for qemu-devel@nongnu.org; Fri, 11 Sep 2026 14:09:05 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:3530:0:640:eca4:0]) by forwardcorp1a.mail.yandex.net (postfix) with ESMTPS id 37D1DC0B53; Fri, 11 Sep 2026 21:08:58 +0300 (MSK) Received: from i115954770.yandex-team.ru (unknown [2a02:6bf:8080:641::1:4]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp) with ESMTPSA id u8VTLcTagiE0-nLJm2nG8; Fri, 11 Sep 2026 21:08:57 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1789150137; bh=fbFSQh3QjfQiC+H+Nv8e1iQ1NC9bj9HmckG7oUuK69o=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=DojNpBeAuRbD/XCoCXJspufn9OrJdapXtNSAMUqHqxgbHZybTxvftTsDx0bDobjRw wiPyctSohIKGrafM+F+K55tbt4Q7VIY5WOUcBdz8kIp8BvsdjtlisKdUmGADREndoE CfT1J/4Yhn8DHSrDrF1c3wFgU6QFmHixiEF6uDfc= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: pbonzini@redhat.com Cc: qemu-devel@nongnu.org, eperezma@redhat.com, sgarzare@redhat.com, mst@redhat.com, jag.raman@oracle.com, elena.ufimtseva@oracle.com, Vladimir Sementsov-Ogievskiy Subject: [PATCH 1/4] util/event_notifier: return -1 for uninitialized notifiers Date: Fri, 11 Sep 2026 21:08:51 +0300 Message-ID: <20260911180854.123969-2-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260911180854.123969-1-vsementsov@yandex-team.ru> References: <20260911180854.123969-1-vsementsov@yandex-team.ru> 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=178.154.239.72; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=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: 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 @yandex-team.ru) X-ZM-MESSAGEID: 1789150200844158500 Content-Type: text/plain; charset="utf-8" Use initialized in event_notifier_get_fd() and event_notifier_get_wfd() instead of exposing the descriptor fields of an uninitialized notifier. This makes a zeroed notifier report the same absent descriptor as one that has been cleaned up, while preserving fd 0 for initialized notifiers. Document the accessor contract so callers can test for an absent notifier without accessing its initialized flag directly. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/qemu/event_notifier.h | 1 + util/event_notifier-posix.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/qemu/event_notifier.h b/include/qemu/event_notifier.h index 8a4ff308e19..de2e876cb15 100644 --- a/include/qemu/event_notifier.h +++ b/include/qemu/event_notifier.h @@ -37,6 +37,7 @@ int event_notifier_test_and_clear(EventNotifier *); =20 #ifdef CONFIG_POSIX void event_notifier_init_fd(EventNotifier *, int fd); +/* These accessors return -1 for an uninitialized notifier. */ int event_notifier_get_fd(const EventNotifier *); int event_notifier_get_wfd(const EventNotifier *); #else diff --git a/util/event_notifier-posix.c b/util/event_notifier-posix.c index 83fdbb96bbc..34a2716dbf2 100644 --- a/util/event_notifier-posix.c +++ b/util/event_notifier-posix.c @@ -96,12 +96,12 @@ void event_notifier_cleanup(EventNotifier *e) =20 int event_notifier_get_fd(const EventNotifier *e) { - return e->rfd; + return e->initialized ? e->rfd : -1; } =20 int event_notifier_get_wfd(const EventNotifier *e) { - return e->wfd; + return e->initialized ? e->wfd : -1; } =20 int event_notifier_set(EventNotifier *e) --=20 2.43.0 From nobody Sat Sep 26 20:52:33 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1789150195; cv=none; d=zohomail.com; s=zohoarc; b=dChMWeex2CCofFpN9+30ueR/tB4agjxOj9/WyImCMf2fECkzxRKRfYwfwAHs2llpGr2Zv86Aow1v8/GdsOjDThHRK2c9KEYJtVBc0Li11TwlqClcalpBBDAaKSxkSc5uWb0zv2llK2HUCd6/v/NHXX/Jh0PyR1ETN6tIf687GT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789150195; 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=bDBpFtIKDIsDfvNAayyEq2eJ3vPvRyYwUiWc7/ztv1E=; b=QSX8+oCpDM2qAW66/VOQwjnmYIMbtQ2TptcLSLo7S6VLLU5yB6phn39viD+Z2IsTntPoVt9MYnQdc1scn7zBX+ShGkMedcDbDS9IjX35fbGWWMUw/FAq04rY9LYAsxX3TGYo4vuD91zETesv53l09ZnX0UTM858i49QX2WEzA38= 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=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789150195417918.7941669190363; Fri, 11 Sep 2026 11:09:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x55gW-0005QD-0r; Fri, 11 Sep 2026 14:09:12 -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 1x55gP-0005Oo-8u for qemu-devel@nongnu.org; Fri, 11 Sep 2026 14:09:05 -0400 Received: from forwardcorp1a.mail.yandex.net ([178.154.239.72]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x55gL-0000Ga-IJ for qemu-devel@nongnu.org; Fri, 11 Sep 2026 14:09:04 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:3530:0:640:eca4:0]) by forwardcorp1a.mail.yandex.net (postfix) with ESMTPS id D2D50C0B5A; Fri, 11 Sep 2026 21:08:58 +0300 (MSK) Received: from i115954770.yandex-team.ru (unknown [2a02:6bf:8080:641::1:4]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp) with ESMTPSA id u8VTLcTagiE0-r7jfOqqL; Fri, 11 Sep 2026 21:08:58 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1789150138; bh=bDBpFtIKDIsDfvNAayyEq2eJ3vPvRyYwUiWc7/ztv1E=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=hgG/Y3qHGim6p6REkO685o2LAsbXDioZdTBlX0TFpsT+xaV33G8lPG+7vpYEfXgLG a48kjDYSCytkLYOffEKL7HQbZfzu0AbRz80NZFQKzb2bAnxk/AbTWtbdsbzQnHgUAa KyW8qTQYOUsQnbZ5VXsxmeWfGPhXJJHGqbZGuhRg= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: pbonzini@redhat.com Cc: qemu-devel@nongnu.org, eperezma@redhat.com, sgarzare@redhat.com, mst@redhat.com, jag.raman@oracle.com, elena.ufimtseva@oracle.com, Vladimir Sementsov-Ogievskiy Subject: [PATCH 2/4] remote/iohub: stop set event notifiers to -1 Date: Fri, 11 Sep 2026 21:08:52 +0300 Message-ID: <20260911180854.123969-3-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260911180854.123969-1-vsementsov@yandex-team.ru> References: <20260911180854.123969-1-vsementsov@yandex-team.ru> 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=178.154.239.72; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=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: 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 @yandex-team.ru) X-ZM-MESSAGEID: 1789150197235158500 Content-Type: text/plain; charset="utf-8" No reason to do it, the notifiers are zeroed out, so fd getter will report -1 correctly. Signed-off-by: Vladimir Sementsov-Ogievskiy --- hw/remote/iohub.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/hw/remote/iohub.c b/hw/remote/iohub.c index 988d3285ccc..58a6e5b4280 100644 --- a/hw/remote/iohub.c +++ b/hw/remote/iohub.c @@ -28,8 +28,6 @@ void remote_iohub_init(RemoteIOHubState *iohub) for (pirq =3D 0; pirq < REMOTE_IOHUB_NB_PIRQS; pirq++) { qemu_mutex_init(&iohub->irq_level_lock[pirq]); iohub->irq_level[pirq] =3D 0; - event_notifier_init_fd(&iohub->irqfds[pirq], -1); - event_notifier_init_fd(&iohub->resamplefds[pirq], -1); } } =20 --=20 2.43.0 From nobody Sat Sep 26 20:52:33 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1789150188; cv=none; d=zohomail.com; s=zohoarc; b=ensk2/kZYkOVs9VG6l+B7rLclkc4utOeXBjqwAeWQ3ngVom0UuNUEI9bqcdvnpttwy7hK8bVPlmgRIbq0mn3sovyWnI0cTBf9qPBQHN0qyQcb4cotjmUd/n7NBlPRvxbN6TzfA+cUXwZtxF1QG8C4NoeXUE+6kiBrMjfLetoovQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789150188; 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=GDufTV9ny9B/lcMIYmpLimUU7/eWy5Qwi37faHkBCJc=; b=K2R+WkksLLM024DgANZ8JpkEmHCC4NDCvzvt3g7vgNV+LWOQjcpibVpw7YU9qVk/jYatXOl7rOEaoIdRBmJXITBZSvfs6sGi6JpRblw6NoTxE/yT3yfD/8EM35DH9U0AVn+InDfyyJtWVnh2lSoklyijWPlkUvJG38OuGyvaViM= 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=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789150187449183.69619369126883; Fri, 11 Sep 2026 11:09:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x55gS-0005PX-LZ; Fri, 11 Sep 2026 14:09: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 1x55gO-0005Od-Ri for qemu-devel@nongnu.org; Fri, 11 Sep 2026 14:09:04 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x55gL-0000Gf-I3 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 14:09:04 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:3530:0:640:eca4:0]) by forwardcorp1a.mail.yandex.net (postfix) with ESMTPS id 7FDACC0B5C; Fri, 11 Sep 2026 21:08:59 +0300 (MSK) Received: from i115954770.yandex-team.ru (unknown [2a02:6bf:8080:641::1:4]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp) with ESMTPSA id u8VTLcTagiE0-BdrIiJBt; Fri, 11 Sep 2026 21:08:58 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1789150139; bh=GDufTV9ny9B/lcMIYmpLimUU7/eWy5Qwi37faHkBCJc=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=e+vPJ8pdhfpv/YTx3tY1J6o4DIHgYOhfJ1oF3dKDXbavluKd092nVUsXz2IYVa+MZ E/M4uKyIkUgcM54VUh44klYCZtgb3tFuiEJyOFdqI8E2gWwHNeeV4nU/v9ys1afNnK f6TOHlPai4m6YjiDu75eyL3bBep2d40E52PFFvXw= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: pbonzini@redhat.com Cc: qemu-devel@nongnu.org, eperezma@redhat.com, sgarzare@redhat.com, mst@redhat.com, jag.raman@oracle.com, elena.ufimtseva@oracle.com, Vladimir Sementsov-Ogievskiy Subject: [PATCH 3/4] vhost: stop set event notifier to -1 Date: Fri, 11 Sep 2026 21:08:53 +0300 Message-ID: <20260911180854.123969-4-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260911180854.123969-1-vsementsov@yandex-team.ru> References: <20260911180854.123969-1-vsementsov@yandex-team.ru> 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=2a02:6b8:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=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: 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 @yandex-team.ru) X-ZM-MESSAGEID: 1789150191926158500 Content-Type: text/plain; charset="utf-8" When notifier is zeroed, it's already "uninitialized", and getter correctly returns -1. No reason to directly set fd=3D-1. Signed-off-by: Vladimir Sementsov-Ogievskiy --- hw/virtio/vhost-shadow-virtqueue.c | 32 +++++++++++++++++------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-vi= rtqueue.c index bcb7f2ffc79..46520549b4f 100644 --- a/hw/virtio/vhost-shadow-virtqueue.c +++ b/hw/virtio/vhost-shadow-virtqueue.c @@ -745,6 +745,15 @@ static void vhost_svq_handle_call(EventNotifier *n) vhost_svq_flush(svq, true); } =20 +static void event_notifier_set_or_zero(EventNotifier *e, int fd) +{ + if (fd =3D=3D VHOST_FILE_UNBIND) { + memset(e, 0, sizeof(*e)); + } else { + event_notifier_init_fd(e, fd); + } +} + /** * Set the call notifier for the SVQ to call the guest * @@ -755,17 +764,13 @@ static void vhost_svq_handle_call(EventNotifier *n) */ void vhost_svq_set_svq_call_fd(VhostShadowVirtqueue *svq, int call_fd) { - if (call_fd =3D=3D VHOST_FILE_UNBIND) { - /* - * Fail event_notifier_set if called handling device call. - * - * SVQ still needs device notifications, since it needs to keep - * forwarding used buffers even with the unbind. - */ - memset(&svq->svq_call, 0, sizeof(svq->svq_call)); - } else { - event_notifier_init_fd(&svq->svq_call, call_fd); - } + /* + * Fail event_notifier_set if called handling device call. + * + * SVQ still needs device notifications, since it needs to keep + * forwarding used buffers even with the unbind. + */ + event_notifier_set_or_zero(&svq->svq_call, call_fd); } =20 /** @@ -808,14 +813,14 @@ size_t vhost_svq_device_area_size(const VhostShadowVi= rtqueue *svq) void vhost_svq_set_svq_kick_fd(VhostShadowVirtqueue *svq, int svq_kick_fd) { EventNotifier *svq_kick =3D &svq->svq_kick; - bool poll_stop =3D VHOST_FILE_UNBIND !=3D event_notifier_get_fd(svq_ki= ck); + bool poll_stop =3D event_notifier_get_fd(svq_kick) >=3D 0; bool poll_start =3D svq_kick_fd !=3D VHOST_FILE_UNBIND; =20 if (poll_stop) { event_notifier_set_handler(svq_kick, NULL); } =20 - event_notifier_init_fd(svq_kick, svq_kick_fd); + event_notifier_set_or_zero(&svq->svq_kick, svq_kick_fd); /* * event_notifier_set_handler already checks for guest's notifications= if * they arrive at the new file descriptor in the switch, so there is no @@ -922,7 +927,6 @@ VhostShadowVirtqueue *vhost_svq_new(const VhostShadowVi= rtqueueOps *ops, { VhostShadowVirtqueue *svq =3D g_new0(VhostShadowVirtqueue, 1); =20 - event_notifier_init_fd(&svq->svq_kick, VHOST_FILE_UNBIND); svq->ops =3D ops; svq->ops_opaque =3D ops_opaque; return svq; --=20 2.43.0 From nobody Sat Sep 26 20:52:33 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1789150188; cv=none; d=zohomail.com; s=zohoarc; b=kWD4+XmzFXbOnc+9EdnyNLO/At5DK1L8tcPL5SncWIET14H2hxvS/FuiZU9+sg05znoENe3SW4h7YaBJvBxq0r+L6QRp0RiwCgGPk0p4t1kvHEgePaBXWBma/aGyPGAzYh8kxnN4TgDiGDbTfQoruNUQQ3lGZlsL6OktCWGnscc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789150188; 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=fWay2CtptdPUxMr7RhcMr4lua84eW9BE1W+kNA3m5gk=; b=RHctRRURjDBHLMSSVcU6AHEBakkVDTwSTwNfn/f2r3TLquVhA6CYrys1+L50lc6VMJtxLb+67ecNxfrt3ISzFI98S+IXvEDwdT9EQKAMQcycuosY0/nMvytvuOIrxp+iNh72egpbdH4h3i+w5iQ0G6zZEeuOsqHRPioWEScXviA= 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=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789150187449324.7559008709778; Fri, 11 Sep 2026 11:09:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x55gY-0005RG-6d; Fri, 11 Sep 2026 14:09: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 1x55gP-0005Op-8s for qemu-devel@nongnu.org; Fri, 11 Sep 2026 14:09:05 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x55gM-0000Gi-Bw for qemu-devel@nongnu.org; Fri, 11 Sep 2026 14:09:04 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:3530:0:640:eca4:0]) by forwardcorp1a.mail.yandex.net (postfix) with ESMTPS id 1C8D8C0B5E; Fri, 11 Sep 2026 21:09:00 +0300 (MSK) Received: from i115954770.yandex-team.ru (unknown [2a02:6bf:8080:641::1:4]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp) with ESMTPSA id u8VTLcTagiE0-JE55Oi4i; Fri, 11 Sep 2026 21:08:59 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1789150139; bh=fWay2CtptdPUxMr7RhcMr4lua84eW9BE1W+kNA3m5gk=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=oZIaMDO9yJCLcicInz2Hzyv6oGERlGkHcAIj7VrO6yKzlUiWwo3ZI3AwerRUsGF4+ 6tdnT8mgiWJocGA9l6ytYjmkGMG3LDDDG2Pc2zvc84cGVr5RTayvME7vBqXGaGbs6G WeMrpQFywzpFkwOfAc11oErK1fTeFu0iy9ZwtF8U= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: pbonzini@redhat.com Cc: qemu-devel@nongnu.org, eperezma@redhat.com, sgarzare@redhat.com, mst@redhat.com, jag.raman@oracle.com, elena.ufimtseva@oracle.com, Vladimir Sementsov-Ogievskiy Subject: [PATCH 4/4] util/event_notifier: assert that init_fd receives a valid fd Date: Fri, 11 Sep 2026 21:08:54 +0300 Message-ID: <20260911180854.123969-5-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260911180854.123969-1-vsementsov@yandex-team.ru> References: <20260911180854.123969-1-vsementsov@yandex-team.ru> 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=2a02:6b8:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=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: 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 @yandex-team.ru) X-ZM-MESSAGEID: 1789150191739158500 Content-Type: text/plain; charset="utf-8" An initialized EventNotifier must have a nonnegative descriptor. Callers can use the initialized flag to represent an absent notifier instead of initializing it with a negative fd. Assert this precondition in event_notifier_init_fd() now that IOHub and shadow virtqueues no longer pass negative placeholder descriptors. Signed-off-by: Vladimir Sementsov-Ogievskiy --- util/event_notifier-posix.c | 1 + 1 file changed, 1 insertion(+) diff --git a/util/event_notifier-posix.c b/util/event_notifier-posix.c index 34a2716dbf2..c6d2caaf9ff 100644 --- a/util/event_notifier-posix.c +++ b/util/event_notifier-posix.c @@ -27,6 +27,7 @@ */ void event_notifier_init_fd(EventNotifier *e, int fd) { + assert(fd >=3D 0); e->rfd =3D fd; e->wfd =3D fd; e->initialized =3D true; --=20 2.43.0