]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
storage: If driver startup state syncing fails, delete statefile
authorCole Robinson <crobinso@redhat.com>
Mon, 27 Apr 2015 14:43:22 +0000 (10:43 -0400)
committerCole Robinson <crobinso@redhat.com>
Tue, 28 Apr 2015 13:37:58 +0000 (09:37 -0400)
If you end up with a state file for a pool that no longer starts up
or refreshes correctly, the state file is never removed and adds
noise to the logs everytime libvirtd is started.

If the initial state syncing fails, delete the statefile.

src/storage/storage_driver.c

index 9abdc6876a92b5bf269272c066e7ad7bd54c0187..ac4a74a1a87ca99e61b79bec802cd085ff987e32 100644 (file)
@@ -79,6 +79,12 @@ storagePoolUpdateState(virStoragePoolObjPtr pool)
 {
     bool active;
     virStorageBackendPtr backend;
+    int ret = -1;
+    char *stateFile;
+
+    if (!(stateFile = virFileBuildPath(driver->stateDir,
+                                       pool->def->name, ".xml")))
+        goto error;
 
     if ((backend = virStorageBackendForType(pool->def->type)) == NULL) {
         VIR_ERROR(_("Missing backend %d"), pool->def->type);
@@ -116,7 +122,14 @@ storagePoolUpdateState(virStoragePoolObjPtr pool)
     }
 
     pool->active = active;
+    ret = 0;
  error:
+    if (ret < 0) {
+        if (stateFile)
+            unlink(stateFile);
+    }
+    VIR_FREE(stateFile);
+
     return;
 }