When libvirtd daemon restart, this patch will reenable those perf events previously enabled. Signed-off-by: Qiaowei Ren <qiaowei.ren@xxxxxxxxx> --- src/qemu/qemu_driver.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 7f3c2a5..91aa79f 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,32 @@ qemuDomainManagedSaveLoad(virDomainObjPtr vm, return ret; } +static int +qemuDomainPerfRestart(virDomainObjPtr vm, + void *data ATTRIBUTE_UNUSED) +{ + virDomainDefPtr def = vm->def; + qemuDomainObjPrivatePtr priv = vm->privateData; + + if (priv->perf) + virPerfFree(priv->perf); + + priv->perf = virPerfNew(); + if (!priv->perf) + return -1; + + if (def->perf.cmt && def->perf.cmt == VIR_TRISTATE_BOOL_YES) { + if (virPerfEventEnable(priv->perf, VIR_PERF_EVENT_CMT, vm->pid)) + goto cleanup; + } + + return 0; + + cleanup: + virPerfFree(priv->perf); + return -1; +} + static int qemuDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags) -- 1.9.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list