This patch uses the new helper to avoid the more complex check for
domain state modification flags.
---
Notes:
Version 2:
- remove unecessary usage of if (current)
- fix cmdSetmaxmem
- convert cmdMemtune too
tools/virsh-domain.c | 300 ---
1 file changed, 118 insertions(+), 182 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 128e516..11db36b 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -1021,25 +1021,21 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
int nparams = 0;
int maxparams = 0;
virTypedParameterPtr params = NULL;
-unsigned int flags = 0, i = 0;
+unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
+unsigned int i = 0;
int rv = 0;
bool current = vshCommandOptBool(cmd, current);
bool config = vshCommandOptBool(cmd, config);
bool live = vshCommandOptBool(cmd, live);
bool ret = false;
-if (current) {
-if (live || config) {
-vshError(ctl, %s, _(--current must be specified exclusively));
-return false;
-}
-flags = VIR_DOMAIN_AFFECT_CURRENT;
-} else {
-if (config)
-flags |= VIR_DOMAIN_AFFECT_CONFIG;
-if (live)
-flags |= VIR_DOMAIN_AFFECT_LIVE;
-}
+VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
+VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
+
+if (config)
+flags |= VIR_DOMAIN_AFFECT_CONFIG;
+if (live)
+flags |= VIR_DOMAIN_AFFECT_LIVE;
if (!(dom = vshCommandOptDomain(ctl, cmd, name)))
goto cleanup;
@@ -1206,23 +1202,18 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
unsigned int i = 0;
virTypedParameterPtr params = NULL;
bool ret = false;
-unsigned int flags = 0;
+unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
bool current = vshCommandOptBool(cmd, current);
bool config = vshCommandOptBool(cmd, config);
bool live = vshCommandOptBool(cmd, live);
-if (current) {
-if (live || config) {
-vshError(ctl, %s, _(--current must be specified exclusively));
-return false;
-}
-flags = VIR_DOMAIN_AFFECT_CURRENT;
-} else {
-if (config)
-flags |= VIR_DOMAIN_AFFECT_CONFIG;
-if (live)
-flags |= VIR_DOMAIN_AFFECT_LIVE;
-}
+VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
+VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
+
+if (config)
+flags |= VIR_DOMAIN_AFFECT_CONFIG;
+if (live)
+flags |= VIR_DOMAIN_AFFECT_LIVE;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false;
@@ -2475,7 +2466,7 @@ cmdDomIftune(vshControl *ctl, const vshCmd *cmd)
virDomainPtr dom;
const char *name = NULL, *device = NULL,
*inboundStr = NULL, *outboundStr = NULL;
-unsigned int flags = 0;
+unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
int nparams = 0;
int maxparams = 0;
virTypedParameterPtr params = NULL;
@@ -2486,18 +2477,13 @@ cmdDomIftune(vshControl *ctl, const vshCmd *cmd)
virNetDevBandwidthRate inbound, outbound;
int i;
-if (current) {
-if (live || config) {
-vshError(ctl, %s, _(--current must be specified exclusively));
-return false;
-}
-flags = VIR_DOMAIN_AFFECT_CURRENT;
-} else {
-if (config)
-flags |= VIR_DOMAIN_AFFECT_CONFIG;
-if (live)
-flags |= VIR_DOMAIN_AFFECT_LIVE;
-}
+VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
+VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
+
+if (config)
+flags |= VIR_DOMAIN_AFFECT_CONFIG;
+if (live)
+flags |= VIR_DOMAIN_AFFECT_LIVE;
if (!(dom = vshCommandOptDomain(ctl, cmd, name)))
return false;
@@ -4027,23 +4013,18 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
int nupdates = 0;
int i, ret;
bool ret_val = false;
-unsigned int flags = 0;
+unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
bool current = vshCommandOptBool(cmd, current);
bool config = vshCommandOptBool(cmd, config);
bool live = vshCommandOptBool(cmd, live);
-if (current) {
-if (live || config) {
-vshError(ctl, %s, _(--current must be specified exclusively));
-return false;
-}
-flags = VIR_DOMAIN_AFFECT_CURRENT;
-} else {
-if (config)
-flags |= VIR_DOMAIN_AFFECT_CONFIG;
-if (live)
-flags |= VIR_DOMAIN_AFFECT_LIVE;
-}
+VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
+VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
+
+if (config)
+flags |= VIR_DOMAIN_AFFECT_CONFIG;
+if (live)
+flags |= VIR_DOMAIN_AFFECT_LIVE;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false;
@@ -5478,23 +5459,18 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
bool live = vshCommandOptBool(cmd, live);