Add a note stating that qemuBlockStorageSourceNeedsStorageSliceLayer
must be used only when setting up a new blockdev, any other case when
the device might been already set up must use the existance of the
nodename to do so.
Adjust qemuBlockStorageSourceAttachPrepareBlockdev to do so and refactor
qemuBlockStorageSourceDetachPrepare to use the same logic.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_block.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index ea1af61561..1a718ae82b 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -1535,11 +1535,9 @@ qemuBlockStorageSourceAttachPrepareBlockdev(virStorageSource *src,
data->storageNodeName = qemuBlockStorageSourceGetStorageNodename(src);
data->formatNodeName = qemuBlockStorageSourceGetFormatNodename(src);
- if (qemuBlockStorageSourceNeedsStorageSliceLayer(src)) {
+ if ((data->storageSliceNodeName = qemuBlockStorageSourceGetSliceNodename(src))) {
if (!(data->storageSliceProps =
qemuBlockStorageSourceGetBlockdevStorageSliceProps(src)))
return NULL;
-
- data->storageSliceNodeName = src->sliceStorage->nodename;
}
return g_steal_pointer(&data);
@@ -1756,13 +1754,8 @@ qemuBlockStorageSourceDetachPrepare(virStorageSource *src)
data->storageNodeName = qemuBlockStorageSourceGetStorageNodename(src);
data->storageAttached = true;
- /* 'raw' format doesn't need the extra 'raw' layer when slicing,
thus
- * the nodename is NULL */
- if (src->sliceStorage &&
- src->sliceStorage->nodename) {
- data->storageSliceNodeName = src->sliceStorage->nodename;
+ if ((data->storageSliceNodeName = qemuBlockStorageSourceGetSliceNodename(src)))
data->storageSliceAttached = true;
- }
if (src->pr &&
!virStoragePRDefIsManaged(src->pr))
@@ -3264,6 +3257,12 @@ qemuBlockReopenReadOnly(virDomainObj *vm,
*
* Returns true if @src requires an extra 'raw' layer for handling of the
storage
* slice.
+ *
+ * Important: This helper must be used only for decisions when setting up a
+ * '-blockdev' backend in which case the storage slice layer node name will be
+ * populated.
+ * Any cases when the backend can be already in use must decide based on the
+ * existence of the storage slice layer nodename.
*/
bool
qemuBlockStorageSourceNeedsStorageSliceLayer(const virStorageSource *src)
--
2.42.0