virsh: schedinfo --set invalid=value would simply ignore the option

For example, virsh -c test:///default schedinfo 1 --set P=k would
mistakenly exit successfully, giving no indication that it had failed
to set the scheduling parameter "P".
* tools/virsh.c (cmdSchedinfo): Diagnose an invalid --set j=k option,
rather than silently ignoring it.
* tests/virsh-schedinfo: New test for the above.
* tests/Makefile.am (test_scripts): Add it.
Reported by Jintao Yang in http://bugzilla.redhat.com/586632
This commit is contained in:
Jim Meyering
2010-05-11 16:37:15 +02:00
parent 5603515127
commit 9a641564fb
3 changed files with 60 additions and 0 deletions
+10
View File
@@ -1594,6 +1594,16 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
ret = virDomainGetSchedulerParameters(dom, params, &nparams);
if (ret == -1)
goto cleanup;
} else {
/* See if we've tried to --set var=val. If so, the fact that
we reach this point (with update == 0) means that "var" did
not match any of the settable parameters. Report the error. */
char *var_value_pair = vshCommandOptString(cmd, "set", NULL);
if (var_value_pair) {
vshError(ctl, _("invalid scheduler option: %s"),
var_value_pair);
goto cleanup;
}
}
ret_val = TRUE;