From nobody Thu Nov 6 12:13:06 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 1540911795228552.7831025777463; Tue, 30 Oct 2018 08:03:15 -0700 (PDT) Received: from localhost ([::1]:53744 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVY1-0000to-Tc for importer@patchew.org; Tue, 30 Oct 2018 11:03:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46383) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVGM-0007dR-3N for qemu-devel@nongnu.org; Tue, 30 Oct 2018 10:44:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHVGL-0000WQ-5P for qemu-devel@nongnu.org; Tue, 30 Oct 2018 10:44:58 -0400 Received: from mail-qt1-x831.google.com ([2607:f8b0:4864:20::831]:33798) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHVGK-0000Vd-Ne for qemu-devel@nongnu.org; Tue, 30 Oct 2018 10:44:57 -0400 Received: by mail-qt1-x831.google.com with SMTP id z2-v6so13770333qts.1 for ; Tue, 30 Oct 2018 07:44:56 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id 94sm29822333qks.8.2018.10.30.07.44.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Oct 2018 07:44:54 -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=Fyz2ry1TpqIu50shL3hkLhyXRS9i03GuB21AeTzokUELPF/X4VI71DcWklMJT+dxt5 Bc3ls8FgbSet0hiBuGevvoPnTbS0dfUtp1fCzSIRMLM8b52bksz7yfL6MVb3NUo5Yzij 7qHw95yKKWvvTxOyDNTq7AB+KLMJwy0sSJ42+E5kPltfDDnt0/w8Ve9fZ8By+STqEMAm hy8uu7Ffolml1nZjCmdTM014R6VQZAIcT9M/eFIdSrk6wV09S6Fzdn/xumgOrVEByBxu r2hC15j3V9zRyG02hhqrYVdh1RFmzQU01+nxDahx+8uWkF4Qgn32doDXMY2/1zp2xuU8 LBXQ== 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=ogzq3tUmjhxQ5/7D44GtzRSvJMx3unTmOXliONvzAXm4kh33Ws1pw8kHVrc88WDqCs tLAhIvv+JTiYrCRlORQ/p85OdYcGSa8RAme5yJMNl+yWPIqMjRWV/nlrMkgWL1ijl4eB 6vfezg1tZXjR5ibkKOSjK+dHt/r02eKO8l8pVV1Stb4iF94PMBIdsewd0DDuHIui5EQV 1HrCSg4GbpXob+Yc2EBuxaMgY+7INdxDH2v/w8OnoBhuQv17+Ia5NwsCS1Wpq73e9DNk 9LMvtliA64EMMz3bzEOdRYH4IT4kBpFu2dx55v2b4Ct2wiF+OlEjiPreTYtQNQk8h9Z8 6bsw== X-Gm-Message-State: AGRZ1gLQve/5B8W4XtO/Hm5QvkS0IA8DHMLC5Vk6sWq/mlo+V8HfBY7P 7XM5T+bkT16sP3mp2R0TdsVh5lv2 X-Google-Smtp-Source: AJdET5cKtzXqM9kBgxEOMTjEDuDIq8fZHrESSIrZ4ebdXGxIGuuZZdpf/mBPg2i7dmLEw+kQXvPs3w== X-Received: by 2002:a0c:d8fd:: with SMTP id w58mr13320078qvj.103.1540910695401; Tue, 30 Oct 2018 07:44:55 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 30 Oct 2018 09:43:53 -0500 Message-Id: <20181030144358.23144-20-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181030144358.23144-1-mdroth@linux.vnet.ibm.com> References: <20181030144358.23144-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::831 Subject: [Qemu-devel] [PULL 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