On 05/17/2011 12:20 AM, Hu Tao wrote: > This enables user to modify cpu.shares even when domain is inactive. > --- > tools/virsh.c | 25 ++++++++++++++++++++++++- > tools/virsh.pod | 6 +++++- > 2 files changed, 29 insertions(+), 2 deletions(-) > > diff --git a/tools/virsh.c b/tools/virsh.c > index a38750f..0e0f8cf 100644 > --- a/tools/virsh.c > +++ b/tools/virsh.c > @@ -1596,6 +1596,9 @@ static const vshCmdOptDef opts_schedinfo[] = { > {"set", VSH_OT_STRING, VSH_OFLAG_NONE, N_("parameter=value")}, > {"weight", VSH_OT_INT, VSH_OFLAG_NONE, N_("weight for XEN_CREDIT")}, > {"cap", VSH_OT_INT, VSH_OFLAG_NONE, N_("cap for XEN_CREDIT")}, > + {"current", VSH_OT_BOOL, 0, N_("get current scheduler info")}, > + {"config", VSH_OT_BOOL, 0, N_("get value to be used on next boot")}, > + {"live", VSH_OT_BOOL, 0, N_("get value from running domain")}, Hmm, this says get, but right now it only affects set. We really need to add virDomainGetSchedulerParametersFlags. > {NULL, 0, 0, NULL} > }; > > @@ -1703,6 +1706,23 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd) > int update = 0; > int i, ret; > bool ret_val = false; > + unsigned int flags = 0; > + int current = vshCommandOptBool(cmd, "current"); > + int config = vshCommandOptBool(cmd, "config"); > + int live = vshCommandOptBool(cmd, "live"); > + > + if (current) { > + if (live || config) { > + vshError(ctl, "%s", _("--current must be specified exclusively")); > + return false; > + } > + flags = VIR_DOMAIN_SCHEDPARAM_CURRENT; But this is 0, ... > + } else { > + if (config) > + flags |= VIR_DOMAIN_SCHEDPARAM_CONFIG; > + if (live) > + flags |= VIR_DOMAIN_SCHEDPARAM_LIVE; > + } > > if (!vshConnectionUsability(ctl, ctl->conn)) > return false; > @@ -1741,7 +1761,10 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd) > > /* Update parameters & refresh data */ > if (update) { > - ret = virDomainSetSchedulerParameters(dom, params, nparams); > + if (flags) > + ret = virDomainSetSchedulerParametersFlags(dom, params, nparams, flags); so this needs to be flags || current > + else > + ret = virDomainSetSchedulerParameters(dom, params, nparams); > if (ret == -1) > goto cleanup; > > diff --git a/tools/virsh.pod b/tools/virsh.pod > index d11a0e3..98e8580 100644 > --- a/tools/virsh.pod > +++ b/tools/virsh.pod > @@ -570,7 +570,7 @@ This is roughly equivalent to doing a hibernate on a running computer, > 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<--set> B<parameter=value> I<domain-id> I<--persistent> Not how we spelled it in virsh.c... > > =item B<schedinfo> optional I<--weight> B<number> optional I<--cap> B<number> I<domain-id> > > @@ -582,6 +582,10 @@ Xen (credit scheduler): weight, cap > > ESX (allocation scheduler): reservation, limit, shares > > +If I<--live> is specified, set scheduler information of a running guest. > +If I<--config> is specified, affect the next boot of a persistent guest. > +If I<--current> is specified, affect the current guest state. > + > B<Note>: The cpu_shares parameter has a valid value range of 0-262144; Negative > values are wrapped to positive, and larger values are capped at the maximum. > Therefore, -1 is a useful shorthand for 262144. ACK with this squashed in, so I'm pushing: diff --git i/tools/virsh.c w/tools/virsh.c index 15d9c7a..77cadcb 100644 --- i/tools/virsh.c +++ w/tools/virsh.c @@ -1596,9 +1596,9 @@ static const vshCmdOptDef opts_schedinfo[] = { {"set", VSH_OT_STRING, VSH_OFLAG_NONE, N_("parameter=value")}, {"weight", VSH_OT_INT, VSH_OFLAG_NONE, N_("weight for XEN_CREDIT")}, {"cap", VSH_OT_INT, VSH_OFLAG_NONE, N_("cap for XEN_CREDIT")}, - {"current", VSH_OT_BOOL, 0, N_("get current scheduler info")}, - {"config", VSH_OT_BOOL, 0, N_("get value to be used on next boot")}, - {"live", VSH_OT_BOOL, 0, N_("get value from running domain")}, + {"current", VSH_OT_BOOL, 0, N_("get/set current scheduler info")}, + {"config", VSH_OT_BOOL, 0, N_("get/set value to be used on next boot")}, + {"live", VSH_OT_BOOL, 0, N_("get/set value from running domain")}, {NULL, 0, 0, NULL} }; @@ -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); @@ -1761,8 +1761,9 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd) /* Update parameters & refresh data */ if (update) { - if (flags) - ret = virDomainSetSchedulerParametersFlags(dom, params, nparams, flags); + if (flags || current) + ret = virDomainSetSchedulerParametersFlags(dom, params, + nparams, flags); else ret = virDomainSetSchedulerParameters(dom, params, nparams); if (ret == -1) diff --git i/tools/virsh.pod w/tools/virsh.pod index 98e8580..ef01f41 100644 --- i/tools/virsh.pod +++ w/tools/virsh.pod @@ -570,11 +570,14 @@ This is roughly equivalent to doing a hibernate on a running computer, 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> I<--persistent> +=item B<schedinfo> optional I<--set> B<parameter=value> I<domain-id> I<--config> +I<--live> I<--current> -=item B<schedinfo> optional I<--weight> B<number> optional I<--cap> B<number> I<domain-id> +=item B<schedinfo> optional I<--weight> B<number> optional I<--cap> B<number> +I<domain-id> -Allows you to show (and set) the domain scheduler parameters. The parameters available for each hypervisor are: +Allows you to show (and set) the domain scheduler parameters. The parameters +available for each hypervisor are: LXC, QEMU/KVM (posix scheduler): cpu_shares -- Eric Blake eblake@xxxxxxxxxx +1-801-349-2682 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list