When libvirtd daemon restart, this patch will reenable those perf
events previously enabled.
Signed-off-by: Qiaowei Ren <qiaowei.ren(a)intel.com>
---
src/qemu/qemu_driver.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 7d95364..09607ca 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -164,6 +164,9 @@ static int qemuDomainGetMaxVcpus(virDomainPtr dom);
static int qemuDomainManagedSaveLoad(virDomainObjPtr vm,
void *opaque);
+static int qemuDomainPerfRestart(virDomainObjPtr vm,
+ void *data);
+
static int qemuOpenFile(virQEMUDriverPtr driver,
virDomainObjPtr vm,
const char *path, int oflags,
@@ -939,6 +942,10 @@ qemuStateInitialize(bool privileged,
qemuDomainManagedSaveLoad,
qemu_driver);
+ virDomainObjListForEach(qemu_driver->domains,
+ qemuDomainPerfRestart,
+ NULL);
+
qemuProcessReconnectAll(conn, qemu_driver);
qemu_driver->workerPool = virThreadPoolNew(0, 1, 0, qemuProcessEventHandler,
qemu_driver);
@@ -3460,6 +3467,35 @@ qemuDomainManagedSaveLoad(virDomainObjPtr vm,
return ret;
}
+static int
+qemuDomainPerfRestart(virDomainObjPtr vm,
+ void *data ATTRIBUTE_UNUSED)
+{
+ size_t i;
+ virDomainDefPtr def = vm->def;
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+
+ virPerfFree(priv->perf);
+
+ priv->perf = virPerfNew();
+ if (!priv->perf)
+ return -1;
+
+ for (i = 0; i < VIR_PERF_EVENT_LAST; i++) {
+ if (def->perf->events[i] &&
+ def->perf->events[i] == VIR_TRISTATE_BOOL_YES) {
+ if (virPerfEventEnable(priv->perf, i, vm->pid))
+ goto cleanup;
+ }
+ }
+
+ return 0;
+
+ cleanup:
+ virPerfFree(priv->perf);
+ return -1;
+}
+
static int
qemuDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags)
--
1.9.1