提交 73ca2014 编写于 作者: P Peter Krempa

qemu: block: Properly format storage slice into backing store strings

When creating overlay images e.g. for snapshots or when merging
snapshots we often specify the backing store string to use. Make the
formatter aware of backing chain entries which have a <slice>
configured so that we record it properly. Otherwise such images
would not work without the XML (when detecting the backing chain).
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 f36d751f
...@@ -1930,44 +1930,48 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr src) ...@@ -1930,44 +1930,48 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr src)
{ {
int actualType = virStorageSourceGetActualType(src); int actualType = virStorageSourceGetActualType(src);
g_autoptr(virJSONValue) backingProps = NULL; g_autoptr(virJSONValue) backingProps = NULL;
g_autoptr(virJSONValue) sliceProps = NULL;
virJSONValuePtr props = NULL;
g_autoptr(virURI) uri = NULL; g_autoptr(virURI) uri = NULL;
g_autofree char *backingJSON = NULL; g_autofree char *backingJSON = NULL;
char *ret = NULL; char *ret = NULL;
if (virStorageSourceIsLocalStorage(src)) { if (!src->sliceStorage) {
ret = g_strdup(src->path); if (virStorageSourceIsLocalStorage(src)) {
return ret; ret = g_strdup(src->path);
} return ret;
}
/* generate simplified URIs for the easy cases */ /* generate simplified URIs for the easy cases */
if (actualType == VIR_STORAGE_TYPE_NETWORK && if (actualType == VIR_STORAGE_TYPE_NETWORK &&
src->nhosts == 1 && src->nhosts == 1 &&
src->hosts->transport == VIR_STORAGE_NET_HOST_TRANS_TCP) { src->hosts->transport == VIR_STORAGE_NET_HOST_TRANS_TCP) {
switch ((virStorageNetProtocol) src->protocol) {
case VIR_STORAGE_NET_PROTOCOL_NBD:
case VIR_STORAGE_NET_PROTOCOL_HTTP:
case VIR_STORAGE_NET_PROTOCOL_HTTPS:
case VIR_STORAGE_NET_PROTOCOL_FTP:
case VIR_STORAGE_NET_PROTOCOL_FTPS:
case VIR_STORAGE_NET_PROTOCOL_TFTP:
case VIR_STORAGE_NET_PROTOCOL_ISCSI:
case VIR_STORAGE_NET_PROTOCOL_GLUSTER:
if (!(uri = qemuBlockStorageSourceGetURI(src)))
return NULL;
switch ((virStorageNetProtocol) src->protocol) { if (!(ret = virURIFormat(uri)))
case VIR_STORAGE_NET_PROTOCOL_NBD: return NULL;
case VIR_STORAGE_NET_PROTOCOL_HTTP:
case VIR_STORAGE_NET_PROTOCOL_HTTPS:
case VIR_STORAGE_NET_PROTOCOL_FTP:
case VIR_STORAGE_NET_PROTOCOL_FTPS:
case VIR_STORAGE_NET_PROTOCOL_TFTP:
case VIR_STORAGE_NET_PROTOCOL_ISCSI:
case VIR_STORAGE_NET_PROTOCOL_GLUSTER:
if (!(uri = qemuBlockStorageSourceGetURI(src)))
return NULL;
if (!(ret = virURIFormat(uri))) return ret;
return NULL;
return ret; case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG:
case VIR_STORAGE_NET_PROTOCOL_RBD:
case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: case VIR_STORAGE_NET_PROTOCOL_VXHS:
case VIR_STORAGE_NET_PROTOCOL_RBD: case VIR_STORAGE_NET_PROTOCOL_SSH:
case VIR_STORAGE_NET_PROTOCOL_VXHS: case VIR_STORAGE_NET_PROTOCOL_LAST:
case VIR_STORAGE_NET_PROTOCOL_SSH: case VIR_STORAGE_NET_PROTOCOL_NONE:
case VIR_STORAGE_NET_PROTOCOL_LAST: break;
case VIR_STORAGE_NET_PROTOCOL_NONE: }
break;
} }
} }
...@@ -1975,7 +1979,21 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr src) ...@@ -1975,7 +1979,21 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr src)
if (!(backingProps = qemuBlockStorageSourceGetBackendProps(src, false, true, false))) if (!(backingProps = qemuBlockStorageSourceGetBackendProps(src, false, true, false)))
return NULL; return NULL;
if (!(backingJSON = virJSONValueToString(backingProps, false))) props = backingProps;
if (src->sliceStorage) {
if (virJSONValueObjectCreate(&sliceProps,
"s:driver", "raw",
"U:offset", src->sliceStorage->offset,
"U:size", src->sliceStorage->size,
"a:file", &backingProps,
NULL) < 0)
return NULL;
props = sliceProps;
}
if (!(backingJSON = virJSONValueToString(props, false)))
return NULL; return NULL;
ret = g_strdup_printf("json:%s", backingJSON); ret = g_strdup_printf("json:%s", backingJSON);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册