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

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

 



(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@xxxxxxxxxxxxxx>
---
 tools/virsh-domain.c |   23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index ebaca2d..3a8da00 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -5325,6 +5325,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;
@@ -5338,6 +5339,11 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd)
         return false;
     }
 
+    if ((vshNodeGetCPUMap(ctl->conn, &hostcpumap)) < 0) {
+        virDomainFree(dom);
+        return false;
+    }
+
     if (virDomainGetInfo(dom, &info) != 0) {
         virDomainFree(dom);
         return false;
@@ -5364,7 +5370,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)) {
@@ -5386,8 +5398,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)) {
-- 
1.7.10.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]