The helper retrieves the nodename of the slice layer if it's present.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_block.c | 23 ++++++++++++++++++++---
src/qemu/qemu_block.h | 3 +++
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index fab122942a..ea1af61561 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -101,6 +101,22 @@ qemuBlockStorageSourceGetEffectiveNodename(virStorageSource *src)
}
+/**
+ * qemuBlockStorageSourceGetSliceNodename:
+ *
+ * Gets the nodename corresponding to the storage slice layer. Returns NULL
+ * when there is no explicit storage slice layer.
+ */
+const char *
+qemuBlockStorageSourceGetSliceNodename(virStorageSource *src)
+{
+ if (!src->sliceStorage)
+ return NULL;
+
+ return src->sliceStorage->nodename;
+}
+
+
/**
* qemuBlockStorageSourceGetEffectiveStorageNodename:
* @src: virStorageSource to get the effective nodename of
@@ -111,9 +127,10 @@ qemuBlockStorageSourceGetEffectiveNodename(virStorageSource *src)
const char *
qemuBlockStorageSourceGetEffectiveStorageNodename(virStorageSource *src)
{
- if (src->sliceStorage &&
- src->sliceStorage->nodename)
- return src->sliceStorage->nodename;
+ const char *slice = qemuBlockStorageSourceGetSliceNodename(src);
+
+ if (slice)
+ return slice;
return src->nodenamestorage;
}
diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h
index 5c784a4386..85616a140d 100644
--- a/src/qemu/qemu_block.h
+++ b/src/qemu/qemu_block.h
@@ -40,6 +40,9 @@ qemuBlockStorageSourceGetEffectiveStorageNodename(virStorageSource
*src);
const char *
qemuBlockStorageSourceGetStorageNodename(virStorageSource *src);
+const char *
+qemuBlockStorageSourceGetSliceNodename(virStorageSource *src);
+
const char *
qemuBlockStorageSourceGetFormatNodename(virStorageSource *src);
--
2.42.0