From nobody Wed May 15 03:14:50 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; 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 1648249258074829.8828503731235; Fri, 25 Mar 2022 16:00:58 -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-643-9obC5LV0M2SEMj5pYWTJLA-1; Fri, 25 Mar 2022 19:00:53 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C17A585A5BE; Fri, 25 Mar 2022 23:00:50 +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 09F352027EB4; Fri, 25 Mar 2022 23:00:48 +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 A8EC8194034E; Fri, 25 Mar 2022 23:00:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B130E1940341 for ; Fri, 25 Mar 2022 23:00:46 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8E226111F3DB; Fri, 25 Mar 2022 23:00:46 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 89AF7111F3D9 for ; Fri, 25 Mar 2022 23:00:43 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (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 4AC30811E78 for ; Fri, 25 Mar 2022 23:00:43 +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-462-_80L_UFbPBKZ3IAJrR7F_w-1; Fri, 25 Mar 2022 19:00:41 -0400 X-MC-Unique: 9obC5LV0M2SEMj5pYWTJLA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: _80L_UFbPBKZ3IAJrR7F_w-1 From: natto1784 To: libvir-list@redhat.com Subject: [PATCH] virsh: Provide completer for virtualization types Date: Sat, 26 Mar 2022 04:21:43 +0530 Message-Id: <20220325225143.1533634-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.78 on 10.11.54.3 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: natto1784 Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 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: 1648249259085100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Related: https://gitlab.com/libvirt/libvirt/-/issues/9 Signed-off-by: natto1784 --- .gitignore | 4 ++++ tools/virsh-completer-host.c | 12 ++++++++++++ tools/virsh-completer-host.h | 5 +++++ tools/virsh-host.c | 3 +++ 4 files changed, 24 insertions(+) diff --git a/.gitignore b/.gitignore index 4695391..62012f4 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,8 @@ tags =20 # clangd related ignores .clangd +.cache/clangd compile_commands.json + +# ccls cache +.ccls-cache diff --git a/tools/virsh-completer-host.c b/tools/virsh-completer-host.c index 40cb687..e481a73 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 2e3cbc3..b28f29f 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", @@ -1577,6 +1578,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 +1688,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