diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h index 39c00b1a807751640848d6d0caddaaaf4ac9e228..96b5f39161dd76b8831305caf7716a3e6a067eed 100644 --- a/src/storage/storage_backend.h +++ b/src/storage/storage_backend.h @@ -48,6 +48,16 @@ typedef int (*virStorageBackendStopPool)(virConnectPtr conn, typedef int (*virStorageBackendDeletePool)(virConnectPtr conn, virStoragePoolObjPtr pool, unsigned int flags); + +/* A 'buildVol' backend must remove any volume created on error since + * the storage driver does not distinguish whether the failure is due + * to failure to create the volume, to reserve any space necessary for + * the volume, to get data about the volume, to change it's accessibility, + * etc. This avoids issues arising from a creation failure due to some + * external action which created a volume of the same name that libvirt + * was not aware of between checking the pool and the create attempt. It + * also avoids extra round trips to just delete a file. + */ typedef int (*virStorageBackendBuildVol)(virConnectPtr conn, virStoragePoolObjPtr pool, virStorageVolDefPtr vol, diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 31b70958978f3225f48e5fd7d96f08ab2930c2d6..ee8b263bac0d9bd2cf73ea77385ad8cf97984a1e 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -1869,8 +1869,8 @@ storageVolCreateXML(virStoragePoolPtr obj, pool->asyncjobs--; if (buildret < 0) { - storageVolDeleteInternal(volobj, backend, pool, voldef, - 0, false); + /* buildVol handles deleting volume on failure */ + storageVolRemoveFromPool(pool, voldef); voldef = NULL; goto cleanup; }