This patch maintains the two Xen-specific --weight and --cap options, but adds support for setting arbitrary parameters by specifying them in param=value syntax. Changes to the virsh manual are included. Changes: - Replace use of 'a' conversion modifier with pre-alloc diff -r 51fd150edd42 -r e441b1a06f1c docs/virsh.pod --- a/docs/virsh.pod Tue Oct 07 11:45:52 2008 -0700 +++ b/docs/virsh.pod Wed Oct 08 07:59:11 2008 -0700 @@ -318,12 +318,14 @@ with all the same limitations. Open network connections may be severed upon restore, as TCP timeouts may have expired. +=item B<schedinfo> optional I<--set> B<parameter=value> I<domain-id> + =item B<schedinfo> optional I<--weight> B<number> optional I<--cap> B<number> I<domain-id> -Allows to show (and set) the domain scheduler parameters. This is currently -only defined for XEN_CREDIT scheduler, and the optional weight and cap -arguments allows to set the associated parameters in that scheduler if -provided. +Allows to show (and set) the domain scheduler parameters. + +B<Note>: The weight and cap parameters are defined only for the +XEN_CREDIT scheduler and are now I<DEPRECATED>. =item B<setmem> I<domain-id> B<kilobytes> diff -r 51fd150edd42 -r e441b1a06f1c src/virsh.c --- a/src/virsh.c Tue Oct 07 11:45:52 2008 -0700 +++ b/src/virsh.c Wed Oct 08 07:59:11 2008 -0700 @@ -1112,6 +1112,7 @@ static const vshCmdOptDef opts_schedinfo[] = { {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")}, + {"set", VSH_OT_STRING, VSH_OFLAG_NONE, gettext_noop("parameter=value")}, {"weight", VSH_OT_INT, VSH_OFLAG_NONE, gettext_noop("weight for XEN_CREDIT")}, {"cap", VSH_OT_INT, VSH_OFLAG_NONE, gettext_noop("cap for XEN_CREDIT")}, {NULL, 0, 0, NULL} @@ -1121,6 +1122,9 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd) { char *schedulertype; + char *set; + char *param_name = NULL; + long long int param_value = 0; virDomainPtr dom; virSchedParameterPtr params = NULL; int i, ret; @@ -1128,6 +1132,7 @@ int nr_inputparams = 0; int inputparams = 0; int weightfound = 0; + int setfound = 0; int weight = 0; int capfound = 0; int cap = 0; @@ -1141,7 +1146,7 @@ if (!(dom = vshCommandOptDomain(ctl, cmd, "domain", NULL))) return FALSE; - /* Currently supports Xen Credit only */ + /* Deprecated Xen-only options */ if(vshCommandOptBool(cmd, "weight")) { weight = vshCommandOptInt(cmd, "weight", &weightfound); if (!weightfound) { @@ -1160,6 +1165,25 @@ } else { nr_inputparams++; } + } + + if(vshCommandOptBool(cmd, "set")) { + set = vshCommandOptString(cmd, "set", &setfound); + if (!setfound) { + vshError(ctl, FALSE, "%s", _("Error getting param")); + goto cleanup; + } + + param_name = vshMalloc(ctl, strlen(set) + 1); + if (param_name == NULL) + goto cleanup; + + if (sscanf(set, "%[^=]=%i", param_name, ¶m_value) != 2) { + vshError(ctl, FALSE, "%s", _("Invalid value of param")); + goto cleanup; + } + + nr_inputparams++; } params = vshMalloc(ctl, sizeof (virSchedParameter) * nr_inputparams); @@ -1180,7 +1204,14 @@ params[inputparams].value.ui = cap; inputparams++; } - /* End Currently supports Xen Credit only */ + /* End Deprecated Xen-only options */ + + if (setfound) { + strncpy(params[inputparams].field,param_name,sizeof(params[0].field)); + params[inputparams].type = VIR_DOMAIN_SCHED_FIELD_LLONG; + params[inputparams].value.l = param_value; + inputparams++; + } assert (inputparams == nr_inputparams); @@ -1247,6 +1278,7 @@ } cleanup: free(params); + free(param_name); virDomainFree(dom); return ret_val; } -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list