From patchwork Tue Jul 16 07:27:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13734064 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.gnu.org (lists.gnu.org [209.51.188.17]) (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 15A38C3DA59 for ; Tue, 16 Jul 2024 07:28:26 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTcbZ-0004Uw-MB; Tue, 16 Jul 2024 03:28:09 -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 1sTcbX-0004MV-JL for qemu-devel@nongnu.org; Tue, 16 Jul 2024 03:28:07 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTcbV-0006Rh-TD for qemu-devel@nongnu.org; Tue, 16 Jul 2024 03:28:07 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1fbfb8e5e0cso32951875ad.0 for ; Tue, 16 Jul 2024 00:28:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1721114883; x=1721719683; 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=gtC7q0ahDp8oBSQjb8wrhk1mVdCAYcUwBwrlKBZsqds=; b=L/usko57OVuJgVMzyLZoqj76y2alzfsIIi532QD7Jl0yh+tLyT0pYZSZzQft5K2ZzS 3K7q4NpDEpB7mLBcev9E/WwBzfi1ti8bbUpaI4h5k8S0HWNSKVxNpMetFFUxg+yC3eq8 RamuEt6ggNxQ7KWS0CM/ooWQH6E015iryAhTzTVHU00aALPXNcjx/MGG8zwgbo3bP7kF xoueyFQJn4Z1SmhbSCUeDbuDa5tasvZYTYg5IFM2y2qSsmdgy81iBHRBCz4DgQ4l5s8C mvVYFfutCDbpyFw1WO6vehM7kQ3dj4q1K1QRvzX+sFPtydbb1SQQNag0TdKhCW6R7Q2V iQnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721114883; x=1721719683; 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=gtC7q0ahDp8oBSQjb8wrhk1mVdCAYcUwBwrlKBZsqds=; b=nr+mDNYqJ8B+JbSAgKzDm7HkNBNLV6vaQKfemNlDpI06JmK9aD6bUWYhSuL7Z60iuP +QJhGsM13qI98MWHCReW4A28qVdnVfe2AIH7bBdqjhJGjN1ojCHrSXESWcL5gjXD5sEI Dq5pgXZ0clsXNxRzb+UajD0v+ELbGjzrJpK2OV1ZTsQjezMuwDhkVmZqH2bt5Gvch5tu 0YO1hjH4wBGYfIXJ50xS2SJR6b5soslfnQ6jLCy9nGAk7CiulHHSxhXhyFxocMvao05u ZdOv7z53F63+mVu/1tR2sFKLFXBe/0mtlTcdSg98N3MZqahYQsO35ZO7hbGHc+3MUzzr qbkQ== X-Gm-Message-State: AOJu0Ywuyvo7bJRkef6V8JCUvcUKFeNfgx6TsZ5QJXii05nJWEluHhb4 9I3C2DZehmSugj49gtJrys6A+lDep3OF2/8b4cD3cWTOBhlBFRa/kixdj2AH2yI= X-Google-Smtp-Source: AGHT+IH83rGAZMP/1OOd2fQZmoyvUCzUIZFQ4e6Req4vKwqodSM5Yc94pNqraANcHPuVIufvouliyw== X-Received: by 2002:a17:902:c40a:b0:1fb:72ea:376 with SMTP id d9443c01a7336-1fc3da1369fmr9808265ad.65.1721114883573; Tue, 16 Jul 2024 00:28:03 -0700 (PDT) Received: from localhost ([157.82.128.7]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1fc0bc382e6sm51626725ad.194.2024.07.16.00.28.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Jul 2024 00:28:03 -0700 (PDT) From: Akihiko Odaki Date: Tue, 16 Jul 2024 16:27:31 +0900 Subject: [PATCH v4 1/7] util: Introduce qemu_get_runtime_dir() MIME-Version: 1.0 Message-Id: <20240716-run-v4-1-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: none client-ip=2607:f8b0:4864:20::635; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x635.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=unavailable 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org qemu_get_runtime_dir() returns a dynamically allocated directory path that is appropriate for storing runtime files. It corresponds to "run" directory in Unix. With a tree-wide search, it was found that there are several cases where such a functionality is implemented so let's have one as a common utlity function. A notable feature of qemu_get_runtime_dir() is that it uses $XDG_RUNTIME_DIR if available. While the function is often called by executables which requires root privileges, it is still possible that they are called from a user without privilege to write the system runtime directory. In fact, I decided to write this patch when I ran virtiofsd in a Linux namespace created by a normal user and realized it tries to write the system runtime directory, not writable in this case. $XDG_RUNTIME_DIR should provide a writable directory in such cases. This function does not use qemu_get_local_state_dir() or its logic for Windows. Actually the implementation of qemu_get_local_state_dir() for Windows seems not right as it calls g_get_system_data_dirs(), which refers to $XDG_DATA_DIRS. In Unix terminology, it is basically "/usr/share", not "/var", which qemu_get_local_state_dir() is intended to provide. Instead, this function try to use the following in order: - $XDG_RUNTIME_DIR - LocalAppData folder - get_relocated_path(CONFIG_QEMU_LOCALSTATEDIR "/run") This function does not use g_get_user_runtime_dir() either as it falls back to g_get_user_cache_dir() when $XDG_DATA_DIRS is not available. In the case, we rather use: get_relocated_path(CONFIG_QEMU_LOCALSTATEDIR "/run") Signed-off-by: Akihiko Odaki Message-Id: <20230921075425.16738-2-akihiko.odaki@daynix.com> --- include/qemu/osdep.h | 12 ++++++++++++ util/oslib-posix.c | 11 +++++++++++ util/oslib-win32.c | 26 ++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 191916f38e6d..fe8609fc1375 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -670,6 +670,18 @@ void qemu_set_cloexec(int fd); */ char *qemu_get_local_state_dir(void); +/** + * qemu_get_runtime_dir: + * + * Return a dynamically allocated directory path that is appropriate for storing + * runtime files. It corresponds to "run" directory in Unix, and uses + * $XDG_RUNTIME_DIR if available. + * + * The caller is responsible for releasing the value returned with g_free() + * after use. + */ +char *qemu_get_runtime_dir(void); + /** * qemu_getauxval: * @type: the auxiliary vector key to lookup diff --git a/util/oslib-posix.c b/util/oslib-posix.c index e76441695bdc..9599509a9aa7 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -278,6 +278,17 @@ qemu_get_local_state_dir(void) return get_relocated_path(CONFIG_QEMU_LOCALSTATEDIR); } +char * +qemu_get_runtime_dir(void) +{ + char *env = getenv("XDG_RUNTIME_DIR"); + if (env) { + return g_strdup(env); + } + + return get_relocated_path(CONFIG_QEMU_LOCALSTATEDIR "/run"); +} + void qemu_set_tty_echo(int fd, bool echo) { struct termios tty; diff --git a/util/oslib-win32.c b/util/oslib-win32.c index b623830d624f..8c5a02ee881d 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -27,6 +27,8 @@ */ #include "qemu/osdep.h" +#include +#include #include #include "qapi/error.h" #include "qemu/main-loop.h" @@ -237,6 +239,30 @@ qemu_get_local_state_dir(void) return g_strdup(data_dirs[0]); } +char * +qemu_get_runtime_dir(void) +{ + size_t size = GetEnvironmentVariableA("XDG_RUNTIME_DIR", NULL, 0); + if (size) { + char *env = g_malloc(size); + GetEnvironmentVariableA("XDG_RUNTIME_DIR", env, size); + return env; + } + + PWSTR wpath; + const wchar_t *cwpath; + if (!SHGetKnownFolderPath(&FOLDERID_LocalAppData, KF_FLAG_DEFAULT, NULL, &wpath)) { + cwpath = wpath; + size = wcsrtombs(NULL, &cwpath, 0, &(mbstate_t){0}) + 1; + char *path = g_malloc(size); + wcsrtombs(path, &cwpath, size, &(mbstate_t){0}); + CoTaskMemFree(wpath); + return path; + } + + return get_relocated_path(CONFIG_QEMU_LOCALSTATEDIR "/run"); +} + void qemu_set_tty_echo(int fd, bool echo) { HANDLE handle = (HANDLE)_get_osfhandle(fd); From patchwork Tue Jul 16 07:27:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13734066 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.gnu.org (lists.gnu.org [209.51.188.17]) (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 BD3FAC3DA5D for ; Tue, 16 Jul 2024 07:29:12 +0000 (UTC) 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) 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) 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) 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 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: 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 @@ #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; +static char *ivshmem_server_get_default_pid_file(void) +{ + g_autofree char *run = 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 = 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 only)\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); } @@ -189,10 +196,10 @@ main(int argc, char *argv[]) { IvshmemServer server; struct sigaction sa, sa_quit; + g_autofree char *default_pid_file = NULL; IvshmemServerArgs args = { .verbose = IVSHMEM_SERVER_DEFAULT_VERBOSE, .foreground = IVSHMEM_SERVER_DEFAULT_FOREGROUND, - .pid_file = IVSHMEM_SERVER_DEFAULT_PID_FILE, .unix_socket_path = IVSHMEM_SERVER_DEFAULT_UNIX_SOCK_PATH, .shm_path = IVSHMEM_SERVER_DEFAULT_SHM_PATH, .use_shm_open = true, @@ -207,6 +214,11 @@ main(int argc, char *argv[]) */ printf("*** Example code, do not use in production ***\n"); + qemu_init_exec_dir(argv[0]); + + default_pid_file = ivshmem_server_get_default_pid_file(); + args.pid_file = default_pid_file; + /* parse arguments, will exit on error */ ivshmem_server_parse_args(&args, argc, argv); From patchwork Tue Jul 16 07:27:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13734072 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.gnu.org (lists.gnu.org [209.51.188.17]) (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 27EE9C3DA49 for ; Tue, 16 Jul 2024 07:30:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTcbu-0005uW-DI; Tue, 16 Jul 2024 03:28:30 -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 1sTcbs-0005kF-3g for qemu-devel@nongnu.org; Tue, 16 Jul 2024 03:28:29 -0400 Received: from mail-ot1-x32c.google.com ([2607:f8b0:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTcbf-0006T5-Ts for qemu-devel@nongnu.org; Tue, 16 Jul 2024 03:28:27 -0400 Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-70847d0cb1fso2856702a34.3 for ; Tue, 16 Jul 2024 00:28:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1721114893; x=1721719693; 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=jnVBgXlsSgyb7y1XOm3dq34QzfGRm0o7Ff/hpdF16J0=; b=QXnppr9lz8/5+suwzwNl+y5+hsFmBsroRgb8D/8Br+6+fwQVlLjEIhApEP46VpX/H3 Bgy6icK+eRkmV6NI1t3b68Sh6q6hfkHRX0eYmW/53IV1rbeWhAs+Ealakfw47WvVY8lp vI29u6cr3THcH7uwnCHXcadVH6y05NLray4JEyBuxwaI53JwKgLH/K+Bx5Jpj+1rsJHf njIFf8memrmol0X/zNrY6rzmUA5jUgPSUgAbbJsgf4TPf3LsZ17hgmF2uLzomefUTaA0 lhkF7NMh4uDiu1tozFEe9N6i8wImPLRPtjrgIX99r4l8xl5xW7BqPLxv0YWzYVTC4t84 85rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721114893; x=1721719693; 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=jnVBgXlsSgyb7y1XOm3dq34QzfGRm0o7Ff/hpdF16J0=; b=tQBPEkf5dn5pVNTcf8Ge4Uk/VqNUFQMLBGE19W/jhWAjWYC2/qsRRLSVkvxQqXWaWD FuvVd26ZRdU0EV2GnUesLkItmnBy7ZdgbM3G4WI3/UY4z6sVR2Wb6kh/VupC4hT7kOtK Ir/xHtNZEGFlQYmcO7f+PZ95wy3a54+4h6FWCHuKhKVBvSjujUjM3u9oPO070M7omSFF TCcMQPpXzG9TkKZIEUo8VliLyFFAso5fZ9jazLv0h70+cNLoeA8XIUZRvsKg75xNJ9gY pNNzo/ZEUgITrQqgJBsAxceqOjkfgB8QZ6jGy1E6DRNJ7+IaC8GHsWgbHVf/3jBLynd/ 9U0A== X-Gm-Message-State: AOJu0Ywn1uTvYu23FYTfrmX4KcO9XFbEYJcHsXcbPAqS1W2oIMqYDYmh oSTgm+FGmgnIES9SnrEFiKBYZ/Lii5CTo48u7GNAbzsSvJ7NMCxYFV/xmoAUEbw= X-Google-Smtp-Source: AGHT+IHW1fxpD7iS5EiceIdlR+QbMGGGRt3QLC9qgdLLAe9827VTS3pptlwm3plRMMRY7flf/OHYow== X-Received: by 2002:a05:6830:6d16:b0:708:d84d:f628 with SMTP id 46e09a7af769-708d99bc4cbmr1778311a34.31.1721114892924; Tue, 16 Jul 2024 00:28:12 -0700 (PDT) Received: from localhost ([157.82.128.7]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-70b7ec7c5b9sm5628994b3a.120.2024.07.16.00.28.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Jul 2024 00:28:12 -0700 (PDT) From: Akihiko Odaki Date: Tue, 16 Jul 2024 16:27:33 +0900 Subject: [PATCH v4 3/7] qga: Use qemu_get_runtime_dir() MIME-Version: 1.0 Message-Id: <20240716-run-v4-3-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: none client-ip=2607:f8b0:4864:20::32c; envelope-from=akihiko.odaki@daynix.com; helo=mail-ot1-x32c.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, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org qemu_get_runtime_dir() is used to construct the default state directory. Signed-off-by: Akihiko Odaki Message-Id: <20230921075425.16738-5-akihiko.odaki@daynix.com> --- qga/main.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/qga/main.c b/qga/main.c index f4d5f15bb3d5..4bb6f7e27b66 100644 --- a/qga/main.c +++ b/qga/main.c @@ -45,12 +45,11 @@ #define QGA_VIRTIO_PATH_DEFAULT "/dev/virtio-ports/org.qemu.guest_agent.0" #endif /* CONFIG_BSD */ #define QGA_SERIAL_PATH_DEFAULT "/dev/ttyS0" -#define QGA_STATE_RELATIVE_DIR "run" #else #define QGA_VIRTIO_PATH_DEFAULT "\\\\.\\Global\\org.qemu.guest_agent.0" -#define QGA_STATE_RELATIVE_DIR "qemu-ga" #define QGA_SERIAL_PATH_DEFAULT "COM1" #endif +#define QGA_STATE_RELATIVE_DIR "qemu-ga" #ifdef CONFIG_FSFREEZE #define QGA_FSFREEZE_HOOK_DEFAULT CONFIG_QEMU_CONFDIR "/fsfreeze-hook" #endif @@ -129,12 +128,12 @@ static void stop_agent(GAState *s, bool requested); static void init_dfl_pathnames(void) { - g_autofree char *state = qemu_get_local_state_dir(); + g_autofree char *run = qemu_get_runtime_dir(); g_assert(dfl_pathnames.state_dir == NULL); g_assert(dfl_pathnames.pidfile == NULL); - dfl_pathnames.state_dir = g_build_filename(state, QGA_STATE_RELATIVE_DIR, NULL); - dfl_pathnames.pidfile = g_build_filename(state, QGA_STATE_RELATIVE_DIR, "qemu-ga.pid", NULL); + dfl_pathnames.state_dir = g_build_filename(run, QGA_STATE_RELATIVE_DIR, NULL); + dfl_pathnames.pidfile = g_build_filename(run, QGA_STATE_RELATIVE_DIR, "qemu-ga.pid", NULL); } static void quit_handler(int sig) From patchwork Tue Jul 16 07:27:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13734065 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.gnu.org (lists.gnu.org [209.51.188.17]) (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 D578CC3DA49 for ; Tue, 16 Jul 2024 07:29:11 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTcbp-0005Zl-Qq; Tue, 16 Jul 2024 03:28:25 -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 1sTcbo-0005RS-43 for qemu-devel@nongnu.org; Tue, 16 Jul 2024 03:28:24 -0400 Received: from mail-oa1-x29.google.com ([2001:4860:4864:20::29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTcbm-0006U5-Hp for qemu-devel@nongnu.org; Tue, 16 Jul 2024 03:28:23 -0400 Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-25d6dd59170so2313453fac.0 for ; Tue, 16 Jul 2024 00:28:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1721114898; x=1721719698; 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=w42/OqwS4II2qccuVnDqy8/Gc/+eGYKSCH7VXQRvu8k=; b=RZjd9wzOCaYgAUqCDPHgD9wPnvCLel0ipzvtBndFLlrL6bLKVuex9DyfiOI1nHWeW/ ZCjnu8nSi2ZwmKEl3o3Z2lrAxHkURCCrb8dwSBv6qRETMYoVeOGlm/Fm9T8Jnt1bVKet B2fdKVq1GNEaAMN5va4mUd/YMF5UXtfXEVSl98NSUouMW7fttKwb08JPv60RBiRlLX9c uKTfPj+4q+wNxoBlgpFPjuA5+oT86XDiGE10EvFeNvgWGjr3uKeGR7W/JQyjMAkN41+j 9B0WX3tfAJ3Ur6Fih5cFZQnK2HdTi6iVATvLjFmBtaUAIAO80GIm22tSm7ZOkhJZzT5R apIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721114898; x=1721719698; 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=w42/OqwS4II2qccuVnDqy8/Gc/+eGYKSCH7VXQRvu8k=; b=NATYTMx9W9qSCbKHsxIZfojZWjMwHUNfpQnVBmBAe+73OOljsQ/tNNEfHjTfs4nSwA udO6wpwN/of5sqG8NSkKdAf6BObLXA9neDM3cSTU5YM9ROUeUvx5agT6Jmr+YOWcdwF/ DqK9OBo/5suYH2trp6zJzJP063x1KTupJjcYB595ZCddQ0cREYhcJBlsWjVXtMK2hzPn Et/OHlvQ107xSzafli509ZqXqiyDmiUA9ZIs5/2xMEwDz+bbjcv9tQOBEIdZzXaR+Pv9 3GX5pd0j3T5IwRw8EHHi1bE8PPZFMVA/70rRED57yevBhtnXtdBYwKypbKiC/e3pDRPG c+mA== X-Gm-Message-State: AOJu0YzhljmdMiJNmSmGfNVoixJPICAsuCAc6QA4LdHorw+oszO4YRKb oBN4zjlY6LA9Ki6BlSFG+RFFZDWn0IgmmBG0iXxg3Vh6i2mJMw0ze/nNI8Yl97c= X-Google-Smtp-Source: AGHT+IFhfAECFQdPaCsZAOGXvHTpLNQ5Pol3qhCLg+VHy1L4OL/vgcxjMptxzv8PM87gQ1j4x//6aA== X-Received: by 2002:a05:6870:d184:b0:24c:b654:c17a with SMTP id 586e51a60fabf-260bdf97ce1mr909542fac.45.1721114897545; Tue, 16 Jul 2024 00:28:17 -0700 (PDT) Received: from localhost ([157.82.128.7]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-70b7ec7da24sm5586892b3a.113.2024.07.16.00.28.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Jul 2024 00:28:17 -0700 (PDT) From: Akihiko Odaki Date: Tue, 16 Jul 2024 16:27:34 +0900 Subject: [PATCH v4 4/7] scsi: Use qemu_get_runtime_dir() MIME-Version: 1.0 Message-Id: <20240716-run-v4-4-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: none client-ip=2001:4860:4864:20::29; envelope-from=akihiko.odaki@daynix.com; helo=mail-oa1-x29.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org qemu_get_runtime_dir() is used to construct the default paths. Signed-off-by: Akihiko Odaki Message-Id: <20230921075425.16738-6-akihiko.odaki@daynix.com> --- scsi/qemu-pr-helper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c index c6c6347e9b6a..507f23357f6b 100644 --- a/scsi/qemu-pr-helper.c +++ b/scsi/qemu-pr-helper.c @@ -77,10 +77,10 @@ static int gid = -1; static void compute_default_paths(void) { - g_autofree char *state = qemu_get_local_state_dir(); + g_autofree char *run = qemu_get_runtime_dir(); - socket_path = g_build_filename(state, "run", "qemu-pr-helper.sock", NULL); - pidfile = g_build_filename(state, "run", "qemu-pr-helper.pid", NULL); + socket_path = g_build_filename(run, "qemu-pr-helper.sock", NULL); + pidfile = g_build_filename(run, "qemu-pr-helper.pid", NULL); } static void usage(const char *name) From patchwork Tue Jul 16 07:27:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13734070 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.gnu.org (lists.gnu.org [209.51.188.17]) (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 058DFC3DA59 for ; Tue, 16 Jul 2024 07:29:41 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTcbs-0005ld-Fx; Tue, 16 Jul 2024 03:28:28 -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 1sTcbp-0005W4-8b for qemu-devel@nongnu.org; Tue, 16 Jul 2024 03:28:25 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTcbn-0006Ux-Jv for qemu-devel@nongnu.org; Tue, 16 Jul 2024 03:28:25 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1fc2a194750so17460355ad.1 for ; Tue, 16 Jul 2024 00:28:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1721114902; x=1721719702; 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=nndFPbveVHvyo+1OtPZPhuGcG+moLsZf8i7KbP3IDpQ=; b=GMoFgHI5HIZzLQ8kNbg//5h4gEezZOaEFSEdKu/O+PQ2O6ZNvho1xCu1g36MBR5XP1 X47RiZuYoSHLKQt4JTXFX94yHItJCnQs0sP8xnU1jDVSDza6/NOiYg1CLqI8qCBjMdp8 /1+vo4QNh4/hOXOhuD+6FywXA5vyjAXUMED5lvfSb+hGoYqkeno0KEH5wysFgDWlnOCr f3EGdSiNaI1GLzm+4zK+huNhEnhaLeePIn0An5X8UIlDZLW8mfJf6NYX0B0RTt4c/dMO h5p2bJvBApeIN+knpV4n9jM/lkQEHvKz70wbsqHXrq/DSTklbYP1SFLiDengbgkt1awz W3dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721114902; x=1721719702; 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=nndFPbveVHvyo+1OtPZPhuGcG+moLsZf8i7KbP3IDpQ=; b=s3qfv6ZtHLN4ctoA94oaCar0eq0TYPrjao3icHyuij+GjHXe/AtLQEcxnTISZIOBtf SKrXSWB/mx9KirIy7XVehTwQouOHyaD+UPF/DS7QZ64uVf3XKAFeoe5o7/EdM/DBu61t XSieFYRko3FZDZsbfHGkb0wDuu9mPBKDhprm5f5maPgeAvtYXHLzZzxsQYA85/C5NRKo v8FTExglBe3i9qhqg6nQZ3iiBqaCdOb4w3S6nKFDIXJsXbuy0WoQ0Te4tV5ulgNFGzrT DjD1UxGBV2OUjqD09Hk0DoUsykQ4/dEEq5JG/mUG2DbqcjKclg268Bz3nX5iYe3wCz37 f2iQ== X-Gm-Message-State: AOJu0YwGkAdfJ9ct8KlCo+y+w5tv6Vpn6o9jfcRyvWfpwTh/t21U0syA KIEaLrzGtitt+rsogHzwHVboHSPTtMT9Dybw5veXD9KJqJ3+XQBBWUkSKq9v01A= X-Google-Smtp-Source: AGHT+IEf2tPScxuna9eeRgCVz8lF9FQkuOGJaZHKNKsE6KIk6bW1YyYbxUrsKAwx2smxtMUX6fvvGA== X-Received: by 2002:a17:903:41cd:b0:1fa:2e45:bcb8 with SMTP id d9443c01a7336-1fc3d921be3mr10484155ad.2.1721114902296; Tue, 16 Jul 2024 00:28:22 -0700 (PDT) Received: from localhost ([157.82.128.7]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1fc0bc45017sm52075555ad.242.2024.07.16.00.28.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Jul 2024 00:28:21 -0700 (PDT) From: Akihiko Odaki Date: Tue, 16 Jul 2024 16:27:35 +0900 Subject: [PATCH v4 5/7] module: Use qemu_get_runtime_dir() MIME-Version: 1.0 Message-Id: <20240716-run-v4-5-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: none client-ip=2607:f8b0:4864:20::62d; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62d.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=unavailable 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org qemu_get_runtime_dir() is used to construct the path to module upgrades. Signed-off-by: Akihiko Odaki Message-Id: <20230921075425.16738-7-akihiko.odaki@daynix.com> --- util/module.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/module.c b/util/module.c index 32e263163c75..580658edf486 100644 --- a/util/module.c +++ b/util/module.c @@ -242,7 +242,8 @@ int module_load(const char *prefix, const char *name, Error **errp) version_dir = g_strcanon(g_strdup(QEMU_PKGVERSION), G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "+-.~", '_'); - dirs[n_dirs++] = g_strdup_printf("/var/run/qemu/%s", version_dir); + g_autofree char *run = qemu_get_runtime_dir(); + dirs[n_dirs++] = g_build_filename(run, "qemu", version_dir, NULL); #endif assert(n_dirs <= ARRAY_SIZE(dirs)); From patchwork Tue Jul 16 07:27:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13734071 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.gnu.org (lists.gnu.org [209.51.188.17]) (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 8835EC3DA49 for ; Tue, 16 Jul 2024 07:29:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTcbx-00067S-3o; Tue, 16 Jul 2024 03:28:33 -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 1sTcbw-00062V-13 for qemu-devel@nongnu.org; Tue, 16 Jul 2024 03:28:32 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTcbu-0006Wr-Da for qemu-devel@nongnu.org; Tue, 16 Jul 2024 03:28:31 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1fbcf71d543so34321555ad.1 for ; Tue, 16 Jul 2024 00:28:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1721114907; x=1721719707; 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=FapB0rloacMPTGYKVxlO1Chp+0XRuBvqN0yTXZ7di5c=; b=rH4BE8YjUe0ma7h4Xgj0UnHIJnt5imLwvsXFVE9cV7IxwYh6J5PG5gdk5o1khu6S28 mps2f1V11gvXi0vHBzmPrErhR0TVXL0BlkU6su5OCzSKO9lGqUAP30N09PU3y+a9TFhL dZp14JLISABAWlnq8UNKPphComTULxK0+HYBGoOmS/bnLlgj++J+ihscoA3aGUoUHSkN lj+LVGQT7e+zaCEmfdFI4e5myaKwpDGEKeeCKvCiLN4GLVJbqM9p256iFTDatCFIEsrF nXEMbChOYY/MBf9fRqwaQQxRugNplnQPNhl7faRvRHqWvDWvRZajyG+lRtYd3XEWKG8b 1m5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721114907; x=1721719707; 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=FapB0rloacMPTGYKVxlO1Chp+0XRuBvqN0yTXZ7di5c=; b=S4GIjj5fs6gaeTphuzpxpq+lavhS+WSnZXypuYaltuL9SWoc3LBr1s2aJZSHVhRIpT K0Bj1Ho26XTwwVTh8QoDKMrD9+nXHwmsBbCWj6ln+HDVz7LuuHrHRrl8H1E6RLAuVcK0 kF/vbwv1vhz/l1Gwuui3lE4nUsgSGwCJP5zh3Y8d5SjoTt8hXUZnxGxeCUvpN7iFhuwX kYBoYtRYTQTp36Aaj/cAP26bEMgQCUPJJNhYqnkC3CHZo7Loj6KJJV959HqKC4/k75OC t4Iaf4yun2acm262ZpxhCdMplUk0GWmDK1zzT+g1DOpfMKiRhVPYt/3UUH2Lo3ag9CLK 6beA== X-Gm-Message-State: AOJu0Yxy4kYtp6wEv0IKdE6S4clZOhVvE9zAw0alVVS/0KetNrSNbtT+ 22AiBiR4HKqsWSoNRf2NU7ZPmrMgUOG3aDCNa6FjLUg1EW5EDuBYEC5vxslpSNjmTl8UuixNRGE F5LQ= X-Google-Smtp-Source: AGHT+IHECRxub+S5to2Fkay3GrLCGjY1xN63+pAZ4NE97aXCQSdcnKtZBsjIuDCNTEzaYXri0TZtNA== X-Received: by 2002:a17:902:d48a:b0:1f9:99d8:4aac with SMTP id d9443c01a7336-1fc3ca07194mr12196005ad.0.1721114906996; Tue, 16 Jul 2024 00:28:26 -0700 (PDT) Received: from localhost ([157.82.128.7]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1fc0bc43febsm51820995ad.234.2024.07.16.00.28.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Jul 2024 00:28:26 -0700 (PDT) From: Akihiko Odaki Date: Tue, 16 Jul 2024 16:27:36 +0900 Subject: [PATCH v4 6/7] util: Remove qemu_get_local_state_dir() MIME-Version: 1.0 Message-Id: <20240716-run-v4-6-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: none client-ip=2607:f8b0:4864:20::636; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x636.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org There are no users of the function anymore. Signed-off-by: Akihiko Odaki Message-Id: <20230921075425.16738-8-akihiko.odaki@daynix.com> --- include/qemu/osdep.h | 8 -------- util/oslib-posix.c | 6 ------ util/oslib-win32.c | 10 ---------- 3 files changed, 24 deletions(-) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index fe8609fc1375..189fdf4fb6f9 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -662,14 +662,6 @@ ssize_t qemu_write_full(int fd, const void *buf, size_t count) void qemu_set_cloexec(int fd); -/* Return a dynamically allocated directory path that is appropriate for storing - * local state. - * - * The caller is responsible for releasing the value returned with g_free() - * after use. - */ -char *qemu_get_local_state_dir(void); - /** * qemu_get_runtime_dir: * diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 9599509a9aa7..60bbd9786b79 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -272,12 +272,6 @@ int qemu_socketpair(int domain, int type, int protocol, int sv[2]) return ret; } -char * -qemu_get_local_state_dir(void) -{ - return get_relocated_path(CONFIG_QEMU_LOCALSTATEDIR); -} - char * qemu_get_runtime_dir(void) { diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 8c5a02ee881d..504a75f548ab 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -229,16 +229,6 @@ int qemu_get_thread_id(void) return GetCurrentThreadId(); } -char * -qemu_get_local_state_dir(void) -{ - const char * const *data_dirs = g_get_system_data_dirs(); - - g_assert(data_dirs && data_dirs[0]); - - return g_strdup(data_dirs[0]); -} - char * qemu_get_runtime_dir(void) { From patchwork Tue Jul 16 07:27:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13734068 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.gnu.org (lists.gnu.org [209.51.188.17]) (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 948EBC3DA49 for ; Tue, 16 Jul 2024 07:29:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTcc1-0006Qi-Cp; Tue, 16 Jul 2024 03:28:37 -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 1sTcbz-0006I0-BF for qemu-devel@nongnu.org; Tue, 16 Jul 2024 03:28:35 -0400 Received: from mail-ot1-x330.google.com ([2607:f8b0:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTcbx-0006Xy-0b for qemu-devel@nongnu.org; Tue, 16 Jul 2024 03:28:35 -0400 Received: by mail-ot1-x330.google.com with SMTP id 46e09a7af769-704156d0e0dso2739194a34.1 for ; Tue, 16 Jul 2024 00:28:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1721114912; x=1721719712; 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=DgK+8Ab0My7nZ1jTou6SSJrbwenaRoM5fcR5nlg4MS0=; b=1FMd6PeQeNKrl5qqpkI67ydyKuD+WJbzGn2zHz+l25pAN3NgSiL/DbLKxgYFFT0BJi 0t63+dogfzW9oZyV3iIC89BzS0xFbKTqmorHPy/pxQIdBYXxtTamzQTE4YrY4z56rMLe J3a97zyRJw4+o+fErB3BDomYbEMowODcUr6eZNpZpeoWa02BQr2xRLHrCcrQadqB1CRf gNWe7NJbO7cTpDL1jSdWiYioZATDNXp8CefXF7+nXDJB1HsSF/zpimMuryP1UEBBew/F zf9rgp301hXJSKaDCjwqY+ehfAz+mO3d+ClgEFwe7KkjrtUdQ/WUqwk3RiCov0qk4CHW we/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721114912; x=1721719712; 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=DgK+8Ab0My7nZ1jTou6SSJrbwenaRoM5fcR5nlg4MS0=; b=wnNbjTZ3AQwRDLBPdAlu9V+s3qftdMIPFMGDynXwRBwkVww7IAt1B6mjE7VeFI55vh sjdetUdasH6F3yyUj93tujPrz33cdbrdPcFuuWUBa7kgw851BIv3HwC+uL/XFTRoIUS/ UX2BoZcewlsl2ENJC8r5fwKmEGKjUuiTYeF7Bq7s5nK6XKlTrKvmRilIS7ieZstcqxqF L9AtzCrMjWygsybcdhe/DPAcDoKgVpISxiI1ycYKtv9H7ba7Alix5S7A78PEJFfZXPwb oj9iITfqG9YeKZ5nLjXN7Q+RjVRqi0JIfMX464J61etBiRdbwtIviwncnv6bYa04gPZV XZ+g== X-Gm-Message-State: AOJu0Yz8RRvZvJH0FuoBruKSerlOtf8vMSy/gsnPv2DEqypnLdMt0rw4 SjBiFhHysX3K2BIQDaXJZC1UC6BvVhMNgm4INhMC7vpJyH2TOKWxZFzUy3uAYOM= X-Google-Smtp-Source: AGHT+IGB8zQ/FUrAaZCwGH4mmwPrK3IkiI9TIQiLOyTf/QokXdHbW+L25GnXfVqtiak8fNaYte6LXA== X-Received: by 2002:a05:6830:929:b0:703:6aa3:d091 with SMTP id 46e09a7af769-708d99609a3mr1848889a34.2.1721114911857; Tue, 16 Jul 2024 00:28:31 -0700 (PDT) Received: from localhost ([157.82.128.7]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-78e3485dcc7sm4400161a12.39.2024.07.16.00.28.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Jul 2024 00:28:31 -0700 (PDT) From: Akihiko Odaki Date: Tue, 16 Jul 2024 16:27:37 +0900 Subject: [PATCH v4 7/7] spice-app: Use qemu_get_runtime_dir() MIME-Version: 1.0 Message-Id: <20240716-run-v4-7-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: none client-ip=2607:f8b0:4864:20::330; envelope-from=akihiko.odaki@daynix.com; helo=mail-ot1-x330.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org qemu_get_runtime_dir() provides QEMU-specific fallback of runtime directory. Signed-off-by: Akihiko Odaki Message-Id: <20230921075425.16738-9-akihiko.odaki@daynix.com> --- ui/spice-app.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/spice-app.c b/ui/spice-app.c index a10b4a58fe74..bbe17358c8d4 100644 --- a/ui/spice-app.c +++ b/ui/spice-app.c @@ -151,8 +151,8 @@ static void spice_app_display_early_init(DisplayOptions *opts) atexit(spice_app_atexit); if (qemu_name) { - app_dir = g_build_filename(g_get_user_runtime_dir(), - "qemu", qemu_name, NULL); + g_autofree char *run = qemu_get_runtime_dir(); + app_dir = g_build_filename(run, "qemu", qemu_name, NULL); if (g_mkdir_with_parents(app_dir, S_IRWXU) < -1) { error_report("Failed to create directory %s: %s", app_dir, strerror(errno));