[PATCH 0 of 3] Add LXC ProcRASD support

This set enables ProcRASD support for LXC domains. It exposes the interfaces to get/set these values, as well as modifies the domain start logic to enforce the values, like we do for Xen.

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1223920960 25200 # Node ID 31edd656481f4a328f16102ab9f7b9e24643d687 # Parent f0a209b602e707305a713611097310ec503451df Make VSMS honor Weight property of ProcRASD for LXC Also, reject if VirtualQuantity or Limit is specified (for the moment) Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r f0a209b602e7 -r 31edd656481f src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Wed Oct 08 09:13:55 2008 -0700 +++ b/src/Virt_VirtualSystemManagementService.c Mon Oct 13 11:02:40 2008 -0700 @@ -522,6 +522,34 @@ return NULL; } +static const char *lxc_proc_rasd_to_vdev(CMPIInstance *inst, + struct virt_device *dev) +{ + CMPIObjectPath *op = NULL; + CMPIrc rc; + uint32_t def_weight = 1024; + + rc = cu_get_u64_prop(inst, "VirtualQuantity", &dev->dev.vcpu.quantity); + if (rc == CMPI_RC_OK) + return "ProcRASD field VirtualQuantity not valid for LXC"; + + op = CMGetObjectPath(inst, NULL); + if (op == NULL) { + CU_DEBUG("Unable to determine class of ProcRASD"); + return NULL; + } + + rc = cu_get_u64_prop(inst, "Limit", &dev->dev.vcpu.limit); + if (rc == CMPI_RC_OK) + return "ProcRASD field Limit not valid for LXC"; + + rc = cu_get_u32_prop(inst, "Weight", &dev->dev.vcpu.weight); + if (rc != CMPI_RC_OK) + dev->dev.vcpu.weight = def_weight; + + return NULL; +} + static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, struct virt_device *dev, uint16_t type, @@ -551,6 +579,8 @@ return lxc_disk_rasd_to_vdev(inst, dev); } else if (type == CIM_RES_TYPE_NET) { return net_rasd_to_vdev(inst, dev, ns); + } else if (type == CIM_RES_TYPE_PROC) { + return lxc_proc_rasd_to_vdev(inst, dev); } return "Resource type not supported on this platform";

+ + op = CMGetObjectPath(inst, NULL); + if (op == NULL) { + CU_DEBUG("Unable to determine class of ProcRASD"); + return NULL; + } +
Getting the ObjectPath here isn't needed - it's not used elsewhere in the function. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

KR> Getting the ObjectPath here isn't needed - it's not used elsewhere KR> in the function. Oops, the intent was to check the classname to make sure it was LXC_. Must have gotten lost in the week between starting and finishing this set :) Thanks! -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1223921465 25200 # Node ID 56b5db360cb4e78cec960c6b31e4f6159edb8c46 # Parent 31edd656481f4a328f16102ab9f7b9e24643d687 Make ComputerSystem enforce LXC scheduling parameters on domain start Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 31edd656481f -r 56b5db360cb4 src/Virt_ComputerSystem.c --- a/src/Virt_ComputerSystem.c Mon Oct 13 11:02:40 2008 -0700 +++ b/src/Virt_ComputerSystem.c Mon Oct 13 11:11:05 2008 -0700 @@ -667,23 +667,70 @@ DEFAULT_EQ(); DEFAULT_INST_CLEANUP(); +static int xen_scheduler_params(struct infostore_ctx *ctx, + virSchedParameter **params) +{ + unsigned long long weight; + unsigned long long cap; + + *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; + } + + 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; + } + + return 2; +} + +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; +} + 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) { CU_DEBUG("Unable to get connection from domain"); - return; - } - - if (!STREQC(virConnectGetType(conn), "xen")) { - CU_DEBUG("Not setting sched params for this domain type"); return; } @@ -693,13 +740,27 @@ return; } - params[0].value.ui = infostore_get_u64(ctx, "weight"); - params[1].value.ui = infostore_get_u64(ctx, "limit"); + 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; + } - virDomainSetSchedulerParameters(dom, params, 2); + if (count < 0) { + CU_DEBUG("Unable to set scheduler parameters"); + goto out; + } + virDomainSetSchedulerParameters(dom, params, count); + out: infostore_close(ctx); + free(params); } + /* This composite operation may be supported as a flag to reboot */ static int domain_reset(virDomainPtr dom)

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1223921490 25200 # Node ID e156ceabb65da50f468235dcf0fccbc4b5fb142f # Parent 56b5db360cb4e78cec960c6b31e4f6159edb8c46 Expose LXC_ProcRASD so that the scheduling parameters are visible Also make ProcRASD not set the VirtualQuantity field if it's zero, so that LXC_ProcRASD's value appears undefined instead of 0. Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 56b5db360cb4 -r e156ceabb65d schema/ResourceAllocationSettingData.registration --- a/schema/ResourceAllocationSettingData.registration Mon Oct 13 11:11:05 2008 -0700 +++ b/schema/ResourceAllocationSettingData.registration Mon Oct 13 11:11:30 2008 -0700 @@ -10,3 +10,4 @@ KVM_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +LXC_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance diff -r 56b5db360cb4 -r e156ceabb65d src/Virt_RASD.c --- a/src/Virt_RASD.c Mon Oct 13 11:11:05 2008 -0700 +++ b/src/Virt_RASD.c Mon Oct 13 11:11:30 2008 -0700 @@ -306,8 +306,13 @@ CMSetProperty(inst, "Limit", (CMPIValue *)&dev->dev.mem.maxsize, CMPI_uint64); } else if (dev->type == CIM_RES_TYPE_PROC) { - CMSetProperty(inst, "VirtualQuantity", - (CMPIValue *)&dev->dev.vcpu.quantity, CMPI_uint64); + if (dev->dev.vcpu.quantity > 0) { + CMSetProperty(inst, + "VirtualQuantity", + (CMPIValue *)&dev->dev.vcpu.quantity, + CMPI_uint64); + } + set_proc_rasd_params(broker, ref, host, inst); }
participants (2)
-
Dan Smith
-
Kaitlin Rupert