ä 2011å05æ09æ 16:31, Hu Tao åé:
This enables user to modify cpu.shares even when domain is inactive. --- tools/virsh.c | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index 2b16714..58facc4 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -1590,6 +1590,7 @@ 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")}, + {"persistent", VSH_OT_BOOL, 0, N_("persist VM on destination")}, {NULL, 0, 0, NULL} }; @@ -1697,6 +1698,7 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd) int update = 0; int i, ret; bool ret_val = false; + unsigned int flags = 0; if (!vshConnectionUsability(ctl, ctl->conn)) return false; @@ -1704,6 +1706,16 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; + if (vshCommandOptBool(cmd, "persistent")) + flags |= VIR_DOMAIN_SCHEDPARAM_CONFIG; + if (virDomainIsActive(dom)) + flags |= VIR_DOMAIN_SCHEDPARAM_LIVE; + + if (!(flags& (VIR_DOMAIN_SCHEDPARAM_CONFIG | VIR_DOMAIN_SCHEDPARAM_LIVE))) { + vshError(ctl, "%s", _("Domain is not running and you didn't specify --persistent parameter.")); + goto cleanup; + } + /* Print SchedulerType */ schedulertype = virDomainGetSchedulerType(dom,&nparams);
Hi HuTao, AFAIK, virDomainGetSchedulerParameters won't work for inactive domain, cgroup for domain is removed when the domain is destroyed/shutdown'ed, (perhaps we will support persistent XML for domain cgroup, but currently it doesn't), means it will fail earlier, before could executing virDomainSetSchedulerParametersFlags. Actually I made similar patches about one month before: https://www.redhat.com/archives/libvir-list/2011-April/msg00806.html the difference with your patches is it only allows changing on running domain, options are "--live" and "--persistent", perhaps your principle is better though. ïï
if (schedulertype!= NULL){ @@ -1735,7 +1747,7 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd) /* Update parameters& refresh data */ if (update) { - ret = virDomainSetSchedulerParameters(dom, params, nparams); + ret = virDomainSetSchedulerParametersFlags(dom, params, nparams, flags); if (ret == -1) goto cleanup;
Regards Osier -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list