From nobody Sun Nov 24 19:46:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1721114952; cv=none; d=zohomail.com; s=zohoarc; b=PO6NMGYmXJOXJwjwjJpKn7au5wMy5dIVGo3DcctxiBMeRvwYlEtVPFFkWs3S6ElyQjkctdXOgrRQ/sor2aflgVE92Ow4GXcsz6aeelUPlc9H4/VwwH4HpZRRVgnkZOXyZBV0F3pDbU8kPrPazEXm5wFpUnxDjHmt/z9dhdviir0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721114952; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=qNvh0sTzcav+0om+9KQZskLO4kNiX/u7v2HI6UKmLHk=; b=YX25nTNs+6h01+bR/bxXN1fs/2XpTUoyz1NsNqg+YVpUQ8SW5R6Z5eNtNum7QxRZTVwGA3RWe0dJdsMz6QnTzJ46g3Vq1ybaYsCYfrYG9tXq9j/XaKYEeuK8sPSLrlYmhBRuoPe7F3q5Sbam02l/D8kuj7lPB5mIv+t2t02dJeg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721114952764327.2105036603597; Tue, 16 Jul 2024 00:29:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTcbc-0004hq-SI; Tue, 16 Jul 2024 03:28:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sTcbb-0004be-9O for qemu-devel@nongnu.org; Tue, 16 Jul 2024 03:28:11 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTcbZ-0006SI-In for qemu-devel@nongnu.org; Tue, 16 Jul 2024 03:28:11 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-70af22a9c19so3833944b3a.2 for ; Tue, 16 Jul 2024 00:28:09 -0700 (PDT) Received: from localhost ([157.82.128.7]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1fc0bc52568sm51780885ad.290.2024.07.16.00.28.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Jul 2024 00:28:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1721114888; x=1721719688; darn=nongnu.org; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=qNvh0sTzcav+0om+9KQZskLO4kNiX/u7v2HI6UKmLHk=; b=LerFN5urRqZgKez4ESAfHVp+SvfTN7fa/1tyWLskur+bKSL1usHxmL/JA6p9sppSUj 6oMcC49hsbOJ5mp7fgY97I1NpP4RXzVNDNhSxWPP6w/0juYWRSvEise4MOe8v31fM2Wt IFZzAvsEFpDnMVrsBOOQgsTHWqL4gMPjijkc4JCvE5yPnzvPszu6vWXV7ZTMKTY+OKxl YdLfK3FyNBN00hz9ph39+CSUvid3nQhSsUoeCabrT55pYNf0ImuHoZkBEzyMF/RI7cjF sk8YzpXBoAXH9hDdxzHo1LThZAtFryt6H1atoKDAJb3YcSF9eqTos3bNis7XGjgSfsfZ MEEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721114888; x=1721719688; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qNvh0sTzcav+0om+9KQZskLO4kNiX/u7v2HI6UKmLHk=; b=e0vwidUowt+6leTCRMdY/hTKK6Tcc+/7pw2kFGRxcJReqTTjhpE/+KxQhupJICOR7N L2xKJ4TyAPtIjaD+o66mMcxhwwBfdzOxT3/oyegkRova9rEpLfCGpdup/m4lIUtvzTUQ LlTqjNqyFG509WIXP9I809mCorXVyHxPnrihCtgy8kX545MWfk5A+ivk3bfOzqN4rtvc t7p5gNXZVUAE0yHBieD1A1BzGxuz8gJf1HXcpj9BEiaQqc7tY21zAUltOzUmnsOA/4JL 9VcN2EYVaByDx54CQ4taO10bOdsCEUwHLwewG3RGPmtCf1d35SJr1kNiFEY4jvOP4PoU meBA== X-Gm-Message-State: AOJu0YwE4QyLjO2WvBe5GlUw2Y3rt0j42dBGorm4W8yuw9RcZdC/6+T4 EhcVOmYg7g0NQba9nCwPtRdCLxetBg/x3tYUh5Rjuq9WohzV78lDeeRKP3jglnU= X-Google-Smtp-Source: AGHT+IFqa3dZaRCSXfEBl+BtO2+GcZJyqDHq2hTmhGre9DnwRCjm9IDiG7gqnIbVtB4XKEdTTdSi3g== X-Received: by 2002:a05:6a20:3d88:b0:1c0:ef24:413e with SMTP id adf61e73a8af0-1c3f1295d2cmr1383042637.36.1721114888199; Tue, 16 Jul 2024 00:28:08 -0700 (PDT) From: Akihiko Odaki Date: Tue, 16 Jul 2024 16:27:32 +0900 Subject: [PATCH v4 2/7] ivshmem-server: Use qemu_get_runtime_dir() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240716-run-v4-2-5f7a29631168@daynix.com> References: <20240716-run-v4-0-5f7a29631168@daynix.com> In-Reply-To: <20240716-run-v4-0-5f7a29631168@daynix.com> To: qemu-devel@nongnu.org, qemu-block@nongnu.org, virtio-fs@redhat.com, Yuval Shaia , Marcel Apfelbaum , Konstantin Kostiuk , Michael Roth , Paolo Bonzini , Fam Zheng , "Dr . David Alan Gilbert" , Stefan Hajnoczi , Gerd Hoffmann , Stefan Weil , Yan Vugenfirer , Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::42a; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42a.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1721114953260116600 qemu_get_runtime_dir() is used to construct the default PID file path. Signed-off-by: Akihiko Odaki Message-Id: <20230921075425.16738-3-akihiko.odaki@daynix.com> --- contrib/ivshmem-server/main.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/contrib/ivshmem-server/main.c b/contrib/ivshmem-server/main.c index 5901f17707e0..313124dd4520 100644 --- a/contrib/ivshmem-server/main.c +++ b/contrib/ivshmem-server/main.c @@ -14,7 +14,6 @@ =20 #define IVSHMEM_SERVER_DEFAULT_VERBOSE 0 #define IVSHMEM_SERVER_DEFAULT_FOREGROUND 0 -#define IVSHMEM_SERVER_DEFAULT_PID_FILE "/var/run/ivshmem-server.pid" #define IVSHMEM_SERVER_DEFAULT_UNIX_SOCK_PATH "/tmp/ivshmem_socket" #define IVSHMEM_SERVER_DEFAULT_SHM_PATH "ivshmem" #define IVSHMEM_SERVER_DEFAULT_SHM_SIZE (4 * 1024 * 1024) @@ -35,15 +34,23 @@ typedef struct IvshmemServerArgs { unsigned n_vectors; } IvshmemServerArgs; =20 +static char *ivshmem_server_get_default_pid_file(void) +{ + g_autofree char *run =3D qemu_get_runtime_dir(); + return g_build_filename(run, "ivshmem-server.pid", NULL); +} + static void ivshmem_server_usage(const char *progname) { + g_autofree char *pid_file =3D ivshmem_server_get_default_pid_file(); + printf("Usage: %s [OPTION]...\n" " -h: show this help\n" " -v: verbose mode\n" " -F: foreground mode (default is to daemonize)\n" " -p : path to the PID file (used in daemon mode onl= y)\n" - " default " IVSHMEM_SERVER_DEFAULT_PID_FILE "\n" + " default %s\n" " -S : path to the unix socket to listen to\= n" " default " IVSHMEM_SERVER_DEFAULT_UNIX_SOCK_PATH "\n" " -M : POSIX shared memory object to use\n" @@ -54,7 +61,7 @@ ivshmem_server_usage(const char *progname) " default %u\n" " -n : number of vectors\n" " default %u\n", - progname, IVSHMEM_SERVER_DEFAULT_SHM_SIZE, + progname, pid_file, IVSHMEM_SERVER_DEFAULT_SHM_SIZE, IVSHMEM_SERVER_DEFAULT_N_VECTORS); } =20 @@ -189,10 +196,10 @@ main(int argc, char *argv[]) { IvshmemServer server; struct sigaction sa, sa_quit; + g_autofree char *default_pid_file =3D NULL; IvshmemServerArgs args =3D { .verbose =3D IVSHMEM_SERVER_DEFAULT_VERBOSE, .foreground =3D IVSHMEM_SERVER_DEFAULT_FOREGROUND, - .pid_file =3D IVSHMEM_SERVER_DEFAULT_PID_FILE, .unix_socket_path =3D IVSHMEM_SERVER_DEFAULT_UNIX_SOCK_PATH, .shm_path =3D IVSHMEM_SERVER_DEFAULT_SHM_PATH, .use_shm_open =3D true, @@ -207,6 +214,11 @@ main(int argc, char *argv[]) */ printf("*** Example code, do not use in production ***\n"); =20 + qemu_init_exec_dir(argv[0]); + + default_pid_file =3D ivshmem_server_get_default_pid_file(); + args.pid_file =3D default_pid_file; + /* parse arguments, will exit on error */ ivshmem_server_parse_args(&args, argc, argv); =20 --=20 2.45.2