qemu: block: Introduce qemuBlockStorageSourceGetSliceNodename

The helper retrieves the nodename of the slice layer if it's present.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2023-11-24 10:14:52 +01:00
parent 156ddb43b1
commit 05326395a9
2 changed files with 23 additions and 3 deletions

View File

@ -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;
}

View File

@ -40,6 +40,9 @@ qemuBlockStorageSourceGetEffectiveStorageNodename(virStorageSource *src);
const char *
qemuBlockStorageSourceGetStorageNodename(virStorageSource *src);
const char *
qemuBlockStorageSourceGetSliceNodename(virStorageSource *src);
const char *
qemuBlockStorageSourceGetFormatNodename(virStorageSource *src);