qemuBlockStorageSourceGetBackendProps: Use qemuBlockStorageSourceAddBlockdevCommonProps

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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2023-10-19 16:23:23 +02:00
parent 3ad5d7b2bb
commit fc18e01e52

View File

@ -1185,33 +1185,10 @@ qemuBlockStorageSourceGetBackendProps(virStorageSource *src,
return NULL; return NULL;
if (!onlytarget && !legacy) { if (!onlytarget && !legacy) {
const char *nodename = qemuBlockStorageSourceGetStorageNodename(src); if (qemuBlockStorageSourceAddBlockdevCommonProps(&fileprops, src,
qemuBlockStorageSourceGetStorageNodename(src),
if (flags & QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_EFFECTIVE_NODE) { !!(flags & QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_EFFECTIVE_NODE)) < 0)
if (qemuBlockStorageSourceAddBlockdevCommonProps(&fileprops, src, nodename, true) < 0)
return NULL; 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); return g_steal_pointer(&fileprops);