mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
qemuBlockStorageSourceAttachPrepareBlockdev: Prepare for optionally missing format layer
Restructure the code logic so that the function is prepared for the possibility that the 'format' blockdev layer may be missing if not needed. To achieve this we need to introduce logic that selects which node (format/slice/storage) becomes the effective node and thus formats the correct set of arguments. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
b27e8b5a0b
commit
10cc057074
@ -1533,22 +1533,34 @@ qemuBlockStorageSourceAttachPrepareBlockdev(virStorageSource *src,
|
||||
virStorageSource *backingStore)
|
||||
{
|
||||
g_autoptr(qemuBlockStorageSourceAttachData) data = NULL;
|
||||
bool effective = true;
|
||||
unsigned int backendpropsflags = 0;
|
||||
|
||||
data = g_new0(qemuBlockStorageSourceAttachData, 1);
|
||||
|
||||
if (!(data->formatProps = qemuBlockStorageSourceGetFormatProps(src, backingStore)) ||
|
||||
!(data->storageProps = qemuBlockStorageSourceGetBackendProps(src,
|
||||
backendpropsflags)))
|
||||
if (qemuBlockStorageSourceGetFormatNodename(src)) {
|
||||
if (!(data->formatProps = qemuBlockStorageSourceGetFormatProps(src, backingStore)))
|
||||
return NULL;
|
||||
|
||||
data->formatNodeName = qemuBlockStorageSourceGetFormatNodename(src);
|
||||
|
||||
effective = false;
|
||||
}
|
||||
|
||||
if ((data->storageSliceNodeName = qemuBlockStorageSourceGetSliceNodename(src))) {
|
||||
if (!(data->storageSliceProps = qemuBlockStorageSourceGetBlockdevStorageSliceProps(src, effective)))
|
||||
return NULL;
|
||||
|
||||
effective = false;
|
||||
}
|
||||
|
||||
if (effective)
|
||||
backendpropsflags = QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_EFFECTIVE_NODE;
|
||||
|
||||
if (!(data->storageProps = qemuBlockStorageSourceGetBackendProps(src, backendpropsflags)))
|
||||
return NULL;
|
||||
|
||||
data->storageNodeName = qemuBlockStorageSourceGetStorageNodename(src);
|
||||
data->formatNodeName = qemuBlockStorageSourceGetFormatNodename(src);
|
||||
|
||||
if ((data->storageSliceNodeName = qemuBlockStorageSourceGetSliceNodename(src))) {
|
||||
if (!(data->storageSliceProps = qemuBlockStorageSourceGetBlockdevStorageSliceProps(src, false)))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return g_steal_pointer(&data);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user