From patchwork Wed Nov 1 09:33:16 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: 13442682 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 C3C64C4332F for ; Wed, 1 Nov 2023 09:46:14 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.626286.976418 (Exim 4.92) (envelope-from ) id 1qy7nR-0006KG-R8; Wed, 01 Nov 2023 09:45:57 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 626286.976418; Wed, 01 Nov 2023 09:45:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qy7nR-0006K9-O6; Wed, 01 Nov 2023 09:45:57 +0000 Received: by outflank-mailman (input) for mailman id 626286; Wed, 01 Nov 2023 09:45:56 +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 1qy7dC-0005sN-4K for xen-devel@lists.xenproject.org; Wed, 01 Nov 2023 09:35:22 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [2001:67c:2178:6::1d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f94e2189-7899-11ee-9b0e-b553b5be7939; Wed, 01 Nov 2023 10:35:20 +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 390291F750; Wed, 1 Nov 2023 09:35:20 +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 0911B13460; Wed, 1 Nov 2023 09:35:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0vbUANgbQmVpCQAAMHmgww (envelope-from ); Wed, 01 Nov 2023 09:35:20 +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: f94e2189-7899-11ee-9b0e-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1698831320; 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=7wErX+mI9M5W1zZSMWgX1THrvuDdFvzbJX+7TeHAugY=; b=M8XlYDPCIN4yQI7dVhoSv4MdaPN+uTAMQJ/C7Ahk02piswSTH+LMe0Ym9QORIQuBQKk8ly DFfgeOODy7P9tSKFg/xAASLd8SSb7z8xpMRNrhi37+fHQFm5dqp/9GypFZUgMo/imV1ave G7T7FhzT3q0rIQn3ll6HNLk/12dI+mk= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD Subject: [PATCH 20/29] tools: add 9pfs device to xenstore-stubdom Date: Wed, 1 Nov 2023 10:33:16 +0100 Message-Id: <20231101093325.30302-21-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 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 = "xenlogd" - path = "/var/lib/xen/xenstore" 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 --- tools/helpers/init-xenstore-domain.c | 2 ++ tools/include/libxl.h | 17 ++++++++++++++++ tools/libs/light/libxl_9pfs.c | 29 ++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/tools/helpers/init-xenstore-domain.c b/tools/helpers/init-xenstore-domain.c index 140ed610ae..a65abae2ac 100644 --- a/tools/helpers/init-xenstore-domain.c +++ b/tools/helpers/init-xenstore-domain.c @@ -543,6 +543,8 @@ int main(int argc, char** argv) } libxl_console_add_xenstore(ctx, domid, 0, console_evtchn, console_gfn, NULL); + libxl_p9_add_xenstore(ctx, domid, 0, LIBXL_P9_TYPE_XENLOGD, "xen", + XEN_LIB_DIR"/xenstore", 0, 0, 0, 0, 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 907aa0a330..ab8a67f50a 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_p9_add_xenstore() in libxl. + */ +#define LIBXL_HAVE_P9_ADD_XENSTORE 1 + /* * libxl ABI compatibility * @@ -2060,6 +2067,16 @@ 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_p9_add_xenstore writes the Xenstore entries for a domain's + * primary 9pfs device based on domid, backend type and device parameters. + */ +int libxl_p9_add_xenstore(libxl_ctx *ctx, uint32_t domid, uint32_t backend, + libxl_p9_type type, char *tag, char *path, + unsigned int max_space, unsigned int max_files, + unsigned int max_open_files, bool auto_delete, + 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 0b9d84dce9..3297389493 100644 --- a/tools/libs/light/libxl_9pfs.c +++ b/tools/libs/light/libxl_9pfs.c @@ -174,6 +174,35 @@ static void libxl__device_p9_add(libxl__egc *egc, uint32_t domid, aodev->callback(egc, aodev); } +int libxl_p9_add_xenstore(libxl_ctx *ctx, uint32_t domid, uint32_t backend, + libxl_p9_type type, char *tag, char *path, + unsigned int max_space, unsigned int max_files, + unsigned int max_open_files, bool auto_delete, + const libxl_asyncop_how *ao_how) +{ + AO_CREATE(ctx, domid, ao_how); + libxl__ao_device *aodev; + libxl_device_p9 p9 = { .backend_domid = backend, + .tag = tag, + .path = path, + .security_model = "none", + .type = type, + .max_space = max_space, + .max_files = max_files, + .max_open_files = max_open_files, + .auto_delete = auto_delete, + }; + + 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