
-----Original Message----- From: Daniel P. Berrange [mailto:berrange@redhat.com] Sent: Thursday, January 28, 2016 11:21 PM To: Ren, Qiaowei Cc: libvir-list@redhat.com; Jiri Denemark Subject: Re: [PATCH 6/8] perf: reenable perf events when libvirtd restart
On Thu, Dec 10, 2015 at 08:34:36PM +0800, Qiaowei Ren wrote:
When libvirtd daemon restart, this patch will reenable those perf events previously enabled.
Signed-off-by: Qiaowei Ren <qiaowei.ren@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; +} +
Oh, I suggested we add this in qemuProcessReconnect in a previous patch
Yes. I will do this in qemuProcessReconnect and qemuProcessAttach according to the comments in patch 4/8, but because this patch have to depend on the new XML element (patch 5/8), and so I have to put these code into the patch and could not merge it into the patch 4/8. ^-^ Thanks, Qiaowei