From nobody Mon Feb 9 16:44:49 2026 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; dkim=pass; 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=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1698832264; cv=none; d=zohomail.com; s=zohoarc; b=mFI9zV13/LngrfkMQt0dbnekZMMRc1aXdEk0EyKnXNxtF4pT/Uge0942cEGOPmS7gOXP3gyKTwkkksUFTBxRA/lAI8ghT+8RcUN9k8sYAxR0iZ+KQ77kfmI2bM1iIlJNRDo+dzau8f02W60CPp8SyE598ZaL58Btn1F3z8j187s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698832264; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=O8ibJTSvpdBw5QYEwaYDmGyzTvOSMmm8TeHf7YRE1kM=; b=Oc7R3y/X9Rv6N88ybr6KOfaR2mnXY3xWTSSegllgS8ac8pe/DIvCkVfgaoVB2GQyYpI4dQFoXvf4EHkNdhUgKzs8ZthzMm2eu8fIfP/GDI/xtCcOApgAI8YL6IVgnGEcmmAcHLgg+R6swZSmJMxCAIim0T29fL/BQRBH+FkzR6Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1698832264057985.8255606470047; Wed, 1 Nov 2023 02:51:04 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.626315.976479 (Exim 4.92) (envelope-from ) id 1qy7ry-0002tp-LN; Wed, 01 Nov 2023 09:50:38 +0000 Received: by outflank-mailman (output) from mailman id 626315.976479; Wed, 01 Nov 2023 09:50:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qy7ry-0002ti-HN; Wed, 01 Nov 2023 09:50:38 +0000 Received: by outflank-mailman (input) for mailman id 626315; Wed, 01 Nov 2023 09:50:36 +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 1qy7di-0005E0-KQ for xen-devel@lists.xenproject.org; Wed, 01 Nov 2023 09:35:54 +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 0d53b678-789a-11ee-98d6-6d05b1d4d9a1; Wed, 01 Nov 2023 10:35:54 +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 B5C2A1F74A; Wed, 1 Nov 2023 09:35:53 +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 8814D13460; Wed, 1 Nov 2023 09:35:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id WHvNH/kbQmWoCQAAMHmgww (envelope-from ); Wed, 01 Nov 2023 09:35:53 +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: 0d53b678-789a-11ee-98d6-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1698831353; 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=O8ibJTSvpdBw5QYEwaYDmGyzTvOSMmm8TeHf7YRE1kM=; b=NYPZa+Qtfa6ex1QlDJbLznL9uTxygKINAzDvHcaSd7HR9tN2w136SHDzRvvt+HJhXXOJR4 4Y22JZdLc4JC+hqPZnA3p5Bzw8sI29uD3iV338qi9Zmy6jam6KZUq/7IUSU+powDzybeX4 OaCxlTf9M6X+uOyoowsh2PVDYZpwlHQ= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD Subject: [PATCH 26/29] tools/xenstored: add helpers for filename handling Date: Wed, 1 Nov 2023 10:33:22 +0100 Message-Id: <20231101093325.30302-27-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 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1698832266068100001 Content-Type: text/plain; charset="utf-8" Add some helpers for handling filenames which might need different implementations between stubdom and daemon environments: - expansion of relative filenames (those are not really defined today, just expand them to be relative to /var/lib/xen/xenstore) - expansion of xenstore_daemon_rundir() (used e.g. for saving the state file in case of live update - needs to be unchanged in the daemon case, but should result in /var/lib/xen/xenstore for stubdom) Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- tools/xenstored/core.c | 9 ++++++++- tools/xenstored/core.h | 3 +++ tools/xenstored/lu_daemon.c | 4 ++-- tools/xenstored/minios.c | 5 +++++ tools/xenstored/posix.c | 6 ++++++ 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c index 1764b1af4e..9f48d91027 100644 --- a/tools/xenstored/core.c +++ b/tools/xenstored/core.c @@ -158,6 +158,13 @@ void trace_destroy(const void *data, const char *type) trace("obj: DESTROY %s %p\n", type, data); } =20 +char *absolute_filename(const void *ctx, const char *filename) +{ + if (filename[0] !=3D '/') + return talloc_asprintf(ctx, XENSTORE_LIB_DIR "/%s", filename); + return talloc_strdup(ctx, filename); +} + /** * Signal handler for SIGHUP, which requests that the trace log is reopened * (in the main loop). A single byte is written to reopen_log_pipe, to aw= aken @@ -2995,7 +3002,7 @@ int main(int argc, char *argv[]) =20 signal(SIGHUP, trigger_reopen_log); if (tracefile) - tracefile =3D talloc_strdup(NULL, tracefile); + tracefile =3D absolute_filename(NULL, tracefile); =20 #ifndef NO_LIVE_UPDATE /* Read state in case of live update. */ diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h index 48ff659ec5..d3cd4a4c8a 100644 --- a/tools/xenstored/core.h +++ b/tools/xenstored/core.h @@ -391,6 +391,9 @@ evtchn_port_t get_xenbus_evtchn(void); void mount_9pfs(void); #endif =20 +const char *xenstore_rundir(void); +char *absolute_filename(const void *ctx, const char *filename); + /* Write out the pidfile */ void write_pidfile(const char *pidfile); =20 diff --git a/tools/xenstored/lu_daemon.c b/tools/xenstored/lu_daemon.c index 71bcabadd3..6351111ab0 100644 --- a/tools/xenstored/lu_daemon.c +++ b/tools/xenstored/lu_daemon.c @@ -24,7 +24,7 @@ void lu_get_dump_state(struct lu_dump_state *state) state->size =3D 0; =20 state->filename =3D talloc_asprintf(NULL, "%s/state_dump", - xenstore_daemon_rundir()); + xenstore_rundir()); if (!state->filename) barf("Allocation failure"); =20 @@ -65,7 +65,7 @@ FILE *lu_dump_open(const void *ctx) int fd; =20 filename =3D talloc_asprintf(ctx, "%s/state_dump", - xenstore_daemon_rundir()); + xenstore_rundir()); if (!filename) return NULL; =20 diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c index e5a3684df6..104f37587b 100644 --- a/tools/xenstored/minios.c +++ b/tools/xenstored/minios.c @@ -89,3 +89,8 @@ void mount_9pfs(void) { create_thread("mount-9pfs", mount_thread, NULL); } + +const char *xenstore_rundir(void) +{ + return XENSTORE_LIB_DIR; +} diff --git a/tools/xenstored/posix.c b/tools/xenstored/posix.c index 7e03dd982d..d02d0e446f 100644 --- a/tools/xenstored/posix.c +++ b/tools/xenstored/posix.c @@ -22,6 +22,7 @@ #include #include #include +#include =20 #include "utils.h" #include "core.h" @@ -157,3 +158,8 @@ void *xenbus_map(void) =20 return addr; } + +const char *xenstore_rundir(void) +{ + return xenstore_daemon_rundir(); +} --=20 2.35.3