When libvirtd daemon restart, this patch will reenable those perf events previously enabled.
Signed-off-by: Qiaowei Ren <qiaowei....@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 cf7df1a..2f4e22f 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3419,6 +3419,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; @@ -3495,6 +3523,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. */ @@ -6089,6 +6120,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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list