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_process.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 4595489..8249c3e 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3499,6 +3499,34 @@ qemuProcessUpdateDevices(virQEMUDriverPtr driver,
return ret;
}
+static int
+qemuDomainPerfRestart(virDomainObjPtr vm)
+{
+ 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;
+}
+
struct qemuProcessReconnectData {
virConnectPtr conn;
virQEMUDriverPtr driver;
@@ -3584,6 +3612,9 @@ qemuProcessReconnect(void *opaque)
if (qemuConnectCgroup(driver, obj) < 0)
goto error;
+ if (qemuDomainPerfRestart(obj) < 0)
+ goto error;
+
/* XXX: Need to change as long as lock is introduced for
* qemu_driver->sharedDevices.
*/
@@ -5681,6 +5712,9 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED,
if (virSecurityManagerGenLabel(driver->securityManager, vm->def) < 0)
goto error;
+ if (qemuDomainPerfRestart(vm) < 0)
+ goto error;
+
VIR_DEBUG("Creating domain log file");
if (!(logCtxt = qemuDomainLogContextNew(driver, vm,
QEMU_DOMAIN_LOG_CONTEXT_MODE_ATTACH)))
--
1.9.1