From nobody Mon Feb 9 00:07:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1565166722; cv=none; d=zoho.com; s=zohoarc; b=cpoGkdPqkU+YRobTUNjP7C/nbU08+aDwZf7gNtlVjJVvOYVTYcwesmh/kw5fxprRnzIl8NMVH+b7+BecYIV+1mB0MtmdWEFC3v2BZsbdUMTXr2l28X2iV2gh/9crOzKpxwKNkRlFUd+ikD0wag9q08nyhzZR9iy9eysd8BVbWE0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565166722; 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:ARC-Authentication-Results; bh=scTxWgjKaVvTJmBNPoxVhc5YseCtK4Pf+JxJfGQWjq8=; b=kiZsmMn5dW75N2j7m7hMkx1cizKWmddhaZqnjX08RK912OZmVhLh9eR6lPO1vekit7lrUMGCusOcNp2Ec+fSeq/XuuyU+Pfmt9aOgdmhVVmsBhbOSzRNz7ER7RN6lh1HWartDvXELi83t8IQKd4+9LM9jDlXo4i30rGgKh9cTCE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 156516672240576.71548343893448; Wed, 7 Aug 2019 01:32:02 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 119D730C3A17; Wed, 7 Aug 2019 08:32:01 +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 D53C31001284; Wed, 7 Aug 2019 08:32:00 +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 8E897149F6; Wed, 7 Aug 2019 08:32:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x778VSe1025083 for ; Wed, 7 Aug 2019 04:31:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id E49C110016E9; Wed, 7 Aug 2019 08:31:28 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E53B10016E8 for ; Wed, 7 Aug 2019 08:31:28 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 7 Aug 2019 10:30:53 +0200 Message-Id: <5b5d3f7d4bc4a1e740ca2f0c80c24041269b2369.1565166420.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 10/15] tools: Separate secret related completers into a file 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 07 Aug 2019 08:32:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Mixing all completers in one file does not support maintainability. Separate those completers which relate to secret (e.g. they complete various secret aspects) into virsh-completer-secret.c Signed-off-by: Michal Privoznik --- tools/Makefile.am | 1 + tools/virsh-completer-secret.c | 91 ++++++++++++++++++++++++++++++++++ tools/virsh-completer-secret.h | 31 ++++++++++++ tools/virsh-completer.c | 65 ------------------------ tools/virsh-completer.h | 9 +--- 5 files changed, 124 insertions(+), 73 deletions(-) create mode 100644 tools/virsh-completer-secret.c create mode 100644 tools/virsh-completer-secret.h diff --git a/tools/Makefile.am b/tools/Makefile.am index 6e6d9a05cc..f229db39d8 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -224,6 +224,7 @@ virsh_SOURCES =3D \ virsh-completer-nodedev.c virsh-completer-nodedev.h \ virsh-completer-nwfilter.c virsh-completer-nwfilter.h \ virsh-completer-pool.c virsh-completer-pool.h \ + virsh-completer-secret.c virsh-completer-secret.h \ virsh-completer-volume.c virsh-completer-volume.h \ virsh-console.c virsh-console.h \ virsh-domain.c virsh-domain.h \ diff --git a/tools/virsh-completer-secret.c b/tools/virsh-completer-secret.c new file mode 100644 index 0000000000..a6924b6b8c --- /dev/null +++ b/tools/virsh-completer-secret.c @@ -0,0 +1,91 @@ +/* + * virsh-completer-secret.c: virsh completer callbacks related to secret + * + * Copyright (C) 2019 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#include + +#include "virsh-completer-secret.h" +#include "viralloc.h" +#include "virsh-secret.h" +#include "virsh.h" +#include "virstring.h" + +char ** +virshSecretUUIDCompleter(vshControl *ctl, + const vshCmd *cmd ATTRIBUTE_UNUSED, + unsigned int flags) +{ + virshControlPtr priv =3D ctl->privData; + virSecretPtr *secrets =3D NULL; + int nsecrets =3D 0; + size_t i =3D 0; + char **ret =3D NULL; + VIR_AUTOSTRINGLIST tmp =3D NULL; + + virCheckFlags(0, NULL); + + if (!priv->conn || virConnectIsAlive(priv->conn) <=3D 0) + return NULL; + + if ((nsecrets =3D virConnectListAllSecrets(priv->conn, &secrets, flags= )) < 0) + return NULL; + + if (VIR_ALLOC_N(tmp, nsecrets + 1) < 0) + goto cleanup; + + for (i =3D 0; i < nsecrets; i++) { + char uuid[VIR_UUID_STRING_BUFLEN]; + + if (virSecretGetUUIDString(secrets[i], uuid) < 0 || + VIR_STRDUP(tmp[i], uuid) < 0) + goto cleanup; + } + + VIR_STEAL_PTR(ret, tmp); + + cleanup: + for (i =3D 0; i < nsecrets; i++) + virSecretFree(secrets[i]); + VIR_FREE(secrets); + return ret; +} + + +char ** +virshSecretEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED, + const vshCmd *cmd ATTRIBUTE_UNUSED, + unsigned int flags) +{ + size_t i; + char **ret =3D NULL; + VIR_AUTOSTRINGLIST tmp =3D NULL; + + virCheckFlags(0, NULL); + + if (VIR_ALLOC_N(tmp, VIR_SECRET_EVENT_ID_LAST + 1) < 0) + return NULL; + + for (i =3D 0; i < VIR_SECRET_EVENT_ID_LAST; i++) { + if (VIR_STRDUP(tmp[i], virshSecretEventCallbacks[i].name) < 0) + return NULL; + } + + VIR_STEAL_PTR(ret, tmp); + return ret; +} diff --git a/tools/virsh-completer-secret.h b/tools/virsh-completer-secret.h new file mode 100644 index 0000000000..3ed6ba5198 --- /dev/null +++ b/tools/virsh-completer-secret.h @@ -0,0 +1,31 @@ +/* + * virsh-completer-secret.h: virsh completer callbacks related to secret + * + * Copyright (C) 2019 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#pragma once + +#include "vsh.h" + +char ** virshSecretUUIDCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); + +char ** virshSecretEventNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c index c985b86fa9..3489f8741a 100644 --- a/tools/virsh-completer.c +++ b/tools/virsh-completer.c @@ -143,47 +143,6 @@ virshCommaStringListComplete(const char *input, } =20 =20 -char ** -virshSecretUUIDCompleter(vshControl *ctl, - const vshCmd *cmd ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virshControlPtr priv =3D ctl->privData; - virSecretPtr *secrets =3D NULL; - int nsecrets =3D 0; - size_t i =3D 0; - char **ret =3D NULL; - VIR_AUTOSTRINGLIST tmp =3D NULL; - - virCheckFlags(0, NULL); - - if (!priv->conn || virConnectIsAlive(priv->conn) <=3D 0) - return NULL; - - if ((nsecrets =3D virConnectListAllSecrets(priv->conn, &secrets, flags= )) < 0) - return NULL; - - if (VIR_ALLOC_N(tmp, nsecrets + 1) < 0) - goto cleanup; - - for (i =3D 0; i < nsecrets; i++) { - char uuid[VIR_UUID_STRING_BUFLEN]; - - if (virSecretGetUUIDString(secrets[i], uuid) < 0 || - VIR_STRDUP(tmp[i], uuid) < 0) - goto cleanup; - } - - VIR_STEAL_PTR(ret, tmp); - - cleanup: - for (i =3D 0; i < nsecrets; i++) - virSecretFree(secrets[i]); - VIR_FREE(secrets); - return ret; -} - - char ** virshCheckpointNameCompleter(vshControl *ctl, const vshCmd *cmd, @@ -359,30 +318,6 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl, } =20 =20 -char ** -virshSecretEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED, - const vshCmd *cmd ATTRIBUTE_UNUSED, - unsigned int flags) -{ - size_t i; - char **ret =3D NULL; - VIR_AUTOSTRINGLIST tmp =3D NULL; - - virCheckFlags(0, NULL); - - if (VIR_ALLOC_N(tmp, VIR_SECRET_EVENT_ID_LAST + 1) < 0) - return NULL; - - for (i =3D 0; i < VIR_SECRET_EVENT_ID_LAST; i++) { - if (VIR_STRDUP(tmp[i], virshSecretEventCallbacks[i].name) < 0) - return NULL; - } - - VIR_STEAL_PTR(ret, tmp); - return ret; -} - - char ** virshCellnoCompleter(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED, diff --git a/tools/virsh-completer.h b/tools/virsh-completer.h index 5cc5794f58..e27d58e536 100644 --- a/tools/virsh-completer.h +++ b/tools/virsh-completer.h @@ -28,15 +28,12 @@ #include "virsh-completer-nodedev.h" #include "virsh-completer-nwfilter.h" #include "virsh-completer-pool.h" +#include "virsh-completer-secret.h" #include "virsh-completer-volume.h" =20 char ** virshCommaStringListComplete(const char *input, const char **options); =20 -char ** virshSecretUUIDCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); - char ** virshCheckpointNameCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); @@ -49,10 +46,6 @@ char ** virshAllocpagesPagesizeCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); =20 -char ** virshSecretEventNameCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); - char ** virshCellnoCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list