mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 01:34:11 +03:00
qemu: block: Extract logic decision when to use a separate 'raw' layer for slice
Introduce qemuBlockStorageSourceNeedsStorageSliceLayer which will hold the decision logic and fix all places that open-code it. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
2e3d17d7a3
commit
a8bcbb4217
@ -1446,8 +1446,7 @@ qemuBlockStorageSourceGetBlockdevProps(virStorageSourcePtr src,
|
||||
g_autoptr(virJSONValue) props = NULL;
|
||||
const char *storagenode = src->nodestorage;
|
||||
|
||||
if (src->sliceStorage &&
|
||||
src->format != VIR_STORAGE_FILE_RAW)
|
||||
if (qemuBlockStorageSourceNeedsStorageSliceLayer(src))
|
||||
storagenode = src->sliceStorage->nodename;
|
||||
|
||||
if (!(props = qemuBlockStorageSourceGetBlockdevFormatProps(src)))
|
||||
@ -1568,7 +1567,7 @@ qemuBlockStorageSourceAttachPrepareBlockdev(virStorageSourcePtr src,
|
||||
data->storageNodeName = src->nodestorage;
|
||||
data->formatNodeName = src->nodeformat;
|
||||
|
||||
if (src->sliceStorage && src->format != VIR_STORAGE_FILE_RAW) {
|
||||
if (qemuBlockStorageSourceNeedsStorageSliceLayer(src)) {
|
||||
if (!(data->storageSliceProps = qemuBlockStorageSourceGetBlockdevStorageSliceProps(src)))
|
||||
return NULL;
|
||||
|
||||
@ -3308,3 +3307,22 @@ qemuBlockReopenReadOnly(virDomainObjPtr vm,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* qemuBlockStorageSourceNeedSliceLayer:
|
||||
* @src: source to inspect
|
||||
*
|
||||
* Returns true if @src requires an extra 'raw' layer for handling of the storage
|
||||
* slice.
|
||||
*/
|
||||
bool
|
||||
qemuBlockStorageSourceNeedsStorageSliceLayer(const virStorageSource *src)
|
||||
{
|
||||
if (!src->sliceStorage)
|
||||
return false;
|
||||
|
||||
if (src->format != VIR_STORAGE_FILE_RAW)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -254,3 +254,6 @@ int
|
||||
qemuBlockReopenReadOnly(virDomainObjPtr vm,
|
||||
virStorageSourcePtr src,
|
||||
qemuDomainAsyncJob asyncJob);
|
||||
|
||||
bool
|
||||
qemuBlockStorageSourceNeedsStorageSliceLayer(const virStorageSource *src);
|
||||
|
@ -16591,8 +16591,7 @@ qemuDomainPrepareStorageSourceBlockdev(virDomainDiskDefPtr disk,
|
||||
src->nodestorage = g_strdup_printf("libvirt-%u-storage", src->id);
|
||||
src->nodeformat = g_strdup_printf("libvirt-%u-format", src->id);
|
||||
|
||||
if (src->sliceStorage &&
|
||||
src->format != VIR_STORAGE_FILE_RAW)
|
||||
if (qemuBlockStorageSourceNeedsStorageSliceLayer(src))
|
||||
src->sliceStorage->nodename = g_strdup_printf("libvirt-%u-slice-sto", src->id);
|
||||
|
||||
if (qemuDomainValidateStorageSource(src, priv->qemuCaps) < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user