From nobody Sun May 5 11:28:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631812602; cv=none; d=zohomail.com; s=zohoarc; b=mw4KLbyLcN5LACNHDL++nuITebPMMWj8HmK/YPB2+RuYFxjZYCf3eoLaHb9J3CtdUZqOB6bfUd5fWZzJ7cCCaVdGflKHFXTezMpTXUTo5lPE9Qy8F5EpWfENNrhTmPq8MgZ/qcr2YvweFeAC3DI+QYyrc3XxUhHkjtsk3cQh6Ng= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631812602; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sgJf9an/s9QT/zhAZQzTs3/4kDR2jlo9mkTQ3JzKBFI=; b=kSXEzJtCjYmgZL5HVu1pbB5YBmMuGGPgZVwP03UiB9rd/IgMOYf7jgeymBjGKTvys2ICvbvJX7cfbamTaD+i8eKCHHPpmA+bSTKQgX9SPCy9ZwOsFkS1NzqJup39Fu1fOWZ1DIasTUcE3HJdw+D9hg4obbSlJJEwF2M7E1PEGNo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1631812602485494.7437632034578; Thu, 16 Sep 2021 10:16:42 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-365-sDKaMKK6OBusDM5hVOzzNQ-1; Thu, 16 Sep 2021 13:16:39 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B06488030AF; Thu, 16 Sep 2021 17:16:32 +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 549455C1D1; Thu, 16 Sep 2021 17:16:32 +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 C43D64EA2A; Thu, 16 Sep 2021 17:16:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18GHAqIF008262 for ; Thu, 16 Sep 2021 13:10:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6D94318B5E; Thu, 16 Sep 2021 17:10:52 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id C679969FAD for ; Thu, 16 Sep 2021 17:10:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631812601; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=sgJf9an/s9QT/zhAZQzTs3/4kDR2jlo9mkTQ3JzKBFI=; b=A/w2w+e7vAQHL8b/Ro9jLf+XMx+aIaAl/nYOJw4BvuNecW25oG1KiwwCyYT37liqy7sjtt 8fuYjWobAqGbph7QnNS4OX/1wTBy7W3OjQXvzajjf1LtO9UIcrPMBvi9Q3+/WO7PO2m/e7 fJd+RsPRfxp2RPil7YoN36YKvqXO+g8= X-MC-Unique: sDKaMKK6OBusDM5hVOzzNQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/14] virshCheckpointNameCompleter: Sanitize forward declaration use Date: Thu, 16 Sep 2021 19:10:32 +0200 Message-Id: <0d03446064e25437d1d3ddb384c1dd00fae701c1.1631811763.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631812604716100003 Content-Type: text/plain; charset="utf-8" Include the proper header instead of duplicating the declaration. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tools/virsh-completer.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tools/virsh-completer.h b/tools/virsh-completer.h index 7edb8e2f7e..874813335d 100644 --- a/tools/virsh-completer.h +++ b/tools/virsh-completer.h @@ -20,6 +20,7 @@ #pragma once +#include "virsh-completer-checkpoint.h" #include "virsh-completer-domain.h" #include "virsh-completer-host.h" #include "virsh-completer-interface.h" @@ -33,7 +34,3 @@ char ** virshCommaStringListComplete(const char *input, const char **options); - -char ** virshCheckpointNameCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); --=20 2.31.1 From nobody Sun May 5 11:28:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631812266; cv=none; d=zohomail.com; s=zohoarc; b=CUS8tZqhdVbKGK66LHG6Pb9PWcJkwSaoTFtwiwwtqTjyIXuEdHeMIrhLmX144AsL3PNrt7NNeR3n5aM5n/am/kag9fKB1EH9p6ciymYhxN3suEXUUR2WTNDRv1UClaIbL16oNfkOCHWTA2R7e//d9YgXHL9UewCI2O8V2VgIpVc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631812266; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ajVA3L05406LLx71+CewTR/ZlXkR4K9FewWgSsXDOq4=; b=ZmgHc7x4c7cr68tkKZfQ80IK2QON4W26Eeqf7N3dR1W6Dr9h9+BST15QzJsVTcROis7kd+NEboqX8RyZ7PKjygRAFMY+Yu+U65H1VqfQktIbR4UztveB8zJ06YtolNRy289BWZqffBhu3hZOpsU4qH+Tf0iBCHBZjdSVIfo2FSw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1631812266076654.1363871991574; Thu, 16 Sep 2021 10:11:06 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-398-FoK3fFO7OZm5rZlMR3o8zg-1; Thu, 16 Sep 2021 13:11:03 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7CB0B101F001; Thu, 16 Sep 2021 17:10:57 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1DAAD60CC9; Thu, 16 Sep 2021 17:10: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 3FD17180598A; Thu, 16 Sep 2021 17:10:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18GHArsE008272 for ; Thu, 16 Sep 2021 13:10:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id B011018B5E; Thu, 16 Sep 2021 17:10:53 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id D695869FAD for ; Thu, 16 Sep 2021 17:10:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631812265; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ajVA3L05406LLx71+CewTR/ZlXkR4K9FewWgSsXDOq4=; b=ChQKCSuCxNKlaZPf8xXETfyUZKH/ZpWd3EvbNcJqF5WOXwA+iR7iIfrzrWDqxupDiJ2IAa FIdXSSjJjvh+Ny2ff/gN8qYxk+kkbn1GRKLNgzatIkPU3JfEvsZrdeuHakpk1Q2xsSDZt6 utFDjU63GJiB3TKVDigkNlQsERecyIY= X-MC-Unique: FoK3fFO7OZm5rZlMR3o8zg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/14] virsh-completer*.h: Use modern header style Date: Thu, 16 Sep 2021 19:10:33 +0200 Message-Id: <082ac9e2f27f615cde458604393e3a0e239966ef.1631811763.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631812267898100001 Content-Type: text/plain; charset="utf-8" Prevent the need to edit the function declarations to put them into the header. There was even inconsistent use. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tools/virsh-completer-checkpoint.h | 7 +- tools/virsh-completer-domain.h | 155 +++++++++++++++++------------ tools/virsh-completer-host.h | 28 +++--- tools/virsh-completer-interface.h | 14 +-- tools/virsh-completer-network.h | 35 ++++--- tools/virsh-completer-nodedev.h | 21 ++-- tools/virsh-completer-nwfilter.h | 14 +-- tools/virsh-completer-pool.h | 21 ++-- tools/virsh-completer-secret.h | 14 +-- tools/virsh-completer-snapshot.h | 7 +- tools/virsh-completer-volume.h | 14 +-- tools/virsh-completer.h | 5 +- 12 files changed, 192 insertions(+), 143 deletions(-) diff --git a/tools/virsh-completer-checkpoint.h b/tools/virsh-completer-che= ckpoint.h index c536a3ffda..f76af14817 100644 --- a/tools/virsh-completer-checkpoint.h +++ b/tools/virsh-completer-checkpoint.h @@ -22,6 +22,7 @@ #include "vsh.h" -char ** virshCheckpointNameCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshCheckpointNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-completer-domain.h b/tools/virsh-completer-domain.h index 39cedf0141..f23ec2735f 100644 --- a/tools/virsh-completer-domain.h +++ b/tools/virsh-completer-domain.h @@ -22,37 +22,44 @@ #include "vsh.h" -char ** virshDomainNameCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshDomainNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); enum { VIRSH_DOMAIN_INTERFACE_COMPLETER_MAC =3D 1 << 0, /* Return just MACs */ }; -char ** virshDomainInterfaceCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshDomainInterfaceCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshDomainDiskTargetCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshDomainDiskTargetCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshDomainEventNameCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshDomainEventNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshDomainInterfaceStateCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshDomainInterfaceStateCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshDomainDeviceAliasCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshDomainDeviceAliasCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshDomainShutdownModeCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshDomainShutdownModeCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); char ** virshDomainInterfaceAddrSourceCompleter(vshControl *ctl, @@ -64,70 +71,86 @@ virshDomainInterfaceSourceModeCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); -char ** virshDomainHostnameSourceCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshDomainHostnameSourceCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshDomainPerfEnableCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshDomainPerfEnableCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshDomainPerfDisableCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshDomainPerfDisableCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshDomainUUIDCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshDomainUUIDCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshDomainIOThreadIdCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshDomainIOThreadIdCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshDomainVcpuCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshDomainVcpuCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); + +char ** +virshDomainVcpulistCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); + +char ** +virshDomainCpulistCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshDomainVcpulistCompleter(vshControl *ctl, +char ** +virshDomainVcpulistViaAgentCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); -char ** virshDomainCpulistCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshDomainConsoleCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshDomainVcpulistViaAgentCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshDomainSignalCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshDomainConsoleCompleter(vshControl *ctl, +char ** +virshDomainLifecycleCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); + +char ** +virshDomainLifecycleActionCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); -char ** virshDomainSignalCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); - -char ** virshDomainLifecycleCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); - -char ** virshDomainLifecycleActionCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshCodesetNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshCodesetNameCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshKeycodeNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshKeycodeNameCompleter(vshControl *ctl, +char ** +virshDomainFSMountpointsCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); -char ** virshDomainFSMountpointsCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); - char ** virshDomainCoreDumpFormatCompleter(vshControl *ctl, const vshCmd *cmd, diff --git a/tools/virsh-completer-host.h b/tools/virsh-completer-host.h index 88106ec3db..e71ccff536 100644 --- a/tools/virsh-completer-host.h +++ b/tools/virsh-completer-host.h @@ -22,18 +22,22 @@ #include "vsh.h" -char ** virshAllocpagesPagesizeCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshAllocpagesPagesizeCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshCellnoCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshCellnoCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshNodeCpuCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshNodeCpuCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshNodeSuspendTargetCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshNodeSuspendTargetCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-completer-interface.h b/tools/virsh-completer-inte= rface.h index 733f18cb88..3c2ad7d9cb 100644 --- a/tools/virsh-completer-interface.h +++ b/tools/virsh-completer-interface.h @@ -22,10 +22,12 @@ #include "vsh.h" -char ** virshInterfaceNameCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshInterfaceNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshInterfaceMacCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshInterfaceMacCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-completer-network.h b/tools/virsh-completer-networ= k.h index 80df5c468e..ffcda68355 100644 --- a/tools/virsh-completer-network.h +++ b/tools/virsh-completer-network.h @@ -22,22 +22,27 @@ #include "vsh.h" -char ** virshNetworkNameCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshNetworkNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshNetworkEventNameCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshNetworkEventNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshNetworkPortUUIDCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshNetworkPortUUIDCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshNetworkUUIDCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshNetworkUUIDCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshNetworkDhcpMacCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshNetworkDhcpMacCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-completer-nodedev.h b/tools/virsh-completer-nodede= v.h index 45c0b73c8c..743f7b2465 100644 --- a/tools/virsh-completer-nodedev.h +++ b/tools/virsh-completer-nodedev.h @@ -22,14 +22,17 @@ #include "vsh.h" -char ** virshNodeDeviceNameCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshNodeDeviceNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshNodeDeviceEventNameCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshNodeDeviceEventNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshNodeDeviceCapabilityNameCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshNodeDeviceCapabilityNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-completer-nwfilter.h b/tools/virsh-completer-nwfil= ter.h index 86e7df7da4..6a5cda8880 100644 --- a/tools/virsh-completer-nwfilter.h +++ b/tools/virsh-completer-nwfilter.h @@ -22,10 +22,12 @@ #include "vsh.h" -char ** virshNWFilterNameCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshNWFilterNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshNWFilterBindingNameCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshNWFilterBindingNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-completer-pool.h b/tools/virsh-completer-pool.h index 510233fb65..059b6ba9e0 100644 --- a/tools/virsh-completer-pool.h +++ b/tools/virsh-completer-pool.h @@ -22,14 +22,17 @@ #include "vsh.h" -char ** virshStoragePoolNameCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshStoragePoolNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshPoolEventNameCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshPoolEventNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshPoolTypeCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshPoolTypeCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-completer-secret.h b/tools/virsh-completer-secret.h index 3ed6ba5198..0b1843605c 100644 --- a/tools/virsh-completer-secret.h +++ b/tools/virsh-completer-secret.h @@ -22,10 +22,12 @@ #include "vsh.h" -char ** virshSecretUUIDCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshSecretUUIDCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshSecretEventNameCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshSecretEventNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-completer-snapshot.h b/tools/virsh-completer-snaps= hot.h index 1af32e28ca..c7f389685c 100644 --- a/tools/virsh-completer-snapshot.h +++ b/tools/virsh-completer-snapshot.h @@ -22,6 +22,7 @@ #include "vsh.h" -char ** virshSnapshotNameCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshSnapshotNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-completer-volume.h b/tools/virsh-completer-volume.h index b41d8f4f3e..dc6eeb4b3c 100644 --- a/tools/virsh-completer-volume.h +++ b/tools/virsh-completer-volume.h @@ -23,11 +23,13 @@ #include "vsh.h" -char ** virshStorageVolNameCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshStorageVolNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); -char ** virshStorageVolKeyCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); +char ** +virshStorageVolKeyCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-completer.h b/tools/virsh-completer.h index 874813335d..1243a13a5e 100644 --- a/tools/virsh-completer.h +++ b/tools/virsh-completer.h @@ -32,5 +32,6 @@ #include "virsh-completer-snapshot.h" #include "virsh-completer-volume.h" -char ** virshCommaStringListComplete(const char *input, - const char **options); +char ** +virshCommaStringListComplete(const char *input, + const char **options); --=20 2.31.1 From nobody Sun May 5 11:28:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631812267; cv=none; d=zohomail.com; s=zohoarc; b=jwz/9tKPdFfkVIYQtFU6Cv4Hd92hGUFxls77bNwjK37gaJesaNUms/DkOTRrwW9kEwILfesTGWREryksHAck+heE05EVWYKK/gi3DOfa34Mw+YF0yuCYZiNNL6k8KNdpJIhMIAygDb04C2bvszi7s5Vb0gWY0vPLfw7q0y7hqqQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631812267; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=b/hf/4YLqqxsarWz27jyDr+hkrnDkwIaj8Z/6TKUtK8=; b=MoeygCVNirn1Cm912Cmmc3UAtBafGAj9GtQH3k3RiFWKESG2FJM3G+V8G5zQNkd85wWcLwybST3w3TBxXW9PjXqBv9M4tbV+4bvPNVgnoHoRwyHaasKhUMbDmwFmI1egSljCDifqCKVK6J/67XYNplAzgXEiC6qtsKI0mZ8H23Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1631812267143574.3274826649994; Thu, 16 Sep 2021 10:11:07 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-175-gq7WxZCoNAK-H0V6JdbP-w-1; Thu, 16 Sep 2021 13:11:03 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 18BB0101F004; Thu, 16 Sep 2021 17:10:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 18E9418EC5; Thu, 16 Sep 2021 17:10: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 579171801241; Thu, 16 Sep 2021 17:10:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18GHAsxF008277 for ; Thu, 16 Sep 2021 13:10:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id BB9D018B5E; Thu, 16 Sep 2021 17:10:54 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D96F60583 for ; Thu, 16 Sep 2021 17:10:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631812266; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=b/hf/4YLqqxsarWz27jyDr+hkrnDkwIaj8Z/6TKUtK8=; b=C8AR/C9dp1xZwiQ9/nZOwY55mnLZwPLw+PXp4ydS6PGASvJPeCTElK/X21ZGgnSRjuaz1J ZWlkQCioL4EFrja4VAmmOgXuSztD2oujwcVQxaZqAl+5fW7LBQcANDJUHAXUcHdnxJ2APv B9koZ+ySpmThDUUvyH3tC5cKbKsZo0Q= X-MC-Unique: gq7WxZCoNAK-H0V6JdbP-w-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/14] virsh: Remove hack using 'VSH_CMD_FLAG_ALIAS' to hide virsh commands Date: Thu, 16 Sep 2021 19:10:34 +0200 Message-Id: <183ffd9e6d560b4ebab39c9f17454ffec312ec6a.1631811763.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631812268019100002 Content-Type: text/plain; charset="utf-8" Introduce a proper flag 'VSH_CMD_FLAG_HIDDEN' for hiding commands from output so that we can validate that there aren't any loops or misconfigured commands. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tools/virsh.c | 3 ++- tools/virt-admin.c | 3 ++- tools/vsh.c | 9 ++++++--- tools/vsh.h | 7 +++---- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index ce5fd247dd..3c6f60f176 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -464,7 +464,8 @@ virshUsage(void) fprintf(stdout, _(" %s (help keyword '%s')\n"), grp->name, grp->keyword); for (cmd =3D grp->commands; cmd->name; cmd++) { - if (cmd->flags & VSH_CMD_FLAG_ALIAS) + if (cmd->flags & VSH_CMD_FLAG_ALIAS || + cmd->flags & VSH_CMD_FLAG_HIDDEN) continue; fprintf(stdout, " %-30s %s\n", cmd->name, diff --git a/tools/virt-admin.c b/tools/virt-admin.c index c8e7ee794a..c0818e850a 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -1235,7 +1235,8 @@ vshAdmUsage(void) fprintf(stdout, _(" %s (help keyword '%s')\n"), grp->name, grp->keyword); for (cmd =3D grp->commands; cmd->name; cmd++) { - if (cmd->flags & VSH_CMD_FLAG_ALIAS) + if (cmd->flags & VSH_CMD_FLAG_ALIAS || + cmd->flags & VSH_CMD_FLAG_HIDDEN) continue; fprintf(stdout, " %-30s %s\n", cmd->name, diff --git a/tools/vsh.c b/tools/vsh.c index ea078c707b..eb17a58dc0 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -577,7 +577,8 @@ vshCmdGrpHelp(vshControl *ctl, const vshCmdGrp *grp) grp->keyword); for (cmd =3D grp->commands; cmd->name; cmd++) { - if (cmd->flags & VSH_CMD_FLAG_ALIAS) + if (cmd->flags & VSH_CMD_FLAG_ALIAS || + cmd->flags & VSH_CMD_FLAG_HIDDEN) continue; vshPrint(ctl, " %-30s %s\n", cmd->name, _(vshCmddefGetInfo(cmd, "help"))); @@ -2544,7 +2545,8 @@ vshReadlineCommandGenerator(void) for (cmd_list_index =3D 0; cmds[cmd_list_index].name; cmd_list_ind= ex++) { const char *name =3D cmds[cmd_list_index].name; - if (cmds[cmd_list_index].flags & VSH_CMD_FLAG_ALIAS) + if (cmds[cmd_list_index].flags & VSH_CMD_FLAG_ALIAS || + cmds[cmd_list_index].flags & VSH_CMD_FLAG_HIDDEN) continue; VIR_REALLOC_N(ret, ret_size + 2); @@ -3029,7 +3031,8 @@ cmdHelp(vshControl *ctl, const vshCmd *cmd) grp->keyword); for (def =3D grp->commands; def->name; def++) { - if (def->flags & VSH_CMD_FLAG_ALIAS) + if (def->flags & VSH_CMD_FLAG_ALIAS || + def->flags & VSH_CMD_FLAG_HIDDEN) continue; vshPrint(ctl, " %-30s %s\n", def->name, _(vshCmddefGetInfo(def, "help"))); diff --git a/tools/vsh.h b/tools/vsh.h index 39f70913fe..ae50f6b220 100644 --- a/tools/vsh.h +++ b/tools/vsh.h @@ -163,6 +163,7 @@ struct _vshCmdOpt { enum { VSH_CMD_FLAG_NOCONNECT =3D (1 << 0), /* no prior connection needed */ VSH_CMD_FLAG_ALIAS =3D (1 << 1), /* command is an alias */ + VSH_CMD_FLAG_HIDDEN =3D (1 << 2), /* command is hidden/internal */ }; /* @@ -446,8 +447,7 @@ bool cmdComplete(vshControl *ctl, const vshCmd *cmd); .handler =3D cmdSelfTest, \ .opts =3D NULL, \ .info =3D info_selftest, \ - .flags =3D VSH_CMD_FLAG_NOCONNECT | VSH_CMD_FLAG_ALIAS, \ - .alias =3D "self-test" \ + .flags =3D VSH_CMD_FLAG_NOCONNECT | VSH_CMD_FLAG_HIDDEN, \ } #define VSH_CMD_COMPLETE \ @@ -456,8 +456,7 @@ bool cmdComplete(vshControl *ctl, const vshCmd *cmd); .handler =3D cmdComplete, \ .opts =3D opts_complete, \ .info =3D info_complete, \ - .flags =3D VSH_CMD_FLAG_NOCONNECT | VSH_CMD_FLAG_ALIAS, \ - .alias =3D "complete" \ + .flags =3D VSH_CMD_FLAG_NOCONNECT | VSH_CMD_FLAG_HIDDEN, \ } --=20 2.31.1 From nobody Sun May 5 11:28:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631812668; cv=none; d=zohomail.com; s=zohoarc; b=aZZrFPN1IZxvcrKIhySqH8ELe6dm33upGB0AhByE4j3maAZuatPbNKaTFpoR4fhGuM7GSiHcErNd7Tn5sY5zU72iuPyTFi6kXoHVo+qaXj2saVM8eS+rDkUYmYDtafbaze17nfyVrHHNP4Q1AnASFUSWvtBAnD9MCpiTR+brMe8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631812668; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1n0rqhFuxc3adl4e0OIOl2cMAZEFCpTG9MFkxE1tAfs=; b=HR5Fi5X25squxikvQJ1RiXX/6hdsawfmE/k/+mCxzd5mZfOi32bAkP20uT9pxK9mAdv80LmScQFIjmWVtHq0N6cMCU5zqGpEaSS3p6zE/BbP4Hkj+1AMa2fzdZTvcE5ngd2ZeotMutkRucehUyr6OQC+JnwcK4IuPxc3FwxTpy4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1631812668518275.0767629474973; Thu, 16 Sep 2021 10:17:48 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-413-HqNI2YJXO3yi0QhIj8eg9w-1; Thu, 16 Sep 2021 13:17:46 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B2422DF8A3; Thu, 16 Sep 2021 17:17:40 +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 92E3B5C1D1; Thu, 16 Sep 2021 17:17:40 +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 615DD4EA2F; Thu, 16 Sep 2021 17:17:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18GHAtFa008285 for ; Thu, 16 Sep 2021 13:10:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id C559418B5E; Thu, 16 Sep 2021 17:10:55 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2803569FAD for ; Thu, 16 Sep 2021 17:10:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631812667; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=1n0rqhFuxc3adl4e0OIOl2cMAZEFCpTG9MFkxE1tAfs=; b=AuZ9YFlmSA0Vbg6HtFc+ztDRbq6POQykU7gOq+eEYJ3PgLRlVYKejSl9/TJHEfu/4hbQDq YcfZ01k9E2a/QIPiAU2E3LTojD7hTs5vtaS6zks6Y3RGNfI6YaUy205zc08HuZjET3i041 VIgbHCK2ot2eozVPggP9zXeULy3rYLg= X-MC-Unique: HqNI2YJXO3yi0QhIj8eg9w-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/14] vshCmddefCheckInternals: Sanitize command alias validation Date: Thu, 16 Sep 2021 19:10:35 +0200 Message-Id: <177895960fa8e2c6db3756c5567425d72f939b3d.1631811763.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631812669396100001 Content-Type: text/plain; charset="utf-8" We don't need to validate the real command twice, but it's better to check that the real command name exists and it's not an alias to prevent loops. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tools/vsh.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tools/vsh.c b/tools/vsh.c index eb17a58dc0..05da50eace 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -269,11 +269,27 @@ vshCmddefCheckInternals(vshControl *ctl, /* in order to perform the validation resolve the alias first */ if (cmd->flags & VSH_CMD_FLAG_ALIAS) { + const vshCmdDef *alias; + if (!cmd->alias) { vshError(ctl, _("command '%s' has inconsistent alias"), cmd->n= ame); return -1; } - cmd =3D vshCmddefSearch(cmd->alias); + + if (!(alias =3D vshCmddefSearch(cmd->alias))) { + vshError(ctl, _("command alias '%s' is pointing to a non-exist= ant command '%s'"), + cmd->name, cmd->alias); + return -1; + } + + if (alias->flags & VSH_CMD_FLAG_ALIAS) { + vshError(ctl, _("command alias '%s' is pointing to another com= mand alias '%s'"), + cmd->name, cmd->alias); + return -1; + } + + /* we don't need to continue as the real command will be checked s= eparately */ + return 0; } /* Each command has to provide a non-empty help string. */ --=20 2.31.1 From nobody Sun May 5 11:28:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631812745; cv=none; d=zohomail.com; s=zohoarc; b=TXcvAPe8/F9nwr3MW3RcAdT4kInXInFvS+cFqVVPBTVjMXXA55mhwXH5GFJVlXuQSTI67zLQ/k0f9Y8FA+OVigi6a5isYgQDWmxxk+8vS7rlwZwfs6UzSAlURLmSyT/0WlCAsn3tfjWhUo/7A/26b4tzEqvMBiQg4eCaxsdFAaE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631812745; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tae0fDfs8St8gCcMhi8/syxMnrmRHqN4ZiYm0VvInEA=; b=B5tzgXahyM5pY6cpQCvejJcGXrR3F3IThMM3ftK5s0xpGbCkjBSpgEIG6BalZqTOusUMAIfarwvZEMWu0jiM1v38Lqvdc6jsu5eyDb5YOefKRQVyO1DyP/8w8qf4zhfDxMeCkhUHsKU+xv0CYOfHzxY6X2vItzCTqfeOZwARBj4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 163181274537229.477179578790583; Thu, 16 Sep 2021 10:19:05 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-68-tX_oUO5pPxuba26B2vp0bg-1; Thu, 16 Sep 2021 13:17:54 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 22E25801E72; Thu, 16 Sep 2021 17:17:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 02A205C1CF; Thu, 16 Sep 2021 17:17:44 +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 C8F291800FE4; Thu, 16 Sep 2021 17:17:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18GHAu6B008300 for ; Thu, 16 Sep 2021 13:10:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id CD44B18B5E; Thu, 16 Sep 2021 17:10:56 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D50F60583 for ; Thu, 16 Sep 2021 17:10:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631812744; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=tae0fDfs8St8gCcMhi8/syxMnrmRHqN4ZiYm0VvInEA=; b=HVS7xfJhnbFgQtRyDf/kO/mQruwPDOm84HyJE07/WFE84FHAw4NvXUi6nqXzBS1JrjPKii NtPKYD6/D1zeFIQ5OEnqg5pMwLXpSU+7jPVtOBYwxLo2tI308Roj32kkXilAiwXbllcvpW zS+vSQLFjEX3dny0DWRRgQcWa87kcZI= X-MC-Unique: tX_oUO5pPxuba26B2vp0bg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/14] vsh: Introduce '--completers-missing' for 'self-test' command Date: Thu, 16 Sep 2021 19:10:36 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631812747694100001 Content-Type: text/plain; charset="utf-8" Make it simple to spot which options of which commands are missing autocompletion functions by introducing this hidden option. In the future when we'll have completers for everything this can be also used as a hard fail so that completers are always added. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tools/vsh.c | 28 ++++++++++++++++++++++++---- tools/vsh.h | 3 ++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/tools/vsh.c b/tools/vsh.c index 05da50eace..9c6783dad1 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -261,11 +261,13 @@ vshCmddefGetInfo(const vshCmdDef * cmd, const char *n= ame) /* Check if the internal command definitions are correct */ static int vshCmddefCheckInternals(vshControl *ctl, - const vshCmdDef *cmd) + const vshCmdDef *cmd, + bool missingCompleters) { size_t i; const char *help =3D NULL; bool seenOptionalOption =3D false; + g_auto(virBuffer) complbuf =3D VIR_BUFFER_INITIALIZER; /* in order to perform the validation resolve the alias first */ if (cmd->flags & VSH_CMD_FLAG_ALIAS) { @@ -309,6 +311,11 @@ vshCmddefCheckInternals(vshControl *ctl, return -1; /* too many options */ } + if (missingCompleters && + (opt->type =3D=3D VSH_OT_STRING || opt->type =3D=3D VSH_OT_DAT= A) && + !opt->completer) + virBufferStrcat(&complbuf, opt->name, ", ", NULL); + switch (opt->type) { case VSH_OT_STRING: case VSH_OT_BOOL: @@ -391,6 +398,12 @@ vshCmddefCheckInternals(vshControl *ctl, break; } } + + virBufferTrim(&complbuf, ", "); + + if (missingCompleters && virBufferUse(&complbuf) > 0) + vshPrintExtra(ctl, "%s: %s\n", cmd->name, virBufferCurrentContent(= &complbuf)); + return 0; } @@ -3250,6 +3263,13 @@ cmdQuit(vshControl *ctl, const vshCmd *cmd G_GNUC_UN= USED) * Command self-test * ----------------- */ +const vshCmdOptDef opts_selftest[] =3D { + {.name =3D "completers-missing", + .type =3D VSH_OT_BOOL, + .help =3D N_("output the list of options which are missing completers= ") + }, + {.name =3D NULL} +}; const vshCmdInfo info_selftest[] =3D { {.name =3D "help", .data =3D N_("internal command for testing virt shells") @@ -3261,15 +3281,15 @@ const vshCmdInfo info_selftest[] =3D { }; bool -cmdSelfTest(vshControl *ctl, - const vshCmd *cmd G_GNUC_UNUSED) +cmdSelfTest(vshControl *ctl, const vshCmd *cmd) { const vshCmdGrp *grp; const vshCmdDef *def; + bool completers =3D vshCommandOptBool(cmd, "completers-missing"); for (grp =3D cmdGroups; grp->name; grp++) { for (def =3D grp->commands; def->name; def++) { - if (vshCmddefCheckInternals(ctl, def) < 0) + if (vshCmddefCheckInternals(ctl, def, completers) < 0) return false; } } diff --git a/tools/vsh.h b/tools/vsh.h index ae50f6b220..e208d957bb 100644 --- a/tools/vsh.h +++ b/tools/vsh.h @@ -375,6 +375,7 @@ extern const vshCmdOptDef opts_echo[]; extern const vshCmdInfo info_echo[]; extern const vshCmdInfo info_pwd[]; extern const vshCmdInfo info_quit[]; +extern const vshCmdOptDef opts_selftest[]; extern const vshCmdInfo info_selftest[]; extern const vshCmdOptDef opts_complete[]; extern const vshCmdInfo info_complete[]; @@ -445,7 +446,7 @@ bool cmdComplete(vshControl *ctl, const vshCmd *cmd); { \ .name =3D "self-test", \ .handler =3D cmdSelfTest, \ - .opts =3D NULL, \ + .opts =3D opts_selftest, \ .info =3D info_selftest, \ .flags =3D VSH_CMD_FLAG_NOCONNECT | VSH_CMD_FLAG_HIDDEN, \ } --=20 2.31.1 From nobody Sun May 5 11:28:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631812674; cv=none; d=zohomail.com; s=zohoarc; b=HkvT55KihYESI/OiDDD5eppCi/W5OZ1Y9iVHMJp0+soLIkjXwX5uiLad3J52VLhGeTJjPov9GktlEF+tSXtTaJDWiU7BF1FHBmnUyVTziUfmflfx4AEMur85VRrCEla9MT3nlf+zbDCwTchpRjY40bVcjAgxFwYHdKfqahNHUPM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631812674; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oSdIh5WZaBq/hu92JStxC/bf9SWX1K7akTS6kzkQwxk=; b=BopOSphSfqvjL1rRiyNIaE+405cwGThyDfIG4cPyge0/lQyULo+f1c5kiuPJjOxkMAN4hSq0X2a3fJnYx2Y2jsDHMSh9Dnr0fQ/PyYj1xcl42v3upNDiXeBE4fbyN0p4+/I2iaduV4pGo8EFME/iqZ/z4KWbKloVipbzKbT6W5I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1631812674647608.5081759288803; Thu, 16 Sep 2021 10:17:54 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-196-0tK4yV5PPMaMIRPwU669UQ-1; Thu, 16 Sep 2021 13:17:51 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DE53A80124F; Thu, 16 Sep 2021 17:17:46 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C02DF5C25A; Thu, 16 Sep 2021 17:17:46 +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 90B701805989; Thu, 16 Sep 2021 17:17:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18GHAvrw008307 for ; Thu, 16 Sep 2021 13:10:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id D566760583; Thu, 16 Sep 2021 17:10:57 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 399A018B5E for ; Thu, 16 Sep 2021 17:10:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631812673; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=oSdIh5WZaBq/hu92JStxC/bf9SWX1K7akTS6kzkQwxk=; b=QY6+l+QOhY0liFv0XzL5nHbe6Oa2bEIvLDPChUZCdyqFKlHDLQcBR5DNUSYM2qZrLodM1x Sp8/1geC6n4u+w40YTiVUwMkuHmEHEdxDVo2H8dNygV8w+4c9epgj29tP6OFr7BIwq0Ms0 YKSYkAe1XIgS+besEc/Qu+X63vWkQao= X-MC-Unique: 0tK4yV5PPMaMIRPwU669UQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/14] virsh-snapshot: Use 'virshSnapshotNameCompleter' for '--from' of 'snapshot-list' Date: Thu, 16 Sep 2021 19:10:37 +0200 Message-Id: <82c0912205a28c4f9fe1ae517b57599426b57e01.1631811763.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631812676074100001 Content-Type: text/plain; charset="utf-8" When listing a snapshot tree, the '--from' option takes a name of a snapshot to limit the subset. Use virshSnapshotNameCompleter as completer for the option. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tools/virsh-snapshot.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index e08ecb6910..60a68b334b 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -1411,6 +1411,7 @@ static const vshCmdOptDef opts_snapshot_list[] =3D { }, {.name =3D "from", .type =3D VSH_OT_STRING, + .completer =3D virshSnapshotNameCompleter, .help =3D N_("limit list to children of given snapshot") }, VIRSH_COMMON_OPT_CURRENT(N_("limit list to children of current snapsho= t")), --=20 2.31.1 From nobody Sun May 5 11:28:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631812957; cv=none; d=zohomail.com; s=zohoarc; b=AbeIy3EglvRNFQCflfAUt2pYkbWbAbiqaQvn4kReZX30M0RmlNT4mW6uFb+QX0cWOgCa/373ZW7PwayA42hCe1/GtetkuGp9R/4no/NpT+cBZz6RJMh4FHCZqL/YJtX3ZqKU8UL/ESUrJrkGSdGxX0TGRD79NvwK7PIM6Euq4is= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631812957; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lVDUZjGVL6/l+OUFiCPGtpvtj1RTmDEmYT8yj3l87iI=; b=JnolYmEOekic7VKDRM17ASCEAungtruz/r1zoMglClBkxljIaGutTPoNjbTQg74YbI2ND8rQsVXyPibJmwz2ZWd16A3Pyy53omAaUipd1ZfdPCR2K0x8E8M7znA4PnbKEdmUfZTpgs4Zo0whZa71v62OtIH9l9KYhIXz7SjxSec= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1631812957653881.9798016825742; Thu, 16 Sep 2021 10:22:37 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-410-fel31vHuNyOffCI3w_lPyg-1; Thu, 16 Sep 2021 13:22:35 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3EFC9DF8A0; Thu, 16 Sep 2021 17:22:30 +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 41E6A19C79; Thu, 16 Sep 2021 17:22:29 +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 477AF4EA2A; Thu, 16 Sep 2021 17:22:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18GHAwtE008322 for ; Thu, 16 Sep 2021 13:10:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id E3A2018B5E; Thu, 16 Sep 2021 17:10:58 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4FB7060583 for ; Thu, 16 Sep 2021 17:10:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631812956; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=lVDUZjGVL6/l+OUFiCPGtpvtj1RTmDEmYT8yj3l87iI=; b=CuCgM8cxqmooBTxhQI1Hx/syggBByKm/ZyOpLmiVaIgmZIqoPazWKvsqaIqwoTdx4XxoEF qBhTuNMlHByrqwxBWgpAcQ34FGUrkfK2un+893MF76obI768QTIgrC9UsmdoGznVpDqY8N Eq6PAZ+tOO+Ya2Kfu5yrdfobJBIGQC4= X-MC-Unique: fel31vHuNyOffCI3w_lPyg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/14] virsh: Use 'virshStoragePoolNameCompleter' for two options Date: Thu, 16 Sep 2021 19:10:38 +0200 Message-Id: <6ed5e4e1f772e29ad0d53516994feb727b762e38.1631811763.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631812958442100001 Content-Type: text/plain; charset="utf-8" '--pool' of the 'pool-event' command and '--inputpool' of 'vol-create-from' use the above mentioned completer. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tools/virsh-pool.c | 1 + tools/virsh-volume.c | 1 + 2 files changed, 2 insertions(+) diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 1a2ab8cc53..f1dfe892e1 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -1988,6 +1988,7 @@ static const vshCmdInfo info_pool_event[] =3D { static const vshCmdOptDef opts_pool_event[] =3D { {.name =3D "pool", .type =3D VSH_OT_STRING, + .completer =3D virshStoragePoolNameCompleter, .help =3D N_("filter by storage pool name or uuid") }, {.name =3D "event", diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index c51dc023e3..197ed2489c 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -454,6 +454,7 @@ static const vshCmdOptDef opts_vol_create_from[] =3D { VIRSH_COMMON_OPT_VOL_FULL, {.name =3D "inputpool", .type =3D VSH_OT_STRING, + .completer =3D virshStoragePoolNameCompleter, .help =3D N_("pool name or uuid of the input volume's pool") }, {.name =3D "prealloc-metadata", --=20 2.31.1 From nobody Sun May 5 11:28:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631812965; cv=none; d=zohomail.com; s=zohoarc; b=Cw99I4ghlOzxMx3SXIuK+4XyQZr6q4C8pCealUyD+g76NK/dhndNW8XMnCAiVAdGB5r+ue7/A0DUlOc5OSUuM+vkgG/IVpijjBo2pNXz8dRi8zKo34KEwUyv7J3bKTBWPYOdZljndPb3BST3ywMCQ3mPKk/PYQMGOLqOXlu/7Hk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631812965; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/0cLyXiAYHWAgB7W9HoOCtFfnECqpFPty1DuuBDeVUg=; b=KqY6eL6pXZsqKbAs8V8AqPVOvAJOTwePrSIBdyUToVCAtetTqhsp0snXKvFiiJqFS9jplLGCZAcPpm9h/RKbnjlQq7yFaMNoRFGRSW3GLHBymtLpSxEFCvNUx4wnrdtu5jsTjKITAEYiMlXROFl5ZdnO3CosaABIEEtD3WhD76Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1631812965256952.4750363227491; Thu, 16 Sep 2021 10:22:45 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-263-Dz2oqXphOVegr36KB7bwcg-1; Thu, 16 Sep 2021 13:22:42 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 328C1180830A; Thu, 16 Sep 2021 17:22:37 +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 0607A100164C; Thu, 16 Sep 2021 17:22:37 +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 C910F4EA37; Thu, 16 Sep 2021 17:22:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18GHB0Nc008329 for ; Thu, 16 Sep 2021 13:11:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 032AF18B5E; Thu, 16 Sep 2021 17:11:00 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5AF126A255 for ; Thu, 16 Sep 2021 17:10:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631812964; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=/0cLyXiAYHWAgB7W9HoOCtFfnECqpFPty1DuuBDeVUg=; b=iXsZmpK2VG6nFcWduCoQsJm0yYFVLavSg6Kwv6WV+oXgaZv1AmZO516gJ7E0Bv9YzRG88i W/LRC8T3IyCahEkOPlQnzlsk8XaWII2RcuNloK4InvgecziPwFDnbhoJ8nZBuH/Kc2CWIk Cg8ghlbE+zOpm2KQv5MAUrCDkjiPurI= X-MC-Unique: Dz2oqXphOVegr36KB7bwcg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/14] vsh: Add completer for '--command' of 'help' command Date: Thu, 16 Sep 2021 19:10:39 +0200 Message-Id: <3d8d2b696699818e40bda394a6ef7c4c33b51b88.1631811763.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631812965755100001 Content-Type: text/plain; charset="utf-8" Wrap 'vshReadlineCommandGenerator' into a function with proper prototype to provide a completer for the help command. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tools/vsh.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/vsh.c b/tools/vsh.c index 9c6783dad1..cf24586b25 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -3026,9 +3026,20 @@ vshDeinit(vshControl *ctl) * Generic commands available to use by any client * ----------------------------------------------- */ + +static char ** +vshCompleteHelpCommand(vshControl *ctl G_GNUC_UNUSED, + const vshCmd *cmd G_GNUC_UNUSED, + unsigned int completerflags G_GNUC_UNUSED) +{ + return vshReadlineCommandGenerator(); +} + + const vshCmdOptDef opts_help[] =3D { {.name =3D "command", .type =3D VSH_OT_STRING, + .completer =3D vshCompleteHelpCommand, .help =3D N_("Prints global help, command specific help, or help for = a group of related commands") }, {.name =3D NULL} --=20 2.31.1 From nobody Sun May 5 11:28:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631812677; cv=none; d=zohomail.com; s=zohoarc; b=lpKXeq9ioNtDYe1JvAfsAGu9QP6bQsC/VAWT4c4rotAGw2SXOxbtluv80Ykp9DWZtAvVJ3H0ldN0GLfC7UpDltCfS42MUWrn+gM6KOevnZkk6tikXsLPY7N+35dW1o7wDrLnNI9R/y5bpiE8bd8pLT51PC0wXLeN5q+JPTYBFHg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631812677; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=l7EyXZa0js38rybXjXaWO8xFFbyJwsNRpCLgWyzl87Y=; b=YEUrmCLFhl9he8gGDWhwkpz9Y3BXlcGNo3012Bq0Z0kpFELnWCN+N0O+rPo0PzoVf6ulueT8zPRXgQhRV7KOcBVU40Pw1+QIr60S17R+HjGGgGsUX00bPgADdj532S6SzBPsS4GtjQxP+nYX+SkAgXF3y8NbgNLiXf8vLMV0pLw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1631812677470797.9342639151089; Thu, 16 Sep 2021 10:17:57 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-592-AK6jZLC-PcaDyrzJ_uEGFw-1; Thu, 16 Sep 2021 13:17:54 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A6E0B1084687; Thu, 16 Sep 2021 17:17:49 +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 8AF0010023AE; Thu, 16 Sep 2021 17:17:49 +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 307274EA30; Thu, 16 Sep 2021 17:17:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18GHB1YQ008343 for ; Thu, 16 Sep 2021 13:11:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0F34318B5E; Thu, 16 Sep 2021 17:11:01 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E09C60583 for ; Thu, 16 Sep 2021 17:11:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631812676; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=l7EyXZa0js38rybXjXaWO8xFFbyJwsNRpCLgWyzl87Y=; b=QGaVB21lfWAShSD6CYx8FDzl50m5dV2CU4JJ161CZWsh8cSnrUnlMz7tgJ8X5o/Nbeew+i i8PZ5P86AN7+tT2qXmcIguMG8Yz/TlMGVAzGVw1PHUzer1Y2reQWbOlySOP3XvXgsVzKuQ 6DXCMklkEoNX5JB5SmXWjC3mycSFlJo= X-MC-Unique: AK6jZLC-PcaDyrzJ_uEGFw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/14] virsh: Provide completers for options taking comma separated list of disk targets Date: Thu, 16 Sep 2021 19:10:40 +0200 Message-Id: <7f8636bb7baf1dbd59134e671a8aba2844565ab4.1631811763.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631812679127100001 Content-Type: text/plain; charset="utf-8" '--storage' of the 'undefine' command and '--migrate-disks' of the 'migrate' command take a list of disk targets as an argument. We can simply combine 'virshDomainDiskTargetCompleter' with 'virshCommaStringListComplete' to provide the completions. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tools/virsh-completer-domain.c | 36 ++++++++++++++++++++++++++++++++++ tools/virsh-completer-domain.h | 10 ++++++++++ tools/virsh-domain.c | 2 ++ 3 files changed, 48 insertions(+) diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index 3ef6c82388..34985f6281 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -220,6 +220,42 @@ virshDomainDiskTargetCompleter(vshControl *ctl, } +static char ** +virshDomainDiskTargetListCompleter(vshControl *ctl, + const vshCmd *cmd, + const char *argname) +{ + const char *curval =3D NULL; + g_auto(GStrv) targets =3D virshDomainDiskTargetCompleter(ctl, cmd, 0); + + if (vshCommandOptStringQuiet(ctl, cmd, argname, &curval) < 0) + return NULL; + + if (!targets) + return NULL; + + return virshCommaStringListComplete(curval, (const char **) targets); +} + + +char ** +virshDomainMigrateDisksCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int completeflags G_GNUC_UNUSED) +{ + return virshDomainDiskTargetListCompleter(ctl, cmd, "migrate-disks"); +} + + +char ** +virshDomainUndefineStorageDisksCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int completeflags G_GNUC_UNUSED) +{ + return virshDomainDiskTargetListCompleter(ctl, cmd, "storage"); +} + + char ** virshDomainEventNameCompleter(vshControl *ctl G_GNUC_UNUSED, const vshCmd *cmd G_GNUC_UNUSED, diff --git a/tools/virsh-completer-domain.h b/tools/virsh-completer-domain.h index f23ec2735f..1ed3f94094 100644 --- a/tools/virsh-completer-domain.h +++ b/tools/virsh-completer-domain.h @@ -166,3 +166,13 @@ char ** virshDomainStorageFileFormatCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); + +char ** +virshDomainMigrateDisksCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int completeflags); + +char ** +virshDomainUndefineStorageDisksCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int completeflags); diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 4d328d2174..05fa5c07f6 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -3552,6 +3552,7 @@ static const vshCmdOptDef opts_undefine[] =3D { }, {.name =3D "storage", .type =3D VSH_OT_STRING, + .completer =3D virshDomainUndefineStorageDisksCompleter, .help =3D N_("remove associated storage volumes (comma separated list= of " "targets or source paths) (see domblklist)") }, @@ -10371,6 +10372,7 @@ static const vshCmdOptDef opts_migrate[] =3D { }, {.name =3D "migrate-disks", .type =3D VSH_OT_STRING, + .completer =3D virshDomainMigrateDisksCompleter, .help =3D N_("comma separated list of disks to be migrated") }, {.name =3D "disks-port", --=20 2.31.1 From nobody Sun May 5 11:28:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631812679; cv=none; d=zohomail.com; s=zohoarc; b=gmblPLnnIsrMpbZrQZXJ5z9LfVOkrMRsFZSrrxHxerwcPMIiPdggfeJdnsReBhYDieFXOmn8KAYf1My0tTeg1EWvB8Wsm8IeMYovROhEuhC8IedIVbpmywAhSmS6EfL6AHUCeNPouukuki+CPKOBUMAuCDxR6RFktrIlE2NA43E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631812679; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kTfZKs6S6n1829ntjyz0IbyqXVawayxOt5OfmT7MWSE=; b=g9jF1g35Lk0PONrXwnmYioN1P0Ut5BUNt77rHm2CmH9nwzZeS7ib7MCg5ttlVLqZSfvGwkiycNxjiN6TXKQyoTvz007Yo3jjjq3ooigquw4gcjGziKrEBJN76Nfp+We511+M9V3LZ0r7ENFm6oFIg8RNVHlkuWFKdIRholnwZvA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1631812679846339.20512029346503; Thu, 16 Sep 2021 10:17:59 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-409-TPWPX2zVNKyDmzRFd2_vaA-1; Thu, 16 Sep 2021 13:17:57 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5F33E824FBD; Thu, 16 Sep 2021 17:17:52 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 438DA7A8CA; Thu, 16 Sep 2021 17:17:52 +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 10A67180598A; Thu, 16 Sep 2021 17:17:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18GHB2TK008351 for ; Thu, 16 Sep 2021 13:11:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 220F518B5E; Thu, 16 Sep 2021 17:11:02 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 709C26A255 for ; Thu, 16 Sep 2021 17:11:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631812678; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=kTfZKs6S6n1829ntjyz0IbyqXVawayxOt5OfmT7MWSE=; b=IW/Uqh+tpF//1lXNbLE2yoRDtSK9ZE+Qznu2wUot+iA9IKVcm5cFtvEy/q1HVyZyXpD7d7 G+84o40YLDx5FHLma/pHz/GxPlC2rCyY0kuSy+3KUGu2iNS1q+eMD0gp+dgEJx3eWHmd5F h1l+iPFr7LABM3nRLWZbvqmoHgv1tXQ= X-MC-Unique: TPWPX2zVNKyDmzRFd2_vaA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/14] virsh: Expand VIRSH_COMMON_OPT_FILE for cases when it's not a local file used by virsh Date: Thu, 16 Sep 2021 19:10:41 +0200 Message-Id: <04aae0932abb85571d3c901a3c66d3a506743350.1631811763.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631812681909100001 Content-Type: text/plain; charset="utf-8" In cases such as the APIs for managed save management, the file path provided via the '--file' option is passed to the API. We'll need to make them distinct from cases for when virsh is using the file so that different completers can be used. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tools/virsh-domain.c | 36 ++++++++++++++++++++++++++++++------ tools/virsh-volume.c | 6 +++++- tools/virsh.h | 1 + 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 05fa5c07f6..f45ab5b9d1 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -4129,7 +4129,11 @@ static const vshCmdInfo info_save[] =3D { static const vshCmdOptDef opts_save[] =3D { VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), - VIRSH_COMMON_OPT_FILE(N_("where to save the data")), + {.name =3D "file", + .type =3D VSH_OT_DATA, + .flags =3D VSH_OFLAG_REQ, + .help =3D N_("where to save the data") + }, {.name =3D "bypass-cache", .type =3D VSH_OT_BOOL, .help =3D N_("avoid file system cache when saving") @@ -4474,7 +4478,11 @@ static const vshCmdInfo info_save_image_dumpxml[] = =3D { }; static const vshCmdOptDef opts_save_image_dumpxml[] =3D { - VIRSH_COMMON_OPT_FILE(N_("saved state file to read")), + {.name =3D "file", + .type =3D VSH_OT_DATA, + .flags =3D VSH_OFLAG_REQ, + .help =3D N_("saved state file to read") + }, {.name =3D "security-info", .type =3D VSH_OT_BOOL, .help =3D N_("include security sensitive information in XML dump") @@ -4518,7 +4526,11 @@ static const vshCmdInfo info_save_image_define[] =3D= { }; static const vshCmdOptDef opts_save_image_define[] =3D { - VIRSH_COMMON_OPT_FILE(N_("saved state file to modify")), + {.name =3D "file", + .type =3D VSH_OT_DATA, + .flags =3D VSH_OFLAG_REQ, + .help =3D N_("saved state file to modify") + }, {.name =3D "xml", .type =3D VSH_OT_DATA, .flags =3D VSH_OFLAG_REQ, @@ -4581,7 +4593,11 @@ static const vshCmdInfo info_save_image_edit[] =3D { }; static const vshCmdOptDef opts_save_image_edit[] =3D { - VIRSH_COMMON_OPT_FILE(N_("saved state file to edit")), + {.name =3D "file", + .type =3D VSH_OT_DATA, + .flags =3D VSH_OFLAG_REQ, + .help =3D N_("saved state file to edit") + }, {.name =3D "running", .type =3D VSH_OT_BOOL, .help =3D N_("set domain to be running on restore") @@ -5221,7 +5237,11 @@ static const vshCmdInfo info_restore[] =3D { }; static const vshCmdOptDef opts_restore[] =3D { - VIRSH_COMMON_OPT_FILE(N_("the state to restore")), + {.name =3D "file", + .type =3D VSH_OT_DATA, + .flags =3D VSH_OFLAG_REQ, + .help =3D N_("the state to restore") + }, {.name =3D "bypass-cache", .type =3D VSH_OT_BOOL, .help =3D N_("avoid file system cache when restoring") @@ -5293,7 +5313,11 @@ static const vshCmdInfo info_dump[] =3D { static const vshCmdOptDef opts_dump[] =3D { VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), - VIRSH_COMMON_OPT_FILE(N_("where to dump the core")), + {.name =3D "file", + .type =3D VSH_OT_DATA, + .flags =3D VSH_OFLAG_REQ, + .help =3D N_("where to dump the core") + }, VIRSH_COMMON_OPT_LIVE(N_("perform a live core dump if supported")), {.name =3D "crash", .type =3D VSH_OT_BOOL, diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 197ed2489c..b73837f4c8 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -775,7 +775,11 @@ static const vshCmdInfo info_vol_download[] =3D { static const vshCmdOptDef opts_vol_download[] =3D { VIRSH_COMMON_OPT_VOL_FULL, - VIRSH_COMMON_OPT_FILE(N_("file")), + {.name =3D "file", + .type =3D VSH_OT_DATA, + .flags =3D VSH_OFLAG_REQ, + .help =3D N_("file") + }, VIRSH_COMMON_OPT_POOL_OPTIONAL, {.name =3D "offset", .type =3D VSH_OT_INT, diff --git a/tools/virsh.h b/tools/virsh.h index 4d777545ff..8e1b8ced90 100644 --- a/tools/virsh.h +++ b/tools/virsh.h @@ -95,6 +95,7 @@ .help =3D _helpstr \ } +/* Use this only for files which are existing and used locally by virsh */ #define VIRSH_COMMON_OPT_FILE(_helpstr) \ {.name =3D "file", \ .type =3D VSH_OT_DATA, \ --=20 2.31.1 From nobody Sun May 5 11:28:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631812749; cv=none; d=zohomail.com; s=zohoarc; b=AxSy7bWIbxW2WvEWaK2PVqoc9vdqGx9yL/+jaLkoy0HaQFlAdJ2/dJGTkzaOWnhDCp8aHGEa0R49e2N5mRWGDD0vranOCvzOUS66x5qXr7xC2SCsZcrjnqgdVo2WaW0pHvNYy+XlvNMFLFjjtggbwGScg1hgECRZ/TfOZLdhu90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631812749; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rtGJQZEc6cG8ZlQO9eXAaC0jmCIUCzuh52a4795Ih08=; b=ZEshJAGZYWAK6GHDOO/28arLW6pk6acJfVEo/ssUMrMD7iAYj/FYVPy8oSNyXvnf2sytCB8WD7PdFdGd5eMAysC3GqLr+35/3wSMMkvrFEhLrNS9IKjnVWnyWEBhPa4QVytXrNcBpcEUrF+G8WPfZDbuvN7aUn4dc7zKCaDkpj0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1631812749361487.11085796895; Thu, 16 Sep 2021 10:19:09 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-553-RQSUrwIPOi-uMXKZu73S2A-1; Thu, 16 Sep 2021 13:18:00 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 191FA192203D; Thu, 16 Sep 2021 17:17:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F21356D981; Thu, 16 Sep 2021 17:17:54 +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 A199A1806D03; Thu, 16 Sep 2021 17:17:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18GHB306008365 for ; Thu, 16 Sep 2021 13:11:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2F64E18B5E; Thu, 16 Sep 2021 17:11:03 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B87460583 for ; Thu, 16 Sep 2021 17:11:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631812748; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=rtGJQZEc6cG8ZlQO9eXAaC0jmCIUCzuh52a4795Ih08=; b=KMHN/lzEtN2/xWCbLXqCEQN66ws6zNnbxepZTSbZYad3wA/zCcxxrGVZGkVbn6WeE0XixV KcpHUsK/FbpzqZRtNMYgB2lwYE0UiW+EZuvq3ZIp1vMeOtXDbnAkDxMTghk+ezIIZWQJ6Z K5RwlFSVOfgkmOg/x5K8ImrxRnFEWGQ= X-MC-Unique: RQSUrwIPOi-uMXKZu73S2A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/14] virsh: completer: Introduce dummy completer for local files Date: Thu, 16 Sep 2021 19:10:42 +0200 Message-Id: <2218ef564a438cf92f53af367701a7eef132f74c.1631811763.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631812750253100001 Content-Type: text/plain; charset="utf-8" For now the completion does the correct thing of completing a local path if NULL is returned. Introduce 'virshCompletePathLocalExisting' and use it in the 'VIRSH_COMMON_OPT_FILE' macro. This for now serves as an annotation for the function which want to read a file on the host running virsh. In the future this can be used with a more sophisticated implementation. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tools/virsh-completer.c | 17 +++++++++++++++++ tools/virsh-completer.h | 5 +++++ tools/virsh.h | 1 + 3 files changed, 23 insertions(+) diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c index 57e0c3905c..100f206598 100644 --- a/tools/virsh-completer.c +++ b/tools/virsh-completer.c @@ -128,3 +128,20 @@ virshCommaStringListComplete(const char *input, return g_steal_pointer(&ret); } + + +/** + * virshCompletePathLocalExisting: + * + * Complete a path to a existing file used as input. The file is used as i= nput + * for virsh so only local files are considered. + * + * Note: For now this is a no-op. Readline does the correct thing. + */ +char ** +virshCompletePathLocalExisting(vshControl *ctl G_GNUC_UNUSED, + const vshCmd *cmd G_GNUC_UNUSED, + unsigned int completerflags G_GNUC_UNUSED) +{ + return NULL; +} diff --git a/tools/virsh-completer.h b/tools/virsh-completer.h index 1243a13a5e..9a77aa117f 100644 --- a/tools/virsh-completer.h +++ b/tools/virsh-completer.h @@ -35,3 +35,8 @@ char ** virshCommaStringListComplete(const char *input, const char **options); + +char ** +virshCompletePathLocalExisting(vshControl *ctl, + const vshCmd *cmd, + unsigned int completerflags); diff --git a/tools/virsh.h b/tools/virsh.h index 8e1b8ced90..cacd54db57 100644 --- a/tools/virsh.h +++ b/tools/virsh.h @@ -100,6 +100,7 @@ {.name =3D "file", \ .type =3D VSH_OT_DATA, \ .flags =3D VSH_OFLAG_REQ, \ + .completer =3D virshCompletePathLocalExisting, \ .help =3D _helpstr \ } --=20 2.31.1 From nobody Sun May 5 11:28:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631812607; cv=none; d=zohomail.com; s=zohoarc; b=denDdb7llVc+OKrCDGw1AbvFHtoq1Sd2qkWCmK10Ad7Er8ZtconzDL6rmbaZTonrUzRCXCEy8EjSoeNXidAxf3zROx5klB0r9enMkubRN5UrZUV2FUsjR8njE0KbKaSjNI3DtGmJMal0dJKzHIf8tru6OctpNlzoaUJQmNZSbsc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631812607; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0w6M7yz8PnceDaK43mbMoo+FSJxSXsQC9qYyiZcAQzM=; b=WeBsy29hNZwgPuf2s2/JnbDXDhXFGO8Kj9/62GRPmCz1JQZNffNtEpFiL7guI8OFVnDCb7Kz1NIeEeJywcSCCqxBX4+SbRm/LK1FQggmeW6G0BhEh6WQro4tmzg0ZODng5r80flx0kJBVakDUJzWrXrvEhn00+rSu3EFA3xRiXU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1631812607625576.1404291526065; Thu, 16 Sep 2021 10:16:47 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-350-54EQPkn1N5uvwpi-ZnbZTw-1; Thu, 16 Sep 2021 13:16:45 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9EAE31922025; Thu, 16 Sep 2021 17:16:39 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7DB6917D4E; Thu, 16 Sep 2021 17:16:39 +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 0F27E1800FE4; Thu, 16 Sep 2021 17:16:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18GHB4kq008370 for ; Thu, 16 Sep 2021 13:11:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 38AEC18B5E; Thu, 16 Sep 2021 17:11:04 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 938C66A255 for ; Thu, 16 Sep 2021 17:11:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631812606; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=0w6M7yz8PnceDaK43mbMoo+FSJxSXsQC9qYyiZcAQzM=; b=CgO9Axwyx69VTzXDH1vX+8+n6rajIsb7v2CsniVZ9hWiSlrxvluKiYzgb6QojM9sV1sctI 4DnKjHvhbIt9lQDHvg4ZE4Q3pJEB+bDULTEqb03tGMLbwF2Ewzroh/Ob0dGC313cRZcUb/ 4bGaKOFNGWFxHdhtXDX5cPp5kcBgWLk= X-MC-Unique: 54EQPkn1N5uvwpi-ZnbZTw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/14] virsh: Use 'virshCompletePathLocalExisting' for options reading local files Date: Thu, 16 Sep 2021 19:10:43 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631812609267100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tools/virsh-backup.c | 2 ++ tools/virsh-checkpoint.c | 1 + tools/virsh-domain.c | 10 ++++++++++ tools/virsh-network.c | 1 + tools/virsh-pool.c | 1 + tools/virsh-secret.c | 1 + tools/virsh-snapshot.c | 1 + 7 files changed, 17 insertions(+) diff --git a/tools/virsh-backup.c b/tools/virsh-backup.c index 9125b7da97..7bac1923a6 100644 --- a/tools/virsh-backup.c +++ b/tools/virsh-backup.c @@ -39,10 +39,12 @@ static const vshCmdOptDef opts_backup_begin[] =3D { VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), {.name =3D "backupxml", .type =3D VSH_OT_STRING, + .completer =3D virshCompletePathLocalExisting, .help =3D N_("domain backup XML"), }, {.name =3D "checkpointxml", .type =3D VSH_OT_STRING, + .completer =3D virshCompletePathLocalExisting, .help =3D N_("domain checkpoint XML"), }, {.name =3D "reuse-external", diff --git a/tools/virsh-checkpoint.c b/tools/virsh-checkpoint.c index 1f3a318014..78272b43c4 100644 --- a/tools/virsh-checkpoint.c +++ b/tools/virsh-checkpoint.c @@ -88,6 +88,7 @@ static const vshCmdOptDef opts_checkpoint_create[] =3D { VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), {.name =3D "xmlfile", .type =3D VSH_OT_STRING, + .completer =3D virshCompletePathLocalExisting, .help =3D N_("domain checkpoint XML") }, {.name =3D "redefine", diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index f45ab5b9d1..25e50064bd 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -2243,6 +2243,7 @@ static const vshCmdOptDef opts_blockcopy[] =3D { }, {.name =3D "xml", .type =3D VSH_OT_STRING, + .completer =3D virshCompletePathLocalExisting, .help =3D N_("filename containing XML description of the copy destina= tion") }, {.name =3D "format", @@ -4140,6 +4141,7 @@ static const vshCmdOptDef opts_save[] =3D { }, {.name =3D "xml", .type =3D VSH_OT_STRING, + .completer =3D virshCompletePathLocalExisting, .help =3D N_("filename containing updated XML for the target") }, {.name =3D "running", @@ -4534,6 +4536,7 @@ static const vshCmdOptDef opts_save_image_define[] = =3D { {.name =3D "xml", .type =3D VSH_OT_DATA, .flags =3D VSH_OFLAG_REQ, + .completer =3D virshCompletePathLocalExisting, .help =3D N_("filename containing updated XML for the target") }, {.name =3D "running", @@ -4946,6 +4949,7 @@ static const vshCmdOptDef opts_managed_save_define[] = =3D { {.name =3D "xml", .type =3D VSH_OT_DATA, .flags =3D VSH_OFLAG_REQ, + .completer =3D virshCompletePathLocalExisting, .help =3D N_("filename containing updated XML for the target") }, {.name =3D "running", @@ -5248,6 +5252,7 @@ static const vshCmdOptDef opts_restore[] =3D { }, {.name =3D "xml", .type =3D VSH_OT_STRING, + .completer =3D virshCompletePathLocalExisting, .help =3D N_("filename containing updated XML for the target") }, {.name =3D "running", @@ -10007,6 +10012,7 @@ static const vshCmdOptDef opts_domxmlfromnative[] = =3D { {.name =3D "config", .type =3D VSH_OT_DATA, .flags =3D VSH_OFLAG_REQ, + .completer =3D virshCompletePathLocalExisting, .help =3D N_("config data file to import from") }, {.name =3D NULL} @@ -10062,6 +10068,7 @@ static const vshCmdOptDef opts_domxmltonative[] =3D= { VIRSH_COMMON_OPT_DOMAIN_OT_STRING_FULL(VSH_OFLAG_REQ_OPT, 0), {.name =3D "xml", .type =3D VSH_OT_STRING, + .completer =3D virshCompletePathLocalExisting, .help =3D N_("xml data file to export from") }, {.name =3D NULL} @@ -10392,6 +10399,7 @@ static const vshCmdOptDef opts_migrate[] =3D { }, {.name =3D "xml", .type =3D VSH_OT_STRING, + .completer =3D virshCompletePathLocalExisting, .help =3D N_("filename containing updated XML for the target") }, {.name =3D "migrate-disks", @@ -10438,6 +10446,7 @@ static const vshCmdOptDef opts_migrate[] =3D { }, {.name =3D "persistent-xml", .type =3D VSH_OT_STRING, + .completer =3D virshCompletePathLocalExisting, .help =3D N_("filename containing updated persistent XML for the targ= et") }, {.name =3D "tls", @@ -13973,6 +13982,7 @@ static const vshCmdOptDef opts_set_user_sshkeys[] = =3D { }, {.name =3D "file", .type =3D VSH_OT_STRING, + .completer =3D virshCompletePathLocalExisting, .help =3D N_("optional file to read keys from"), }, {.name =3D "reset", diff --git a/tools/virsh-network.c b/tools/virsh-network.c index a8f7f46905..5c35310344 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -937,6 +937,7 @@ static const vshCmdOptDef opts_network_update[] =3D { {.name =3D "xml", .type =3D VSH_OT_DATA, .flags =3D VSH_OFLAG_REQ, + .completer =3D virshCompletePathLocalExisting, .help =3D N_("name of file containing xml (or, if it starts with '<',= the complete " "xml element itself) to add/modify, or to be matched for s= earch") }, diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index f1dfe892e1..6ab0490b89 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -1509,6 +1509,7 @@ static const vshCmdOptDef opts_find_storage_pool_sour= ces[] =3D { }, {.name =3D "srcSpec", .type =3D VSH_OT_STRING, + .completer =3D virshCompletePathLocalExisting, .help =3D N_("optional file of source xml to query for pools") }, {.name =3D NULL} diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index 173a77fd90..d23cbf04bf 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -186,6 +186,7 @@ static const vshCmdOptDef opts_secret_set_value[] =3D { {.name =3D "file", .type =3D VSH_OT_STRING, .flags =3D VSH_OFLAG_REQ_OPT, + .completer =3D virshCompletePathLocalExisting, .help =3D N_("read secret from file"), }, {.name =3D "plain", diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index 60a68b334b..5a3c468c53 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -115,6 +115,7 @@ static const vshCmdOptDef opts_snapshot_create[] =3D { VIRSH_COMMON_OPT_DOMAIN_FULL(0), {.name =3D "xmlfile", .type =3D VSH_OT_STRING, + .completer =3D virshCompletePathLocalExisting, .help =3D N_("domain snapshot XML") }, {.name =3D "redefine", --=20 2.31.1 From nobody Sun May 5 11:28:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631812687; cv=none; d=zohomail.com; s=zohoarc; b=QrtAEBXd21fKN2dwXYmliULRVCPx7/1FYgT01YTsBsC9bjFeOwTNhFoiNyH02HUS9H1EnB1SsJ+a3HN72iRiS+xzPIbEfza0p8u+/fT8FFjsq6pS7sd5veJbRMdHhGRoERLzvdhNji3I7JL+l5vmATVyJnRH8/iCOOsBJp/bXJE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631812687; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=l1qGBm8UXlyxS+9hnVGXoOCQL6oUXKjuWIlahdyWhkE=; b=SGrObzQqxIfG3wBJa4IfLFmOMcHNNAuDMz1WGk5wmUfNxckRgTSPrK29xNbm5hpzoeTUOfZsI5Z+7+UBR3g7w/B2RR9MrtsLyYBtAG0tmYcxBVX8TXgfjPNn3HC+fm6Q7KLHPTZWmZiRKR79xhy5voY6zO6C4A519EfD9W3cp1o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1631812687535567.6078755196194; Thu, 16 Sep 2021 10:18:07 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-32-jZukUpqGOGSRReTYcMtJ_A-1; Thu, 16 Sep 2021 13:18:03 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 61D67802C91; Thu, 16 Sep 2021 17:17:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3989F19D9F; Thu, 16 Sep 2021 17:17:58 +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 099F718199EE; Thu, 16 Sep 2021 17:17:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18GHB55L008375 for ; Thu, 16 Sep 2021 13:11:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 457B218B5E; Thu, 16 Sep 2021 17:11:05 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id A36AF60583 for ; Thu, 16 Sep 2021 17:11:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631812686; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=l1qGBm8UXlyxS+9hnVGXoOCQL6oUXKjuWIlahdyWhkE=; b=bGgKxz05sUYK808HjyhdEu1KoG/dyYYGZJIz8Z1bUWlvG38ZlV7E1NIXBywVFtFfoZjy3T BX0JneJoHqGVruuNO3zawmV9nnrpa4hAvxUhJVVWSjX23SpKrf93akuPek+9OlGBWp1I6U c7MJ5HuziX9QlhIvYX9mS3Utr5LssJM= X-MC-Unique: jZukUpqGOGSRReTYcMtJ_A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/14] virsh: Introduce virshCompleteEmpty and use it for places where we can't suggest anything Date: Thu, 16 Sep 2021 19:10:44 +0200 Message-Id: <79f28dc221ab5990060e526c0e49630cdb98d056.1631811763.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631812688156100001 Content-Type: text/plain; charset="utf-8" For now this serves just as an annotation because readline and also the bash completion script insist on completing local paths when an empty list is returned. This will serve for future reference once we'll be able to properly refuse to suggest anything. The completer is used for fields such as names for new objects, description strings, password strings etc, URIs and hostnames which we can't feasibly autocomplete. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tools/virsh-checkpoint.c | 2 ++ tools/virsh-completer.c | 18 ++++++++++++++++++ tools/virsh-completer.h | 5 +++++ tools/virsh-domain.c | 33 +++++++++++++++++++++++++++++++++ tools/virsh-pool.c | 7 +++++++ tools/virsh-secret.c | 1 + tools/virsh-snapshot.c | 2 ++ tools/virsh-volume.c | 5 +++++ tools/virsh.c | 1 + 9 files changed, 74 insertions(+) diff --git a/tools/virsh-checkpoint.c b/tools/virsh-checkpoint.c index 78272b43c4..8ad37ece69 100644 --- a/tools/virsh-checkpoint.c +++ b/tools/virsh-checkpoint.c @@ -200,10 +200,12 @@ static const vshCmdOptDef opts_checkpoint_create_as[]= =3D { VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), {.name =3D "name", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("name of checkpoint") }, {.name =3D "description", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("description of checkpoint") }, {.name =3D "print-xml", diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c index 100f206598..3d77be3121 100644 --- a/tools/virsh-completer.c +++ b/tools/virsh-completer.c @@ -145,3 +145,21 @@ virshCompletePathLocalExisting(vshControl *ctl G_GNUC_= UNUSED, { return NULL; } + + +/** + * virshCompleteEmpty: + * + * Complete nothing. For cases where an user input is required and we can't + * suggest anything. + * + * TODO: This is currently just an annotation, readline still completes lo= cal + * file list. + */ +char ** +virshCompleteEmpty(vshControl *ctl G_GNUC_UNUSED, + const vshCmd *cmd G_GNUC_UNUSED, + unsigned int completerflags G_GNUC_UNUSED) +{ + return NULL; +} diff --git a/tools/virsh-completer.h b/tools/virsh-completer.h index 9a77aa117f..1d7affbb23 100644 --- a/tools/virsh-completer.h +++ b/tools/virsh-completer.h @@ -40,3 +40,8 @@ char ** virshCompletePathLocalExisting(vshControl *ctl, const vshCmd *cmd, unsigned int completerflags); + +char ** +virshCompleteEmpty(vshControl *ctl, + const vshCmd *cmd, + unsigned int completerflags); diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 25e50064bd..d2e604f5dd 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -395,6 +395,7 @@ static const vshCmdOptDef opts_attach_disk[] =3D { {.name =3D "target", .type =3D VSH_OT_DATA, .flags =3D VSH_OFLAG_REQ, + .completer =3D virshCompleteEmpty, .help =3D N_("target of disk device") }, {.name =3D "targetbus", @@ -440,14 +441,17 @@ static const vshCmdOptDef opts_attach_disk[] =3D { }, {.name =3D "serial", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("serial of disk device") }, {.name =3D "wwn", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("wwn of disk device") }, {.name =3D "alias", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("custom alias name of disk device") }, {.name =3D "rawio", @@ -456,6 +460,7 @@ static const vshCmdOptDef opts_attach_disk[] =3D { }, {.name =3D "address", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("address of disk device") }, {.name =3D "multifunction", @@ -472,6 +477,7 @@ static const vshCmdOptDef opts_attach_disk[] =3D { }, {.name =3D "source-host-name", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("host name for source of disk device") }, {.name =3D "source-host-transport", @@ -793,10 +799,12 @@ static const vshCmdOptDef opts_attach_interface[] =3D= { }, {.name =3D "target", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("target network name") }, {.name =3D "mac", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("MAC address") }, {.name =3D "script", @@ -809,14 +817,17 @@ static const vshCmdOptDef opts_attach_interface[] =3D= { }, {.name =3D "alias", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("custom alias name of interface device") }, {.name =3D "inbound", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("control domain's incoming traffics") }, {.name =3D "outbound", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("control domain's outgoing traffics") }, VIRSH_COMMON_OPT_DOMAIN_PERSISTENT, @@ -1277,6 +1288,7 @@ static const vshCmdOptDef opts_blkdeviotune[] =3D { }, {.name =3D "group-name", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("group name to share I/O quota between multiple drives") }, {.name =3D "total_bytes_sec_max_length", @@ -1493,22 +1505,27 @@ static const vshCmdOptDef opts_blkiotune[] =3D { }, {.name =3D "device-weights", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("per-device IO Weights, in the form of /path/to/device,w= eight,...") }, {.name =3D "device-read-iops-sec", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("per-device read I/O limit per second, in the form of /p= ath/to/device,read_iops_sec,...") }, {.name =3D "device-write-iops-sec", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("per-device write I/O limit per second, in the form of /= path/to/device,write_iops_sec,...") }, {.name =3D "device-read-bytes-sec", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("per-device bytes read per second, in the form of /path/= to/device,read_bytes_sec,...") }, {.name =3D "device-write-bytes-sec", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("per-device bytes wrote per second, in the form of /path= /to/device,write_bytes_sec,...") }, VIRSH_COMMON_OPT_DOMAIN_CONFIG, @@ -3210,10 +3227,12 @@ static const vshCmdOptDef opts_domiftune[] =3D { }, {.name =3D "inbound", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("control domain's incoming traffics") }, {.name =3D "outbound", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("control domain's outgoing traffics") }, VIRSH_COMMON_OPT_DOMAIN_CONFIG, @@ -3991,6 +4010,7 @@ static const vshCmdOptDef opts_start[] =3D { }, {.name =3D "pass-fds", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("pass file descriptors N,M,... to the guest") }, {.name =3D NULL} @@ -5741,6 +5761,7 @@ static const vshCmdOptDef opts_set_user_password[] = =3D { {.name =3D "password", .type =3D VSH_OT_DATA, .flags =3D VSH_OFLAG_REQ, + .completer =3D virshCompleteEmpty, .help =3D N_("the new password") }, {.name =3D "encrypted", @@ -8100,6 +8121,7 @@ static const vshCmdOptDef opts_create[] =3D { }, {.name =3D "pass-fds", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("pass file descriptors N,M,... to the guest") }, {.name =3D "validate", @@ -8457,6 +8479,7 @@ static const vshCmdOptDef opts_metadata[] =3D { }, {.name =3D "set", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("new metadata to set"), }, {.name =3D "remove", @@ -8718,6 +8741,7 @@ static const vshCmdOptDef opts_send_process_signal[] = =3D { {.name =3D "pid", .type =3D VSH_OT_DATA, .flags =3D VSH_OFLAG_REQ, + .completer =3D virshCompleteEmpty, .help =3D N_("the process ID") }, {.name =3D "signame", @@ -9659,6 +9683,7 @@ static const vshCmdOptDef opts_qemu_attach[] =3D { {.name =3D "pid", .type =3D VSH_OT_DATA, .flags =3D VSH_OFLAG_REQ, + .completer =3D virshCompleteEmpty, .help =3D N_("pid") }, {.name =3D NULL} @@ -10173,6 +10198,7 @@ static const vshCmdOptDef opts_domrename[] =3D { {.name =3D "new-name", .type =3D VSH_OT_DATA, .flags =3D VSH_OFLAG_REQ, + .completer =3D virshCompleteEmpty, .help =3D N_("new domain name") }, {.name =3D NULL} @@ -10289,6 +10315,7 @@ static const vshCmdOptDef opts_migrate[] =3D { {.name =3D "desturi", .type =3D VSH_OT_DATA, .flags =3D VSH_OFLAG_REQ, + .completer =3D virshCompleteEmpty, .help =3D N_("connection URI of the destination host as seen from the= client(normal migration) or source(p2p migration)") }, VIRSH_COMMON_OPT_LIVE(N_("live migration")), @@ -10370,18 +10397,22 @@ static const vshCmdOptDef opts_migrate[] =3D { }, {.name =3D "migrateuri", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("migration URI, usually can be omitted") }, {.name =3D "graphicsuri", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("graphics URI to be used for seamless graphics migration= ") }, {.name =3D "listen-address", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("listen address that destination should bind to for inco= ming migration") }, {.name =3D "dname", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("rename to new name during migration (if supported)") }, {.name =3D "timeout", @@ -10413,6 +10444,7 @@ static const vshCmdOptDef opts_migrate[] =3D { }, {.name =3D "disks-uri", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("URI to use for disks migration (overrides --disks-port)= ") }, {.name =3D "comp-methods", @@ -10471,6 +10503,7 @@ static const vshCmdOptDef opts_migrate[] =3D { }, {.name =3D "tls-destination", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("override the destination host name used for TLS verific= ation") }, {.name =3D NULL} diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 6ab0490b89..b9948ea622 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -59,6 +59,7 @@ {.name =3D "name", \ .type =3D VSH_OT_DATA, \ .flags =3D VSH_OFLAG_REQ, \ + .completer =3D virshCompleteEmpty, \ .help =3D N_("name of the pool") \ }, \ {.name =3D "type", \ @@ -73,6 +74,7 @@ }, \ {.name =3D "source-host", \ .type =3D VSH_OT_STRING, \ + .completer =3D virshCompleteEmpty, \ .help =3D N_("source-host for underlying storage") \ }, \ {.name =3D "source-path", \ @@ -101,6 +103,7 @@ }, \ {.name =3D "auth-username", \ .type =3D VSH_OT_STRING, \ + .completer =3D virshCompleteEmpty, \ .help =3D N_("auth username to be used for underlying storage") \ }, \ {.name =3D "secret-usage", \ @@ -145,6 +148,7 @@ }, \ {.name =3D "source-initiator", \ .type =3D VSH_OT_STRING, \ + .completer =3D virshCompleteEmpty, \ .help =3D N_("initiator iqn for underlying storage") \ } @@ -1425,14 +1429,17 @@ static const vshCmdOptDef opts_find_storage_pool_so= urces_as[] =3D { }, {.name =3D "host", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("optional host to query") }, {.name =3D "port", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("optional port to query") }, {.name =3D "initiator", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("optional initiator IQN to use for query") }, {.name =3D NULL} diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index d23cbf04bf..dff2710928 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -199,6 +199,7 @@ static const vshCmdOptDef opts_secret_set_value[] =3D { }, {.name =3D "base64", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("base64-encoded secret value") }, {.name =3D NULL} diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index 5a3c468c53..2659b4340d 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -324,10 +324,12 @@ static const vshCmdOptDef opts_snapshot_create_as[] = =3D { VIRSH_COMMON_OPT_DOMAIN_FULL(0), {.name =3D "name", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("name of snapshot") }, {.name =3D "description", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("description of snapshot") }, {.name =3D "print-xml", diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index b73837f4c8..103a9b9237 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -185,15 +185,18 @@ static const vshCmdOptDef opts_vol_create_as[] =3D { {.name =3D "name", .type =3D VSH_OT_DATA, .flags =3D VSH_OFLAG_REQ, + .completer =3D virshCompleteEmpty, .help =3D N_("name of the volume") }, {.name =3D "capacity", .type =3D VSH_OT_DATA, .flags =3D VSH_OFLAG_REQ, + .completer =3D virshCompleteEmpty, .help =3D N_("size of the vol, as scaled integer (default bytes)") }, {.name =3D "allocation", .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, .help =3D N_("initial allocation size, as scaled integer (default byt= es)") }, {.name =3D "format", @@ -561,6 +564,7 @@ static const vshCmdOptDef opts_vol_clone[] =3D { {.name =3D "newname", .type =3D VSH_OT_DATA, .flags =3D VSH_OFLAG_REQ, + .completer =3D virshCompleteEmpty, .help =3D N_("clone name") }, VIRSH_COMMON_OPT_POOL_OPTIONAL, @@ -1131,6 +1135,7 @@ static const vshCmdOptDef opts_vol_resize[] =3D { {.name =3D "capacity", .type =3D VSH_OT_DATA, .flags =3D VSH_OFLAG_REQ, + .completer =3D virshCompleteEmpty, .help =3D N_("new capacity for the vol, as scaled integer (default by= tes)") }, VIRSH_COMMON_OPT_POOL_OPTIONAL, diff --git a/tools/virsh.c b/tools/virsh.c index 3c6f60f176..b9f3f851d3 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -252,6 +252,7 @@ static const vshCmdOptDef opts_connect[] =3D { {.name =3D "name", .type =3D VSH_OT_STRING, .flags =3D VSH_OFLAG_EMPTY_OK, + .completer =3D virshCompleteEmpty, .help =3D N_("hypervisor connection URI") }, {.name =3D "readonly", --=20 2.31.1 From nobody Sun May 5 11:28:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631812611; cv=none; d=zohomail.com; s=zohoarc; b=IOKxdO1nnoA3IFQqzihZLJjbYy7d1bkcJv9VjWd07pfRepyKR5M+DylAENYeEK8GUmKA4xez9rygl1iROaqOc/Y2EnXPr4nE0glEL17pwt7CHtmLqPsYrDVDM1YxzIwBCDa/myv1S/+nl8nR9ZhEWrmF1RKp7RMThi77mORTn80= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631812611; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZhDg4VSYLQ8At1dJhmYoYgPjlaEmuOjapq8sNM10o8I=; b=VQ6gvvpHRgAbXklcecJrM2XWJzskiBkSDUFrwIe5RGNCzKrEzLQ0la3B6HKlIpl7mmscHXv41BNuneQYNNaj+wjQeSk3AWS6mFK80HZz2nvk8jgdxFs4DENwfj9ZOXV+9zsT7ItGT2sOehJT7VRRzkmYsn6hdJ20EzlOEiwgM20= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1631812611735735.3736284944941; Thu, 16 Sep 2021 10:16:51 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-47-cvo_RlwYOFGuQCsF6h6jAA-1; Thu, 16 Sep 2021 13:16:48 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 17ED110B746E; Thu, 16 Sep 2021 17:16:42 +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 EAC8B6A902; Thu, 16 Sep 2021 17:16:41 +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 B4F544EA30; Thu, 16 Sep 2021 17:16:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18GHB6c8008388 for ; Thu, 16 Sep 2021 13:11:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5064E18B5E; Thu, 16 Sep 2021 17:11:06 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id A806D60583 for ; Thu, 16 Sep 2021 17:11:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631812609; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ZhDg4VSYLQ8At1dJhmYoYgPjlaEmuOjapq8sNM10o8I=; b=bcaD9k9UzDKjbmsBGUtCgByiaRJW7S/0UHmXjwjR8p04xxjyj6tqxvBhi/BNljLZHJ6TZm awt8efpVxWwtj9jkAq10wKc8c7KfeujvwK9QbBjhgZv7Yfdq+pl784Ju4H1XhS+Cj5+RxG /Pj/aAOt3o1hN+bg6l4CGN0Q9ukOB2k= X-MC-Unique: cvo_RlwYOFGuQCsF6h6jAA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/14] virsh-completer: Provide completer for '--top' and '--base' for blockjobs Date: Thu, 16 Sep 2021 19:10:45 +0200 Message-Id: <833a15754a054a4dfefb82bb55fa590743854fff.1631811763.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631812612663100003 Content-Type: text/plain; charset="utf-8" Complete with the indexed targets (e.g. vda[3]) based on existing indexes. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tools/virsh-completer-domain.c | 100 +++++++++++++++++++++++++++++++++ tools/virsh-completer-domain.h | 5 ++ tools/virsh-domain.c | 3 + 3 files changed, 108 insertions(+) diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index 34985f6281..93e992e9b1 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -32,6 +32,7 @@ #include "virperf.h" #include "virbitmap.h" #include "virkeycode.h" +#include "virglibutil.h" #include "virkeynametable_linux.h" #include "virkeynametable_osx.h" #include "virkeynametable_win32.h" @@ -256,6 +257,105 @@ virshDomainUndefineStorageDisksCompleter(vshControl *= ctl, } +static GSList * +virshDomainBlockjobBaseTopCompleteDisk(const char *target, + xmlXPathContext *ctxt) +{ + g_autofree xmlNodePtr *indexlist =3D NULL; + int nindexlist =3D 0; + size_t i; + GSList *ret =3D NULL; + + if ((nindexlist =3D virXPathNodeSet("./source|./backingStore", + ctxt, &indexlist)) < 0) + return NULL; + + ret =3D g_slist_prepend(ret, g_strdup(target)); + + for (i =3D 0; i < nindexlist; i++) { + g_autofree char *idx =3D virXMLPropString(indexlist[i], "index"); + + if (!idx) + continue; + + ret =3D g_slist_prepend(ret, g_strdup_printf("%s[%s]", target, idx= )); + } + + return ret; +} + + +char ** +virshDomainBlockjobBaseTopCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags) +{ + virshControl *priv =3D ctl->privData; + g_autoptr(xmlDoc) xmldoc =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; + g_autofree xmlNodePtr *disks =3D NULL; + int ndisks; + size_t i; + const char *path =3D NULL; + g_autoptr(virGSListString) list =3D NULL; + GSList *n; + GStrv ret =3D NULL; + size_t nelems; + + virCheckFlags(0, NULL); + + if (!priv->conn || virConnectIsAlive(priv->conn) <=3D 0) + return NULL; + + if (virshDomainGetXML(ctl, cmd, 0, &xmldoc, &ctxt) < 0) + return NULL; + + ignore_value(vshCommandOptStringQuiet(ctl, cmd, "path", &path)); + + if ((ndisks =3D virXPathNodeSet("./devices/disk", ctxt, &disks)) <=3D = 0) + return NULL; + + for (i =3D 0; i < ndisks; i++) { + g_autofree char *disktarget =3D NULL; + + ctxt->node =3D disks[i]; + disktarget =3D virXPathString("string(./target/@dev)", ctxt); + + if (STREQ_NULLABLE(path, disktarget)) + break; + } + + if (i =3D=3D ndisks) + path =3D NULL; + + for (i =3D 0; i < ndisks; i++) { + g_autofree char *disktarget =3D NULL; + GSList *tmplist; + + ctxt->node =3D disks[i]; + + if (!(disktarget =3D virXPathString("string(./target/@dev)", ctxt)= )) + return NULL; + + if (path && STRNEQ(path, disktarget)) + continue; + + /* note that ctxt->node moved */ + if ((tmplist =3D virshDomainBlockjobBaseTopCompleteDisk(disktarget= , ctxt))) + list =3D g_slist_concat(tmplist, list); + } + + list =3D g_slist_reverse(list); + nelems =3D g_slist_length(list); + ret =3D g_new0(char *, nelems + 1); + i =3D 0; + + for (n =3D list; n; n =3D n->next) + ret[i++] =3D g_strdup(n->data); + + return ret; +} + char ** virshDomainEventNameCompleter(vshControl *ctl G_GNUC_UNUSED, const vshCmd *cmd G_GNUC_UNUSED, diff --git a/tools/virsh-completer-domain.h b/tools/virsh-completer-domain.h index 1ed3f94094..ec7909888e 100644 --- a/tools/virsh-completer-domain.h +++ b/tools/virsh-completer-domain.h @@ -176,3 +176,8 @@ char ** virshDomainUndefineStorageDisksCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int completeflags); + +char ** +virshDomainBlockjobBaseTopCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index d2e604f5dd..1d8af2d274 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -1991,6 +1991,7 @@ static const vshCmdOptDef opts_blockcommit[] =3D { }, {.name =3D "base", .type =3D VSH_OT_STRING, + .completer =3D virshDomainBlockjobBaseTopCompleter, .help =3D N_("path of base file to commit into (default bottom of cha= in)") }, {.name =3D "shallow", @@ -1999,6 +2000,7 @@ static const vshCmdOptDef opts_blockcommit[] =3D { }, {.name =3D "top", .type =3D VSH_OT_STRING, + .completer =3D virshDomainBlockjobBaseTopCompleter, .help =3D N_("path of top file to commit from (default top of chain)") }, {.name =3D "active", @@ -2772,6 +2774,7 @@ static const vshCmdOptDef opts_blockpull[] =3D { }, {.name =3D "base", .type =3D VSH_OT_STRING, + .completer =3D virshDomainBlockjobBaseTopCompleter, .help =3D N_("path of backing file in chain for a partial pull") }, {.name =3D "wait", --=20 2.31.1