From patchwork Fri Nov 10 16:07:56 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: 13452520 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 54976C4332F for ; Fri, 10 Nov 2023 16:18:14 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.630551.983500 (Exim 4.92) (envelope-from ) id 1r1UCp-00025M-4f; Fri, 10 Nov 2023 16:18:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 630551.983500; Fri, 10 Nov 2023 16:18:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r1UCp-00025F-1c; Fri, 10 Nov 2023 16:18:03 +0000 Received: by outflank-mailman (input) for mailman id 630551; Fri, 10 Nov 2023 16:18:02 +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 1r1U58-0004cS-6w for xen-devel@lists.xenproject.org; Fri, 10 Nov 2023 16:10:06 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [2001:67c:2178:6::1c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 9be5011b-7fe3-11ee-9b0e-b553b5be7939; Fri, 10 Nov 2023 17:10:04 +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-out1.suse.de (Postfix) with ESMTPS id 6490D219B4; Fri, 10 Nov 2023 16:10:04 +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 34DB813398; Fri, 10 Nov 2023 16:10:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2kyUC9xVTmVVCQAAMHmgww (envelope-from ); Fri, 10 Nov 2023 16:10:04 +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: 9be5011b-7fe3-11ee-9b0e-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1699632604; 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=xXrI1g3Tvz8/s3KD+jk6UgdILP23SjhAZanYf4v0CdE=; b=EUKZTg0W+7XorSEy1L1YhxkUCzrrBiMgIauLfCY1hfNf0HLs55rTlEAlJVPfH8ey1ARC7L 2tjNKt2sPStZB/lRJBFVrVGJODWY49v8L8tOwR17JEvI7SGNQV9zGJ82Q/mlAawRrLzhEY YvVFKZQQlCSU8a5r6+MukxmCzG+UtgY= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD , Jason Andryuk Subject: [PATCH v2 21/29] tools/xenstored: add early_init() function Date: Fri, 10 Nov 2023 17:07:56 +0100 Message-Id: <20231110160804.29021-22-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231110160804.29021-1-jgross@suse.com> References: <20231110160804.29021-1-jgross@suse.com> MIME-Version: 1.0 Some xenstored initialization needs to be done in the daemon case only, so split it out into a new early_init() function being a stub in the stubdom case. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- V2: - rename function - move patch earlier in the series --- tools/xenstored/core.c | 6 +----- tools/xenstored/core.h | 3 +++ tools/xenstored/minios.c | 3 +++ tools/xenstored/posix.c | 11 +++++++++++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c index edd07711db..0c14823fb0 100644 --- a/tools/xenstored/core.c +++ b/tools/xenstored/core.c @@ -2933,11 +2933,7 @@ int main(int argc, char *argv[]) if (optind != argc) barf("%s: No arguments desired", argv[0]); - reopen_log(); - - /* Make sure xenstored directory exists. */ - /* Errors ignored here, will be reported when we open files */ - mkdir(xenstore_daemon_rundir(), 0755); + early_init(); if (dofork) { openlog("xenstored", 0, LOG_DAEMON); diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h index 480b0f5f7b..d0ac587f8f 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. */ @@ -384,6 +386,7 @@ static inline bool domain_is_unprivileged(const struct connection *conn) /* Return the event channel used by xenbus. */ evtchn_port_t get_xenbus_evtchn(void); +void early_init(void); /* Write out the pidfile */ void write_pidfile(const char *pidfile); diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c index 0779efbf91..0cdec3ae51 100644 --- a/tools/xenstored/minios.c +++ b/tools/xenstored/minios.c @@ -54,3 +54,6 @@ void unmap_xenbus(void *interface) xengnttab_unmap(*xgt_handle, interface, 1); } +void early_init(void) +{ +} diff --git a/tools/xenstored/posix.c b/tools/xenstored/posix.c index 7e03dd982d..fcb7791bd7 100644 --- a/tools/xenstored/posix.c +++ b/tools/xenstored/posix.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "utils.h" #include "core.h" @@ -157,3 +158,13 @@ void *xenbus_map(void) return addr; } + +void early_init(void) +{ + reopen_log(); + + /* Make sure xenstored directories exist. */ + /* Errors ignored here, will be reported when we open files */ + mkdir(xenstore_daemon_rundir(), 0755); + mkdir(XENSTORE_LIB_DIR, 0755); +}