From nobody Tue Feb 10 12:39:29 2026 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; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=weirdnatto.in 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 1648895541279837.3034915493615; Sat, 2 Apr 2022 03:32:21 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-529-K6cYOF9tN4SuvcCvRvgoZw-1; Sat, 02 Apr 2022 06:32:16 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4DB3885A5A8; Sat, 2 Apr 2022 10:32:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A0C1145BEFA; Sat, 2 Apr 2022 10:32:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D491F1940363; Sat, 2 Apr 2022 10:32:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 50A4D194035F for ; Sat, 2 Apr 2022 10:32:12 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 372D4C4C7D0; Sat, 2 Apr 2022 10:32:12 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 336E1C44B1F for ; Sat, 2 Apr 2022 10:32:12 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1A73F833959 for ; Sat, 2 Apr 2022 10:32:12 +0000 (UTC) Received: from mail.weirdnatto.in (140.238.230.155 [140.238.230.155]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-651-FPoVm9PGPXeHNoHyniBmFA-1; Sat, 02 Apr 2022 06:32:09 -0400 X-MC-Unique: K6cYOF9tN4SuvcCvRvgoZw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: FPoVm9PGPXeHNoHyniBmFA-1 From: Amneesh Singh To: libvir-list@redhat.com Subject: [PATCH 1/3] virsh: Provide completer for virtualization types Date: Sat, 2 Apr 2022 16:01:45 +0530 Message-Id: <20220402103147.428242-2-natto@weirdnatto.in> In-Reply-To: <20220402103147.428242-1-natto@weirdnatto.in> References: <20220402103147.428242-1-natto@weirdnatto.in> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amneesh Singh Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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-ZM-MESSAGEID: 1648895542060100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Related: https://gitlab.com/libvirt/libvirt/-/issues/9 Signed-off-by: Amneesh Singh --- tools/virsh-completer-host.c | 12 ++++++++++++ tools/virsh-completer-host.h | 5 +++++ tools/virsh-host.c | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/tools/virsh-completer-host.c b/tools/virsh-completer-host.c index cbdc3f0..14c68d3 100644 --- a/tools/virsh-completer-host.c +++ b/tools/virsh-completer-host.c @@ -27,6 +27,7 @@ #include "virxml.h" #include "virutil.h" #include "virsh-host.h" +#include "conf/domain_conf.h" =20 static char * virshPagesizeNodeToString(xmlNodePtr node) @@ -180,3 +181,14 @@ virshNodeSuspendTargetCompleter(vshControl *ctl G_GNUC= _UNUSED, return virshEnumComplete(VIR_NODE_SUSPEND_TARGET_LAST, virshNodeSuspendTargetTypeToString); } + +char ** +virshVirtTypeCompleter(vshControl *ctl G_GNUC_UNUSED, + const vshCmd *cmd G_GNUC_UNUSED, + unsigned int flags) +{ + virCheckFlags(0, NULL); + + return virshEnumComplete(VIR_DOMAIN_VIRT_LAST, + virDomainVirtTypeToString); +} diff --git a/tools/virsh-completer-host.h b/tools/virsh-completer-host.h index e71ccff..372ac14 100644 --- a/tools/virsh-completer-host.h +++ b/tools/virsh-completer-host.h @@ -41,3 +41,8 @@ char ** virshNodeSuspendTargetCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); + +char ** +virshVirtTypeCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 1e83d19..664f9fd 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -77,6 +77,7 @@ static const vshCmdInfo info_domcapabilities[] =3D { static const vshCmdOptDef opts_domcapabilities[] =3D { {.name =3D "virttype", .type =3D VSH_OT_STRING, + .completer =3D virshVirtTypeCompleter, .help =3D N_("virtualization type (/domain/@type)"), }, {.name =3D "emulatorbin", @@ -559,6 +560,7 @@ static const vshCmdInfo info_maxvcpus[] =3D { static const vshCmdOptDef opts_maxvcpus[] =3D { {.name =3D "type", .type =3D VSH_OT_STRING, + .completer =3D virshVirtTypeCompleter, .help =3D N_("domain type") }, {.name =3D NULL} @@ -1577,6 +1579,7 @@ static const vshCmdOptDef opts_hypervisor_cpu_compare= [] =3D { VIRSH_COMMON_OPT_FILE(N_("file containing an XML CPU description")), {.name =3D "virttype", .type =3D VSH_OT_STRING, + .completer =3D virshVirtTypeCompleter, .help =3D N_("virtualization type (/domain/@type)"), }, {.name =3D "emulator", @@ -1686,6 +1689,7 @@ static const vshCmdOptDef opts_hypervisor_cpu_baselin= e[] =3D { VIRSH_COMMON_OPT_FILE(N_("file containing XML CPU descriptions")), {.name =3D "virttype", .type =3D VSH_OT_STRING, + .completer =3D virshVirtTypeCompleter, .help =3D N_("virtualization type (/domain/@type)"), }, {.name =3D "emulator", --=20 2.35.1