From: Akihiko Odaki <akihiko.odaki@daynix.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
virtio-fs@redhat.com, Yuval Shaia <yuval.shaia.ml@gmail.com>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
Konstantin Kostiuk <kkostiuk@redhat.com>,
Michael Roth <michael.roth@amd.com>,
Paolo Bonzini <pbonzini@redhat.com>, Fam Zheng <fam@euphon.net>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>, Stefan Weil <sw@weilnetz.de>,
Yan Vugenfirer <yan@daynix.com>,
Akihiko Odaki <akihiko.odaki@daynix.com>
Subject: [Virtio-fs] [PATCH 00/10] util: Introduce qemu_get_runtime_dir()
Date: Thu, 10 Nov 2022 15:23:19 +0900 [thread overview]
Message-ID: <20221110062329.13363-1-akihiko.odaki@daynix.com> (raw)
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")
Akihiko Odaki (10):
qga: Remove platform GUID definitions
util: Introduce qemu_get_runtime_dir()
ivshmem-server: Use qemu_get_runtime_dir()
contrib/rdmacm-mux: Use qemu_get_runtime_dir()
qga: Use qemu_get_runtime_dir()
scsi: Use qemu_get_runtime_dir()
virtiofsd: Use qemu_get_runtime_dir()
module: Use qemu_get_runtime_dir()
util: Remove qemu_get_local_state_dir()
spice-app: Use qemu_get_runtime_dir()
include/qemu/osdep.h | 10 +++++++---
contrib/ivshmem-server/main.c | 20 ++++++++++++++++----
contrib/rdmacm-mux/main.c | 22 ++++++++++++++--------
qga/commands-win32.c | 7 -------
qga/main.c | 9 ++++-----
scsi/qemu-pr-helper.c | 6 +++---
tools/virtiofsd/fuse_virtio.c | 6 +++---
ui/spice-app.c | 4 ++--
util/module.c | 3 ++-
util/oslib-posix.c | 9 +++++++--
util/oslib-win32.c | 24 ++++++++++++++++++++----
contrib/rdmacm-mux/meson.build | 2 +-
12 files changed, 79 insertions(+), 43 deletions(-)
--
2.38.1
next reply other threads:[~2022-11-10 6:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-10 6:23 Akihiko Odaki [this message]
2022-11-10 6:23 ` [Virtio-fs] [PATCH 01/10] qga: Remove platform GUID definitions Akihiko Odaki
2022-11-10 8:03 ` Konstantin Kostiuk
2022-11-10 6:23 ` [Virtio-fs] [PATCH 02/10] util: Introduce qemu_get_runtime_dir() Akihiko Odaki
2022-11-10 6:23 ` [Virtio-fs] [PATCH 03/10] ivshmem-server: Use qemu_get_runtime_dir() Akihiko Odaki
2022-11-10 6:23 ` [Virtio-fs] [PATCH 04/10] contrib/rdmacm-mux: " Akihiko Odaki
2022-11-10 6:23 ` [Virtio-fs] [PATCH 05/10] qga: " Akihiko Odaki
2022-11-10 6:23 ` [Virtio-fs] [PATCH 06/10] scsi: " Akihiko Odaki
2022-11-10 6:23 ` [Virtio-fs] [PATCH 07/10] virtiofsd: " Akihiko Odaki
2022-11-10 6:23 ` [Virtio-fs] [PATCH 08/10] module: " Akihiko Odaki
2022-11-10 6:23 ` [Virtio-fs] [PATCH 09/10] util: Remove qemu_get_local_state_dir() Akihiko Odaki
2022-11-10 6:23 ` [Virtio-fs] [PATCH 10/10] spice-app: Use qemu_get_runtime_dir() Akihiko Odaki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221110062329.13363-1-akihiko.odaki@daynix.com \
--to=akihiko.odaki@daynix.com \
--cc=dgilbert@redhat.com \
--cc=fam@euphon.net \
--cc=kkostiuk@redhat.com \
--cc=kraxel@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=michael.roth@amd.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=sw@weilnetz.de \
--cc=virtio-fs@redhat.com \
--cc=yan@daynix.com \
--cc=yuval.shaia.ml@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).