fetching resctrl monitoring group settings from def->resmons
and createing resctrl group accodring to cachetune element
status. This patch relies on the function of resctrl of
util.
---
src/qemu/qemu_process.c | 45 +++++++++++++++++++++++++++++++++++++++++----
1 file changed, 41 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 40d35cb..eb0778d 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2444,10 +2444,12 @@ qemuProcessResctrlCreate(virQEMUDriverPtr driver,
{
int ret = -1;
size_t i = 0;
+ size_t j = 0;
virCapsPtr caps = NULL;
+ virResctrlAllocPtr alloc = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
- if (!vm->def->ncachetunes)
+ if (!vm->def->ncachetunes && !vm->def->nresmons)
return 0;
/* Force capability refresh since resctrl info can change
@@ -2463,6 +2465,29 @@ qemuProcessResctrlCreate(virQEMUDriverPtr driver,
goto cleanup;
}
+ for (i = 0; i < vm->def->nresmons; i++) {
+ alloc = NULL;
+ for (j = 0; j < vm->def->ncachetunes; j++) {
+ const char *monid
+ = virResctrlMonGetID(vm->def->resmons[i]->mon);
+ const char *allocid
+ = virResctrlAllocGetID(vm->def->cachetunes[j]->alloc);
+ if (STREQ(monid, allocid) &&
+ (virBitmapEqual(vm->def->resmons[i]->vcpus,
+ vm->def->cachetunes[j]->vcpus))) {
+ alloc = vm->def->cachetunes[j]->alloc;
+ break;
+ }
+
+ }
+
+ if (virResctrlMonCreate(
+ alloc,
+ vm->def->resmons[i]->mon,
+ priv->machineName) < 0)
+ goto cleanup;
+ }
+
ret = 0;
cleanup:
virObjectUnref(caps);
@@ -5272,6 +5297,16 @@ qemuProcessSetupVcpu(virDomainObjPtr vm,
}
}
+ for (i = 0; i < vm->def->nresmons; i++) {
+ virDomainCpuResmonDefPtr rt = vm->def->resmons[i];
+
+ if (virBitmapIsBitSet(rt->vcpus, vcpuid)) {
+ if (virResctrlMonAddPID(rt->mon, vcpupid) < 0)
+ return -1;
+ break;
+ }
+ }
+
return 0;
}
@@ -6960,11 +6995,13 @@ void qemuProcessStop(virQEMUDriverPtr driver,
vm->def->name);
}
- /* Remove resctrl allocation after cgroups are cleaned up which makes it
- * kind of safer (although removing the allocation should work even with
- * pids in tasks file */
+ /* Remove resctrl allocation and monitoring group after cgroups are cleaned
+ * up which makes it kind of safer (although removing the allocation should
+ * work even with pids in tasks file */
for (i = 0; i < vm->def->ncachetunes; i++)
virResctrlAllocRemove(vm->def->cachetunes[i]->alloc);
+ for (i = 0; i < vm->def->nresmons; i++)
+ virResctrlMonRemove(vm->def->resmons[i]->mon);
qemuProcessRemoveDomainStatus(driver, vm);
--
2.7.4