Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Evergreen:11.1
libvirt-cim
lxc-sched-param.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File lxc-sched-param.patch of Package libvirt-cim
# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1224089333 25200 # Node ID c9faf7ec24553425ffc3068b0b8a19b9b83ee99b # Parent 96cf38e8a1101ce68965509c9e76f6d7f41516d7 Make ComputerSystem enforce LXC scheduling parameters on domain start Changes: - Return an accurate param count and only call the set function if we have some to set Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 96cf38e8a110 -r c9faf7ec2455 src/Virt_ComputerSystem.c --- a/src/Virt_ComputerSystem.c Tue Oct 14 12:10:58 2008 -0700 +++ b/src/Virt_ComputerSystem.c Wed Oct 15 09:48:53 2008 -0700 @@ -667,14 +667,71 @@ DEFAULT_EQ(); DEFAULT_EQ(); DEFAULT_INST_CLEANUP(); +static int xen_scheduler_params(struct infostore_ctx *ctx, + virSchedParameter **params) +{ + unsigned long long weight; + unsigned long long cap; + int nparams = 0; + + *params = calloc(2, sizeof(virSchedParameter)); + if (*params == NULL) + return -1; + + weight = infostore_get_u64(ctx, "weight"); + cap = infostore_get_u64(ctx, "limit"); + + if (weight != 0) { + strncpy((*params)[0].field, + "weight", + sizeof((*params)[0].field)); + (*params)[0].type = VIR_DOMAIN_SCHED_FIELD_UINT; + (*params)[0].value.ui = weight; + nparams++; + } + + if (cap != 0) { + strncpy((*params)[0].field, + "cap", + sizeof((*params)[0].field)); + (*params)[0].type = VIR_DOMAIN_SCHED_FIELD_UINT; + (*params)[0].value.ui = cap; + nparams++; + } + + return nparams; +} + +static int lxc_scheduler_params(struct infostore_ctx *ctx, + virSchedParameter **params) +{ + unsigned long long value; + + *params = calloc(1, sizeof(virSchedParameter)); + if (*params == NULL) + return -1; + + value = infostore_get_u64(ctx, "weight"); + + if (value != 0) { + strncpy((*params)[0].field, + "cpu_shares", + sizeof((*params)[0].field)); + (*params)[0].type = VIR_DOMAIN_SCHED_FIELD_UINT; + (*params)[0].value.ui = value; + + return 1; + } + + return 0; +} + static void set_scheduler_params(virDomainPtr dom) { struct infostore_ctx *ctx; virConnectPtr conn = NULL; - virSchedParameter params[] = - {{ "weight", VIR_DOMAIN_SCHED_FIELD_UINT }, - { "cap", VIR_DOMAIN_SCHED_FIELD_UINT }, - }; + virSchedParameter *params = NULL; + int count; conn = virDomainGetConnect(dom); if (conn == NULL) { @@ -682,24 +739,36 @@ static void set_scheduler_params(virDoma return; } - if (!STREQC(virConnectGetType(conn), "xen")) { - CU_DEBUG("Not setting sched params for this domain type"); - return; - } - ctx = infostore_open(dom); if (ctx == NULL) { CU_DEBUG("Unable to open infostore for domain"); return; } - params[0].value.ui = infostore_get_u64(ctx, "weight"); - params[1].value.ui = infostore_get_u64(ctx, "limit"); - - virDomainSetSchedulerParameters(dom, params, 2); - + if (STREQC(virConnectGetType(conn), "xen")) + count = xen_scheduler_params(ctx, ¶ms); + else if (STREQC(virConnectGetType(conn), "lxc")) + count = lxc_scheduler_params(ctx, ¶ms); + else { + CU_DEBUG("Not setting sched params for type %s", + virConnectGetType(conn)); + goto out; + } + + if (count < 0) { + CU_DEBUG("Unable to set scheduler parameters"); + goto out; + } + + if (count > 0) + virDomainSetSchedulerParameters(dom, params, count); + else + CU_DEBUG("No sched parameters to set"); + out: infostore_close(ctx); -} + free(params); +} + /* This composite operation may be supported as a flag to reboot */ static int domain_reset(virDomainPtr dom)
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor