Received: from eggs.gnu.org ([2001:4830:134:3::10]:58845) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azxli-0000J0-Gc for qemu-devel@nongnu.org; Mon, 09 May 2016 22:51:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1azxlh-0004V2-30 for qemu-devel@nongnu.org; Mon, 09 May 2016 22:51:30 -0400 From: Fam Zheng Date: Tue, 10 May 2016 10:50:35 +0800 Message-Id: <1462848659-28659-4-git-send-email-famz@redhat.com> In-Reply-To: <1462848659-28659-1-git-send-email-famz@redhat.com> References: <1462848659-28659-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH v4 03/27] blockdev: Add and parse "lock-image" option for block devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Max Reitz , Jeff Cody , Markus Armbruster , Eric Blake , qemu-block@nongnu.org, rjones@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, John Snow , berrange@redhat.com, den@openvz.org Honor the locking switch specified in CLI or QMP, and set the open flags for the image accordingly. Signed-off-by: Fam Zheng --- blockdev.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/blockdev.c b/blockdev.c index f1f520a..200fa56 100644 --- a/blockdev.c +++ b/blockdev.c @@ -382,6 +382,10 @@ static void extract_common_blockdev_options(QemuOpts *opts, int *bdrv_flags, return; } } + + if (!qemu_opt_get_bool(opts, "lock-image", false)) { + *bdrv_flags |= BDRV_O_NO_LOCK; + } } /* disk I/O throttling */ @@ -4249,6 +4253,10 @@ QemuOptsList qemu_common_drive_opts = { .type = QEMU_OPT_BOOL, .help = "whether to account for failed I/O operations " "in the statistics", + },{ + .name = "lock-image", + .type = QEMU_OPT_BOOL, + .help = "whether to lock the image (default: on)", }, { /* end of list */ } }, @@ -4278,6 +4286,10 @@ static QemuOptsList qemu_root_bds_opts = { .name = "detect-zeroes", .type = QEMU_OPT_STRING, .help = "try to optimize zero writes (off, on, unmap)", + },{ + .name = "lock-image", + .type = QEMU_OPT_BOOL, + .help = "whether to lock the image (default: on)", }, { /* end of list */ } }, -- 2.8.2