]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: process: Fix failure semantics for perf events
authorPeter Krempa <pkrempa@redhat.com>
Wed, 27 Apr 2016 12:58:32 +0000 (14:58 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 2 May 2016 07:06:52 +0000 (09:06 +0200)
For strange reasons if a perf event type was not supported or failed to
be enabled at VM start libvirt would ignore the failure.

On the other hand on restart if the event could not be re-enabled
libvirt would fail to reconnect to the VM and kill it.

Both don't make really sense. Fix it by failing to start the VM if the
event is not supported and change the event to disabled if it can't be
reconnected (unlikely).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1329045

src/qemu/qemu_process.c

index 4dd0fc37f956be641ea7f4f918894d561f7c4878..8ca9841fe5fdb94a3ac447d94c72eb1d841dd9ad 100644 (file)
@@ -3501,17 +3501,14 @@ qemuDomainPerfRestart(virDomainObjPtr vm)
     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;
+
+            /* Failure to re-enable the perf event should not be fatal */
+            if (virPerfEventEnable(priv->perf, i, vm->pid) < 0)
+                def->perf->events[i] = VIR_TRISTATE_BOOL_NO;
         }
     }
 
     return 0;
-
- cleanup:
-    virPerfFree(priv->perf);
-    priv->perf = NULL;
-    return -1;
 }
 
 struct qemuProcessReconnectData {
@@ -5414,8 +5411,9 @@ qemuProcessLaunch(virConnectPtr conn,
         goto cleanup;
 
     for (i = 0; i < VIR_PERF_EVENT_LAST; i++) {
-        if (vm->def->perf->events[i] == VIR_TRISTATE_BOOL_YES)
-            virPerfEventEnable(priv->perf, i, vm->pid);
+        if (vm->def->perf->events[i] == VIR_TRISTATE_BOOL_YES &&
+            virPerfEventEnable(priv->perf, i, vm->pid) < 0)
+            goto cleanup;
     }
 
     /* This must be done after cgroup placement to avoid resetting CPU