mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
qemu: block: Unify conditions to format backing store of format node definition
Move all bits of the formatting of the 'backing' attribute to a single condition and make it use a single extracted copy of the backing store. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
510d154a0b
commit
d6f1116091
@ -1404,26 +1404,20 @@ qemuBlockStorageSourceGetBlockdevFormatProps(virStorageSourcePtr src)
|
||||
virJSONValuePtr
|
||||
qemuBlockStorageSourceGetBlockdevProps(virStorageSourcePtr src)
|
||||
{
|
||||
bool backingSupported = src->format >= VIR_STORAGE_FILE_BACKING;
|
||||
virStorageSourcePtr backingStore = src->backingStore;
|
||||
VIR_AUTOPTR(virJSONValue) props = NULL;
|
||||
|
||||
if (virStorageSourceHasBacking(src) && !backingSupported) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("storage format '%s' does not support backing store"),
|
||||
virStorageFileFormatTypeToString(src->format));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(props = qemuBlockStorageSourceGetBlockdevFormatProps(src)))
|
||||
return NULL;
|
||||
|
||||
if (virJSONValueObjectAppendString(props, "file", src->nodestorage) < 0)
|
||||
return NULL;
|
||||
|
||||
if (src->backingStore && backingSupported) {
|
||||
if (virStorageSourceHasBacking(src)) {
|
||||
if (backingStore) {
|
||||
if (src->format >= VIR_STORAGE_FILE_BACKING) {
|
||||
if (virStorageSourceIsBacking(backingStore)) {
|
||||
if (virJSONValueObjectAppendString(props, "backing",
|
||||
src->backingStore->nodeformat) < 0)
|
||||
backingStore->nodeformat) < 0)
|
||||
return NULL;
|
||||
} else {
|
||||
/* chain is terminated, indicate that no detection should happen
|
||||
@ -1431,6 +1425,14 @@ qemuBlockStorageSourceGetBlockdevProps(virStorageSourcePtr src)
|
||||
if (virJSONValueObjectAppendNull(props, "backing") < 0)
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
if (virStorageSourceIsBacking(backingStore)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("storage format '%s' does not support backing store"),
|
||||
virStorageFileFormatTypeToString(src->format));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VIR_RETURN_PTR(props);
|
||||
|
Loading…
Reference in New Issue
Block a user