hmm. my git configuration seems to have
stripped out all my comments... sorry. This should have been included:
---------
Patch to earlier cpu cgroup support
in libvirt-cim to accommodate support in
latest versions of libvirt for persisting
cpu cgroup setting for KVM guests
in new <cputune> section of XML
config. Patch is conditionally compiled
based on libvirt version built against.
New libvirt versions will exploit
this patch and libvirt-cim will no longer
save cpu cgroup setting in
infostore, and is better interoperable
with virsh management commands.
Older libvirt versions will continue
to exploit previous libvirt-cim cpu
cgroup support (ie save cpu cgroup setting
in infostore, less interoperable
with vish management commands).
----------
- G
Dr. Gareth S. Bestor
IBM Senior Software Engineer
Systems & Technology Group - Systems Management Standards
971-285-6375 (mobile)
bestor@us.ibm.com
+#if LIBVIR_VERSION_NUMBER >= 9000
+ /* Recent libvirt versions add new <cputune>
section to XML */
+ msg = cputune_xml(root, dominfo);
+ if (msg != NULL)
+ goto out;
+#endif
+
devices = xmlNewChild(root, NULL, BAD_CAST
"devices", NULL);
if (devices == NULL) {
msg = XML_ERROR;
diff --git a/src/Virt_ComputerSystem.c b/src/Virt_ComputerSystem.c
index e1f1cec..098b07a 100644
--- a/src/Virt_ComputerSystem.c
+++ b/src/Virt_ComputerSystem.c
@@ -861,6 +861,11 @@ static int lxc_scheduler_params(struct infostore_ctx
*ctx,
static int kvm_scheduler_params(struct infostore_ctx *ctx,
virSchedParameter **params)
{
+#if LIBVIR_VERSION_NUMBER < 9000
+ /* Old versions of libvirt only support CPU
cgroups for running guests */
+ /* so instead read cpu cgroup setting for
inactive guest from infostore. */
+ /* New versions there is nothing to do because
libvirt takes care of it. */
+
unsigned long long value;
- /* Currently only support CPU cgroups for
running KVM guests */
+ /* Early versions of libvirt only support
CPU cgroups for *running* KVM guests */
+#if LIBVIR_VERSION_NUMBER < 9000
if (domain_online(dom) && STREQC(virConnectGetType(conn),
"QEMU")) {
+#else
+ if (STREQC(virConnectGetType(conn), "QEMU"))
{
+#endif
char *sched;
int nparams;
unsigned int i;
diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c
index 21979c3..f6b191e 100644
--- a/src/Virt_VirtualSystemManagementService.c
+++ b/src/Virt_VirtualSystemManagementService.c
@@ -1783,7 +1783,37 @@ static CMPIStatus update_dominfo(const struct domain
*dominfo,
goto out;
}
+#if LIBVIR_VERSION_NUMBER < 9000
+ /* Old libvirt versions dont save cpu cgroup
setting for inactive */
+ /* guests, so save in infostore instead */
infostore_set_u64(ctx, "weight",
dev->dev.vcpu.weight);
+#else
+ /* New libvirt versions save cpu cgroup setting
in KVM guest config */
+ if (STREQC(virConnectGetType(conn), "QEMU"))
{
+ int ret;
+ virSchedParameter
params;
+ strncpy(params.field,
+
"cpu_shares",
+
VIR_DOMAIN_SCHED_FIELD_LENGTH);
+ params.type =
VIR_DOMAIN_SCHED_FIELD_ULLONG;
+ params.value.ul
= dev->dev.vcpu.weight;
+
+ CU_DEBUG("setting
%s scheduler param cpu_shares=%d",
+
dominfo->name,
+
dev->dev.vcpu.weight);
+ ret = virDomainSetSchedulerParametersFlags(dom,
¶ms, 1,
+
VIR_DOMAIN_AFFECT_CONFIG);
+ if (ret != 0)
{
+
CU_DEBUG("Failed to set config scheduler param");
+
cu_statusf(_BROKER, &s,
+
CMPI_RC_ERR_FAILED,
+
"Failed to set config
scheduler param");
+
goto out;
+ }
+ }
+ else
+ infostore_set_u64(ctx,
"weight", dev->dev.vcpu.weight);
+#endif
infostore_set_u64(ctx, "limit",
dev->dev.vcpu.limit);