mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00: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;
|
g_autoptr(virJSONValue) props = NULL;
|
||||||
const char *storagenode = src->nodestorage;
|
const char *storagenode = src->nodestorage;
|
||||||
|
|
||||||
if (src->sliceStorage &&
|
if (qemuBlockStorageSourceNeedsStorageSliceLayer(src))
|
||||||
src->format != VIR_STORAGE_FILE_RAW)
|
|
||||||
storagenode = src->sliceStorage->nodename;
|
storagenode = src->sliceStorage->nodename;
|
||||||
|
|
||||||
if (!(props = qemuBlockStorageSourceGetBlockdevFormatProps(src)))
|
if (!(props = qemuBlockStorageSourceGetBlockdevFormatProps(src)))
|
||||||
@ -1568,7 +1567,7 @@ qemuBlockStorageSourceAttachPrepareBlockdev(virStorageSourcePtr src,
|
|||||||
data->storageNodeName = src->nodestorage;
|
data->storageNodeName = src->nodestorage;
|
||||||
data->formatNodeName = src->nodeformat;
|
data->formatNodeName = src->nodeformat;
|
||||||
|
|
||||||
if (src->sliceStorage && src->format != VIR_STORAGE_FILE_RAW) {
|
if (qemuBlockStorageSourceNeedsStorageSliceLayer(src)) {
|
||||||
if (!(data->storageSliceProps = qemuBlockStorageSourceGetBlockdevStorageSliceProps(src)))
|
if (!(data->storageSliceProps = qemuBlockStorageSourceGetBlockdevStorageSliceProps(src)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -3308,3 +3307,22 @@ qemuBlockReopenReadOnly(virDomainObjPtr vm,
|
|||||||
|
|
||||||
return 0;
|
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,
|
qemuBlockReopenReadOnly(virDomainObjPtr vm,
|
||||||
virStorageSourcePtr src,
|
virStorageSourcePtr src,
|
||||||
qemuDomainAsyncJob asyncJob);
|
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->nodestorage = g_strdup_printf("libvirt-%u-storage", src->id);
|
||||||
src->nodeformat = g_strdup_printf("libvirt-%u-format", src->id);
|
src->nodeformat = g_strdup_printf("libvirt-%u-format", src->id);
|
||||||
|
|
||||||
if (src->sliceStorage &&
|
if (qemuBlockStorageSourceNeedsStorageSliceLayer(src))
|
||||||
src->format != VIR_STORAGE_FILE_RAW)
|
|
||||||
src->sliceStorage->nodename = g_strdup_printf("libvirt-%u-slice-sto", src->id);
|
src->sliceStorage->nodename = g_strdup_printf("libvirt-%u-slice-sto", src->id);
|
||||||
|
|
||||||
if (qemuDomainValidateStorageSource(src, priv->qemuCaps) < 0)
|
if (qemuDomainValidateStorageSource(src, priv->qemuCaps) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user