From patchwork Wed Nov 1 09:33:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 13442679 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 88923C001B5 for ; Wed, 1 Nov 2023 09:43:56 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.626281.976399 (Exim 4.92) (envelope-from ) id 1qy7lA-0004rN-9X; Wed, 01 Nov 2023 09:43:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 626281.976399; Wed, 01 Nov 2023 09:43:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qy7lA-0004rG-6G; Wed, 01 Nov 2023 09:43:36 +0000 Received: by outflank-mailman (input) for mailman id 626281; Wed, 01 Nov 2023 09:43:34 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qy7dc-0005E0-SC for xen-devel@lists.xenproject.org; Wed, 01 Nov 2023 09:35:48 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 09ffa01c-789a-11ee-98d6-6d05b1d4d9a1; Wed, 01 Nov 2023 10:35:48 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 2A5291F74A; Wed, 1 Nov 2023 09:35:48 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id F2EC813460; Wed, 1 Nov 2023 09:35:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Nw32OfMbQmWbCQAAMHmgww (envelope-from ); Wed, 01 Nov 2023 09:35:47 +0000 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: 09ffa01c-789a-11ee-98d6-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1698831348; h=from:from:reply-to: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=Tql+TwCFijc3h7ziLqKYIH9oAU5Ll8hidyNHEMqapi8=; b=tf7oOnno8VcyQjNgDDdCvapvHU1C0OEkpFM44RMBVHYVi3DFKOdHulwj2aNhbBqjE7xo0c kscb0hjhSIhvKNK7RAvnL5424iCWY0XQMWLx5e2l9C3vzGs+QcSdArdpyPe5laET9Tbfan DFu5CcbwESWCvybaaspba7xiwzmO5+s= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD Subject: [PATCH 25/29] tools/xenstored: mount 9pfs device in stubdom Date: Wed, 1 Nov 2023 10:33:21 +0100 Message-Id: <20231101093325.30302-26-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231101093325.30302-1-jgross@suse.com> References: <20231101093325.30302-1-jgross@suse.com> MIME-Version: 1.0 Mount the 9pfs device in stubdom enabling it to use files. This has to happen in a worker thread in order to allow the main thread handling the required Xenstore accesses in parallel. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- tools/xenstored/core.h | 5 +++++ tools/xenstored/domain.c | 2 ++ tools/xenstored/minios.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h index f7a27a4131..48ff659ec5 100644 --- a/tools/xenstored/core.h +++ b/tools/xenstored/core.h @@ -35,6 +35,8 @@ #include "list.h" #include "hashtable.h" +#define XENSTORE_LIB_DIR XEN_LIB_DIR "/xenstore" + #ifndef O_CLOEXEC #define O_CLOEXEC 0 /* O_CLOEXEC support is needed for Live Update in the daemon case. */ @@ -385,6 +387,9 @@ static inline bool domain_is_unprivileged(const struct connection *conn) /* Return the event channel used by xenbus. */ evtchn_port_t get_xenbus_evtchn(void); +#ifdef __MINIOS__ +void mount_9pfs(void); +#endif /* Write out the pidfile */ void write_pidfile(const char *pidfile); diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c index 162b87b460..4263c1360f 100644 --- a/tools/xenstored/domain.c +++ b/tools/xenstored/domain.c @@ -1236,6 +1236,8 @@ void stubdom_init(void) barf_perror("Failed to initialize stubdom"); xenevtchn_notify(xce_handle, stubdom->port); + + mount_9pfs(); #endif } diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c index 0779efbf91..e5a3684df6 100644 --- a/tools/xenstored/minios.c +++ b/tools/xenstored/minios.c @@ -19,6 +19,14 @@ #include #include "core.h" #include +#include +#include +#include +#include + +#define P9_STATE_PATH "device/9pfs/0/state" + +static void *p9_device; void write_pidfile(const char *pidfile) { @@ -54,3 +62,30 @@ void unmap_xenbus(void *interface) xengnttab_unmap(*xgt_handle, interface, 1); } +static void mount_thread(void *p) +{ + xenbus_event_queue events = NULL; + char *err; + char *dummy; + + free(xenbus_watch_path_token(XBT_NIL, P9_STATE_PATH, "9pfs", &events)); + + for (;;) { + xenbus_wait_for_watch(&events); + err = xenbus_read(XBT_NIL, P9_STATE_PATH, &dummy); + if (!err) + break; + free(err); + } + + free(dummy); + + free(xenbus_unwatch_path_token(XBT_NIL, P9_STATE_PATH, "9pfs")); + + p9_device = init_9pfront(0, XENSTORE_LIB_DIR); +} + +void mount_9pfs(void) +{ + create_thread("mount-9pfs", mount_thread, NULL); +}