The qemu_get_local_state_dir() users only need the QEMU "run" directory, but the Windows implementation is not suitable for that. It calls g_get_system_data_dirs(), which in turn is documented as follows: > On Windows it follows XDG Base Directory Specification if > `XDG_DATA_DIRS` is defined. > If `XDG_DATA_DIRS` is undefined, > the first elements in the list are the Application Data > and Documents folders for All Users. (These can be determined only > on Windows 2000 or later and are not present in the list on other > Windows versions.) See documentation for FOLDERID_ProgramData and > FOLDERID_PublicDocuments. > > Then follows the "share" subfolder in the installation folder for > the package containing the DLL that calls this function, if it can > be determined. > > Finally the list contains the "share" subfolder in the installation > folder for GLib, and in the installation folder for the package the > application's .exe file belongs to. Use get_relocated_path(CONFIG_QEMU_LOCALSTATEDIR "/run") for the vmsr helper paths to allow removing it. qemu_get_runtime_dir() is not appropriate here because it points to a user-specific runtime directory, while the vmsr helper and QEMU are typically run by different users and need to agree on the socket path. Signed-off-by: Akihiko Odaki --- target/i386/kvm/vmsr_energy.c | 6 +++--- tools/i386/qemu-vmsr-helper.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/target/i386/kvm/vmsr_energy.c b/target/i386/kvm/vmsr_energy.c index d24e827a214a..77f39ed12b98 100644 --- a/target/i386/kvm/vmsr_energy.c +++ b/target/i386/kvm/vmsr_energy.c @@ -12,6 +12,7 @@ */ #include "qemu/osdep.h" +#include "qemu/cutils.h" #include "qemu/error-report.h" #include "vmsr_energy.h" #include "io/channel.h" @@ -22,9 +23,8 @@ char *vmsr_compute_default_paths(void) { - g_autofree char *state = qemu_get_local_state_dir(); - - return g_build_filename(state, "run", "qemu-vmsr-helper.sock", NULL); + return get_relocated_path(CONFIG_QEMU_LOCALSTATEDIR + "/run/qemu-vmsr-helper.sock"); } int is_rapl_enabled(void) diff --git a/tools/i386/qemu-vmsr-helper.c b/tools/i386/qemu-vmsr-helper.c index f12fd3c3e816..7c507695f571 100644 --- a/tools/i386/qemu-vmsr-helper.c +++ b/tools/i386/qemu-vmsr-helper.c @@ -62,10 +62,10 @@ static int gid = -1; static void compute_default_paths(void) { - g_autofree char *state = qemu_get_local_state_dir(); + g_autofree char *run = get_relocated_path(CONFIG_QEMU_LOCALSTATEDIR "/run"); - socket_path = g_build_filename(state, "run", "qemu-vmsr-helper.sock", NULL); - pidfile = g_build_filename(state, "run", "qemu-vmsr-helper.pid", NULL); + socket_path = g_build_filename(run, "qemu-vmsr-helper.sock", NULL); + pidfile = g_build_filename(run, "qemu-vmsr-helper.pid", NULL); } static int is_intel_processor(void) -- 2.54.0