From patchwork Thu Apr 28 12:57:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 616210 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qwcN33v1Vz9sCg for ; Thu, 28 Apr 2016 22:58:58 +1000 (AEST) Received: from localhost ([::1]:48734 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avlWc-0001w7-9W for incoming@patchwork.ozlabs.org; Thu, 28 Apr 2016 08:58:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60519) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avlW3-0000gt-4i for qemu-devel@nongnu.org; Thu, 28 Apr 2016 08:58:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1avlW2-0000Cy-9I for qemu-devel@nongnu.org; Thu, 28 Apr 2016 08:57:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56630) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avlW0-0000BL-7B; Thu, 28 Apr 2016 08:57:56 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BE4C7124542; Thu, 28 Apr 2016 12:57:55 +0000 (UTC) Received: from lemon.redhat.com (vpn1-5-154.pek2.redhat.com [10.72.5.154]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3SCvWN6001193; Thu, 28 Apr 2016 08:57:51 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 28 Apr 2016 20:57:22 +0800 Message-Id: <1461848266-32119-4-git-send-email-famz@redhat.com> In-Reply-To: <1461848266-32119-1-git-send-email-famz@redhat.com> References: <1461848266-32119-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 28 Apr 2016 12:57:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 03/27] blockdev: Add and parse "lock-image" option for block devices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, Jeff Cody , Markus Armbruster , Max Reitz , stefanha@redhat.com, den@openvz.org, pbonzini@redhat.com, John Snow Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 */ } },