[PATCH 18/22] qemuBlockStorageSourceGetBackendProps: Introduce QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_EFFECTIVE_NODE

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

 



Introduce a mode where the protocol layer -blockdev will be formatted
so that it can be used as the effective node (used to access data from
the device). For this new mode we'll use
qemuBlockStorageSourceAddBlockdevCommonProps.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_block.c | 40 ++++++++++++++++++++++++----------------
 src/qemu/qemu_block.h |  1 +
 2 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index dc6f34530b..7902ef31b3 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -1030,6 +1030,8 @@ qemuBlockStorageSourceAddBlockdevCommonProps(virJSONValue **props,
  *  QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_SKIP_UNMAP:
  *      don't enable 'discard:unmap' option for passing through discards
  *      (note that this is disabled also for _LEGACY and _TARGET_ONLY options)
+ *  QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_EFFECTIVE_NODE:
+ *      the 'protocol' node is used as the effective/top node of a virStorageSource
  *
  * Creates a JSON object describing the underlying storage or protocol of a
  * storage source. Returns NULL on error and reports an appropriate error message.
@@ -1182,27 +1184,33 @@ qemuBlockStorageSourceGetBackendProps(virStorageSource *src,
         return NULL;

     if (!onlytarget && !legacy) {
-        g_autoptr(virJSONValue) cache = NULL;
-        const char *discardstr = "unmap";
         const char *nodename = qemuBlockStorageSourceGetStorageNodename(src);

-        if (flags & QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_SKIP_UNMAP)
-            discardstr = NULL;
+        if (flags & QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_EFFECTIVE_NODE) {
+            if (qemuBlockStorageSourceAddBlockdevCommonProps(&fileprops, src, nodename, true) < 0)
+                return NULL;
+        } else {
+            g_autoptr(virJSONValue) cache = NULL;
+            const char *discardstr = "unmap";

-        if (qemuBlockNodeNameValidate(nodename) < 0)
-            return NULL;
+            if (flags & QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_SKIP_UNMAP)
+                discardstr = NULL;

-        if (qemuBlockStorageSourceGetBlockdevGetCacheProps(src, &cache) < 0)
-            return NULL;
+            if (qemuBlockNodeNameValidate(nodename) < 0)
+                return NULL;

-        if (virJSONValueObjectAdd(&fileprops,
-                                  "s:node-name", nodename,
-                                  "T:read-only", ro,
-                                  "T:auto-read-only", aro,
-                                  "S:discard", discardstr,
-                                  "A:cache", &cache,
-                                  NULL) < 0)
-            return NULL;
+            if (qemuBlockStorageSourceGetBlockdevGetCacheProps(src, &cache) < 0)
+                return NULL;
+
+            if (virJSONValueObjectAdd(&fileprops,
+                                      "s:node-name", nodename,
+                                      "T:read-only", ro,
+                                      "T:auto-read-only", aro,
+                                      "S:discard", discardstr,
+                                      "A:cache", &cache,
+                                      NULL) < 0)
+                return NULL;
+        }
     }

     return g_steal_pointer(&fileprops);
diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h
index 7bb83d8d44..9757108501 100644
--- a/src/qemu/qemu_block.h
+++ b/src/qemu/qemu_block.h
@@ -68,6 +68,7 @@ typedef enum {
     QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_TARGET_ONLY = 1 << 1,
     QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_AUTO_READONLY = 1 << 2,
     QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_SKIP_UNMAP = 1 << 3,
+    QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_EFFECTIVE_NODE = 1 << 4,
 } qemuBlockStorageSourceBackendPropsFlags;

 virJSONValue *
-- 
2.41.0




[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