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

qemuBlockGetBackingStoreString: Add 'pretty' argument

Add support for pretty-printing of the JSON variant of the output for
consumption in tests. All current callers pass 'false'.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 fed97cb4
...@@ -2027,13 +2027,15 @@ qemuBlockStorageGetCopyOnReadProps(virDomainDiskDefPtr disk) ...@@ -2027,13 +2027,15 @@ qemuBlockStorageGetCopyOnReadProps(virDomainDiskDefPtr disk)
/** /**
* qemuBlockGetBackingStoreString: * qemuBlockGetBackingStoreString:
* @src: storage source to get the string for * @src: storage source to get the string for
* @pretty: pretty-print the JSON (if applicable, used by tests)
* *
* Formats a string used in the backing store field of a disk image which * Formats a string used in the backing store field of a disk image which
* supports backing store. Non-local storage may result in use of the json: * supports backing store. Non-local storage may result in use of the json:
* pseudo protocol for any complex configuration. * pseudo protocol for any complex configuration.
*/ */
char * char *
qemuBlockGetBackingStoreString(virStorageSourcePtr src) qemuBlockGetBackingStoreString(virStorageSourcePtr src,
bool pretty)
{ {
int actualType = virStorageSourceGetActualType(src); int actualType = virStorageSourceGetActualType(src);
g_autoptr(virJSONValue) backingProps = NULL; g_autoptr(virJSONValue) backingProps = NULL;
...@@ -2100,7 +2102,7 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr src) ...@@ -2100,7 +2102,7 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr src)
props = sliceProps; props = sliceProps;
} }
if (!(backingJSON = virJSONValueToString(props, false))) if (!(backingJSON = virJSONValueToString(props, pretty)))
return NULL; return NULL;
ret = g_strdup_printf("json:%s", backingJSON); ret = g_strdup_printf("json:%s", backingJSON);
...@@ -2128,7 +2130,7 @@ qemuBlockStorageSourceCreateAddBacking(virStorageSourcePtr backing, ...@@ -2128,7 +2130,7 @@ qemuBlockStorageSourceCreateAddBacking(virStorageSourcePtr backing,
backingFormatStr = virStorageFileFormatTypeToString(backing->format); backingFormatStr = virStorageFileFormatTypeToString(backing->format);
} }
if (!(backingFileStr = qemuBlockGetBackingStoreString(backing))) if (!(backingFileStr = qemuBlockGetBackingStoreString(backing, false)))
return -1; return -1;
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(props,
......
...@@ -178,7 +178,8 @@ qemuBlockSnapshotAddBlockdev(virJSONValuePtr actions, ...@@ -178,7 +178,8 @@ qemuBlockSnapshotAddBlockdev(virJSONValuePtr actions,
virStorageSourcePtr newsrc); virStorageSourcePtr newsrc);
char * char *
qemuBlockGetBackingStoreString(virStorageSourcePtr src) qemuBlockGetBackingStoreString(virStorageSourcePtr src,
bool pretty)
ATTRIBUTE_NONNULL(1); ATTRIBUTE_NONNULL(1);
int int
......
...@@ -17499,7 +17499,7 @@ qemuDomainBlockPullCommon(virDomainObjPtr vm, ...@@ -17499,7 +17499,7 @@ qemuDomainBlockPullCommon(virDomainObjPtr vm,
if (baseSource) { if (baseSource) {
nodebase = baseSource->nodeformat; nodebase = baseSource->nodeformat;
if (!backingPath && if (!backingPath &&
!(backingPath = qemuBlockGetBackingStoreString(baseSource))) !(backingPath = qemuBlockGetBackingStoreString(baseSource, false)))
goto endjob; goto endjob;
} }
device = disk->src->nodeformat; device = disk->src->nodeformat;
...@@ -18667,7 +18667,7 @@ qemuDomainBlockCommit(virDomainPtr dom, ...@@ -18667,7 +18667,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
nodebase = baseSource->nodeformat; nodebase = baseSource->nodeformat;
device = qemuDomainDiskGetTopNodename(disk); device = qemuDomainDiskGetTopNodename(disk);
if (!backingPath && top_parent && if (!backingPath && top_parent &&
!(backingPath = qemuBlockGetBackingStoreString(baseSource))) !(backingPath = qemuBlockGetBackingStoreString(baseSource, false)))
goto endjob; goto endjob;
if (bitmapDisableActions) { if (bitmapDisableActions) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册