Since we can now set just --live or --config, we also need to be able to query that back. In the case of setting both --live and --config, it shouldn't matter which value we read back; otherwise, since querying treats the two flags as mutually exclusive, so does this patch. * tools/virsh.c (cmdSchedinfo): Use new API where appropriate. --- tools/virsh.c | 32 +++++++++++++++++++++++++++----- 1 files changed, 27 insertions(+), 5 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index 77cadcb..a47d938 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -1732,7 +1732,7 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd) /* Print SchedulerType */ schedulertype = virDomainGetSchedulerType(dom, &nparams); - if (schedulertype != NULL){ + if (schedulertype != NULL) { vshPrint(ctl, "%-15s: %s\n", _("Scheduler"), schedulertype); VIR_FREE(schedulertype); @@ -1745,12 +1745,22 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd) params = vshMalloc(ctl, sizeof(virSchedParameter)* nparams); memset(params, 0, sizeof(virSchedParameter)* nparams); - ret = virDomainGetSchedulerParameters(dom, 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. */ + ret = virDomainGetSchedulerParametersFlags(dom, params, &nparams, + ((live && config) ? 0 + : flags)); + } else { + ret = virDomainGetSchedulerParameters(dom, params, &nparams); + } if (ret == -1) goto cleanup; /* See if any params are being set */ - for (i = 0; i < nparams; i++){ + for (i = 0; i < nparams; i++) { ret = cmdSchedInfoUpdate(ctl, cmd, &(params[i])); if (ret == -1) goto cleanup; @@ -1769,7 +1779,13 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd) if (ret == -1) goto cleanup; - ret = virDomainGetSchedulerParameters(dom, params, &nparams); + if (flags || current) + ret = virDomainGetSchedulerParametersFlags(dom, params, + &nparams, + ((live && config) ? 0 + : flags)); + else + ret = virDomainGetSchedulerParameters(dom, params, &nparams); if (ret == -1) goto cleanup; } else { @@ -1782,10 +1798,16 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd) var_value_pair); goto cleanup; } + /* When not doing --set, --live and --config do not mix. */ + if (live && config) { + vshError(ctl, "%s", + _("cannot query both live and config at once")); + goto cleanup; + } } ret_val = true; - for (i = 0; i < nparams; i++){ + for (i = 0; i < nparams; i++) { switch (params[i].type) { case VIR_DOMAIN_SCHED_FIELD_INT: vshPrint(ctl, "%-15s: %d\n", params[i].field, params[i].value.i); -- 1.7.4.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list