From: Laszlo Ersek <lersek@redhat.com>
To: mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 6/6] qga: save state directory in ga_install_service()
Date: Sat, 18 May 2013 06:31:53 +0200 [thread overview]
Message-ID: <1368851513-20550-7-git-send-email-lersek@redhat.com> (raw)
In-Reply-To: <1368851513-20550-1-git-send-email-lersek@redhat.com>
If the user selects a non-default state directory at service installation
time, we should remember it in the registered service.
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
qga/service-win32.h | 3 ++-
qga/main.c | 11 ++++++++++-
qga/service-win32.c | 6 +++++-
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/qga/service-win32.h b/qga/service-win32.h
index 99dfc53..3b9e870 100644
--- a/qga/service-win32.h
+++ b/qga/service-win32.h
@@ -24,7 +24,8 @@ typedef struct GAService {
SERVICE_STATUS_HANDLE status_handle;
} GAService;
-int ga_install_service(const char *path, const char *logfile);
+int ga_install_service(const char *path, const char *logfile,
+ const char *state_dir);
int ga_uninstall_service(void);
#endif
diff --git a/qga/main.c b/qga/main.c
index 5f2d141..0e04e73 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -1022,7 +1022,16 @@ int main(int argc, char **argv)
case 's':
service = optarg;
if (strcmp(service, "install") == 0) {
- return ga_install_service(path, log_filepath);
+ const char *fixed_state_dir;
+
+ /* If the user passed the "-t" option, we save that state dir
+ * in the service. Otherwise we let the service fetch the state
+ * dir from the environment when it starts.
+ */
+ fixed_state_dir = (state_dir == dfl_pathnames.state_dir) ?
+ NULL :
+ state_dir;
+ return ga_install_service(path, log_filepath, fixed_state_dir);
} else if (strcmp(service, "uninstall") == 0) {
return ga_uninstall_service();
} else {
diff --git a/qga/service-win32.c b/qga/service-win32.c
index 8a5de8a..02926ab 100644
--- a/qga/service-win32.c
+++ b/qga/service-win32.c
@@ -35,7 +35,8 @@ static int printf_win_error(const char *text)
return n;
}
-int ga_install_service(const char *path, const char *logfile)
+int ga_install_service(const char *path, const char *logfile,
+ const char *state_dir)
{
SC_HANDLE manager;
SC_HANDLE service;
@@ -56,6 +57,9 @@ int ga_install_service(const char *path, const char *logfile)
if (logfile) {
g_string_append_printf(cmdline, " -l %s -v", logfile);
}
+ if (state_dir) {
+ g_string_append_printf(cmdline, " -t %s", state_dir);
+ }
g_debug("service's cmdline: %s", cmdline->str);
--
1.7.1
next prev parent reply other threads:[~2013-05-18 4:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-18 4:31 [Qemu-devel] [PATCH 0/6] local state directory fixes for win32 qga Laszlo Ersek
2013-05-18 4:31 ` [Qemu-devel] [PATCH 1/6] osdep: add qemu_get_local_state_pathname() Laszlo Ersek
2013-05-18 4:31 ` [Qemu-devel] [PATCH 2/6] qga: determine default state dir and pidfile dynamically Laszlo Ersek
2013-05-18 4:31 ` [Qemu-devel] [PATCH 3/6] configure: don't save any fixed local_statedir for win32 Laszlo Ersek
2013-05-18 4:31 ` [Qemu-devel] [PATCH 4/6] qga: create state directory on win32 Laszlo Ersek
2013-05-18 4:31 ` [Qemu-devel] [PATCH 5/6] qga: remove undefined behavior in ga_install_service() Laszlo Ersek
2013-05-18 4:31 ` Laszlo Ersek [this message]
2013-05-18 5:13 ` [Qemu-devel] [PATCH 7/6] Makefile: create ".../var/run" when installing the POSIX guest agent Laszlo Ersek
2013-05-20 16:15 ` [Qemu-devel] [PATCH 0/6] local state directory fixes for win32 qga mdroth
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=1368851513-20550-7-git-send-email-lersek@redhat.com \
--to=lersek@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
/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 NNTP newsgroup(s).