mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 10:35:20 +00:00
qemuBlockStorageSourceGetBlockdevGetCacheProps: Return the cache object rather than appending it
Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
4cf223962a
commit
e60c3057cc
@ -913,24 +913,20 @@ qemuBlockStorageSourceGetVhostVdpaProps(virStorageSource *src)
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
qemuBlockStorageSourceGetBlockdevGetCacheProps(virStorageSource *src,
|
qemuBlockStorageSourceGetBlockdevGetCacheProps(virStorageSource *src,
|
||||||
virJSONValue *props)
|
virJSONValue **cache)
|
||||||
{
|
{
|
||||||
g_autoptr(virJSONValue) cacheobj = NULL;
|
|
||||||
bool direct = false;
|
bool direct = false;
|
||||||
bool noflush = false;
|
bool noflush = false;
|
||||||
|
|
||||||
if (!qemuDomainDiskCachemodeFlags(src->cachemode, NULL, &direct, &noflush))
|
if (!qemuDomainDiskCachemodeFlags(src->cachemode, NULL, &direct, &noflush))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (virJSONValueObjectAdd(&cacheobj,
|
if (virJSONValueObjectAdd(cache,
|
||||||
"b:direct", direct,
|
"b:direct", direct,
|
||||||
"b:no-flush", noflush,
|
"b:no-flush", noflush,
|
||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (virJSONValueObjectAppend(props, "cache", &cacheobj) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1109,10 +1105,13 @@ qemuBlockStorageSourceGetBackendProps(virStorageSource *src,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!legacy) {
|
if (!legacy) {
|
||||||
if (qemuBlockStorageSourceGetBlockdevGetCacheProps(src, fileprops) < 0)
|
g_autoptr(virJSONValue) cache = NULL;
|
||||||
|
|
||||||
|
if (qemuBlockStorageSourceGetBlockdevGetCacheProps(src, &cache) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (virJSONValueObjectAdd(&fileprops,
|
if (virJSONValueObjectAdd(&fileprops,
|
||||||
|
"A:cache", &cache,
|
||||||
"T:read-only", ro,
|
"T:read-only", ro,
|
||||||
"T:auto-read-only", aro,
|
"T:auto-read-only", aro,
|
||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
@ -1278,10 +1277,14 @@ qemuBlockStorageSourceGetBlockdevFormatCommonProps(virStorageSource *src)
|
|||||||
int detectZeroesMode = virDomainDiskGetDetectZeroesMode(src->discard,
|
int detectZeroesMode = virDomainDiskGetDetectZeroesMode(src->discard,
|
||||||
src->detect_zeroes);
|
src->detect_zeroes);
|
||||||
g_autoptr(virJSONValue) props = NULL;
|
g_autoptr(virJSONValue) props = NULL;
|
||||||
|
g_autoptr(virJSONValue) cache = NULL;
|
||||||
|
|
||||||
if (qemuBlockNodeNameValidate(qemuBlockStorageSourceGetFormatNodename(src)) < 0)
|
if (qemuBlockNodeNameValidate(qemuBlockStorageSourceGetFormatNodename(src)) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (qemuBlockStorageSourceGetBlockdevGetCacheProps(src, &cache) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if (src->discard)
|
if (src->discard)
|
||||||
discard = virDomainDiskDiscardTypeToString(src->discard);
|
discard = virDomainDiskDiscardTypeToString(src->discard);
|
||||||
|
|
||||||
@ -1297,12 +1300,10 @@ qemuBlockStorageSourceGetBlockdevFormatCommonProps(virStorageSource *src)
|
|||||||
"b:read-only", src->readonly,
|
"b:read-only", src->readonly,
|
||||||
"S:discard", discard,
|
"S:discard", discard,
|
||||||
"S:detect-zeroes", detectZeroes,
|
"S:detect-zeroes", detectZeroes,
|
||||||
|
"A:cache", &cache,
|
||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (qemuBlockStorageSourceGetBlockdevGetCacheProps(src, props) < 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return g_steal_pointer(&props);
|
return g_steal_pointer(&props);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1439,10 +1440,14 @@ static virJSONValue *
|
|||||||
qemuBlockStorageSourceGetBlockdevStorageSliceProps(virStorageSource *src)
|
qemuBlockStorageSourceGetBlockdevStorageSliceProps(virStorageSource *src)
|
||||||
{
|
{
|
||||||
g_autoptr(virJSONValue) props = NULL;
|
g_autoptr(virJSONValue) props = NULL;
|
||||||
|
g_autoptr(virJSONValue) cache = NULL;
|
||||||
|
|
||||||
if (qemuBlockNodeNameValidate(src->sliceStorage->nodename) < 0)
|
if (qemuBlockNodeNameValidate(src->sliceStorage->nodename) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (qemuBlockStorageSourceGetBlockdevGetCacheProps(src, &cache) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if (virJSONValueObjectAdd(&props,
|
if (virJSONValueObjectAdd(&props,
|
||||||
"s:driver", "raw",
|
"s:driver", "raw",
|
||||||
"s:node-name", src->sliceStorage->nodename,
|
"s:node-name", src->sliceStorage->nodename,
|
||||||
@ -1451,12 +1456,10 @@ qemuBlockStorageSourceGetBlockdevStorageSliceProps(virStorageSource *src)
|
|||||||
"s:file", qemuBlockStorageSourceGetStorageNodename(src),
|
"s:file", qemuBlockStorageSourceGetStorageNodename(src),
|
||||||
"b:auto-read-only", true,
|
"b:auto-read-only", true,
|
||||||
"s:discard", "unmap",
|
"s:discard", "unmap",
|
||||||
|
"A:cache", &cache,
|
||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (qemuBlockStorageSourceGetBlockdevGetCacheProps(src, props) < 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return g_steal_pointer(&props);
|
return g_steal_pointer(&props);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user