|
|
9ae3a8 |
From 211077f1cceb5f814d0750b183ff19995b37c6d3 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Date: Wed, 31 Jul 2013 14:03:23 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 02/28] qga: determine default state dir and pidfile dynamically
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1375279407-13573-3-git-send-email-lersek@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 52861
|
|
|
9ae3a8 |
O-Subject: [RHEL-7 qemu-kvm PATCH 2/6] qga: determine default state dir and pidfile dynamically
|
|
|
9ae3a8 |
Bugzilla: 964304
|
|
|
9ae3a8 |
RH-Acked-by: Michal Novotny <minovotn@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
No effective change on POSIX, but on Win32 the defaults come from the
|
|
|
9ae3a8 |
environment / session.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Since commit 39097daf ("qemu-ga: use key-value store to avoid recycling fd
|
|
|
9ae3a8 |
handles after restart") we've relied on the state directory for the fd
|
|
|
9ae3a8 |
handles' key-value store. Even though we don't support the guest-file-*
|
|
|
9ae3a8 |
commands on win32 yet, the key-value store is written, and it's the first
|
|
|
9ae3a8 |
use of the state directory on win32. We should have a sensible default for
|
|
|
9ae3a8 |
its location.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
|
|
|
9ae3a8 |
(cherry picked from commit c394ecb7bf55b7234f852b9c8518aefb5d0943fa)
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
qga/main.c | 32 ++++++++++++++++++++++++++------
|
|
|
9ae3a8 |
1 files changed, 26 insertions(+), 6 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
qga/main.c | 32 ++++++++++++++++++++++++++------
|
|
|
9ae3a8 |
1 files changed, 26 insertions(+), 6 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/qga/main.c b/qga/main.c
|
|
|
9ae3a8 |
index c2ba5d9..050b968 100644
|
|
|
9ae3a8 |
--- a/qga/main.c
|
|
|
9ae3a8 |
+++ b/qga/main.c
|
|
|
9ae3a8 |
@@ -45,16 +45,21 @@
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
#ifndef _WIN32
|
|
|
9ae3a8 |
#define QGA_VIRTIO_PATH_DEFAULT "/dev/virtio-ports/org.qemu.guest_agent.0"
|
|
|
9ae3a8 |
+#define QGA_STATE_RELATIVE_DIR "run"
|
|
|
9ae3a8 |
#else
|
|
|
9ae3a8 |
#define QGA_VIRTIO_PATH_DEFAULT "\\\\.\\Global\\org.qemu.guest_agent.0"
|
|
|
9ae3a8 |
+#define QGA_STATE_RELATIVE_DIR "qemu-ga"
|
|
|
9ae3a8 |
#endif
|
|
|
9ae3a8 |
-#define QGA_STATEDIR_DEFAULT CONFIG_QEMU_LOCALSTATEDIR "/run"
|
|
|
9ae3a8 |
-#define QGA_PIDFILE_DEFAULT QGA_STATEDIR_DEFAULT "/qemu-ga.pid"
|
|
|
9ae3a8 |
#ifdef CONFIG_FSFREEZE
|
|
|
9ae3a8 |
#define QGA_FSFREEZE_HOOK_DEFAULT CONFIG_QEMU_CONFDIR "/fsfreeze-hook"
|
|
|
9ae3a8 |
#endif
|
|
|
9ae3a8 |
#define QGA_SENTINEL_BYTE 0xFF
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+static struct {
|
|
|
9ae3a8 |
+ const char *state_dir;
|
|
|
9ae3a8 |
+ const char *pidfile;
|
|
|
9ae3a8 |
+} dfl_pathnames;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
typedef struct GAPersistentState {
|
|
|
9ae3a8 |
#define QGA_PSTATE_DEFAULT_FD_COUNTER 1000
|
|
|
9ae3a8 |
int64_t fd_counter;
|
|
|
9ae3a8 |
@@ -106,6 +111,17 @@ DWORD WINAPI service_ctrl_handler(DWORD ctrl, DWORD type, LPVOID data,
|
|
|
9ae3a8 |
VOID WINAPI service_main(DWORD argc, TCHAR *argv[]);
|
|
|
9ae3a8 |
#endif
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+static void
|
|
|
9ae3a8 |
+init_dfl_pathnames(void)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ g_assert(dfl_pathnames.state_dir == NULL);
|
|
|
9ae3a8 |
+ g_assert(dfl_pathnames.pidfile == NULL);
|
|
|
9ae3a8 |
+ dfl_pathnames.state_dir = qemu_get_local_state_pathname(
|
|
|
9ae3a8 |
+ QGA_STATE_RELATIVE_DIR);
|
|
|
9ae3a8 |
+ dfl_pathnames.pidfile = qemu_get_local_state_pathname(
|
|
|
9ae3a8 |
+ QGA_STATE_RELATIVE_DIR G_DIR_SEPARATOR_S "qemu-ga.pid");
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
static void quit_handler(int sig)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
/* if we're frozen, don't exit unless we're absolutely forced to,
|
|
|
9ae3a8 |
@@ -198,11 +214,11 @@ static void usage(const char *cmd)
|
|
|
9ae3a8 |
" -h, --help display this help and exit\n"
|
|
|
9ae3a8 |
"\n"
|
|
|
9ae3a8 |
"Report bugs to <mdroth@linux.vnet.ibm.com>\n"
|
|
|
9ae3a8 |
- , cmd, QEMU_VERSION, QGA_VIRTIO_PATH_DEFAULT, QGA_PIDFILE_DEFAULT,
|
|
|
9ae3a8 |
+ , cmd, QEMU_VERSION, QGA_VIRTIO_PATH_DEFAULT, dfl_pathnames.pidfile,
|
|
|
9ae3a8 |
#ifdef CONFIG_FSFREEZE
|
|
|
9ae3a8 |
QGA_FSFREEZE_HOOK_DEFAULT,
|
|
|
9ae3a8 |
#endif
|
|
|
9ae3a8 |
- QGA_STATEDIR_DEFAULT);
|
|
|
9ae3a8 |
+ dfl_pathnames.state_dir);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static const char *ga_log_level_str(GLogLevelFlags level)
|
|
|
9ae3a8 |
@@ -908,11 +924,11 @@ int main(int argc, char **argv)
|
|
|
9ae3a8 |
const char *sopt = "hVvdm:p:l:f:F::b:s:t:";
|
|
|
9ae3a8 |
const char *method = NULL, *path = NULL;
|
|
|
9ae3a8 |
const char *log_filepath = NULL;
|
|
|
9ae3a8 |
- const char *pid_filepath = QGA_PIDFILE_DEFAULT;
|
|
|
9ae3a8 |
+ const char *pid_filepath;
|
|
|
9ae3a8 |
#ifdef CONFIG_FSFREEZE
|
|
|
9ae3a8 |
const char *fsfreeze_hook = NULL;
|
|
|
9ae3a8 |
#endif
|
|
|
9ae3a8 |
- const char *state_dir = QGA_STATEDIR_DEFAULT;
|
|
|
9ae3a8 |
+ const char *state_dir;
|
|
|
9ae3a8 |
#ifdef _WIN32
|
|
|
9ae3a8 |
const char *service = NULL;
|
|
|
9ae3a8 |
#endif
|
|
|
9ae3a8 |
@@ -942,6 +958,10 @@ int main(int argc, char **argv)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
module_call_init(MODULE_INIT_QAPI);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ init_dfl_pathnames();
|
|
|
9ae3a8 |
+ pid_filepath = dfl_pathnames.pidfile;
|
|
|
9ae3a8 |
+ state_dir = dfl_pathnames.state_dir;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
while ((ch = getopt_long(argc, argv, sopt, lopt, &opt_ind)) != -1) {
|
|
|
9ae3a8 |
switch (ch) {
|
|
|
9ae3a8 |
case 'm':
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|