From nobody Tue May 14 07:36:21 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; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com 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 164691975474778.2944669762586; Thu, 10 Mar 2022 05:42:34 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-194-6gGswfxEMM2eWW7bj5A7TQ-1; Thu, 10 Mar 2022 08:42:31 -0500 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 CA4891C0515E; Thu, 10 Mar 2022 13:42:29 +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 2E5FF1402404; Thu, 10 Mar 2022 13:42:28 +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 C784F1953576; Thu, 10 Mar 2022 13:42:27 +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 37D83195356D for ; Thu, 10 Mar 2022 13:41:11 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 14318C15E6F; Thu, 10 Mar 2022 13:41:11 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 102FFC159F6 for ; Thu, 10 Mar 2022 13:41:11 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 EB6D6185A7BA for ; Thu, 10 Mar 2022 13:41:10 +0000 (UTC) Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-269-UxViZz-gOC2MkCWRLFvU0w-1; Thu, 10 Mar 2022 08:41:08 -0500 Received: by mail-pg1-f170.google.com with SMTP id bc27so4768588pgb.4 for ; Thu, 10 Mar 2022 05:41:08 -0800 (PST) Received: from ubuntu.localdomain ([218.197.153.12]) by smtp.gmail.com with ESMTPSA id nu4-20020a17090b1b0400b001bf497a9324sm10820756pjb.31.2022.03.10.05.41.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 05:41:06 -0800 (PST) X-MC-Unique: 6gGswfxEMM2eWW7bj5A7TQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: UxViZz-gOC2MkCWRLFvU0w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=c3HeOUQzxNtozpB770dXEUFS7/SmFAEieQI/udIDEbY=; b=sazpYno8t5+mvjnOUlGI8YDAd7OzWY6vihEJguxdUgvpoAq55jUgZBuAUY5IalD23u kqHz4EMqURWPwCNT2G4KhIAJIkptIiQbf8dXF/6S6N0+fxWI/d76v9PfBXZE3uGcwoU7 +nA/H07LW5ogcxQBqx7Whkd8UlUi6LXbo/Qux3pduaBQbg0kZ6AX0+Gm8gvZ9emfd/nZ 2bnz7wWfH9L1oWCg1stObnr/4xWpQh6mMh0MlzY5Arl3Q6pGvSexDDEtfYmEzJti/8Yw YjrG1NJ3kSvDlOi/bi7Kf8EByT5IuM/gQDjYgq/yBhSA/MGVg/grOCBaj3j56zVLK8ug tf0w== X-Gm-Message-State: AOAM530sVle3/tOtrbWyVNCjwEHOVNyArWQPPZgd3Uw50zA/LPp/gWAR Vhsgpbs1aLKRyUzITpAeJmMvBwvRQV3IaOcZ X-Google-Smtp-Source: ABdhPJyZQDOC5KWxDhY+DSmAMg46MY/ysRkS4lRb1jRWzFoUiKGIN6Qt3s3O2Dd3ALijfBffQDQuCQ== X-Received: by 2002:a63:1d6:0:b0:380:a063:660c with SMTP id 205-20020a6301d6000000b00380a063660cmr4154545pgb.149.1646919666873; Thu, 10 Mar 2022 05:41:06 -0800 (PST) From: Haonan Wang To: libvir-list@redhat.com Subject: [PATCH] virsh: Provide completer for vol-wipe algorithms Date: Thu, 10 Mar 2022 21:40:50 +0800 Message-Id: <20220310134050.65131-1-hnwanga1@gmail.com> 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-Mailman-Approved-At: Thu, 10 Mar 2022 13:42:26 +0000 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: Haonan Wang 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: 1646919756863100001 Content-Type: text/plain; charset="utf-8" Related issue: https://gitlab.com/libvirt/libvirt/-/issues/9 Signed-off-by: Haonan Wang --- tools/virsh-completer-volume.c | 20 ++++++++++++++++++++ tools/virsh-completer-volume.h | 6 ++++++ tools/virsh-volume.c | 3 +-- tools/virsh-volume.h | 3 +++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/tools/virsh-completer-volume.c b/tools/virsh-completer-volume.c index ac3c472177..66b8828702 100644 --- a/tools/virsh-completer-volume.c +++ b/tools/virsh-completer-volume.c @@ -26,6 +26,7 @@ #include "virsh-pool.h" #include "virsh.h" #include "virstring.h" +#include "virsh-volume.h" =20 char ** virshStorageVolNameCompleter(vshControl *ctl, @@ -116,3 +117,22 @@ virshStorageVolKeyCompleter(vshControl *ctl, virshStoragePoolListFree(list); return ret; } + +char** +virshStorageVolWipeAlgorithmCompleter(vshControl *ctl G_GNUC_UNUSED, + const vshCmd *cmd G_GNUC_UNUSED, + unsigned int completerflags G_GNUC_U= NUSED) +{ + size_t nalgorithms =3D VIR_STORAGE_VOL_WIPE_ALG_LAST; + size_t i =3D 0; + char **ret =3D NULL; + g_auto(GStrv) tmp =3D g_new0(char *, nalgorithms); + + for (i =3D 0; i < nalgorithms; i++) { + const char *str =3D virshStorageVolWipeAlgorithmTypeToString(i); + tmp[i] =3D g_strdup(str); + } + + ret =3D g_steal_pointer(&tmp); + return ret; +} diff --git a/tools/virsh-completer-volume.h b/tools/virsh-completer-volume.h index dc6eeb4b3c..17e50f450d 100644 --- a/tools/virsh-completer-volume.h +++ b/tools/virsh-completer-volume.h @@ -33,3 +33,9 @@ char ** virshStorageVolKeyCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); + + +char ** +virshStorageVolWipeAlgorithmCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index d005602fe8..b6fa9555ad 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -902,12 +902,12 @@ static const vshCmdOptDef opts_vol_wipe[] =3D { VIRSH_COMMON_OPT_POOL_OPTIONAL, {.name =3D "algorithm", .type =3D VSH_OT_STRING, + .completer =3D virshStorageVolWipeAlgorithmCompleter, .help =3D N_("perform selected wiping algorithm") }, {.name =3D NULL} }; =20 -VIR_ENUM_DECL(virshStorageVolWipeAlgorithm); VIR_ENUM_IMPL(virshStorageVolWipeAlgorithm, VIR_STORAGE_VOL_WIPE_ALG_LAST, "zero", "nnsa", "dod", "bsi", "gutmann", "schneier", @@ -950,7 +950,6 @@ cmdVolWipe(vshControl *ctl, const vshCmd *cmd) } =20 =20 -VIR_ENUM_DECL(virshStorageVol); VIR_ENUM_IMPL(virshStorageVol, VIR_STORAGE_VOL_LAST, N_("file"), diff --git a/tools/virsh-volume.h b/tools/virsh-volume.h index 15cab0fd8c..32e5394f5c 100644 --- a/tools/virsh-volume.h +++ b/tools/virsh-volume.h @@ -33,3 +33,6 @@ virStorageVolPtr virshCommandOptVolBy(vshControl *ctl, co= nst vshCmd *cmd, VIRSH_BYUUID | VIRSH_BYNAME) =20 extern const vshCmdDef storageVolCmds[]; + +VIR_ENUM_DECL(virshStorageVolWipeAlgorithm); +VIR_ENUM_DECL(virshStorageVol); --=20 2.25.1