From patchwork Thu Feb 8 16:55:42 2024 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: 13550216 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 3127AC4828F for ; Thu, 8 Feb 2024 17:09:28 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.678416.1055714 (Exim 4.92) (envelope-from ) id 1rY7to-0001Hk-Ia; Thu, 08 Feb 2024 17:09:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 678416.1055714; Thu, 08 Feb 2024 17:09:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rY7to-0001Gk-F9; Thu, 08 Feb 2024 17:09:20 +0000 Received: by outflank-mailman (input) for mailman id 678416; Thu, 08 Feb 2024 17:09:19 +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 1rY7iN-0005bD-3X for xen-devel@lists.xenproject.org; Thu, 08 Feb 2024 16:57:31 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2542a858-c6a3-11ee-8a4a-1f161083a0e0; Thu, 08 Feb 2024 17:57:30 +0100 (CET) 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-out2.suse.de (Postfix) with ESMTPS id 234F31FCF9; Thu, 8 Feb 2024 16:57:30 +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 E9C571326D; Thu, 8 Feb 2024 16:57:29 +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 sJenN/kHxWVNFAAAD6G6ig (envelope-from ); Thu, 08 Feb 2024 16:57:29 +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: 2542a858-c6a3-11ee-8a4a-1f161083a0e0 From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD Subject: [PATCH v5 18/22] tools: add 9pfs device to xenstore-stubdom Date: Thu, 8 Feb 2024 17:55:42 +0100 Message-Id: <20240208165546.5715-19-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240208165546.5715-1-jgross@suse.com> References: <20240208165546.5715-1-jgross@suse.com> MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 234F31FCF9 Add a 9pfs device to Xenstore stubdom in order to allow it to do e.g. logging into a dom0 file. Use the following parameters for the new device: - tag = "Xen" - type = "xen_9pfsd" - path = "/var/lib/xen/xenstore" - security-model = "none" For now don't limit allowed file space or number of files. Add a new libxl function for adding it similar to the function for adding the console device. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk Reviewed-by: Anthony PERARD --- V2: - add security_model parameter to new libxl function (Jason Andryuk) V4: - rename function to libxl_device_9pfs_add() (Anthony Perard) - use a libxl_device_p9 pointer as parameter (Anthony Perard) --- tools/helpers/init-xenstore-domain.c | 7 +++++++ tools/include/libxl.h | 15 +++++++++++++++ tools/libs/light/libxl_9pfs.c | 16 ++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/tools/helpers/init-xenstore-domain.c b/tools/helpers/init-xenstore-domain.c index 140ed610ae..1683438c5c 100644 --- a/tools/helpers/init-xenstore-domain.c +++ b/tools/helpers/init-xenstore-domain.c @@ -433,6 +433,12 @@ int main(int argc, char** argv) int rv, fd; char *maxmem_str = NULL; libxl_ctx *ctx; + libxl_device_p9 p9 = { .backend_domid = 0, + .tag = "Xen", + .path = XEN_LIB_DIR"/xenstore", + .security_model = "none", + .type = LIBXL_P9_TYPE_XEN_9PFSD, + }; while ( (opt = getopt_long(argc, argv, "v", options, NULL)) != -1 ) { @@ -543,6 +549,7 @@ int main(int argc, char** argv) } libxl_console_add_xenstore(ctx, domid, 0, console_evtchn, console_gfn, NULL); + libxl_device_9pfs_add(ctx, domid, &p9, NULL); libxl_ctx_free(ctx); fd = creat(XEN_RUN_DIR "/xenstored.pid", 0666); diff --git a/tools/include/libxl.h b/tools/include/libxl.h index a554f2ccd6..e6ab5ddb94 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -583,6 +583,13 @@ * libxl_console_add_xenstore() in libxl. */ #define LIBXL_HAVE_CONSOLE_ADD_XENSTORE 1 + +/* + * LIBXL_HAVE_P9_ADD_XENSTORE indicates presence of the function + * libxl_device_9pfs_add() in libxl. + */ +#define LIBXL_HAVE_P9_ADD_XENSTORE 1 + /* * libxl ABI compatibility * @@ -2074,6 +2081,14 @@ int libxl_console_add_xenstore(libxl_ctx *ctx, uint32_t domid, uint32_t backend, const libxl_asyncop_how *ao_how) LIBXL_EXTERNAL_CALLERS_ONLY; +/* libxl_device_9pfs_add writes the Xenstore entries for a domain's + * primary 9pfs device based on domid, and device parameters. + * If needed it will start the backend daemon. + */ +int libxl_device_9pfs_add(libxl_ctx *ctx, uint32_t domid, libxl_device_p9 *p9, + const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; + /* May be called with info_r == NULL to check for domain's existence. * Returns ERROR_DOMAIN_NOTFOUND if domain does not exist (used to return * ERROR_INVAL for this scenario). */ diff --git a/tools/libs/light/libxl_9pfs.c b/tools/libs/light/libxl_9pfs.c index 7593686a90..8f5d475322 100644 --- a/tools/libs/light/libxl_9pfs.c +++ b/tools/libs/light/libxl_9pfs.c @@ -208,6 +208,22 @@ static void libxl__device_p9_add(libxl__egc *egc, uint32_t domid, aodev->callback(egc, aodev); } +int libxl_device_9pfs_add(libxl_ctx *ctx, uint32_t domid, libxl_device_p9 *p9, + const libxl_asyncop_how *ao_how) +{ + AO_CREATE(ctx, domid, ao_how); + libxl__ao_device *aodev; + + GCNEW(aodev); + libxl__prepare_ao_device(ao, aodev); + aodev->action = LIBXL__DEVICE_ACTION_ADD; + aodev->callback = device_addrm_aocomplete; + + libxl__device_p9_add(egc, domid, p9, aodev); + + return AO_INPROGRESS; +} + #define libxl_device_p9_list NULL #define libxl_device_p9_compare NULL