[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] tool/virsh-domain.c: Fix the display of Affinity in function cmdVcpuinfo.



(1).Introduce a symbol 'x' to mean the physical cpu on host is offline.
(2).And the symbol '-' means the physical cpu on host is online but the
affinity of domain for this cpu is not set.

There was no diffrence in display between the two kinds of cpu state
before this patch, both are '-'.

Signed-off-by: yangdongsheng <yangds fnst cn fujitsu com>
---
    I have removed the vshNodeGetCPUMap patch from this patchset.
    So this patch will only fix the display of virsh vcpuinfo, please
give me your comment. Thanx~

 tools/virsh-domain.c |   24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 0402aef..6e13076 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -5271,6 +5271,7 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd)
     virDomainPtr dom;
     virVcpuInfoPtr cpuinfo;
     unsigned char *cpumaps;
+    unsigned char *hostcpumap;
     int ncpus, maxcpu;
     size_t cpumaplen;
     bool ret = true;
@@ -5284,6 +5285,11 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd)
         return false;
     }
 
+    if ((virNodeGetCPUMap(ctl->conn, &hostcpumap, NULL, 0)) < 0) {
+        virDomainFree(dom);
+        return false;
+    }
+
     if (virDomainGetInfo(dom, &info) != 0) {
         virDomainFree(dom);
         return false;
@@ -5310,7 +5316,13 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd)
             }
             vshPrint(ctl, "%-15s ", _("CPU Affinity:"));
             for (m = 0; m < maxcpu; m++) {
-                vshPrint(ctl, "%c", VIR_CPU_USABLE(cpumaps, cpumaplen, n, m) ? 'y' : '-');
+                if VIR_CPU_USED(hostcpumap, m) {
+                    vshPrint(ctl, "%c", VIR_CPU_USABLE(cpumaps,
+                                        cpumaplen, n, m) ? 'y' : '-');
+                }
+                else {
+                    vshPrint(ctl, "%c", 'x');
+                }
             }
             vshPrint(ctl, "\n");
             if (n < (ncpus - 1)) {
@@ -5332,8 +5344,13 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd)
                 vshPrint(ctl, "%-15s %s\n", _("CPU time"), _("N/A"));
                 vshPrint(ctl, "%-15s ", _("CPU Affinity:"));
                 for (m = 0; m < maxcpu; m++) {
-                    vshPrint(ctl, "%c",
-                             VIR_CPU_USABLE(cpumaps, cpumaplen, n, m) ? 'y' : '-');
+                    if VIR_CPU_USED(hostcpumap, m) {
+                        vshPrint(ctl, "%c", VIR_CPU_USABLE(cpumaps,
+                                            cpumaplen, n, m) ? 'y' : '-');
+                    }
+                    else {
+                        vshPrint(ctl, "%c", 'x');
+                    }
                 }
                 vshPrint(ctl, "\n");
                 if (n < (ncpus - 1)) {
@@ -5346,6 +5363,7 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd)
     }
 
     VIR_FREE(cpumaps);
+    VIR_FREE(hostcpumap);
     VIR_FREE(cpuinfo);
     virDomainFree(dom);
     return ret;
-- 
1.7.10.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]