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(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;
+}
+
Oh, I suggested we add this in qemuProcessReconnect in a previous
patch
Regards,
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|