Re: [PATCH] virsh: Add a helper to parse cpulist

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

 



On 28/03/13 19:36, Osier Yang wrote:
vcpupin and emulatorpin use same code to parse the cpulist, this
abstracts the same code as a helper. Along with various code style
fixes, and error improvement (only error "Physical CPU %d doesn't
exist" if the specified CPU exceed the range, no "cpulist: Invalid
format", see the following for an example of the error prior to
this patch).

% virsh vcpupin 4 0 0-8
error: Physical CPU 4 doesn't exist.
error: cpulist: Invalid format.
---
  tools/virsh-domain.c | 278 ++++++++++++++++++++-------------------------------
  1 file changed, 106 insertions(+), 172 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index d1e6f9d..0fe2a51 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -5460,6 +5460,97 @@ vshPrintPinInfo(unsigned char *cpumaps, size_t cpumaplen,
      return true;
  }
+static unsigned char *
+virParseCPUList(vshControl *ctl, const char *cpulist,
+                int maxcpu, size_t cpumaplen)
+{


I meant vshParseCPUList. With the attached diff squashed in:


diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 0fe2a51..1729182 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -5461,7 +5461,7 @@ vshPrintPinInfo(unsigned char *cpumaps, size_t cpumaplen,
 }
 
 static unsigned char *
-virParseCPUList(vshControl *ctl, const char *cpulist,
+vshParseCPUList(vshControl *ctl, const char *cpulist,
                 int maxcpu, size_t cpumaplen)
 {
     unsigned char *cpumap = NULL;
@@ -5650,7 +5650,7 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
     }
 
     /* Pin mode: pinning specified vcpu to specified physical cpus*/
-    if (!(cpumap = virParseCPUList(ctl, cpulist, maxcpu, cpumaplen)))
+    if (!(cpumap = vshParseCPUList(ctl, cpulist, maxcpu, cpumaplen)))
         goto cleanup;
 
     if (flags == -1) {
@@ -5776,7 +5776,7 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd)
     }
 
     /* Pin mode: pinning emulator threads to specified physical cpus*/
-    if (!(cpumap = virParseCPUList(ctl, cpulist, maxcpu, cpumaplen)))
+    if (!(cpumap = vshParseCPUList(ctl, cpulist, maxcpu, cpumaplen)))
         goto cleanup;
 
     if (flags == -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]