]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: Provide better error message if metadata pre-alloc is unsupported
authorPeter Krempa <pkrempa@redhat.com>
Wed, 5 Jun 2013 07:38:41 +0000 (09:38 +0200)
committerCole Robinson <crobinso@redhat.com>
Thu, 11 Jul 2013 21:46:32 +0000 (17:46 -0400)
Instead of a unknown flag error report that metadata pre-allocation is
not supported with the requested volume creation method.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=969982
(cherry picked from commit 77e7f69c3b88ae0a7364fa88334a483a247d7200)

src/storage/storage_backend.c

index f05fbc72fb1486c2e7c1ac914d53fff19d1a8f5a..85062c0294ffb7ef9af9232797cfa70b1be47411 100644 (file)
@@ -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,
@@ -898,7 +912,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",