]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: cmdSchedinfo: Add separate variable for holding flags used for query
authorPeter Krempa <pkrempa@redhat.com>
Mon, 28 Feb 2022 17:21:48 +0000 (18:21 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 3 Mar 2022 10:06:56 +0000 (11:06 +0100)
Instead of having two ad-hoc places which decide whether the original
flags can be used add another variable specifically for flags used for
query.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tools/virsh-domain.c

index ca1145428fb9cc31bf3ba6d24534715c0e39d398..2d1889c71ed8daf15361bd1d163cd8434ca42511 100644 (file)
@@ -5158,6 +5158,7 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
     size_t i;
     bool ret_val = false;
     unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
+    unsigned int queryflags = VIR_DOMAIN_AFFECT_CURRENT;
     bool current = vshCommandOptBool(cmd, "current");
     bool config = vshCommandOptBool(cmd, "config");
     bool live = vshCommandOptBool(cmd, "live");
@@ -5170,6 +5171,14 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
+    /* We cannot query both live and config at once, so settle
+       on current in that case.  If we are setting, then the two values should
+       match when we re-query; otherwise, we report the error later.  */
+    if (config && live)
+        queryflags = VIR_DOMAIN_AFFECT_CURRENT;
+    else
+        queryflags = flags;
+
     if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
@@ -5188,12 +5197,7 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
     memset(params, 0, sizeof(*params) * nparams);
 
     if (flags || current) {
-        /* We cannot query both live and config at once, so settle
-           on current in that case.  If we are setting, then the
-           two values should match when we re-query; otherwise, we
-           report the error later.  */
-        if (virDomainGetSchedulerParametersFlags(dom, params, &nparams,
-                                                 ((live && config) ? 0 : flags)) == -1)
+        if (virDomainGetSchedulerParametersFlags(dom, params, &nparams, queryflags) == -1)
             goto cleanup;
     } else {
         if (virDomainGetSchedulerParameters(dom, params, &nparams) == -1)
@@ -5212,8 +5216,7 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
                                                      nupdates, flags) == -1)
                 goto cleanup;
 
-            if (virDomainGetSchedulerParametersFlags(dom, params, &nparams,
-                                                     ((live && config) ? 0 : flags)) == -1)
+            if (virDomainGetSchedulerParametersFlags(dom, params, &nparams, queryflags) == -1)
                 goto cleanup;
         } else {
             if (virDomainSetSchedulerParameters(dom, updates, nupdates) == -1)