qemu: block: Introduce helper for deciding when a 'format' layer is needed

The 'format' layer is not required in certain cases. As the logic for
this will be a bit more involved create a helper function to do the
decision.

For now we'll keep to always format the 'format' -blockdev layer.

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 22:07:49 +02:00
parent aaf828d3d4
commit 7f19a55a9e
2 changed files with 22 additions and 0 deletions

View File

@ -3291,6 +3291,25 @@ qemuBlockStorageSourceNeedsStorageSliceLayer(const virStorageSource *src)
}
/**
* qemuBlockStorageSourceNeedsFormatLayer:
* @src: storage source
*
* Returns true if configuration of @src requires a 'format' layer -blockdev.
*
* Important: This helper must be used only for decisions when setting up a
* '-blockdev' backend in which case the format layer node name will be populated.
* Any cases when the backend can be already in use must decide based on the
* existence of the format layer nodename.
*/
bool
qemuBlockStorageSourceNeedsFormatLayer(const virStorageSource *src G_GNUC_UNUSED)
{
/* Currently we always create a 'format' layer */
return true;
}
/**
* qemuBlockStorageSourceGetCookieString:
* @src: storage source

View File

@ -280,6 +280,9 @@ qemuBlockReopenReadOnly(virDomainObj *vm,
bool
qemuBlockStorageSourceNeedsStorageSliceLayer(const virStorageSource *src);
bool
qemuBlockStorageSourceNeedsFormatLayer(const virStorageSource *src);
char *
qemuBlockStorageSourceGetCookieString(virStorageSource *src);