
On 01/09/2014 09:15 AM, Peter Krempa wrote:
---
A little sparse on the intent of the new flag...
src/storage/storage_backend.h | 2 +- src/storage/storage_backend_disk.c | 3 ++- src/storage/storage_backend_fs.c | 30 +++++++++++++++++++++++------- src/storage/storage_backend_logical.c | 6 ++++-- src/storage/storage_backend_rbd.c | 3 ++- src/storage/storage_backend_sheepdog.c | 3 ++- src/storage/storage_driver.c | 4 ++-- 7 files changed, 36 insertions(+), 15 deletions(-)
diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h index 9e07dd8..4d0c057 100644 --- a/src/storage/storage_backend.h +++ b/src/storage/storage_backend.h @@ -41,7 +41,7 @@ typedef int (*virStorageBackendDeletePool)(virConnectPtr conn, virStoragePoolObj typedef int (*virStorageBackendBuildVol)(virConnectPtr conn, virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int flags); -typedef int (*virStorageBackendCreateVol)(virConnectPtr conn, virStoragePoolObjPtr pool, virStorageVolDefPtr vol); +typedef int (*virStorageBackendCreateVol)(virConnectPtr conn, virStoragePoolObjPtr pool, virStorageVolDefPtr vol, bool internal);
...and maybe worth line-wrapping the long lines in this area of code. But know I know what the patch is doing - adding an internal flag; where use of the flag can suppress error reporting (since presumably all internal creation would be done on a name already tied to a <domain>, where we can assume that the name is either valid or the domain will fail to start).
@@ -1008,15 +1010,29 @@ virStorageBackendFileSystemVolCreate(virConnectPtr conn ATTRIBUTE_UNUSED, vol->name) == -1) return -1;
- if (virFileExists(vol->target.path)) { - virReportError(VIR_ERR_OPERATION_INVALID, - _("volume target path '%s' already exists"), - vol->target.path); - return -1; + if (internal) { + if (stat(vol->target.path, &st) == 0) { + if (S_ISDIR(st.st_mode)) + vol->type = VIR_STORAGE_VOL_DIR; + else if (S_ISBLK(st.st_mode)) + vol->type = VIR_STORAGE_VOL_BLOCK; + else + vol->type = VIR_STORAGE_VOL_FILE; + }
And if the stat() fails, you just leave vol->type uninitialized? -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org