]> git.proxmox.com Git - qemu.git/commitdiff
blockdev: add discard suboption to -drive
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 8 Feb 2013 13:06:12 +0000 (14:06 +0100)
committerKevin Wolf <kwolf@redhat.com>
Fri, 22 Feb 2013 20:29:42 +0000 (21:29 +0100)
Add support for BDRV_O_UNMAP from the QEMU command-line.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
blockdev.c
qemu-options.hx

index b307ed9ba911d647d303ea0b373e96a7f6ab995b..0e67d0633043be0fbec5f0e84572d8c45fa7d5a1 100644 (file)
@@ -391,6 +391,13 @@ DriveInfo *drive_init(QemuOpts *opts, BlockInterfaceType block_default_type)
        }
     }
 
+    if ((buf = qemu_opt_get(opts, "discard")) != NULL) {
+        if (bdrv_parse_discard_flags(buf, &bdrv_flags) != 0) {
+            error_report("invalid discard option");
+            return NULL;
+        }
+    }
+
     bdrv_flags |= BDRV_O_CACHE_WB;
     if ((buf = qemu_opt_get(opts, "cache")) != NULL) {
         if (bdrv_parse_cache_flags(buf, &bdrv_flags) != 0) {
@@ -1500,6 +1507,10 @@ QemuOptsList qemu_drive_opts = {
             .name = "file",
             .type = QEMU_OPT_STRING,
             .help = "disk image",
+        },{
+            .name = "discard",
+            .type = QEMU_OPT_STRING,
+            .help = "discard operation (ignore/off, unmap/on)",
         },{
             .name = "cache",
             .type = QEMU_OPT_STRING,
index 2832d821484d1a63703f45c8ac01cfc2d0bd4485..51ff726490fd716de8be89fc552f5840447b52f8 100644 (file)
@@ -440,6 +440,8 @@ These options have the same definition as they have in @option{-hdachs}.
 @var{cache} is "none", "writeback", "unsafe", "directsync" or "writethrough" and controls how the host cache is used to access block data.
 @item aio=@var{aio}
 @var{aio} is "threads", or "native" and selects between pthread based disk I/O and native Linux AIO.
+@item discard=@var{discard}
+@var{discard} is one of "ignore" (or "off") or "unmap" (or "on") and controls whether @dfn{discard} (also known as @dfn{trim} or @dfn{unmap}) requests are ignored or passed to the filesystem.  Some machine types may not support discard requests.
 @item format=@var{format}
 Specify which disk @var{format} will be used rather than detecting
 the format.  Can be used to specifiy format=raw to avoid interpreting