From nobody Mon Feb 9 05:01:29 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=1565166726; cv=none; d=zoho.com; s=zohoarc; b=IWLKOr9V9F7KaU3ufLN5wxVqbLQ5KUFWOkwbi1V9/mNioy4oahGTwFJ+LHEJSLYSVr8TReST4kvRcwtAkknfMb1KCJuCDnkEeFlkPgq9HvjRN9KJ9z46sp59heikbneFcENWrdVZh4ktsA03otEY4BpoIGwPDFYqvt9Fpi37oS0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565166726; 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=dQv2zCPqPQqYVRCpQt2R8l6XIlPGBENsBjMZbXfbIZw=; b=BeF4YDjUu658lxV+9XrHBjIjt2VPF8PyMZOUqJ9hbHn2Au2d/iCJSdEAa0mfIM+FMTOdiQ2wZPALGsU1qzNChX5en3Dv+s1wNcGQ18UPzQwztArWQxoYUiPTBhLhyMA+tVsDiW2z17VrZeT79aHo8FPIHllcmWgKlczbSp0SoyE= 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 1565166726591263.79406259972495; Wed, 7 Aug 2019 01:32:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3CB4931CD6C; Wed, 7 Aug 2019 08:32:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 05BED67625; Wed, 7 Aug 2019 08:32:05 +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 B942918005C7; Wed, 7 Aug 2019 08:32:04 +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 x778VVjU025111 for ; Wed, 7 Aug 2019 04:31:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 503BC100194E; Wed, 7 Aug 2019 08:31:31 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE5121001938 for ; Wed, 7 Aug 2019 08:31:30 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 7 Aug 2019 10:30:56 +0200 Message-Id: <475715d6d47eab83330e82f339be492463009fc8.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 13/15] tools: Separate checkpoint 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 07 Aug 2019 08:32:05 +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 host (e.g. they complete various checkpoint aspects) into virsh-completer-checkpoint.c Signed-off-by: Michal Privoznik --- tools/Makefile.am | 1 + tools/virsh-completer-checkpoint.c | 78 ++++++++++++++++++++++++++++++ tools/virsh-completer-checkpoint.h | 27 +++++++++++ tools/virsh-completer.c | 52 -------------------- 4 files changed, 106 insertions(+), 52 deletions(-) create mode 100644 tools/virsh-completer-checkpoint.c create mode 100644 tools/virsh-completer-checkpoint.h diff --git a/tools/Makefile.am b/tools/Makefile.am index 43083f4afa..274f941d74 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-checkpoint.c virsh-completer-checkpoint.h \ virsh-completer-host.c virsh-completer-host.h \ virsh-completer-interface.c virsh-completer-interface.h \ virsh-completer-network.c virsh-completer-network.h \ diff --git a/tools/virsh-completer-checkpoint.c b/tools/virsh-completer-che= ckpoint.c new file mode 100644 index 0000000000..ce9d32844d --- /dev/null +++ b/tools/virsh-completer-checkpoint.c @@ -0,0 +1,78 @@ +/* + * virsh-completer-checkpoint.c: virsh completer callbacks related to chec= kpoints + * + * 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-checkpoint.h" +#include "viralloc.h" +#include "virsh-util.h" +#include "virsh.h" +#include "virstring.h" + +char ** +virshCheckpointNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags) +{ + virshControlPtr priv =3D ctl->privData; + virDomainPtr dom =3D NULL; + virDomainCheckpointPtr *checkpoints =3D NULL; + int ncheckpoints =3D 0; + size_t i =3D 0; + char **ret =3D NULL; + + virCheckFlags(0, NULL); + + if (!priv->conn || virConnectIsAlive(priv->conn) <=3D 0) + return NULL; + + if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + return NULL; + + if ((ncheckpoints =3D virDomainListAllCheckpoints(dom, &checkpoints, + flags)) < 0) + goto error; + + if (VIR_ALLOC_N(ret, ncheckpoints + 1) < 0) + goto error; + + for (i =3D 0; i < ncheckpoints; i++) { + const char *name =3D virDomainCheckpointGetName(checkpoints[i]); + + if (VIR_STRDUP(ret[i], name) < 0) + goto error; + + virshDomainCheckpointFree(checkpoints[i]); + } + VIR_FREE(checkpoints); + virshDomainFree(dom); + + return ret; + + error: + for (; i < ncheckpoints; i++) + virshDomainCheckpointFree(checkpoints[i]); + VIR_FREE(checkpoints); + for (i =3D 0; i < ncheckpoints; i++) + VIR_FREE(ret[i]); + VIR_FREE(ret); + virshDomainFree(dom); + return NULL; +} diff --git a/tools/virsh-completer-checkpoint.h b/tools/virsh-completer-che= ckpoint.h new file mode 100644 index 0000000000..c536a3ffda --- /dev/null +++ b/tools/virsh-completer-checkpoint.h @@ -0,0 +1,27 @@ +/* + * virsh-completer-checkpoint.h: virsh completer callbacks related to chec= kpoints + * + * 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 ** virshCheckpointNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c index ce42f62fc1..0f1709b4ba 100644 --- a/tools/virsh-completer.c +++ b/tools/virsh-completer.c @@ -141,55 +141,3 @@ virshCommaStringListComplete(const char *input, =20 VIR_RETURN_PTR(ret); } - - -char ** -virshCheckpointNameCompleter(vshControl *ctl, - const vshCmd *cmd, - unsigned int flags) -{ - virshControlPtr priv =3D ctl->privData; - virDomainPtr dom =3D NULL; - virDomainCheckpointPtr *checkpoints =3D NULL; - int ncheckpoints =3D 0; - size_t i =3D 0; - char **ret =3D NULL; - - virCheckFlags(0, NULL); - - if (!priv->conn || virConnectIsAlive(priv->conn) <=3D 0) - return NULL; - - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) - return NULL; - - if ((ncheckpoints =3D virDomainListAllCheckpoints(dom, &checkpoints, - flags)) < 0) - goto error; - - if (VIR_ALLOC_N(ret, ncheckpoints + 1) < 0) - goto error; - - for (i =3D 0; i < ncheckpoints; i++) { - const char *name =3D virDomainCheckpointGetName(checkpoints[i]); - - if (VIR_STRDUP(ret[i], name) < 0) - goto error; - - virshDomainCheckpointFree(checkpoints[i]); - } - VIR_FREE(checkpoints); - virshDomainFree(dom); - - return ret; - - error: - for (; i < ncheckpoints; i++) - virshDomainCheckpointFree(checkpoints[i]); - VIR_FREE(checkpoints); - for (i =3D 0; i < ncheckpoints; i++) - VIR_FREE(ret[i]); - VIR_FREE(ret); - virshDomainFree(dom); - return NULL; -} --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list