mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
virsh: cmdBlockJob: Switch to declarative flag interlocking
Use the VSH_EXCLUSIVE_OPTIONS_VAR to interlock incompatible options. Since a variable named 'abort' would conflict with older compilers use VSH_EXCLUSIVE_OPTIONS for the --abort option.
This commit is contained in:
parent
dda95b531f
commit
2f12cb9355
@ -2542,26 +2542,31 @@ cmdBlockJob(vshControl *ctl, const vshCmd *cmd)
|
|||||||
bool ret = false;
|
bool ret = false;
|
||||||
bool raw = vshCommandOptBool(cmd, "raw");
|
bool raw = vshCommandOptBool(cmd, "raw");
|
||||||
bool bytes = vshCommandOptBool(cmd, "bytes");
|
bool bytes = vshCommandOptBool(cmd, "bytes");
|
||||||
bool abortMode = (vshCommandOptBool(cmd, "abort") ||
|
bool abortMode = vshCommandOptBool(cmd, "abort");
|
||||||
vshCommandOptBool(cmd, "async") ||
|
bool pivot = vshCommandOptBool(cmd, "pivot");
|
||||||
vshCommandOptBool(cmd, "pivot"));
|
bool async = vshCommandOptBool(cmd, "async");
|
||||||
bool infoMode = vshCommandOptBool(cmd, "info") || raw;
|
bool info = vshCommandOptBool(cmd, "info");
|
||||||
bool bandwidth = vshCommandOptBool(cmd, "bandwidth");
|
bool bandwidth = vshCommandOptBool(cmd, "bandwidth");
|
||||||
virDomainPtr dom = NULL;
|
virDomainPtr dom = NULL;
|
||||||
const char *path;
|
const char *path;
|
||||||
|
|
||||||
if (abortMode + infoMode + bandwidth > 1) {
|
VSH_EXCLUSIVE_OPTIONS("raw", "abort");
|
||||||
vshError(ctl, "%s",
|
VSH_EXCLUSIVE_OPTIONS_VAR(raw, pivot);
|
||||||
_("conflict between abort, info, and bandwidth modes"));
|
VSH_EXCLUSIVE_OPTIONS_VAR(raw, async);
|
||||||
return false;
|
VSH_EXCLUSIVE_OPTIONS_VAR(raw, bandwidth);
|
||||||
}
|
|
||||||
/* XXX also support --bytes with bandwidth mode */
|
|
||||||
if (bytes && (abortMode || bandwidth)) {
|
|
||||||
vshError(ctl, "%s", _("--bytes requires info mode"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (abortMode)
|
VSH_EXCLUSIVE_OPTIONS("info", "abort");
|
||||||
|
VSH_EXCLUSIVE_OPTIONS_VAR(info, pivot);
|
||||||
|
VSH_EXCLUSIVE_OPTIONS_VAR(info, async);
|
||||||
|
VSH_EXCLUSIVE_OPTIONS_VAR(info, bandwidth);
|
||||||
|
|
||||||
|
VSH_EXCLUSIVE_OPTIONS("bytes", "abort");
|
||||||
|
VSH_EXCLUSIVE_OPTIONS_VAR(bytes, pivot);
|
||||||
|
VSH_EXCLUSIVE_OPTIONS_VAR(bytes, async);
|
||||||
|
/* XXX also support --bytes with bandwidth mode */
|
||||||
|
VSH_EXCLUSIVE_OPTIONS_VAR(bytes, bandwidth);
|
||||||
|
|
||||||
|
if (abortMode || pivot || async)
|
||||||
return blockJobImpl(ctl, cmd, VSH_CMD_BLOCK_JOB_ABORT, NULL);
|
return blockJobImpl(ctl, cmd, VSH_CMD_BLOCK_JOB_ABORT, NULL);
|
||||||
if (bandwidth)
|
if (bandwidth)
|
||||||
return blockJobImpl(ctl, cmd, VSH_CMD_BLOCK_JOB_SPEED, NULL);
|
return blockJobImpl(ctl, cmd, VSH_CMD_BLOCK_JOB_SPEED, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user