From nobody Mon Feb 9 01:48:07 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=1565166688; cv=none; d=zoho.com; s=zohoarc; b=RqKWvYl6pPwz7igefFt0BO7RQhZTTcRhVr4OVxO8clXMGqCAjJET8FgYJQUbpr56rud+WStJc/ycK6jkcAUbZwbPdzjY6BVVo3e0+iqA3d9b3WcV5431uupk9rI183Cwafl8fyYiTjHr/SRiLKMn9T9PnAfZJdCkKsBNUTRGq+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565166688; 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=xnAMxCFnOErmZkPyLCSUbmeK8n/bg8IQmnRhxLR6bsA=; b=aQ7cRZZHYuHF30/1It86/ourTsZ8diWhjLaUvxcWMtgBoIdfBNASLKlr0LpJillvyNf/MylC6zOTuOJtnmxNiNs9+obsX5l/C64A4tFI9uqX8bt8FS3qiWmE9jkWKtSz6OexFJRu5r8nxB1xeEeodAsQW167kcV0jHmESacqR9U= 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 1565166688338509.70089116097677; Wed, 7 Aug 2019 01:31:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ABF383098444; Wed, 7 Aug 2019 08:31:26 +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 87FBB5D71C; Wed, 7 Aug 2019 08:31:26 +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 081132551C; Wed, 7 Aug 2019 08:31:26 +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 x778VO6P025021 for ; Wed, 7 Aug 2019 04:31:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 245C710016E8; Wed, 7 Aug 2019 08:31:24 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2D661001284 for ; Wed, 7 Aug 2019 08:31:23 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 7 Aug 2019 10:30:47 +0200 Message-Id: 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 04/15] tools: Separate storage pool 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.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 07 Aug 2019 08:31:27 +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 storage pools (e.g. they complete various storage pool aspects) into virsh-completer-pool.c. Signed-off-by: Michal Privoznik --- tools/Makefile.am | 1 + tools/virsh-completer-pool.c | 93 ++++++++++++++++++++++++++++++++++++ tools/virsh-completer-pool.h | 31 ++++++++++++ tools/virsh-completer.c | 67 -------------------------- tools/virsh-completer.h | 9 +--- 5 files changed, 126 insertions(+), 75 deletions(-) create mode 100644 tools/virsh-completer-pool.c create mode 100644 tools/virsh-completer-pool.h diff --git a/tools/Makefile.am b/tools/Makefile.am index 4a3f72b357..a5ce6a45d4 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -219,6 +219,7 @@ virsh_SOURCES =3D \ virsh-checkpoint.c virsh-checkpoint.h \ virsh-completer.c virsh-completer.h \ virsh-completer-domain.c virsh-completer-domain.h \ + virsh-completer-pool.c virsh-completer-pool.h \ virsh-console.c virsh-console.h \ virsh-domain.c virsh-domain.h \ virsh-domain-monitor.c virsh-domain-monitor.h \ diff --git a/tools/virsh-completer-pool.c b/tools/virsh-completer-pool.c new file mode 100644 index 0000000000..fc01550908 --- /dev/null +++ b/tools/virsh-completer-pool.c @@ -0,0 +1,93 @@ +/* + * virsh-completer-pool.c: virsh completer callbacks related to pools + * + * 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-pool.h" +#include "viralloc.h" +#include "virsh-pool.h" +#include "virsh.h" +#include "virstring.h" + +char ** +virshStoragePoolNameCompleter(vshControl *ctl, + const vshCmd *cmd ATTRIBUTE_UNUSED, + unsigned int flags) +{ + virshControlPtr priv =3D ctl->privData; + virStoragePoolPtr *pools =3D NULL; + int npools =3D 0; + size_t i =3D 0; + char **ret =3D NULL; + VIR_AUTOSTRINGLIST tmp =3D NULL; + + virCheckFlags(VIR_CONNECT_LIST_STORAGE_POOLS_INACTIVE | + VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE | + VIR_CONNECT_LIST_STORAGE_POOLS_PERSISTENT, + NULL); + + if (!priv->conn || virConnectIsAlive(priv->conn) <=3D 0) + return NULL; + + if ((npools =3D virConnectListAllStoragePools(priv->conn, &pools, flag= s)) < 0) + return NULL; + + if (VIR_ALLOC_N(tmp, npools + 1) < 0) + goto cleanup; + + for (i =3D 0; i < npools; i++) { + const char *name =3D virStoragePoolGetName(pools[i]); + + if (VIR_STRDUP(tmp[i], name) < 0) + goto cleanup; + } + + VIR_STEAL_PTR(ret, tmp); + + cleanup: + for (i =3D 0; i < npools; i++) + virStoragePoolFree(pools[i]); + VIR_FREE(pools); + return ret; +} + + +char ** +virshPoolEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED, + const vshCmd *cmd ATTRIBUTE_UNUSED, + unsigned int flags) +{ + size_t i =3D 0; + char **ret =3D NULL; + VIR_AUTOSTRINGLIST tmp =3D NULL; + + virCheckFlags(0, NULL); + + if (VIR_ALLOC_N(tmp, VIR_STORAGE_POOL_EVENT_ID_LAST + 1) < 0) + return NULL; + + for (i =3D 0; i < VIR_STORAGE_POOL_EVENT_ID_LAST; i++) { + if (VIR_STRDUP(tmp[i], virshPoolEventCallbacks[i].name) < 0) + return NULL; + } + + VIR_STEAL_PTR(ret, tmp); + return ret; +} diff --git a/tools/virsh-completer-pool.h b/tools/virsh-completer-pool.h new file mode 100644 index 0000000000..778ab25df2 --- /dev/null +++ b/tools/virsh-completer-pool.h @@ -0,0 +1,31 @@ +/* + * virsh-completer-pool.h: virsh completer callbacks related to pools + * + * 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 ** virshStoragePoolNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); + +char ** virshPoolEventNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c index 787bac08f6..3b22688562 100644 --- a/tools/virsh-completer.c +++ b/tools/virsh-completer.c @@ -143,49 +143,6 @@ virshCommaStringListComplete(const char *input, } =20 =20 -char ** -virshStoragePoolNameCompleter(vshControl *ctl, - const vshCmd *cmd ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virshControlPtr priv =3D ctl->privData; - virStoragePoolPtr *pools =3D NULL; - int npools =3D 0; - size_t i =3D 0; - char **ret =3D NULL; - VIR_AUTOSTRINGLIST tmp =3D NULL; - - virCheckFlags(VIR_CONNECT_LIST_STORAGE_POOLS_INACTIVE | - VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE | - VIR_CONNECT_LIST_STORAGE_POOLS_PERSISTENT, - NULL); - - if (!priv->conn || virConnectIsAlive(priv->conn) <=3D 0) - return NULL; - - if ((npools =3D virConnectListAllStoragePools(priv->conn, &pools, flag= s)) < 0) - return NULL; - - if (VIR_ALLOC_N(tmp, npools + 1) < 0) - goto cleanup; - - for (i =3D 0; i < npools; i++) { - const char *name =3D virStoragePoolGetName(pools[i]); - - if (VIR_STRDUP(tmp[i], name) < 0) - goto cleanup; - } - - VIR_STEAL_PTR(ret, tmp); - - cleanup: - for (i =3D 0; i < npools; i++) - virStoragePoolFree(pools[i]); - VIR_FREE(pools); - return ret; -} - - char ** virshStorageVolNameCompleter(vshControl *ctl, const vshCmd *cmd, @@ -754,30 +711,6 @@ virshSecretEventNameCompleter(vshControl *ctl ATTRIBUT= E_UNUSED, } =20 =20 -char ** -virshPoolEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED, - const vshCmd *cmd ATTRIBUTE_UNUSED, - unsigned int flags) -{ - size_t i =3D 0; - char **ret =3D NULL; - VIR_AUTOSTRINGLIST tmp =3D NULL; - - virCheckFlags(0, NULL); - - if (VIR_ALLOC_N(tmp, VIR_STORAGE_POOL_EVENT_ID_LAST + 1) < 0) - return NULL; - - for (i =3D 0; i < VIR_STORAGE_POOL_EVENT_ID_LAST; i++) { - if (VIR_STRDUP(tmp[i], virshPoolEventCallbacks[i].name) < 0) - return NULL; - } - - VIR_STEAL_PTR(ret, tmp); - return ret; -} - - char ** virshNodeDeviceEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd ATTRIBUTE_UNUSED, diff --git a/tools/virsh-completer.h b/tools/virsh-completer.h index 5a58bd797e..dcfc405331 100644 --- a/tools/virsh-completer.h +++ b/tools/virsh-completer.h @@ -23,14 +23,11 @@ #include "vsh.h" =20 #include "virsh-completer-domain.h" +#include "virsh-completer-pool.h" =20 char ** virshCommaStringListComplete(const char *input, const char **options); =20 -char ** virshStoragePoolNameCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); - char ** virshStorageVolNameCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); @@ -83,10 +80,6 @@ char ** virshSecretEventNameCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); =20 -char ** virshPoolEventNameCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags); - char ** virshNodeDeviceEventNameCompleter(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