Introduce a set of accessors, which return node names based on semantics. This will allow to us to modify how we setup the backing chain in cases when e.g. the format driver can be omitted, without breaking all the code. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_block.c | 31 +++++++++++++++++++++++++++++++ src/qemu/qemu_block.h | 7 +++++++ 2 files changed, 38 insertions(+) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index a2414dc2e3..cba1fb1c1e 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -69,6 +69,23 @@ qemuBlockStorageSourceSetStorageNodename(virStorageSource *src, } +/** + * qemuBlockStorageSourceSetFormatNodename: + * @src: virStorageSource to set the format nodename + * @nodename: The node name to set (stolen) + * + * Sets @nodename as the format node name of @src. Using NULL @nodename clears + * the nodename. @src takes ownership of @nodename. + */ +void +qemuBlockStorageSourceSetFormatNodename(virStorageSource *src, + char *nodename) +{ + g_free(src->nodeformat); + src->nodeformat = nodename; +} + + /** * qemuBlockStorageSourceGetEffectiveStorageNodename: * @src: virStorageSource to get the effective nodename of @@ -100,6 +117,20 @@ qemuBlockStorageSourceGetStorageNodename(virStorageSource *src) } +/** + * qemuBlockStorageSourceGetFormatNodename: + * @src: virStorageSource to get the effective nodename of + * + * Gets the nodename corresponding to the format layer. Useful when accessing + * format specific features. Returns NULL if there is no format layer. + */ +const char * +qemuBlockStorageSourceGetFormatNodename(virStorageSource *src) +{ + return src->nodeformat; +} + + /** * qemuBlockStorageSourceSupportsConcurrentAccess: * @src: disk storage source diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index ecc5711dcd..6ed0aa85b2 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -30,12 +30,19 @@ void qemuBlockStorageSourceSetStorageNodename(virStorageSource *src, char *nodename); +void +qemuBlockStorageSourceSetFormatNodename(virStorageSource *src, + char *nodename); + const char * qemuBlockStorageSourceGetEffectiveStorageNodename(virStorageSource *src); const char * qemuBlockStorageSourceGetStorageNodename(virStorageSource *src); +const char * +qemuBlockStorageSourceGetFormatNodename(virStorageSource *src); + typedef struct qemuBlockNodeNameBackingChainData qemuBlockNodeNameBackingChainData; struct qemuBlockNodeNameBackingChainData { -- 2.41.0