qemuBlockStorageSourceGetBackendProps: Allow skipping "discard":"unmap"

It doesn't make sense to format "discard" when doing a -blockdev backend
of scsi-generic used with SCSI hostdevs. Add a way to skip it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2020-06-19 16:37:43 +02:00
parent d73c5eda63
commit 4f28b1a51c
2 changed files with 9 additions and 0 deletions

View File

@ -1061,6 +1061,9 @@ qemuBlockStorageSourceGetBlockdevGetCacheProps(virStorageSourcePtr src,
* omit any data which does not identify the image itself
* QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_AUTO_READONLY:
* use the auto-read-only feature of qemu
* QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_SKIP_UNMAP:
* don't enable 'discard:unmap' option for passing through discards
* (note that this is disabled also for _LEGACY and _TARGET_ONLY options)
*
* Creates a JSON object describing the underlying storage or protocol of a
* storage source. Returns NULL on error and reports an appropriate error message.
@ -1202,6 +1205,11 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src,
if (virJSONValueObjectAdd(fileprops,
"T:read-only", ro,
"T:auto-read-only", aro,
NULL) < 0)
return NULL;
if (!(flags & QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_SKIP_UNMAP) &&
virJSONValueObjectAdd(fileprops,
"s:discard", "unmap",
NULL) < 0)
return NULL;

View File

@ -60,6 +60,7 @@ typedef enum {
QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_LEGACY = 1 << 0,
QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_TARGET_ONLY = 1 << 1,
QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_AUTO_READONLY = 1 << 2,
QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_SKIP_UNMAP = 1 << 3,
} qemuBlockStorageSourceBackendPropsFlags;
virJSONValuePtr