From patchwork Sat May 18 04:31:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 244734 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id EB2802C00A2 for ; Sat, 18 May 2013 14:31:41 +1000 (EST) Received: from localhost ([::1]:55671 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UdYo0-00063F-3o for incoming@patchwork.ozlabs.org; Sat, 18 May 2013 00:31:40 -0400 Received: from eggs.gnu.org ([208.118.235.92]:44655) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UdYmC-0003WT-Hw for qemu-devel@nongnu.org; Sat, 18 May 2013 00:29:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UdYm9-0002M1-PC for qemu-devel@nongnu.org; Sat, 18 May 2013 00:29:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58951) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UdYm9-0002Lh-FG for qemu-devel@nongnu.org; Sat, 18 May 2013 00:29:45 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4I4ThUp009819 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 18 May 2013 00:29:43 -0400 Received: from lacos-laptop.usersys.redhat.com (vpn1-5-212.ams2.redhat.com [10.36.5.212]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r4I4TXCs014174; Sat, 18 May 2013 00:29:42 -0400 From: Laszlo Ersek To: mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org Date: Sat, 18 May 2013 06:31:53 +0200 Message-Id: <1368851513-20550-7-git-send-email-lersek@redhat.com> In-Reply-To: <1368851513-20550-1-git-send-email-lersek@redhat.com> References: <1368851513-20550-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 6/6] qga: save state directory in ga_install_service() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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);