]> xenbits.xensource.com Git - libvirt.git/commitdiff
daemon: cleanup state drivers in order reverse to init order
authorNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Tue, 17 May 2016 11:44:46 +0000 (14:44 +0300)
committerCole Robinson <crobinso@redhat.com>
Thu, 26 May 2016 12:25:40 +0000 (08:25 -0400)
This patch aims to fix observed crash on daemon shutdown. Main thread is in
the process of state drivers cleanup, network driver is cleaned up and
qemu driver is not yet. Meanwhile eof event from qemu process triggers
qemuProcessStop -> networkReleaseActualDevice and crash happens as
network driver is already cleaned up.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
src/libvirt.c

index 0e7e435bbfcb53340eae81831585ae08b115ad92..6d9dba8887169f99c0394168c33a5d71110b9f5a 100644 (file)
@@ -799,12 +799,12 @@ virStateInitialize(bool privileged,
 int
 virStateCleanup(void)
 {
-    size_t i;
+    int r;
     int ret = 0;
 
-    for (i = 0; i < virStateDriverTabCount; i++) {
-        if (virStateDriverTab[i]->stateCleanup &&
-            virStateDriverTab[i]->stateCleanup() < 0)
+    for (r = virStateDriverTabCount - 1; r >= 0; r--) {
+        if (virStateDriverTab[r]->stateCleanup &&
+            virStateDriverTab[r]->stateCleanup() < 0)
             ret = -1;
     }
     return ret;