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(a)redhat.com>
---
src/qemu/qemu_block.c | 34 ++++++++++++++++++----------------
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index e33aad4458..54b829efed 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -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;
+ }
}
}
--
2.21.0