]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuBlockStorageSourceGetBackendProps: Allow skipping "discard":"unmap"
authorPeter Krempa <pkrempa@redhat.com>
Fri, 19 Jun 2020 14:37:43 +0000 (16:37 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 17 Jul 2020 05:41:20 +0000 (07:41 +0200)
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>
src/qemu/qemu_block.c
src/qemu/qemu_block.h

index 947a503d0a610a0699d3ab3c2216607efba9a9db..5faa6b8f1da17b341172771e35610745aafef88b 100644 (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;
index 715739e59c80953cf8f74bee8cbfda28b7919cee..0701fc18d12297f24f2633c635bf5523cd86b7fa 100644 (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