[PATCH 05/17] qemuBlockStorageSourceAttachPrepareBlockdev: Prepare for optionally missing format layer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Restructure the code logic so that the function is prepared for the
possibility that the 'format' blockdev layer may be missing if not
needed.

To achieve this we need to introduce logic that selects which node
(format/slice/storage) becomes the effective node and thus formats the
correct set of arguments.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_block.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index f7e912ece0..749cd9fdac 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -1533,23 +1533,35 @@ qemuBlockStorageSourceAttachPrepareBlockdev(virStorageSource *src,
                                             virStorageSource *backingStore)
 {
     g_autoptr(qemuBlockStorageSourceAttachData) data = NULL;
+    bool effective = true;
     unsigned int backendpropsflags = 0;

     data = g_new0(qemuBlockStorageSourceAttachData, 1);

-    if (!(data->formatProps = qemuBlockStorageSourceGetFormatProps(src, backingStore)) ||
-        !(data->storageProps = qemuBlockStorageSourceGetBackendProps(src,
-                                                                     backendpropsflags)))
-        return NULL;
+    if (qemuBlockStorageSourceGetFormatNodename(src)) {
+        if (!(data->formatProps = qemuBlockStorageSourceGetFormatProps(src, backingStore)))
+            return NULL;

-    data->storageNodeName = qemuBlockStorageSourceGetStorageNodename(src);
-    data->formatNodeName = qemuBlockStorageSourceGetFormatNodename(src);
+        data->formatNodeName = qemuBlockStorageSourceGetFormatNodename(src);
+
+        effective = false;
+    }

     if ((data->storageSliceNodeName = qemuBlockStorageSourceGetSliceNodename(src))) {
-        if (!(data->storageSliceProps = qemuBlockStorageSourceGetBlockdevStorageSliceProps(src, false)))
+        if (!(data->storageSliceProps = qemuBlockStorageSourceGetBlockdevStorageSliceProps(src, effective)))
             return NULL;
+
+        effective = false;
     }

+    if (effective)
+        backendpropsflags = QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_EFFECTIVE_NODE;
+
+    if (!(data->storageProps = qemuBlockStorageSourceGetBackendProps(src, backendpropsflags)))
+        return NULL;
+
+    data->storageNodeName = qemuBlockStorageSourceGetStorageNodename(src);
+
     return g_steal_pointer(&data);
 }

-- 
2.42.0
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux