]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: block: Unify conditions to format backing store of format node definition
authorPeter Krempa <pkrempa@redhat.com>
Tue, 3 Sep 2019 11:16:39 +0000 (13:16 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 6 Sep 2019 06:12:21 +0000 (08:12 +0200)
Move all bits of the formatting of the 'backing' attribute to a single
condition and make it use a single extracted copy of the backing store.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_block.c

index e33aad4458ef43160475b29bf62e0d1c61f8c759..54b829efeddadab4bfbaa7a8e0474071b6dc804e 100644 (file)
@@ -1404,32 +1404,34 @@ qemuBlockStorageSourceGetBlockdevFormatProps(virStorageSourcePtr src)
 virJSONValuePtr
 qemuBlockStorageSourceGetBlockdevProps(virStorageSourcePtr src)
 {
-    bool backingSupported = src->format >= VIR_STORAGE_FILE_BACKING;
+    virStorageSourcePtr backingStore = src->backingStore;
     VIR_AUTOPTR(virJSONValue) props = NULL;
 
-    if (virStorageSourceHasBacking(src) && !backingSupported) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("storage format '%s' does not support backing store"),
-                       virStorageFileFormatTypeToString(src->format));
-        return NULL;
-    }
-
     if (!(props = qemuBlockStorageSourceGetBlockdevFormatProps(src)))
         return NULL;
 
     if (virJSONValueObjectAppendString(props, "file", src->nodestorage) < 0)
         return NULL;
 
-    if (src->backingStore && backingSupported) {
-        if (virStorageSourceHasBacking(src)) {
-            if (virJSONValueObjectAppendString(props, "backing",
-                                               src->backingStore->nodeformat) < 0)
-                return NULL;
+    if (backingStore) {
+        if (src->format >= VIR_STORAGE_FILE_BACKING) {
+            if (virStorageSourceIsBacking(backingStore)) {
+                if (virJSONValueObjectAppendString(props, "backing",
+                                                   backingStore->nodeformat) < 0)
+                    return NULL;
+            } else {
+                /* chain is terminated, indicate that no detection should happen
+                 * in qemu */
+                if (virJSONValueObjectAppendNull(props, "backing") < 0)
+                    return NULL;
+            }
         } else {
-            /* chain is terminated, indicate that no detection should happen
-             * in qemu */
-            if (virJSONValueObjectAppendNull(props, "backing") < 0)
+            if (virStorageSourceIsBacking(backingStore)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                               _("storage format '%s' does not support backing store"),
+                               virStorageFileFormatTypeToString(src->format));
                 return NULL;
+            }
         }
     }