[PATCH 20/22] qemuBlockStorageSourceGetBackendProps: Use qemuBlockStorageSourceAddBlockdevCommonProps

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

 



Use the qemuBlockStorageSourceAddBlockdevCommonProps helper when
formatting protocol layer both when it's used as backing for a format
node and when it's used as the effective node.

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

diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 7902ef31b3..5c8d107257 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -1184,33 +1184,10 @@ qemuBlockStorageSourceGetBackendProps(virStorageSource *src,
         return NULL;

     if (!onlytarget && !legacy) {
-        const char *nodename = qemuBlockStorageSourceGetStorageNodename(src);
-
-        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 (flags & QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_SKIP_UNMAP)
-                discardstr = NULL;
-
-            if (qemuBlockNodeNameValidate(nodename) < 0)
+        if (qemuBlockStorageSourceAddBlockdevCommonProps(&fileprops, src,
+                                                         qemuBlockStorageSourceGetStorageNodename(src),
+                                                         !!(flags & QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_EFFECTIVE_NODE)) < 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);
-- 
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