From nobody Thu May 2 08:12:28 2024 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; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1527152950756459.4324632586354; Thu, 24 May 2018 02:09:10 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 010F51FB3D1; Thu, 24 May 2018 09:09:09 +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 BEAB728D3F; Thu, 24 May 2018 09:09:08 +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 4DA0918033F0; Thu, 24 May 2018 09:09:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4O94qQJ029866 for ; Thu, 24 May 2018 05:04:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id E68B75B682; Thu, 24 May 2018 09:04:52 +0000 (UTC) Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DE0C65D761 for ; Thu, 24 May 2018 09:04:49 +0000 (UTC) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BCF9D30A7C62 for ; Thu, 24 May 2018 09:04:38 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id t11-v6so2971195wmt.0 for ; Thu, 24 May 2018 02:04:38 -0700 (PDT) Received: from rolandPC.redhat.com ([213.175.37.12]) by smtp.gmail.com with ESMTPSA id h188-v6sm4268815wmf.8.2018.05.24.02.04.36 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 May 2018 02:04:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=vvPvC7YnwYXce3I1t4bcSOUukcfyfUGcAo86YC6fhRA=; b=arpq2lJ8jdOU/W9/v7PjSXjZwt5a9Y4Cx6rW2Vv/4xtLrydcWGyJAzKwG8Dm5gz4xv mC+lnWuFSWuclqatmBi+PETH0VJvwTjk/Z2DY1CK4vxD8zf9V9WVrPJUpcePA+PZvHXV v3y6b/4Gy9wWl83PfBunCcAGYF9y0cQU1PXufQ2AbiV4ESV54dI887nSmITlj6UvkEtX TX73TCEh74NSa8oWeGlsDVvouam4tlVdxcsid+ibgFzycZoSb1CnYjWp6Bgp2ZYwLkjk D0RQJ1+UtbPKbj6TrueaWfM77kejS4qVSOg1XMr5jfmr+qOIhlEhKIHF7lg1vhvAneSz ql6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=vvPvC7YnwYXce3I1t4bcSOUukcfyfUGcAo86YC6fhRA=; b=DUUhGRs5LF8pa+GdCj6dT2jUl6NkS1YVXQJFl1c3YYSKzKOBkoXhYzBA1S3xnpsnlA JESO7TGCCUvkU58VamTJJYsvvuQ2Qrd8ndHO0H+S593JrX2g2+L+lmOMc9jyVn6F49wY odJgNQj35EyzlfsjfVZWl64rAaRqV/5+eJ1t9lzJo1tK7jElQgEr30UqfWQQJNZBbnSq mKzpOzw8n/UfUOZlHtdkUcVyHAJUUux7HovX3ZKRXpkdheQd8yPuXew2pzIhFtTfkmp9 Y5us8xVQBVu9J3tOD0tbywyIUZGqbJJ33g45Kbommql3l1w8xZpAmVQV+OXFMMCShsGA CmUA== X-Gm-Message-State: ALKqPwcU4A17zUt7Vq9HvXjNH6Dz9o4J9bzRnlyuEMbP2NIfZiKF0k/L 71fvpVhJgxRyGn5qw3U3GUOnfQ== X-Google-Smtp-Source: AB8JxZqWcSASuc7oEQbJYXDt68xdSoM/QkEPw5n6+mnyau14lj62MQBgEsgp5oe8ovQ2eQE321dUdg== X-Received: by 2002:a1c:4294:: with SMTP id k20-v6mr6079997wmi.7.1527152677255; Thu, 24 May 2018 02:04:37 -0700 (PDT) From: Roland Schulz To: libvir-list@redhat.com Date: Thu, 24 May 2018 11:04:34 +0200 Message-Id: <20180524090434.20338-2-schullzroll@gmail.com> In-Reply-To: <20180524090434.20338-1-schullzroll@gmail.com> References: <20180524090434.20338-1-schullzroll@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 24 May 2018 09:04:39 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 24 May 2018 09:04:39 +0000 (UTC) for IP:'74.125.82.66' DOMAIN:'mail-wm0-f66.google.com' HELO:'mail-wm0-f66.google.com' FROM:'schullzroll@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.281 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS, T_DKIM_INVALID) 74.125.82.66 mail-wm0-f66.google.com 74.125.82.66 mail-wm0-f66.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] tools: virsh: Add virshCellnoCompleter. 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: , MIME-Version: 1.0 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 24 May 2018 09:09:09 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Roland Schulz --- tools/virsh-completer.c | 58 +++++++++++++++++++++++++++++++++++++++++ tools/virsh-completer.h | 3 +++ tools/virsh-host.c | 3 +++ 3 files changed, 64 insertions(+) diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c index 1df4d55af..b9ea42874 100644 --- a/tools/virsh-completer.c +++ b/tools/virsh-completer.c @@ -649,3 +649,61 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl, VIR_FREE(ret); goto cleanup; } + +char ** +virshCellnoCompleter(vshControl *ctl, + const vshCmd *cmd ATTRIBUTE_UNUSED, + unsigned int flags) +{ + xmlXPathContextPtr ctxt =3D NULL; + virshControlPtr priv =3D ctl->privData; + unsigned int ncells =3D 0; + xmlNodePtr *cells =3D NULL; + xmlDocPtr doc =3D NULL; + size_t i =3D 0; + char *cellid =3D NULL; + char *cap_xml =3D NULL; + char **ret =3D NULL; + + virCheckFlags(0, NULL); + + if (!priv->conn || virConnectIsAlive(priv->conn) <=3D 0) + goto error; + + if (!(cap_xml =3D virConnectGetCapabilities(priv->conn))) + goto error; + + if (!(doc =3D virXMLParseStringCtxt(cap_xml, _("capabilities"), &ctxt)= )) + goto error; + + ncells =3D virXPathNodeSet("/capabilities/host/topology/cells/cell", c= txt, &cells); + if (ncells <=3D 0) + goto error; + + if (VIR_ALLOC_N(ret, ncells + 1)) + goto error; + + for (i =3D 0; i < ncells; i++) { + VIR_FREE(cellid); + cellid =3D virXMLPropString(cells[i], "id"); + if (VIR_STRDUP(ret[i], cellid) < 0) + goto error; + } + + cleanup: + xmlXPathFreeContext(ctxt); + VIR_FREE(cells); + xmlFreeDoc(doc); + VIR_FREE(cap_xml); + VIR_FREE(cellid); + + return ret; + + error: + if (ret) { + for (i =3D 0; i < ncells; i++) + VIR_FREE(ret[i]); + } + VIR_FREE(ret); + goto cleanup; +} diff --git a/tools/virsh-completer.h b/tools/virsh-completer.h index 8e4d46394..ee0234ce0 100644 --- a/tools/virsh-completer.h +++ b/tools/virsh-completer.h @@ -78,4 +78,7 @@ char ** virshAllocpagesPagesizeCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); =20 +char ** virshCellnoCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); #endif diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 293f06e9e..dfe58de30 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -149,6 +149,7 @@ static const vshCmdInfo info_freecell[] =3D { static const vshCmdOptDef opts_freecell[] =3D { {.name =3D "cellno", .type =3D VSH_OT_INT, + .completer =3D virshCellnoCompleter, .help =3D N_("NUMA cell number") }, {.name =3D "all", @@ -274,6 +275,7 @@ static const vshCmdInfo info_freepages[] =3D { static const vshCmdOptDef opts_freepages[] =3D { {.name =3D "cellno", .type =3D VSH_OT_INT, + .completer =3D virshCellnoCompleter, .help =3D N_("NUMA cell number") }, {.name =3D "pagesize", @@ -482,6 +484,7 @@ static const vshCmdOptDef opts_allocpages[] =3D { }, {.name =3D "cellno", .type =3D VSH_OT_INT, + .completer =3D virshCellnoCompleter, .help =3D N_("NUMA cell number") }, {.name =3D "add", --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list