From nobody Mon Sep 16 19:19:21 2024 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 1716801596477793.6389491754722; Mon, 27 May 2024 02:19:56 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D8DC11B12; Mon, 27 May 2024 05:19:54 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A9080191B; Mon, 27 May 2024 05:19:09 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 40E36191C; Mon, 27 May 2024 05:19:07 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 CDC111919 for ; Mon, 27 May 2024 05:19:06 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-594-vkAyJ1_ANOmqVatisCVP1Q-1; Mon, 27 May 2024 05:19:04 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2AA163C025BF for ; Mon, 27 May 2024 09:19:04 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB17740005B for ; Mon, 27 May 2024 09:19:03 +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.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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=1716801546; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=34mI4s05n1XL7GkSWZt0YUfIgbTeDaVByLveudukf2U=; b=CzrGmGdnX14g62bf6cQ5Cp7LYD789G+Wat1WlSD+GrHf3fQzUbxkkYqnxMqz2mtGgcYY1W lOoRgBbwBpjIeieYL0dEDfDZE9jG5LpSt0LRcFjLFoacJrGXXCaDlTcXC8sUfxhmNMIpzM +/PjohN0peaYupW+ABzgx61OmUNi/2s= X-MC-Unique: vkAyJ1_ANOmqVatisCVP1Q-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 1/6] kbase: Use virt-admin daemon-timeout correctly Date: Mon, 27 May 2024 11:18:49 +0200 Message-ID: <691a9d2bb393688fc6e149b1eb1889ef1bfa6eda.1716801414.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: Z6WAOKHIVIGFQJQBUVT33B5J5XT2L3SJ X-Message-ID-Hash: Z6WAOKHIVIGFQJQBUVT33B5J5XT2L3SJ X-MailFrom: mprivozn@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: 1716801598383100001 Content-Type: text/plain; charset="utf-8"; x-default="true" In a few examples we recommend disabling daemon timeout when fetching debug logs. While it makes sense the actual syntax used results in an error: # virt-admin daemon-timeout 0 error: unexpected data '0' This is because --timeout is required. Update examples to include it. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- docs/kbase/debuglogs.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/kbase/debuglogs.rst b/docs/kbase/debuglogs.rst index f08132d099..dff2cfd144 100644 --- a/docs/kbase/debuglogs.rst +++ b/docs/kbase/debuglogs.rst @@ -25,7 +25,7 @@ the system clears this setting:: =20 # virt-admin -c virtqemud:///system daemon-log-outputs "3:journald 1:fi= le:/var/log/libvirt/libvirtd.log" # virt-admin -c virtqemud:///system daemon-log-filters "3:remote 4:even= t 3:util.json 3:util.object 3:util.dbus 3:util.netlink 3:node_device 3:rpc = 3:access 1:*" - # virt-admin -c virtqemud:///system daemon-timeout 0 + # virt-admin -c virtqemud:///system daemon-timeout --timeout 0 =20 The last command disabling timeout of the daemon is available since ``libvirt-8.6.0``. With older versions make sure to reproduce the issue wi= thin @@ -224,7 +224,7 @@ is re-started with another command. =20 To prevent auto-shutdown of the daemon you can use the following command:: =20 - virt-admin daemon-timeout 0 + virt-admin daemon-timeout --timeout 0 =20 The above is introduced in libvirt-8.6.0. =20 --=20 2.44.1 From nobody Mon Sep 16 19:19:21 2024 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 1716801688782817.2023420243526; Mon, 27 May 2024 02:21:28 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D419B1A3A; Mon, 27 May 2024 05:21:24 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id AD9801A40; Mon, 27 May 2024 05:19:19 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id A7E571918; Mon, 27 May 2024 05:19:07 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 49964191E for ; Mon, 27 May 2024 05:19:07 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-594-qwVyyF3MOf2MhHjc1di3QQ-1; Mon, 27 May 2024 05:19:04 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id B27CD185A78E for ; Mon, 27 May 2024 09:19:04 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E50A40005C for ; Mon, 27 May 2024 09:19:04 +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.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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=1716801547; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lOVl+RqC5menpPAyGavcOFuedssFLUgRVNb5pS3XP5U=; b=b1z2D/UzzA0V42KUCb1W9TOgEOXQRwPjIcjeihhEWvhVFNCQ6LEp4xj3kpG62aBwrYpXC4 ZsAsTQzeXctpDm996Rn4Z+wEKQPhjTFjZEXElWhv20q2age0uuEqJiW66DsbEAfuYiVV6h xbGOmVyNgZY4jIW7d94iNqDTA+BGog8= X-MC-Unique: qwVyyF3MOf2MhHjc1di3QQ-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 2/6] virt-admin: Make --timeout of daemon-timeout positional argument Date: Mon, 27 May 2024 11:18:50 +0200 Message-ID: <286620b4cba8cdfb36299824d86f40ee10e689ec.1716801414.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 4HT36TXH2K7TGVFLMC7DKDM3GY6DUMJP X-Message-ID-Hash: 4HT36TXH2K7TGVFLMC7DKDM3GY6DUMJP X-MailFrom: mprivozn@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: 1716801689312100001 Content-Type: text/plain; charset="utf-8"; x-default="true" We currently require full argument specification: virt-admin daemon-timeout --timeout X Well, the '--timeout' feels a bit redundant. Turn the argument into a positional so that the following works too: virt-admin daemon-timeout X Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- docs/manpages/virt-admin.rst | 2 +- tools/virt-admin.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/manpages/virt-admin.rst b/docs/manpages/virt-admin.rst index 5108781636..54a6512ef7 100644 --- a/docs/manpages/virt-admin.rst +++ b/docs/manpages/virt-admin.rst @@ -320,7 +320,7 @@ daemon-timeout =20 :: =20 - daemon-timeout --timeout NUM + daemon-timeout [--timeout] NUM =20 Sets the daemon timeout to the value of '--timeout' argument. Use ``--time= out 0`` to disable auto-shutdown of the daemon. diff --git a/tools/virt-admin.c b/tools/virt-admin.c index 1805618035..3eb4f0f3fd 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -1009,6 +1009,7 @@ static const vshCmdOptDef opts_daemon_timeout[] =3D { {.name =3D "timeout", .type =3D VSH_OT_INT, .required =3D true, + .positional =3D true, .help =3D N_("number of seconds the daemon will run without any activ= e connection"), }, {.name =3D NULL} --=20 2.44.1 From nobody Mon Sep 16 19:19:21 2024 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 171680175819413.142639259802309; Mon, 27 May 2024 02:22:38 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 216841BF0; Mon, 27 May 2024 05:22:37 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 925F61A6A; Mon, 27 May 2024 05:19:28 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id C60001919; Mon, 27 May 2024 05:19:08 -0400 (EDT) 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 408B11918 for ; Mon, 27 May 2024 05:19:08 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-381-XbdGggVrNsm5PovyihHdKg-1; Mon, 27 May 2024 05:19:05 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 45F1C80590D for ; Mon, 27 May 2024 09:19:05 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5D7C400E89 for ; Mon, 27 May 2024 09:19:04 +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.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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=1716801547; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=K7H8zb1u67EGJo5t+A7sXkvd4ETaPhYPu5/fdn3AOyU=; b=hsDLDBQqrFuSBMP/W6zxefbOlc53HutRmMh+Ap+YsB288/vId2ybow9nWAtzx6MMfY2h/H qZ71GkyDBonfYipqV1s2bGIlhNw6JLmQV9xixGR6oTFrbZZkNRGcmkM0+QK9ArSzwf+NiR 0f5l3ChXaXPHjr2MUctgdUPV8QKDNEM= X-MC-Unique: XbdGggVrNsm5PovyihHdKg-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 3/6] bash-completion: Run virsh/virt-admin in quiet mode Date: Mon, 27 May 2024 11:18:51 +0200 Message-ID: <9b550caccf26fc0f4b709fa4c11013f9c69d0045.1716801414.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: WQ643F2GODBNE7C5A75U3NIE3GOPDN7S X-Message-ID-Hash: WQ643F2GODBNE7C5A75U3NIE3GOPDN7S X-MailFrom: mprivozn@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: 1716801759799100001 Content-Type: text/plain; charset="utf-8"; x-default="true" In some cases (e.g. when virt-admin connects to the default URI) some info message is printed onto stdout (using vshPrintExtra()). This hurts user experience, just consider: virt-admin NOTE\:\ Connecting\ to\ default\ daemon.\ Specify\ daemon\ using\ -c\ \(e= .g.\ virtqemud\:///system\) when no daemon is running. Suppress extra prints by passing '-q' in the bash-completion script. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- tools/bash-completion/vsh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bash-completion/vsh.in b/tools/bash-completion/vsh.in index 897f74cc08..5692788d63 100644 --- a/tools/bash-completion/vsh.in +++ b/tools/bash-completion/vsh.in @@ -30,7 +30,7 @@ _@command@_complete() c=3D$((++c)) done =20 - CMDLINE=3D( ) + CMDLINE=3D( "-q" ) if [ -n "${RO}" ]; then CMDLINE+=3D("-r") fi --=20 2.44.1 From nobody Mon Sep 16 19:19:21 2024 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 1716801723485557.0548371379518; Mon, 27 May 2024 02:22:03 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 5C44F1C16; Mon, 27 May 2024 05:22:02 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 1338D1B98; Mon, 27 May 2024 05:19:24 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 99D46191C; Mon, 27 May 2024 05:19:08 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 22B3C1919 for ; Mon, 27 May 2024 05:19:08 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-686-J04rAKteMM6juqf0QA6l0g-1; Mon, 27 May 2024 05:19:06 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id CD5D429AA3A2 for ; Mon, 27 May 2024 09:19:05 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7981A40005B for ; Mon, 27 May 2024 09:19:05 +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.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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=1716801547; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=063QWXJrgKfWAJzNPM1lzCnAwiESadtl7cxfOeeldMo=; b=R22IPNQ6aHf/vemLROlEOVo4PuLXFNkAgjX0B+xW+9tlVJZEMzhFIxK8HQyfEXWJtfT0mx 8xwHeqJnblgD0glbLbqR1GPtXTGZp4ueKLe9M0T/n8jLcyGZzzwnZOh1Ix9nOqCNBU9Z0d mRSNUwiIyVfX8HOOltSk80pETslRyEg= X-MC-Unique: J04rAKteMM6juqf0QA6l0g-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 4/6] vsh: Close stderr among with stdin in cmdComplete Date: Mon, 27 May 2024 11:18:52 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: DKLWYPY27STDL3FN3KWUOSS2VDVWYBUE X-Message-ID-Hash: DKLWYPY27STDL3FN3KWUOSS2VDVWYBUE X-MailFrom: mprivozn@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: 1716801729623100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Our completer callbacks must refrain from printing anything onto stderr, but unfortunately that's not how service code around behaves. It may call vshError() and what not. Rather trying to fix all possible paths (just consider opening a connection), just close the stderr. We're already closing stdin. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- tools/vsh.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/vsh.c b/tools/vsh.c index 61a3066f49..de869248b4 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -3488,17 +3488,20 @@ const vshCmdInfo info_complete =3D { =20 #ifdef WITH_READLINE =20 -static virOnceControl vshCmdCompleteCloseStdinOnce =3D VIR_ONCE_CONTROL_IN= ITIALIZER; +static virOnceControl vshCmdCompleteCloseStdinStderrOnce =3D VIR_ONCE_CONT= ROL_INITIALIZER; =20 static void -vshCmdCompleteCloseStdin(void) +vshCmdCompleteCloseStdinStderr(void) { /* In non-interactive mode which is how the 'complete' command is inte= nded * to be used we need to ensure that any authentication callback will = not - * attempt to read any input which would break the completion */ + * attempt to read any input which would break the completion. Similar= ly, + * printing anything onto stderr should be avoided. */ int stdin_fileno =3D STDIN_FILENO; + int stderr_fileno =3D STDERR_FILENO; =20 VIR_FORCE_CLOSE(stdin_fileno); + VIR_FORCE_CLOSE(stderr_fileno); } =20 =20 @@ -3519,7 +3522,7 @@ cmdComplete(vshControl *ctl, const vshCmd *cmd) * need to prevent auth hooks reading any input. Therefore, we * have to close stdin and then connect ourselves. */ if (!ctl->imode) { - if (virOnce(&vshCmdCompleteCloseStdinOnce, vshCmdCompleteCloseStdi= n) < 0) + if (virOnce(&vshCmdCompleteCloseStdinStderrOnce, vshCmdCompleteClo= seStdinStderr) < 0) return false; } =20 --=20 2.44.1 From nobody Mon Sep 16 19:19:21 2024 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 171680179341862.48050593756659; Mon, 27 May 2024 02:23:13 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 566D11AD1; Mon, 27 May 2024 05:23:12 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id D9F0D1B2C; Mon, 27 May 2024 05:19:32 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1AC391B8B; Mon, 27 May 2024 05:19:23 -0400 (EDT) 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 064481939 for ; Mon, 27 May 2024 05:19:09 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-121-cNzOizD_Pg-CXjyD5lzflA-1; Mon, 27 May 2024 05:19:07 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 610FF1C0512D for ; Mon, 27 May 2024 09:19:06 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0CD8640005B for ; Mon, 27 May 2024 09:19:05 +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.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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=1716801549; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=njHVQ2PXrFFpnOOFEIytTf5gZySrlfAXOmLK4TRXXDM=; b=WxQxXyv4eaMyky65dEn8Qgk9+kkQIhXRPFl9afvnyABZvOYyrrVKSrXS+Hme26U3O+Rzsa u3rxWfAcBvUc/jtXUaQuJeP6Za/le2aeOTlBQqVc+4v+w4LGOy2cUFyHNRQB81HisnPdBE I1uIxTp9f2RWsFaw4CtXjEKG14jiecc= X-MC-Unique: cNzOizD_Pg-CXjyD5lzflA-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 5/6] vsh: Restore original rl_line_buffer after completion Date: Mon, 27 May 2024 11:18:53 +0200 Message-ID: <734050628dc177d495c3dd3ebb99d8092b204504.1716801414.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: VD7OAVTZGF76IKSHII2HR7J34ZZVHVUD X-Message-ID-Hash: VD7OAVTZGF76IKSHII2HR7J34ZZVHVUD X-MailFrom: mprivozn@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: 1716801793809100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Problem with readline is its API. It's basically a bunch of global variables with no clear dependencies between them. In this specific case that I'm seeing: in interactive mode the cmdComplete() causes instant crash of virsh/virt-admin: =3D=3D27999=3D=3D Invalid write of size 1 =3D=3D27999=3D=3D at 0x516EF71: _rl_init_line_state (readline.c:742) =3D=3D27999=3D=3D by 0x5170054: rl_initialize (readline.c:1192) =3D=3D27999=3D=3D by 0x516E5E4: readline (readline.c:379) =3D=3D27999=3D=3D by 0x1B7024: vshReadline (vsh.c:3048) =3D=3D27999=3D=3D by 0x140DCF: main (virsh.c:905) =3D=3D27999=3D=3D Address 0x0 is not stack'd, malloc'd or (recently) free'd This is because readline keeps a copy of pointer to rl_line_buffer and the moment cmdComplete() returns and readline takes over, it accesses the copy which is now a dangling pointer. To fix this, just keep the original state of rl_line_buffer and restore it. Fixes: 41400ac1dda55b817388a4050aa823051bda2e05 Fixes: a0e1ada63c0afdc2af3b9405cbf637d8bd28700c Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- tools/vsh.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/vsh.c b/tools/vsh.c index de869248b4..c91d756885 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -3511,6 +3511,7 @@ cmdComplete(vshControl *ctl, const vshCmd *cmd) const vshClientHooks *hooks =3D ctl->hooks; const char *lastArg =3D NULL; const char **args =3D NULL; + char *old_rl_line_buffer =3D NULL; g_auto(GStrv) matches =3D NULL; char **iter; =20 @@ -3531,6 +3532,7 @@ cmdComplete(vshControl *ctl, const vshCmd *cmd) =20 vshReadlineInit(ctl); =20 + old_rl_line_buffer =3D g_steal_pointer(&rl_line_buffer); if (!(rl_line_buffer =3D g_strdup(vshCommandOptArgvString(cmd, "string= ")))) rl_line_buffer =3D g_strdup(""); =20 @@ -3540,6 +3542,7 @@ cmdComplete(vshControl *ctl, const vshCmd *cmd) =20 matches =3D vshReadlineCompletion(lastArg, 0, 0); g_clear_pointer(&rl_line_buffer, g_free); + rl_line_buffer =3D g_steal_pointer(&old_rl_line_buffer); =20 if (!matches) return false; --=20 2.44.1 From nobody Mon Sep 16 19:19:21 2024 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 1716801825449372.1903600499842; Mon, 27 May 2024 02:23:45 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 761791918; Mon, 27 May 2024 05:23:44 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id EC2C51BBF; Mon, 27 May 2024 05:19:37 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E06CA194F; Mon, 27 May 2024 05:19:24 -0400 (EDT) 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 25A83194F for ; Mon, 27 May 2024 05:19:10 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-461-7I9a-36aMwCxblrGAMDRyA-1; Mon, 27 May 2024 05:19:07 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id E8040185AD2D for ; Mon, 27 May 2024 09:19:06 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 94220400057 for ; Mon, 27 May 2024 09:19:06 +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.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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=1716801549; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wJd85tLGfFicl5gZMsryzqm19hBWXR3oKEd0ZB1LNpE=; b=DAqOdTO5bBG/AodklrCVpRnyEnggYbqGvzkm2MrT3bbDUIAarWoIg11LCRWtJF5aT75zhH mjlWHtqk9ct+ngJ4ps77rFRoV02WZe74EZGq46tu+bOPUd49ganRNCXx9GERB3LHGbr+xf DTKrQg20eRyql+GYcBWD2V+QPwjJF6s= X-MC-Unique: 7I9a-36aMwCxblrGAMDRyA-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 6/6] vsh: Don't crash when @text is NULL in vshCompleterFilter() Date: Mon, 27 May 2024 11:18:54 +0200 Message-ID: <415b67be980d63e72f71e4517c0485a4b9d8ebea.1716801414.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: R2TKT5YRYTUPDM6RP354OOLOCNEKNITL X-Message-ID-Hash: R2TKT5YRYTUPDM6RP354OOLOCNEKNITL X-MailFrom: mprivozn@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: 1716801825988100001 Content-Type: text/plain; charset="utf-8"; x-default="true" This can happen only for cmdComplete() in interactive mode (which I'm still not convinced is any useful for users and whether we should support it). Anyway, running plain 'complete' command with no additional arguments boils down to @text being NULL in vshReadlineParse() which handles the case just right but is then subsequently passed to vshCompleterFilter() which isn't prepared for this case. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- tools/vsh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/vsh.c b/tools/vsh.c index c91d756885..6cc1f60d87 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -2820,7 +2820,7 @@ vshCompleterFilter(char ***list, newList =3D g_new0(char *, list_len + 1); =20 for (i =3D 0; i < list_len; i++) { - if (!STRPREFIX((*list)[i], text)) { + if (text && !STRPREFIX((*list)[i], text)) { g_clear_pointer(&(*list)[i], g_free); continue; } --=20 2.44.1