From fc18e01e520e87f146902c9f526ff97813e26af9 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 19 Oct 2023 16:23:23 +0200 Subject: [PATCH] qemuBlockStorageSourceGetBackendProps: Use qemuBlockStorageSourceAddBlockdevCommonProps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Ján Tomko --- 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 79671b9222..52286c4ec0 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1185,33 +1185,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) + if (qemuBlockStorageSourceAddBlockdevCommonProps(&fileprops, src, + qemuBlockStorageSourceGetStorageNodename(src), + !!(flags & QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_EFFECTIVE_NODE)) < 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) - 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);