From nobody Thu May 15 13:05:31 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1512467639432645.638691415082; Tue, 5 Dec 2017 01:53:59 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 417016868D; Tue, 5 Dec 2017 09:53:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BC9E062461; Tue, 5 Dec 2017 09:53:57 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9278D4BB78; Tue, 5 Dec 2017 09:53:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB59rtlZ007348 for ; Tue, 5 Dec 2017 04:53:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id 408DB62461; Tue, 5 Dec 2017 09:53:55 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3713F62464 for ; Tue, 5 Dec 2017 09:53:52 +0000 (UTC) Received: from smtp.nue.novell.com (smtp.nue.novell.com [195.135.221.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8EE068553C for ; Tue, 5 Dec 2017 09:53:50 +0000 (UTC) Received: from emea4-mta.ukb.novell.com ([10.120.13.87]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Tue, 05 Dec 2017 10:53:49 +0100 Received: from laptop.tf.local (nwb-a10-snat.microfocus.com [10.120.13.202]) by emea4-mta.ukb.novell.com with ESMTP (TLS encrypted); Tue, 05 Dec 2017 09:53:26 +0000 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= To: libvir-list@redhat.com Date: Tue, 5 Dec 2017 10:53:17 +0100 Message-Id: <20171205095322.24258-2-cbosdonnat@suse.com> In-Reply-To: <20171205095322.24258-1-cbosdonnat@suse.com> References: <20171205095322.24258-1-cbosdonnat@suse.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 05 Dec 2017 09:53:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 05 Dec 2017 09:53:51 +0000 (UTC) for IP:'195.135.221.5' DOMAIN:'smtp.nue.novell.com' HELO:'smtp.nue.novell.com' FROM:'cbosdonnat@suse.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 195.135.221.5 smtp.nue.novell.com 195.135.221.5 smtp.nue.novell.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= Subject: [libvirt] [sandbox 1/6] Pass debug and verbose values to init X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 05 Dec 2017 09:53:58 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" libvirt-sandbox-init-common is expecting -d and -v parameters to set it in debug or verbose mode... but those will never be passed by the launcher program. Writing the core.debug and core.verbose parameters in the sandbox configuration makes those values actually usable from the init. Reviewed-by: Daniel P. Berrange --- bin/virt-sandbox.c | 3 ++ libvirt-sandbox/libvirt-sandbox-config.c | 75 +++++++++++++++++++++++= ++++ libvirt-sandbox/libvirt-sandbox-config.h | 6 +++ libvirt-sandbox/libvirt-sandbox-init-common.c | 3 ++ libvirt-sandbox/libvirt-sandbox.sym | 4 ++ 5 files changed, 91 insertions(+) diff --git a/bin/virt-sandbox.c b/bin/virt-sandbox.c index 3058013..6032562 100644 --- a/bin/virt-sandbox.c +++ b/bin/virt-sandbox.c @@ -273,6 +273,9 @@ int main(int argc, char **argv) { if (shell) gvir_sandbox_config_set_shell(cfg, TRUE); =20 + gvir_sandbox_config_set_debug(cfg, debug); + gvir_sandbox_config_set_verbose(cfg, verbose); + if (isatty(STDIN_FILENO)) gvir_sandbox_config_interactive_set_tty(icfg, TRUE); =20 diff --git a/libvirt-sandbox/libvirt-sandbox-config.c b/libvirt-sandbox/lib= virt-sandbox-config.c index 8709736..73a0fa4 100644 --- a/libvirt-sandbox/libvirt-sandbox-config.c +++ b/libvirt-sandbox/libvirt-sandbox-config.c @@ -68,6 +68,9 @@ struct _GVirSandboxConfigPrivate =20 gchar *secLabel; gboolean secDynamic; + + gboolean debug; + gboolean verbose; }; =20 G_DEFINE_ABSTRACT_TYPE(GVirSandboxConfig, gvir_sandbox_config, G_TYPE_OBJE= CT); @@ -1926,6 +1929,59 @@ gboolean gvir_sandbox_config_set_security_opts(GVirS= andboxConfig *config, return ret; } =20 +/** + * gvir_sandbox_config_set_debug: + * @config: (transfer none): the sandbox config + * @debug: true if the container init should print debugging messages + * + * Set whether the container init should print debugging messages. + */ +void gvir_sandbox_config_set_debug(GVirSandboxConfig *config, gboolean deb= ug) +{ + GVirSandboxConfigPrivate *priv =3D config->priv; + priv->debug =3D debug; +} + +/** + * gvir_sandbox_config_get_debug: + * @config: (transfer none): the sandbox config + * + * Retrieves the sandbox debug flag + * + * Returns: the debug flag + */ +gboolean gvir_sandbox_config_get_debug(GVirSandboxConfig *config) +{ + GVirSandboxConfigPrivate *priv =3D config->priv; + return priv->debug; +} + +/** + * gvir_sandbox_config_set_verbose: + * @config: (transfer none): the sandbox config + * @verbose: true if the container init should be verbose + * + * Set whether the container init should be verbose. + */ +void gvir_sandbox_config_set_verbose(GVirSandboxConfig *config, gboolean v= erbose) +{ + GVirSandboxConfigPrivate *priv =3D config->priv; + priv->verbose =3D verbose; +} + +/** + * gvir_sandbox_config_get_verbose: + * @config: (transfer none): the sandbox config + * + * Retrieves the sandbox verbose flag + * + * Returns: the verbose flag + */ +gboolean gvir_sandbox_config_get_verbose(GVirSandboxConfig *config) +{ + GVirSandboxConfigPrivate *priv =3D config->priv; + return priv->verbose; +} =20 static GVirSandboxConfigMount *gvir_sandbox_config_load_config_mount(GKeyF= ile *file, guint= i, @@ -2415,6 +2471,22 @@ static gboolean gvir_sandbox_config_load_config(GVir= SandboxConfig *config, priv->secDynamic =3D b; } =20 + b =3D g_key_file_get_boolean(file, "core", "debug", &e); + if (e) { + g_error_free(e); + e =3D NULL; + } else { + priv->debug =3D b; + } + + b =3D g_key_file_get_boolean(file, "core", "verbose", &e); + if (e) { + g_error_free(e); + e =3D NULL; + } else { + priv->verbose =3D b; + } + ret =3D TRUE; cleanup: return ret; @@ -2677,6 +2749,9 @@ static void gvir_sandbox_config_save_config(GVirSandb= oxConfig *config, if (priv->secLabel) g_key_file_set_string(file, "security", "label", priv->secLabel); g_key_file_set_boolean(file, "security", "dynamic", priv->secDynamic); + + g_key_file_set_boolean(file, "core", "debug", priv->debug); + g_key_file_set_boolean(file, "core", "verbose", priv->verbose); } =20 =20 diff --git a/libvirt-sandbox/libvirt-sandbox-config.h b/libvirt-sandbox/lib= virt-sandbox-config.h index e5e53f7..8950e25 100644 --- a/libvirt-sandbox/libvirt-sandbox-config.h +++ b/libvirt-sandbox/libvirt-sandbox-config.h @@ -180,6 +180,12 @@ gboolean gvir_sandbox_config_set_security_opts(GVirSan= dboxConfig *config, const gchar *optstr, GError**error); =20 +void gvir_sandbox_config_set_debug(GVirSandboxConfig *config, gboolean deb= ug); +gboolean gvir_sandbox_config_get_debug(GVirSandboxConfig *config); + +void gvir_sandbox_config_set_verbose(GVirSandboxConfig *config, gboolean v= erbose); +gboolean gvir_sandbox_config_get_verbose(GVirSandboxConfig *config); + gchar **gvir_sandbox_config_get_command(GVirSandboxConfig *config); =20 G_END_DECLS diff --git a/libvirt-sandbox/libvirt-sandbox-init-common.c b/libvirt-sandbo= x/libvirt-sandbox-init-common.c index 7ea63cf..240ca83 100644 --- a/libvirt-sandbox/libvirt-sandbox-init-common.c +++ b/libvirt-sandbox/libvirt-sandbox-init-common.c @@ -1442,6 +1442,9 @@ int main(int argc, char **argv) { goto cleanup; } =20 + debug =3D gvir_sandbox_config_get_debug(config); + verbose =3D gvir_sandbox_config_get_verbose(config); + setenv("PATH", "/bin:/usr/bin:/usr/local/bin:/sbin/:/usr/sbin", 1); unsetenv("LD_LIBRARY_PATH"); =20 diff --git a/libvirt-sandbox/libvirt-sandbox.sym b/libvirt-sandbox/libvirt-= sandbox.sym index b7c5921..1bead3e 100644 --- a/libvirt-sandbox/libvirt-sandbox.sym +++ b/libvirt-sandbox/libvirt-sandbox.sym @@ -120,6 +120,8 @@ LIBVIRT_SANDBOX_0.6.0 { gvir_sandbox_config_get_userid; gvir_sandbox_config_get_username; gvir_sandbox_config_get_uuid; + gvir_sandbox_config_get_debug; + gvir_sandbox_config_get_verbose; gvir_sandbox_config_find_mount; gvir_sandbox_config_has_networks; gvir_sandbox_config_has_mounts; @@ -143,6 +145,8 @@ LIBVIRT_SANDBOX_0.6.0 { gvir_sandbox_config_set_security_label; gvir_sandbox_config_set_security_opts; gvir_sandbox_config_set_uuid; + gvir_sandbox_config_set_debug; + gvir_sandbox_config_set_verbose; =20 gvir_sandbox_config_initrd_add_module; gvir_sandbox_config_initrd_get_init; --=20 2.15.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list