[libvirt] [PATCH 3/3] Delete vol while the vol is building

Guannan Ren gren at redhat.com
Sun Jul 10 14:29:05 UTC 2011


---
 src/storage/storage_driver.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index d1fef92..61048ce 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -1350,6 +1350,7 @@ storageVolumeCreateXML(virStoragePoolPtr obj,
         storageDriverUnlock(driver);
 
         voldef->building = 0;
+        virCondBroadcast(&pool->cond);
         pool->asyncjobs--;
 
         voldef = NULL;
@@ -1508,6 +1509,8 @@ storageVolumeCreateXMLFrom(virStoragePoolPtr obj,
 
     origvol->building = 0;
     newvol->building = 0;
+    virCondBroadcast(&pool->cond);
+    virCondBroadcast(&origpool->cond);
     newvol = NULL;
     pool->asyncjobs--;
 
@@ -1912,12 +1915,20 @@ storageVolumeDelete(virStorageVolPtr obj,
     }
 
     if (vol->building) {
-        virStorageReportError(VIR_ERR_INTERNAL_ERROR,
-                              _("volume '%s' is still being allocated."),
-                              vol->name);
-        goto cleanup;
+        if (vol->type == VIR_STORAGE_VOL_FILE) {
+            goto deletevol;
+        } else if (vol->type == VIR_STORAGE_VOL_BLOCK) {
+            while(vol->building){
+                if (virCondWait(&pool->cond, &pool->lock) < 0){
+                    virStorageReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                                          _("unable to wait on storage condition"));
+                    goto cleanup;
+                }
+            }
+        }
     }
 
+deletevol:
     if (!backend->deleteVol) {
         virStorageReportError(VIR_ERR_NO_SUPPORT,
                               "%s", _("storage pool does not support vol deletion"));
-- 
1.7.1




More information about the libvir-list mailing list