From patchwork Fri Feb 22 21:23:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 222671 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 262452C0079 for ; Sat, 23 Feb 2013 09:17:31 +1100 (EST) Received: from localhost ([::1]:40791 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U907E-0003WD-1k for incoming@patchwork.ozlabs.org; Fri, 22 Feb 2013 16:25:12 -0500 Received: from eggs.gnu.org ([208.118.235.92]:35940) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U906c-0002po-FI for qemu-devel@nongnu.org; Fri, 22 Feb 2013 16:24:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U906Y-0003qc-3h for qemu-devel@nongnu.org; Fri, 22 Feb 2013 16:24:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60418) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U906X-0003qO-OK for qemu-devel@nongnu.org; Fri, 22 Feb 2013 16:24:30 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r1MLOS7I021525 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 22 Feb 2013 16:24:28 -0500 Received: from dhcp-200-207.str.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r1MLNuFi010868; Fri, 22 Feb 2013 16:24:27 -0500 From: Kevin Wolf To: anthony@codemonkey.ws Date: Fri, 22 Feb 2013 22:23:48 +0100 Message-Id: <1361568231-18198-20-git-send-email-kwolf@redhat.com> In-Reply-To: <1361568231-18198-1-git-send-email-kwolf@redhat.com> References: <1361568231-18198-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 19/22] blockdev: add discard suboption to -drive X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Paolo Bonzini Add support for BDRV_O_UNMAP from the QEMU command-line. Signed-off-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- blockdev.c | 11 +++++++++++ qemu-options.hx | 2 ++ 2 files changed, 13 insertions(+) diff --git a/blockdev.c b/blockdev.c index b307ed9..0e67d06 100644 --- a/blockdev.c +++ b/blockdev.c @@ -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) { @@ -1501,6 +1508,10 @@ QemuOptsList qemu_drive_opts = { .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, .help = "host cache usage (none, writeback, writethrough, " diff --git a/qemu-options.hx b/qemu-options.hx index 2832d82..51ff726 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -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