mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 19:32:19 +00:00
qemu: block: Format cache modes for disk storage backends
When used directly with blockdev-add/-blockdev the cache mode will need to be specified directly for every image rather than just for the disk itself. This implements the backing options 'direct' and 'no-flush'. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
58505900c5
commit
de5a15bc3d
@ -1038,6 +1038,35 @@ qemuBlockStorageSourceGetVvfatProps(virStorageSourcePtr src)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuBlockStorageSourceGetBlockdevGetCacheProps(virStorageSourcePtr src,
|
||||||
|
virJSONValuePtr props)
|
||||||
|
{
|
||||||
|
virJSONValuePtr cacheobj;
|
||||||
|
bool direct = false;
|
||||||
|
bool noflush = false;
|
||||||
|
|
||||||
|
if (src->cachemode == VIR_DOMAIN_DISK_CACHE_DEFAULT)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (qemuDomainDiskCachemodeFlags(src->cachemode, NULL, &direct, &noflush) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (virJSONValueObjectCreate(&cacheobj,
|
||||||
|
"b:direct", direct,
|
||||||
|
"b:no-flush", noflush,
|
||||||
|
NULL) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (virJSONValueObjectAppend(props, "cache", cacheobj) < 0) {
|
||||||
|
virJSONValueFree(cacheobj);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemuBlockStorageSourceGetBackendProps:
|
* qemuBlockStorageSourceGetBackendProps:
|
||||||
* @src: disk source
|
* @src: disk source
|
||||||
@ -1052,6 +1081,7 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src,
|
|||||||
{
|
{
|
||||||
int actualType = virStorageSourceGetActualType(src);
|
int actualType = virStorageSourceGetActualType(src);
|
||||||
virJSONValuePtr fileprops = NULL;
|
virJSONValuePtr fileprops = NULL;
|
||||||
|
virJSONValuePtr ret = NULL;
|
||||||
|
|
||||||
switch ((virStorageType)actualType) {
|
switch ((virStorageType)actualType) {
|
||||||
case VIR_STORAGE_TYPE_BLOCK:
|
case VIR_STORAGE_TYPE_BLOCK:
|
||||||
@ -1126,10 +1156,17 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (qemuBlockNodeNameValidate(src->nodestorage) < 0 ||
|
if (qemuBlockNodeNameValidate(src->nodestorage) < 0 ||
|
||||||
virJSONValueObjectAdd(fileprops, "S:node-name", src->nodestorage, NULL) < 0) {
|
virJSONValueObjectAdd(fileprops, "S:node-name", src->nodestorage, NULL) < 0)
|
||||||
virJSONValueFree(fileprops);
|
goto cleanup;
|
||||||
return NULL;
|
|
||||||
|
if (!legacy) {
|
||||||
|
if (qemuBlockStorageSourceGetBlockdevGetCacheProps(src, fileprops) < 0)
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fileprops;
|
VIR_STEAL_PTR(ret, fileprops);
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
virJSONValueFree(fileprops);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user