From nobody Fri May 3 20:20:41 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 152723238033524.794670277398154; Fri, 25 May 2018 00:13:00 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 72CBE30E024F; Fri, 25 May 2018 07:12:58 +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 7958B5C542; Fri, 25 May 2018 07:12:57 +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 105D94CA80; Fri, 25 May 2018 07:12:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4P7CtMI029921 for ; Fri, 25 May 2018 03:12:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5AC4660BF7; Fri, 25 May 2018 07:12:55 +0000 (UTC) Received: from mx1.redhat.com (ext-mx18.extmail.prod.ext.phx2.redhat.com [10.5.110.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 49BCB17981 for ; Fri, 25 May 2018 07:12:52 +0000 (UTC) Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) (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 CB01D30BDB91 for ; Fri, 25 May 2018 07:12:40 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id a8-v6so11519446wmg.5 for ; Fri, 25 May 2018 00:12:40 -0700 (PDT) Received: from rolandPC.redhat.com ([213.175.37.12]) by smtp.gmail.com with ESMTPSA id 135-v6sm11545325wmx.21.2018.05.25.00.12.37 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 May 2018 00:12:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=5v9BKd+Ul+UCqFRBOWuiuwrvIwl4bO2FpNxFNXPdYrw=; b=iY2cuTWpG6tpcd+AMFaprQVubHdiyFMQv0QjjScuGvn4Z/64zf7GqkoM/aq2BnfNqt hDLk62sVywwxmWnBaATxVTEgYrSz7NwCKlBFKJCj6sHRpbk2HgW81NcBFJfkZs0omVrr bvY7BdIvgxLw8+PDxEeZj8KXRaYkcAXfY9GWmoK1M8i40YZIW6Mb6NC4fihfzrtwGHXh miOTV1HDUto/SgS3ElYHmGCRMUSZHiFrnidPFu8fYefhgMJ1SJjNtrvmLVw0eTEPZXt4 2XEd5X2bizdKmMsRWvwRTQCrapqYDYSlcvw0asx9yNMeBUZH3Id2UBT5iEyYdhJjVKD+ mRVA== 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; bh=5v9BKd+Ul+UCqFRBOWuiuwrvIwl4bO2FpNxFNXPdYrw=; b=AIxA/ZmY8PuSh74njb9LiMvrSABc62RbsAEx5uoHaONl1Y0Tx2Zd93eKXkQWWHi7SD eBrx3PmVWbc3gtztuZVZ9dsH4h3Zx7cK7QmnMLyvonCPkjqYThnyFE6ukNgNhlHS/LqG FVAVLGSfWYlL8SDYYnoWIgaf7xwOOkMfB6ga4Rq0snfIGl2wjYT/ljOmQGEdB9Zxx/WV PkXYDa1GiNYpq31y0cFKDNq17yM6MBDYdzOVMaAxNnTJro335wA9lC1TqGCbxs5WOEU6 wxI44HZx67D6H/6cOYL6/jUksIReA9v+HdmCFuuYHD2keCcEM4Reguu2BXaL+THYkblI gXQA== X-Gm-Message-State: ALKqPwf/DvO9pDas13wlu/GxCUhef+OTeGUKlKyRnJUeoimNa5V+KAsM WmYPN2P63ZG7Jw66FohDMVmbcg== X-Google-Smtp-Source: ADUXVKKTELc3rRxcmQcojVN7wUu5gxadRCudk/gOVS94sdf3+oWyOkll30VIRW/8l5GevlK3rNI9EA== X-Received: by 2002:a1c:6b11:: with SMTP id g17-v6mr776019wmc.65.1527232359254; Fri, 25 May 2018 00:12:39 -0700 (PDT) From: Roland Schulz To: libvir-list@redhat.com Date: Fri, 25 May 2018 09:12:37 +0200 Message-Id: <20180525071237.13570-1-schullzroll@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 25 May 2018 07:12:41 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 25 May 2018 07:12:41 +0000 (UTC) for IP:'74.125.82.67' DOMAIN:'mail-wm0-f67.google.com' HELO:'mail-wm0-f67.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.67 mail-wm0-f67.google.com 74.125.82.67 mail-wm0-f67.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.47 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 25 May 2018 07:12:59 +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 | 59 +++++++++++++++++++++++++++++++++++++++++ tools/virsh-completer.h | 3 +++ tools/virsh-host.c | 3 +++ 3 files changed, 65 insertions(+) diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c index 5713a887e..ce152226f 100644 --- a/tools/virsh-completer.c +++ b/tools/virsh-completer.c @@ -756,3 +756,62 @@ virshNodedevEventNameCompleter(vshControl *ctl ATTRIBU= TE_UNUSED, virStringListFree(ret); return NULL; } + + +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 *cap_xml =3D NULL; + char *cellid =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 86632ee91..ee7eec68c 100644 --- a/tools/virsh-completer.h +++ b/tools/virsh-completer.h @@ -94,4 +94,7 @@ char ** virshNodedevEventNameCompleter(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 12c13f522..991c0f50a 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", @@ -483,6 +485,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