[libvirt] [PATCH 4/4] storage: Provide better error message if metadata pre-alloc is unsupported

Peter Krempa pkrempa at redhat.com
Wed Jun 5 08:59:24 UTC 2013


Instead of a unknown flag error report that metadata pre-allocation is
not supported with the requested volume creation method.
---
 src/storage/storage_backend.c | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 4846210..6127fd3 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -254,7 +254,14 @@ virStorageBackendCreateBlockFrom(virConnectPtr conn ATTRIBUTE_UNUSED,
     gid_t gid;
     uid_t uid;

-    virCheckFlags(0, -1);
+    virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, -1);
+
+    if (flags & VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("metadata preallocation is not supported for block "
+                         "volumes"));
+        goto cleanup;
+    }

     if ((fd = open(vol->target.path, O_RDWR)) < 0) {
         virReportSystemError(errno,
@@ -385,7 +392,14 @@ virStorageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED,
     int fd = -1;
     int operation_flags;

-    virCheckFlags(0, -1);
+    virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, -1);
+
+    if (flags & VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("metadata preallocation is not supported for raw "
+                         "volumes"));
+        goto cleanup;
+    }

     if (vol->target.encryption != NULL) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -887,7 +901,14 @@ virStorageBackendCreateQcowCreate(virConnectPtr conn ATTRIBUTE_UNUSED,
     char *size;
     virCommandPtr cmd;

-    virCheckFlags(0, -1);
+    virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, -1);
+
+    if (flags & VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("metadata preallocation is not supported with "
+                         "qcow-create"));
+        return -1;
+    }

     if (inputvol) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-- 
1.8.2.1




More information about the libvir-list mailing list