[libvirt] [PATCH] storage: handle NULL return from virGetStorageVol

Michael Chapman mike at very.puzzling.org
Wed Feb 12 11:05:51 UTC 2014


virGetStorageVol can return NULL on out-of-memory. If it does, cleanly
abort the volume clone operation.

Signed-off-by: Michael Chapman <mike at very.puzzling.org>
---
 src/storage/storage_driver.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index c83aa8a..2f7b2e5 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -1828,6 +1828,10 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj,
     pool->volumes.objs[pool->volumes.count++] = newvol;
     volobj = virGetStorageVol(obj->conn, pool->def->name, newvol->name,
                               newvol->key, NULL, NULL);
+    if (!volobj) {
+        pool->volumes.count--;
+        goto cleanup;
+    }
 
     /* Drop the pool lock during volume allocation */
     pool->asyncjobs++;
-- 
1.8.3.1




More information about the libvir-list mailing list