[libvirt] [PATCHv2 6/9] virNodeGetCPUMapFlags: Implement virsh support.

Eric Blake eblake at redhat.com
Tue Oct 23 22:35:21 UTC 2012


On 10/16/2012 08:05 AM, Viktor Mihajlovski wrote:

s/Flags// - but by now we know the drill :)

> - Added a new host command nodecpumap
> - Added documentation
> 
> Example:
> $ virsh nodecpumap
> CPUs present:  8
> CPUs online:   3
> CPU map:       10101000
> 
> Signed-off-by: Viktor Mihajlovski <mihajlov at linux.vnet.ibm.com>
> ---
>  tools/virsh-host.c |   41 +++++++++++++++++++++++++++++++++++++++++
>  tools/virsh.pod    |    5 +++++
>  2 files changed, 46 insertions(+), 0 deletions(-)
> 


> +    vshPrint(ctl, "%-15s ", _("CPU map:"));
> +    for (cpu = 0; cpu < cpunum; cpu++) {
> +        vshPrint(ctl, "%d", VIR_CPU_USED(cpumap, cpu) ? 1 : 0);

Perhaps more efficient as %c, and matching the vcpuinfo command's output
('y' and '-' instead of 1/0).  Might also be nice to put in some spacing
for legibility, but we didn't do that for vcpuinfo.

Thanks for remembering the docs!

Here's what I'm squashing in, plus the obvious update to the commit message:

diff --git i/tools/virsh-host.c w/tools/virsh-host.c
index 4ef4a57..2d814cd 100644
--- i/tools/virsh-host.c
+++ w/tools/virsh-host.c
@@ -288,7 +288,7 @@ cmdNodeCpuMap(vshControl *ctl, const vshCmd *cmd
ATTRIBUTE_UNUSED)
     unsigned int online;
     bool ret = false;

-    cpunum = virNodeGetCPUMapFlags(ctl->conn, &cpumap, &online, 0);
+    cpunum = virNodeGetCPUMap(ctl->conn, &cpumap, &online, 0);
     if (cpunum < 0) {
         vshError(ctl, "%s", _("Unable to get cpu map"));
         goto cleanup;
@@ -298,9 +298,8 @@ cmdNodeCpuMap(vshControl *ctl, const vshCmd *cmd
ATTRIBUTE_UNUSED)
     vshPrint(ctl, "%-15s %d\n", _("CPUs online:"), online);

     vshPrint(ctl, "%-15s ", _("CPU map:"));
-    for (cpu = 0; cpu < cpunum; cpu++) {
-        vshPrint(ctl, "%d", VIR_CPU_USED(cpumap, cpu) ? 1 : 0);
-    }
+    for (cpu = 0; cpu < cpunum; cpu++)
+        vshPrint(ctl, "%c", VIR_CPU_USED(cpumap, cpu) ? 'y' : '-');
     vshPrint(ctl, "\n");

     ret = true;


-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 617 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20121023/3a4ae61a/attachment-0001.sig>


More information about the libvir-list mailing list