[libvirt] [PATCH 6/8] Implement schedular tunables API using cgroups
Daniel Veillard
veillard at redhat.com
Thu Jul 23 15:38:45 UTC 2009
On Wed, Jul 22, 2009 at 04:23:45PM +0100, Daniel P. Berrange wrote:
> * src/qemu_driver.c: Add driver methods qemuGetSchedulerType,
> qemuGetSchedulerParameters, qemuSetSchedulerParameters
> * src/lxc_driver.c: Fix to use unsigned long long consistently
> for schedular parameters
> * src/cgroup.h, src/cgroup.c: Fix cpu_shares to take unsigned
> long long
> * src/util.c, src/util.h, src/libvirt_private.syms: Add a
> virStrToDouble helper
> * src/virsh.c: Fix handling of --set arg to schedinfo command
> to honour the designated data type of each schedular tunable
> as declared by the driver
>
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---
> src/cgroup.c | 10 +-
> src/cgroup.h | 4 +-
> src/libvirt_private.syms | 1 +
> src/lxc_driver.c | 9 ++-
> src/qemu_driver.c | 151 +++++++++++++++++++++++++++++-
> src/util.c | 20 ++++
> src/util.h | 3 +
[...]
> @@ -1355,9 +1355,14 @@ static int lxcSetSchedulerParameters(virDomainPtr domain,
>
> for (i = 0; i < nparams; i++) {
> virSchedParameterPtr param = ¶ms[i];
> + if (param->type != VIR_DOMAIN_SCHED_FIELD_ULLONG) {
> + lxcError(NULL, domain, VIR_ERR_INVALID_ARG,
> + _("invalid type for cpu_shares tunable, expected a 'ullong'"));
> + goto cleanup;
> + }
Humpf, we are actually breaking the API in some ways there, what is
the argument ? Consistency with qemu scheduling parameters ?
> if (STREQ(param->field, "cpu_shares")) {
[...]
> + if (STREQ(param->field, "cpu_shares")) {
> + int rc;
> + if (param->type != VIR_DOMAIN_SCHED_FIELD_ULLONG) {
Apparently, but is that worth it ?
[...]
> --- a/src/virsh.c
> +++ b/src/virsh.c
> @@ -1181,111 +1181,118 @@ static const vshCmdOptDef opts_schedinfo[] = {
> };
>
> static int
> -cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
> +cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd,
> + virSchedParameterPtr param)
> {
[...]
> + /* Legacy 'weight' parameter */
> + if (STREQ(param->field, "weight") &&
> + param->type == VIR_DOMAIN_SCHED_FIELD_UINT &&
> + vshCommandOptBool(cmd, "weight")) {
> + int val;
> + val = vshCommandOptInt(cmd, "weight", &found);
> + if (!found) {
> vshError(ctl, FALSE, "%s", _("Invalid value of weight"));
> - goto cleanup;
> + return -1;
> } else {
> - nr_inputparams++;
> + param->value.ui = val;
> }
> + return 1;
This API is and remains a pain, looking at the ESX driver there is
just yet another completely different set ...
ACK, though the lxc breakage is a bit nasty IMHO
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel at veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
More information about the libvir-list
mailing list