From nobody Thu Nov 6 12:15:35 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1540950217187508.0339644997098; Tue, 30 Oct 2018 18:43:37 -0700 (PDT) Received: from localhost ([::1]:56592 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHfXk-0002UH-3b for importer@patchew.org; Tue, 30 Oct 2018 21:43:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHfUt-0000YM-B9 for qemu-devel@nongnu.org; Tue, 30 Oct 2018 21:40:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHfUs-0002HG-8W for qemu-devel@nongnu.org; Tue, 30 Oct 2018 21:40:39 -0400 Received: from mail-qt1-x82d.google.com ([2607:f8b0:4864:20::82d]:35448) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHfUr-0002EY-BE for qemu-devel@nongnu.org; Tue, 30 Oct 2018 21:40:38 -0400 Received: by mail-qt1-x82d.google.com with SMTP id a10-v6so15979019qtp.2 for ; Tue, 30 Oct 2018 18:40:32 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id v23-v6sm19086056qtv.65.2018.10.30.18.40.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Oct 2018 18:40:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=J2hDdIIMnNOSP+USzHUBuxWsUR55MYaTRzDvre6P60A=; b=J2nAOd5pogfB8B5OnyEentTxuMlPDwMZEkiKEs7EAnpypqpVuHfvUqnBvzLUFuzazM n9iJr5nM9yvjw/kCn3aXaGbPb6kGn1WH8mMI7JmAl55ZQmQoFqrJ0Ph/7ZwuOkaB5X0v Z1zS2/c1iI0qASwsI1oiuXp8KQXiPd3o5I81mNqMAozEkZbIFeL/iQrtBA6P0NMG5C0t 68SDOngY5RHRF3rRsBX6sHDJ+/iaa381oJasff7JkbjI7rSEC5DOy7XgQW7hEVk1Ritk 4/x8ah1NcsGYPH5gBsUdU7odK6mJ5cpVNcsB2l+jarqiq2UReirCGPpJaZVEXKLLniO2 iSSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=J2hDdIIMnNOSP+USzHUBuxWsUR55MYaTRzDvre6P60A=; b=F/fCn9yRZSfWs89URf0pDWgJCW2w8OVa7m4I24f5UA1OcH4W6SZrEU8+fXCEWkMHUz qP/kg8OfGn3wHR5FeLWXJV/Ha6eak5fHmLGMRXamUE3K6eDoxMKNhDJIkxcCl4etb9S2 cJ9BBEgNy9iGHRlISYiVfTz/q/6+5VMSd2vsdSTUzexFv6QwbSTRO/quDw/KhN7rmeBQ l0/x9+RsRIo9Z5f2XLqJs8IFI614fSkei4v6kznNWpZ9jzy1QzSJ6wq5H4yktUHnbRHw B7Y+O3a7afI88dHgRtjCIzC0BlruITKZZVA3n9hatXV6Hs1RSqvbFO3tS5llb6/sOM1c gPHA== X-Gm-Message-State: AGRZ1gK26a1J+4dUCqTNKCM9CQYEVkUYwLAkJkuTprsK3KdqouXnEgvS BIxBVBzYUX+MAdbvbXgntQNJr71F X-Google-Smtp-Source: AJdET5ddsH2YZx1+ahob4hA9gxrbZRTl+VchfZJcJ97RJej9xavhnrWuJMVCZRfA52AJ6nQ1sMFnxg== X-Received: by 2002:aed:36a4:: with SMTP id f33-v6mr966904qtb.367.1540950031529; Tue, 30 Oct 2018 18:40:31 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 30 Oct 2018 20:38:16 -0500 Message-Id: <20181031013821.24023-20-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031013821.24023-1-mdroth@linux.vnet.ibm.com> References: <20181031013821.24023-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::82d Subject: [Qemu-devel] [PULL v2 19/24] qga: hang GAConfig/socket_activation off of GAState global X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Sameeh Jubran Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" For w32 services we rely on the global GAState to access resources associated with the agent within service_main(). Currently this is sufficient for starting the agent since we open the channel once prior to calling service_main(), and simply start the GMainLoop to start the agent from within service_main(). Eventually we want to be able to also [re-]open the communication channel from within service_main(), which requires access to config/socket_activation variables, so we hang them off GAState in preparation for that. Signed-off-by: Michael Roth Signed-off-by: Sameeh Jubran *dont move GAConfig struct, just the typedef *fix build bisect for w32 Signed-off-by: Michael Roth --- qga/main.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/qga/main.c b/qga/main.c index ab3eaa5163..eb31f99b38 100644 --- a/qga/main.c +++ b/qga/main.c @@ -69,6 +69,8 @@ typedef struct GAPersistentState { int64_t fd_counter; } GAPersistentState; =20 +typedef struct GAConfig GAConfig; + struct GAState { JSONMessageParser parser; GMainLoop *main_loop; @@ -94,6 +96,8 @@ struct GAState { #endif gchar *pstate_filepath; GAPersistentState pstate; + GAConfig *config; + int socket_activation; }; =20 struct GAState *ga_state; @@ -905,7 +909,7 @@ static GList *split_list(const gchar *str, const gchar = *delim) return list; } =20 -typedef struct GAConfig { +struct GAConfig { char *channel_path; char *method; char *log_filepath; @@ -922,7 +926,7 @@ typedef struct GAConfig { int daemonize; GLogLevelFlags log_level; int dumpconf; -} GAConfig; +}; =20 static void config_load(GAConfig *config) { @@ -1211,7 +1215,7 @@ static bool check_is_frozen(GAState *s) return false; } =20 -static GAState *initialize_agent(GAConfig *config) +static GAState *initialize_agent(GAConfig *config, int socket_activation) { GAState *s =3D g_new0(GAState, 1); =20 @@ -1304,6 +1308,8 @@ static GAState *initialize_agent(GAConfig *config) =20 s->main_loop =3D g_main_loop_new(NULL, false); =20 + s->config =3D config; + s->socket_activation =3D socket_activation; ga_state =3D s; return s; } @@ -1327,17 +1333,17 @@ static void cleanup_agent(GAState *s) ga_state =3D NULL; } =20 -static int run_agent(GAState *s, GAConfig *config, int socket_activation) +static int run_agent(GAState *s) { - if (!channel_init(ga_state, config->method, config->channel_path, - socket_activation ? FIRST_SOCKET_ACTIVATION_FD : -1)= ) { + if (!channel_init(s, s->config->method, s->config->channel_path, + s->socket_activation ? FIRST_SOCKET_ACTIVATION_FD : = -1)) { g_critical("failed to initialize guest agent channel"); return EXIT_FAILURE; } #ifndef _WIN32 g_main_loop_run(ga_state->main_loop); #else - if (config->daemonize) { + if (s->config->daemonize) { SERVICE_TABLE_ENTRY service_table[] =3D { { (char *)QGA_SERVICE_NAME, service_main }, { NULL, NULL } }; StartServiceCtrlDispatcher(service_table); @@ -1425,12 +1431,12 @@ int main(int argc, char **argv) goto end; } =20 - s =3D initialize_agent(config); + s =3D initialize_agent(config, socket_activation); if (!s) { g_critical("error initializing guest agent"); goto end; } - ret =3D run_agent(s, config, socket_activation); + ret =3D run_agent(s); cleanup_agent(s); =20 end: --=20 2.17.1