From 2337098b633ab6f1b84bbca55cb03be10f005c74 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 28 Feb 2022 18:21:48 +0100 Subject: [PATCH] virsh: cmdSchedinfo: Add separate variable for holding flags used for query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Ján Tomko --- tools/virsh-domain.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index ca1145428f..2d1889c71e 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -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)