From: Cole Robinson Date: Mon, 27 Apr 2015 14:43:22 +0000 (-0400) Subject: storage: If driver startup state syncing fails, delete statefile X-Git-Tag: v1.2.15-rc2~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65fc82466695045b83a4a90df5550c7fae6bfe25;p=thirdparty%2Flibvirt.git storage: If driver startup state syncing fails, delete statefile 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. --- diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 9abdc6876a..ac4a74a1a8 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -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; }