]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: cmdVcpuPin: Simplify handling of API flags
authorPeter Krempa <pkrempa@redhat.com>
Fri, 12 Feb 2016 05:15:47 +0000 (06:15 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 19 Feb 2016 14:13:21 +0000 (15:13 +0100)
Rather than setting flags to -1 if none were specified, move the logic
to use the old API to the place where we need to decide. It simplifies
the logic a bit.

tools/virsh-domain.c

index 7a8162bf7ae3af785df8f2c83e55494dcb3840f5..8b82640630656ab7efc4ddc73778bc3a9bab7745 100644 (file)
@@ -6432,9 +6432,6 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
         flags |= VIR_DOMAIN_AFFECT_CONFIG;
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
-    /* none of the options were specified */
-    if (!current && !live && !config)
-        flags = -1;
 
     if (vshCommandOptStringReq(ctl, cmd, "cpulist", &cpulist) < 0)
         return false;
@@ -6459,11 +6456,6 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
 
     /* Query mode: show CPU affinity information then exit.*/
     if (!cpulist) {
-        /* When query mode and neither "live", "config" nor "current"
-         * is specified, set VIR_DOMAIN_AFFECT_CURRENT as flags */
-        if (flags == -1)
-            flags = VIR_DOMAIN_AFFECT_CURRENT;
-
         if ((ncpus = virshCPUCountCollect(ctl, dom, flags, true)) < 0) {
             if (ncpus == -1) {
                 if (flags & VIR_DOMAIN_AFFECT_LIVE)
@@ -6511,7 +6503,8 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
         if (!(cpumap = virshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu)))
             goto cleanup;
 
-        if (flags == -1) {
+        /* use old API without any explicit flags */
+        if (flags == VIR_DOMAIN_AFFECT_CURRENT && !current) {
             if (virDomainPinVcpu(dom, vcpu, cpumap, cpumaplen) != 0)
                 goto cleanup;
         } else {