提交 a7bc9841 编写于 作者: P Peter Krempa

virsh: cmdVcpuPin: Simplify handling of API flags

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.
上级 b6c40bd5
...@@ -6432,9 +6432,6 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd) ...@@ -6432,9 +6432,6 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_DOMAIN_AFFECT_CONFIG; flags |= VIR_DOMAIN_AFFECT_CONFIG;
if (live) if (live)
flags |= VIR_DOMAIN_AFFECT_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) if (vshCommandOptStringReq(ctl, cmd, "cpulist", &cpulist) < 0)
return false; return false;
...@@ -6459,11 +6456,6 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd) ...@@ -6459,11 +6456,6 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
/* Query mode: show CPU affinity information then exit.*/ /* Query mode: show CPU affinity information then exit.*/
if (!cpulist) { 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 = virshCPUCountCollect(ctl, dom, flags, true)) < 0) {
if (ncpus == -1) { if (ncpus == -1) {
if (flags & VIR_DOMAIN_AFFECT_LIVE) if (flags & VIR_DOMAIN_AFFECT_LIVE)
...@@ -6511,7 +6503,8 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd) ...@@ -6511,7 +6503,8 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
if (!(cpumap = virshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu))) if (!(cpumap = virshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu)))
goto cleanup; 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) if (virDomainPinVcpu(dom, vcpu, cpumap, cpumaplen) != 0)
goto cleanup; goto cleanup;
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册