[PATCH 1/6] virsh: cmdVcpuPin: Simplify handling of API flags

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

 



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 | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 6dd75e2..028df1f 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -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 == 0 && !current) {
             if (virDomainPinVcpu(dom, vcpu, cpumap, cpumaplen) != 0)
                 goto cleanup;
         } else {
-- 
2.6.2

--
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]