提交 a8bcbb42 编写于 作者: P Peter Krempa

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: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 2e3d17d7
...@@ -1446,8 +1446,7 @@ qemuBlockStorageSourceGetBlockdevProps(virStorageSourcePtr src, ...@@ -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, ...@@ -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, ...@@ -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 ...@@ -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, ...@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册