From nobody Tue Feb 10 06:58:50 2026 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 1538034143370970.2809759689009; Thu, 27 Sep 2018 00:42:23 -0700 (PDT) Received: from localhost ([::1]:34193 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5QwF-0002Va-WC for importer@patchew.org; Thu, 27 Sep 2018 03:42:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59262) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Qqe-00066K-T8 for qemu-devel@nongnu.org; Thu, 27 Sep 2018 03:36:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5Qqd-0003fC-Hs for qemu-devel@nongnu.org; Thu, 27 Sep 2018 03:36:32 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:39195) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5Qqd-0003eh-AK for qemu-devel@nongnu.org; Thu, 27 Sep 2018 03:36:31 -0400 Received: by mail-wr1-x42e.google.com with SMTP id s14-v6so1416452wrw.6 for ; Thu, 27 Sep 2018 00:36:31 -0700 (PDT) Received: from bark.daynix ([141.226.163.173]) by smtp.gmail.com with ESMTPSA id y206-v6sm1708129wmg.14.2018.09.27.00.36.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Sep 2018 00:36:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pLbvuiTOHY3b1SCuXYwS6lnZkP9+UJfVAP+5Zvqc9WE=; b=tyQMGMx7Zy1izsMnya7JLVn6yK4M6Sl6yTDB/ndxFBdKTfcweLt5dfOBPuGeNvYA34 NoOar3mS54ntSCvU5Nj0aKtcOesErwxWSSLvgaZr8xRjPGXhr2xbF2AHCYtIcZTyBAJJ 9YKX8j7VNJZ2FXNqYKvbekkGKuCDSUWNkwt4ip4ivQ50pO9pwr3fE8zHwmS6kE3zQ7SD Li+VeVFoShL/H3TdC10EPKrsXo8Z+unPtLU05Pp9Na7M1J3Zq6kPrF0Jtz7vHZBJnt34 rYlGoUOcJsSzYwem81aLrjlnZzQvH/s6/vxTrzq9K3OffbCNRTd1lgM9fH6UBscS9vQe mlJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pLbvuiTOHY3b1SCuXYwS6lnZkP9+UJfVAP+5Zvqc9WE=; b=Dff3Kb/qSLXOxmujtmq4dAuJgvFzj0KNU9WzBKlVR6qNwGdYkgST7NWBTnCZeBfCcb ix6RQznVirH1WCBGiStgAlVllWBbH/5+7eXAYFeI6ccPuvAXPqaGe+nsn5WTPLYC3aGd JCHO7eLuqiFJ+iYwhnRGlmxgEcqU6Z1o2yPxbusIP9xgVBCfz6EydhjgLeweIl5wZ2bD v4KuUzUL7HjHKjnndzNFZ8ZPzDBto2QKrqvGexA5qm3qAdgj68wKIijLTMVHPp72DLmE DPxshmdl6BjFmQro7ED5GX1D2cKjykDs2YxP838vDLowl1pd2kaCFvdxKQE36/ArutIJ AJlw== X-Gm-Message-State: ABuFfoi898OJObiSSK6wG8rbIbZ+yf+xz7MczUPcLtLacXyHKsbwkwF2 naOel65XvJZl9M+00r2+bagMeFg7hos= X-Google-Smtp-Source: ACcGV60QZ+FR64s+R6nRBpq6xdQnhBe2rJGgLym/8cpQ300+zZGHx/d97r6O5JWx2URAoyAPo8Ziyg== X-Received: by 2002:adf:8483:: with SMTP id 3-v6mr7777181wrg.34.1538033789979; Thu, 27 Sep 2018 00:36:29 -0700 (PDT) From: Bishara AbuHattoum To: qemu-devel@nongnu.org, Michael Roth Date: Thu, 27 Sep 2018 10:36:19 +0300 Message-Id: <20180927073624.17163-3-bishara@daynix.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180927073624.17163-1-bishara@daynix.com> References: <20180927073624.17163-1-bishara@daynix.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42e Subject: [Qemu-devel] [PATCH 2/7] 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: Yan Vugenfirer Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Michael Roth 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 Message-Id: <20171026233054.21133-3-mdroth@linux.vnet.ibm.com> Signed-off-by: Sameeh Jubran --- qga/main.c | 54 +++++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/qga/main.c b/qga/main.c index 7b7b837a14..7381053a0f 100644 --- a/qga/main.c +++ b/qga/main.c @@ -69,6 +69,25 @@ typedef struct GAPersistentState { int64_t fd_counter; } GAPersistentState; =20 +typedef struct GAConfig { + char *channel_path; + char *method; + char *log_filepath; + char *pid_filepath; +#ifdef CONFIG_FSFREEZE + char *fsfreeze_hook; +#endif + char *state_dir; +#ifdef _WIN32 + const char *service; +#endif + gchar *bliststr; /* blacklist may point to this string */ + GList *blacklist; + int daemonize; + GLogLevelFlags log_level; + int dumpconf; +} GAConfig; + struct GAState { JSONMessageParser parser; GMainLoop *main_loop; @@ -94,6 +113,8 @@ struct GAState { #endif gchar *pstate_filepath; GAPersistentState pstate; + GAConfig *config; + int socket_activation; }; =20 struct GAState *ga_state; @@ -939,25 +960,6 @@ static GList *split_list(const gchar *str, const gchar= *delim) return list; } =20 -typedef struct GAConfig { - char *channel_path; - char *method; - char *log_filepath; - char *pid_filepath; -#ifdef CONFIG_FSFREEZE - char *fsfreeze_hook; -#endif - char *state_dir; -#ifdef _WIN32 - const char *service; -#endif - gchar *bliststr; /* blacklist may point to this string */ - GList *blacklist; - int daemonize; - GLogLevelFlags log_level; - int dumpconf; -} GAConfig; - static void config_load(GAConfig *config) { GError *gerr =3D NULL; @@ -1245,7 +1247,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 @@ -1338,6 +1340,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; } @@ -1361,10 +1365,10 @@ 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; } @@ -1459,12 +1463,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.0