From nobody Mon May 13 22:02:24 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=gmail.com 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 164692577227121.911414913495037; Thu, 10 Mar 2022 07:22:52 -0800 (PST) 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-607-8HXo71vuNKSPqiOIysaxyw-1; Thu, 10 Mar 2022 10:22:47 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7A8E918E6C40; Thu, 10 Mar 2022 15:22:44 +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 DCC35463EB6; Thu, 10 Mar 2022 15:22:42 +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 91A401953576; Thu, 10 Mar 2022 15:22:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 64A141953573 for ; Thu, 10 Mar 2022 15:22:41 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 50E3B141DEE0; Thu, 10 Mar 2022 15:22:41 +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 4D16E141DEDF for ; Thu, 10 Mar 2022 15:22:41 +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 31B0A18E6C40 for ; Thu, 10 Mar 2022 15:22:41 +0000 (UTC) Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-513-HPQuFaeeOAawNia5ZBDZTA-1; Thu, 10 Mar 2022 10:22:39 -0500 Received: by mail-pj1-f49.google.com with SMTP id mr24-20020a17090b239800b001bf0a375440so8500975pjb.4 for ; Thu, 10 Mar 2022 07:22:39 -0800 (PST) Received: from ubuntu.localdomain ([218.197.153.12]) by smtp.gmail.com with ESMTPSA id b20-20020a17090a991400b001befe07ae5csm10437033pjp.22.2022.03.10.07.22.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 07:22:37 -0800 (PST) X-MC-Unique: 8HXo71vuNKSPqiOIysaxyw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: HPQuFaeeOAawNia5ZBDZTA-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=x3629J8UO2Xt5XQkvDHnGV4UQVKoxuyYALuNKjBwjvM=; b=C8dTnh4slBl95w2ydP4H0Gjy6fYXj2UPrzt77XlfgOnk94/5FHu+AyGuMAzlGTrugl Qx5BmPK+isv4q4s6ORQNRi9m9OMqbcn7erC8xW50nt49Sg4qTyM2LR5RVldywtiBKxVA biwPI/ukpi31vrnjZwXZmilqbyfc2rk3zxVxZEzAcQ1qVeZLOtfsL/3F58Q8l9eypT4o ve/t6mR/jO+hM7ZiIH21k2umV+IZxrs0/gN1p13T0i8moZzoD9tPoSYYZPEYhcjEaCfI B6k7ijrszFp0fRs124bF7r1+/jjHCPdd/S0sXmCAcJ2wF7Q2AK9awvuKGQrIaXM/h38c 1dsw== X-Gm-Message-State: AOAM531wSONans4rcYwqdfl391BnN0MdUmaEcE/pf3/WNbiKbQj874oR rBmm4UxxfN6a87oOKlAGKvmlDaPOoz7sIg== X-Google-Smtp-Source: ABdhPJyZXUTziQegfiOXdH59GHQK9DYvHRUj/2lIv5Rpws9AO8pYwDOuq7/Ou+wc1ohDsFnvuoUW/g== X-Received: by 2002:a17:90a:7f84:b0:1bc:aba8:f281 with SMTP id m4-20020a17090a7f8400b001bcaba8f281mr5558382pjl.101.1646925758081; Thu, 10 Mar 2022 07:22:38 -0800 (PST) From: Haonan Wang To: libvir-list@redhat.com Subject: [PATCH RESEND] virsh: Provide completer for vol-wipe algorithms Date: Thu, 10 Mar 2022 23:22:24 +0800 Message-Id: <20220310152224.9036-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.7 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.10 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: 1646925773880100001 Content-Type: text/plain; charset="utf-8" Related issue: https://gitlab.com/libvirt/libvirt/-/issues/9 Signed-off-by: Haonan Wang Reviewed-by: Michal Privoznik --- tools/virsh-completer-volume.c | 19 +++++++++++++++++++ tools/virsh-completer-volume.h | 6 ++++++ tools/virsh-volume.c | 3 +-- tools/virsh-volume.h | 3 +++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/tools/virsh-completer-volume.c b/tools/virsh-completer-volume.c index ac3c472177..bed45fa1ca 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,21 @@ virshStorageVolKeyCompleter(vshControl *ctl, virshStoragePoolListFree(list); return ret; } + +char ** +virshStorageVolWipeAlgorithmCompleter(vshControl *ctl G_GNUC_UNUSED, + const vshCmd *cmd G_GNUC_UNUSED, + unsigned int flags) +{ + char **ret =3D NULL; + size_t i; + + virCheckFlags(0, NULL); + + ret =3D g_new0(char *, VIR_STORAGE_VOL_WIPE_ALG_LAST + 1); + + for (i =3D 0; i < VIR_STORAGE_VOL_WIPE_ALG_LAST; i++) + ret[i] =3D g_strdup(virshStorageVolWipeAlgorithmTypeToString(i)); + + 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