From patchwork Fri Apr 7 20:55:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 9670383 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1A6C9602B3 for ; Fri, 7 Apr 2017 20:57:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0275020265 for ; Fri, 7 Apr 2017 20:57:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EAA7A204BD; Fri, 7 Apr 2017 20:57:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 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 mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 86C1E20265 for ; Fri, 7 Apr 2017 20:57:06 +0000 (UTC) Received: from localhost ([::1]:52535 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwawL-00061T-FY for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Apr 2017 16:57:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwav6-0005yT-2X for qemu-devel@nongnu.org; Fri, 07 Apr 2017 16:55:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cwav5-0003LO-1G for qemu-devel@nongnu.org; Fri, 07 Apr 2017 16:55:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39798) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cwav1-0003Ke-QE; Fri, 07 Apr 2017 16:55:44 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9E40475EC1; Fri, 7 Apr 2017 20:55:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9E40475EC1 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jcody@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9E40475EC1 Received: from localhost (ovpn-116-76.phx2.redhat.com [10.3.116.76]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 952DD60F83; Fri, 7 Apr 2017 20:55:38 +0000 (UTC) From: Jeff Cody To: qemu-devel@nongnu.org Date: Fri, 7 Apr 2017 16:55:25 -0400 Message-Id: <9b18972d05f5fa2ac16c014f0af98d680553048d.1491597120.git.jcody@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 07 Apr 2017 20:55:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 for-2.10 1/8] block: add bdrv_set_read_only() helper function 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: kwolf@redhat.com, jsnow@redhat.com, stefanha@redhat.com, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP We have a helper wrapper for checking for the BDS read_only flag, add a helper wrapper to set the read_only flag as well. Reviewed-by: Stefan Hajnoczi Signed-off-by: Jeff Cody --- block.c | 5 +++++ block/bochs.c | 2 +- block/cloop.c | 2 +- block/dmg.c | 2 +- block/rbd.c | 2 +- block/vvfat.c | 4 ++-- include/block/block.h | 1 + 7 files changed, 12 insertions(+), 6 deletions(-) diff --git a/block.c b/block.c index 927ba89..7b4c7ef 100644 --- a/block.c +++ b/block.c @@ -192,6 +192,11 @@ void path_combine(char *dest, int dest_size, } } +void bdrv_set_read_only(BlockDriverState *bs, bool read_only) +{ + bs->read_only = read_only; +} + void bdrv_get_full_backing_filename_from_filename(const char *backed, const char *backing, char *dest, size_t sz, diff --git a/block/bochs.c b/block/bochs.c index 516da56..bdc2831 100644 --- a/block/bochs.c +++ b/block/bochs.c @@ -110,7 +110,7 @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags, return -EINVAL; } - bs->read_only = true; /* no write support yet */ + bdrv_set_read_only(bs, true); /* no write support yet */ ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs)); if (ret < 0) { diff --git a/block/cloop.c b/block/cloop.c index a6c7b9d..11f17c8 100644 --- a/block/cloop.c +++ b/block/cloop.c @@ -72,7 +72,7 @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags, return -EINVAL; } - bs->read_only = true; + bdrv_set_read_only(bs, true); /* read header */ ret = bdrv_pread(bs->file, 128, &s->block_size, 4); diff --git a/block/dmg.c b/block/dmg.c index a7d25fc..27ce4a6 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -420,7 +420,7 @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags, } block_module_load_one("dmg-bz2"); - bs->read_only = true; + bdrv_set_read_only(bs, true); s->n_chunks = 0; s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL; diff --git a/block/rbd.c b/block/rbd.c index 1ceeeb5..6ad2904 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -641,7 +641,7 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, goto failed_open; } - bs->read_only = (s->snap != NULL); + bdrv_set_read_only(bs, (s->snap != NULL)); qemu_opts_del(opts); return 0; diff --git a/block/vvfat.c b/block/vvfat.c index af5153d..d4ce6d7 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -1157,7 +1157,7 @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags, s->current_cluster=0xffffffff; /* read only is the default for safety */ - bs->read_only = true; + bdrv_set_read_only(bs, true); s->qcow = NULL; s->qcow_filename = NULL; s->fat2 = NULL; @@ -1173,7 +1173,7 @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags, if (ret < 0) { goto fail; } - bs->read_only = false; + bdrv_set_read_only(bs, false); } bs->total_sectors = cyls * heads * secs; diff --git a/include/block/block.h b/include/block/block.h index 5149260..06c9032 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -426,6 +426,7 @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base, int64_t sector_num, int nb_sectors, int *pnum); bool bdrv_is_read_only(BlockDriverState *bs); +void bdrv_set_read_only(BlockDriverState *bs, bool read_only); bool bdrv_is_sg(BlockDriverState *bs); bool bdrv_is_inserted(BlockDriverState *bs); int bdrv_media_changed(BlockDriverState *bs);