From nobody Tue Jan 21 04:05:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1736328812811833.5435983276053; Wed, 8 Jan 2025 01:33:32 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id B1BFB1221; Wed, 8 Jan 2025 04:33:29 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 5AD5211BC; Wed, 8 Jan 2025 04:33:09 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 0175F11BC; Wed, 8 Jan 2025 04:33:06 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 7439C11B2 for ; Wed, 8 Jan 2025 04:33:05 -0500 (EST) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-385-oU-7Gw5yOgGFt9Y7SwzlwA-1; Wed, 08 Jan 2025 04:33:03 -0500 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 151B019560A2 for ; Wed, 8 Jan 2025 09:33:03 +0000 (UTC) Received: from toolbx.redhat.com (unknown [10.42.28.103]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 07D711956094; Wed, 8 Jan 2025 09:33:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736328785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xuNzkLG8fwduL4KkNANr+NJD2GbHNANOfCT5zrGGz3s=; b=aoS6spqEt2sjTSYas2zrmt942l0MSK4HoA+b3cQKP3HrGk+BWkdUGMGSyh4c8BFSdjNGZ6 S8Deu/q46q/0i4YSWjAqQl29yCdN03k2WswrjTm4Iit0mHBpuv1wRQYY3XKitQ/o9uXXCR Dbg0xOHnMCY4CqumU2xgyrczKuNaIs4= X-MC-Unique: oU-7Gw5yOgGFt9Y7SwzlwA-1 X-Mimecast-MFC-AGG-ID: oU-7Gw5yOgGFt9Y7SwzlwA From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: devel@lists.libvirt.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH] tools: fix ordering mistake in virt-admin daemon-set-timeout code Date: Wed, 8 Jan 2025 09:33:00 +0000 Message-ID: <20250108093300.680440-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: HFMVss8H5ZDBCSk6Z9kTgMgZVmjqoBm2y9FhYx_KrIk_1736328783 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: UPLDGEGBHBEWZBEVKMH6CULW4N4UYZ3A X-Message-ID-Hash: UPLDGEGBHBEWZBEVKMH6CULW4N4UYZ3A X-MailFrom: berrange@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1736328814302116600 Content-Type: text/plain; charset="utf-8" Most of the impl for the 'daemon-set-timeout' command was ordered under the heading for the 'daemon-log-filters' command. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Martin Kletzander --- tools/virt-admin.c | 67 +++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/tools/virt-admin.c b/tools/virt-admin.c index 3eb4f0f3fd..325b7aa827 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -1005,27 +1005,38 @@ static const vshCmdInfo info_daemon_log_outputs =3D= { "daemon."), }; =20 -static const vshCmdOptDef opts_daemon_timeout[] =3D { - {.name =3D "timeout", - .type =3D VSH_OT_INT, - .required =3D true, +static const vshCmdOptDef opts_daemon_log_outputs[] =3D { + {.name =3D "outputs", + .type =3D VSH_OT_STRING, .positional =3D true, - .help =3D N_("number of seconds the daemon will run without any activ= e connection"), + .help =3D N_("redefine the existing set of logging outputs"), + .allowEmpty =3D true }, {.name =3D NULL} }; =20 static bool -cmdDaemonTimeout(vshControl *ctl, const vshCmd *cmd) +cmdDaemonLogOutputs(vshControl *ctl, const vshCmd *cmd) { vshAdmControl *priv =3D ctl->privData; - unsigned int timeout =3D 0; =20 - if (vshCommandOptUInt(ctl, cmd, "timeout", &timeout) < 0) - return false; + if (vshCommandOptBool(cmd, "outputs")) { + const char *outputs =3D NULL; + if ((vshCommandOptString(ctl, cmd, "outputs", &outputs) < 0 || + virAdmConnectSetLoggingOutputs(priv->conn, outputs, 0) < 0)) { + vshError(ctl, _("Unable to change daemon logging settings")); + return false; + } + } else { + g_autofree char *outputs =3D NULL; + if (virAdmConnectGetLoggingOutputs(priv->conn, &outputs, 0) < 0) { + vshError(ctl, _("Unable to get daemon logging outputs informat= ion")); + return false; + } =20 - if (virAdmConnectSetDaemonTimeout(priv->conn, timeout, 0) < 0) - return false; + vshPrintExtra(ctl, " %-15s", _("Logging outputs: ")); + vshPrint(ctl, "%s\n", NULLSTR_EMPTY(outputs)); + } =20 return true; } @@ -1040,42 +1051,32 @@ static const vshCmdInfo info_daemon_timeout =3D { .desc =3D N_("set the auto shutdown timeout of the daemon"), }; =20 -static const vshCmdOptDef opts_daemon_log_outputs[] =3D { - {.name =3D "outputs", - .type =3D VSH_OT_STRING, +static const vshCmdOptDef opts_daemon_timeout[] =3D { + {.name =3D "timeout", + .type =3D VSH_OT_INT, + .required =3D true, .positional =3D true, - .help =3D N_("redefine the existing set of logging outputs"), - .allowEmpty =3D true + .help =3D N_("number of seconds the daemon will run without any activ= e connection"), }, {.name =3D NULL} }; =20 static bool -cmdDaemonLogOutputs(vshControl *ctl, const vshCmd *cmd) +cmdDaemonTimeout(vshControl *ctl, const vshCmd *cmd) { vshAdmControl *priv =3D ctl->privData; + unsigned int timeout =3D 0; =20 - if (vshCommandOptBool(cmd, "outputs")) { - const char *outputs =3D NULL; - if ((vshCommandOptString(ctl, cmd, "outputs", &outputs) < 0 || - virAdmConnectSetLoggingOutputs(priv->conn, outputs, 0) < 0)) { - vshError(ctl, _("Unable to change daemon logging settings")); - return false; - } - } else { - g_autofree char *outputs =3D NULL; - if (virAdmConnectGetLoggingOutputs(priv->conn, &outputs, 0) < 0) { - vshError(ctl, _("Unable to get daemon logging outputs informat= ion")); - return false; - } + if (vshCommandOptUInt(ctl, cmd, "timeout", &timeout) < 0) + return false; =20 - vshPrintExtra(ctl, " %-15s", _("Logging outputs: ")); - vshPrint(ctl, "%s\n", NULLSTR_EMPTY(outputs)); - } + if (virAdmConnectSetDaemonTimeout(priv->conn, timeout, 0) < 0) + return false; =20 return true; } =20 + static void * vshAdmConnectionHandler(vshControl *ctl) { --=20 2.47.1