From nobody Fri Oct 31 04:02:06 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=quarantine dis=quarantine) header.from=suse.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 175144446287649.81377187762962; Wed, 2 Jul 2025 01:21:02 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1030437.1404123 (Exim 4.92) (envelope-from ) id 1uWshw-0004XG-GI; Wed, 02 Jul 2025 08:20:44 +0000 Received: by outflank-mailman (output) from mailman id 1030437.1404123; Wed, 02 Jul 2025 08:20:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWshw-0004Vh-1c; Wed, 02 Jul 2025 08:20:44 +0000 Received: by outflank-mailman (input) for mailman id 1030437; Wed, 02 Jul 2025 08:20:43 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWsbG-00082X-OB for xen-devel@lists.xenproject.org; Wed, 02 Jul 2025 08:13:50 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7a51eb2c-571c-11f0-b894-0df219b8e170; Wed, 02 Jul 2025 10:13:47 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 130932117F; Wed, 2 Jul 2025 08:13:47 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D892813A54; Wed, 2 Jul 2025 08:13:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id PcglMzrqZGhGSQAAD6G6ig (envelope-from ); Wed, 02 Jul 2025 08:13:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7a51eb2c-571c-11f0-b894-0df219b8e170 Authentication-Results: smtp-out1.suse.de; none From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Julien Grall , Anthony PERARD Subject: [PATCH 6/9] xenstored: don't use xenevtchn_fdopen() in stubdom Date: Wed, 2 Jul 2025 10:13:02 +0200 Message-ID: <20250702081305.14440-7-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250702081305.14440-1-jgross@suse.com> References: <20250702081305.14440-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: 130932117F X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Level: X-Spam-Flag: NO X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: -4.00 X-ZM-MESSAGEID: 1751444464806116600 Content-Type: text/plain; charset="utf-8" When running in a stubdom environment xenevtchn_fdopen() won't work, as any file descriptor state is lost across kexec(). Use a wrapper to replace the call of xenevtchn_fdopen() with the really needed xenevtchn_open() when running on top of Mini-OS. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- tools/xenstored/core.h | 3 +++ tools/xenstored/domain.c | 2 +- tools/xenstored/minios.c | 5 +++++ tools/xenstored/posix.c | 5 +++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h index 1ba9592d16..bef24a688c 100644 --- a/tools/xenstored/core.h +++ b/tools/xenstored/core.h @@ -29,6 +29,7 @@ #include #include #include +#include =20 #include "xenstore_lib.h" #include "xenstore_state.h" @@ -405,6 +406,8 @@ void handle_special_fds(void); int get_socket_fd(void); void set_socket_fd(int fd); =20 +xenevtchn_handle *evtchn_fdopen(int fd); + #ifdef __MINIOS__ void mount_9pfs(void); #endif diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c index e1d5e8d614..e0c2342edb 100644 --- a/tools/xenstored/domain.c +++ b/tools/xenstored/domain.c @@ -1326,7 +1326,7 @@ void domain_init(int evtfd) if (evtfd < 0) xce_handle =3D xenevtchn_open(NULL, XENEVTCHN_NO_CLOEXEC); else - xce_handle =3D xenevtchn_fdopen(NULL, evtfd, 0); + xce_handle =3D evtchn_fdopen(evtfd); =20 if (xce_handle =3D=3D NULL) barf_perror("Failed to open evtchn device"); diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c index a229954cf4..aa1f03fd6b 100644 --- a/tools/xenstored/minios.c +++ b/tools/xenstored/minios.c @@ -85,6 +85,11 @@ void set_socket_fd(int fd) { } =20 +xenevtchn_handle *evtchn_fdopen(int fd) +{ + return xenevtchn_open(NULL, XENEVTCHN_NO_CLOEXEC); +} + static void mount_thread(void *p) { xenbus_event_queue events =3D NULL; diff --git a/tools/xenstored/posix.c b/tools/xenstored/posix.c index 6037d739d0..ebdec82215 100644 --- a/tools/xenstored/posix.c +++ b/tools/xenstored/posix.c @@ -408,6 +408,11 @@ void set_socket_fd(int fd) sock =3D fd; } =20 +xenevtchn_handle *evtchn_fdopen(int fd) +{ + return xenevtchn_fdopen(NULL, fd, 0); +} + const char *xenstore_rundir(void) { return xenstore_daemon_rundir(); --=20 2.43.0