From nobody Wed Apr 30 19:03:31 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493061887410941.7546948048372; Mon, 24 Apr 2017 12:24:47 -0700 (PDT) Received: from localhost ([::1]:45600 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1d2jbJ-00054n-TJ for importer@patchew.org; Mon, 24 Apr 2017 15:24:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46491) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <jcody@redhat.com>) id 1d2jWx-0001WO-2M for qemu-devel@nongnu.org; Mon, 24 Apr 2017 15:20:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <jcody@redhat.com>) id 1d2jWv-0002fa-Rp for qemu-devel@nongnu.org; Mon, 24 Apr 2017 15:20:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56372) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <jcody@redhat.com>) id 1d2jWs-0002cj-Kr; Mon, 24 Apr 2017 15:20:10 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A29B865D1A; Mon, 24 Apr 2017 19:20:09 +0000 (UTC) Received: from localhost (ovpn-120-118.rdu2.redhat.com [10.10.120.118]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6826E88F28; Mon, 24 Apr 2017 19:20:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A29B865D1A Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jcody@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A29B865D1A From: Jeff Cody <jcody@redhat.com> To: qemu-block@nongnu.org Date: Mon, 24 Apr 2017 15:19:54 -0400 Message-Id: <20170424192002.18622-5-jcody@redhat.com> In-Reply-To: <20170424192002.18622-1-jcody@redhat.com> References: <20170424192002.18622-1-jcody@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 24 Apr 2017 19:20:09 +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] [PULL v2 04/12] block: add bdrv_set_read_only() helper function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: peter.maydell@linaro.org, jcody@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 <stefanha@redhat.com> Signed-off-by: Jeff Cody <jcody@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Message-id: 9b18972d05f5fa2ac16c014f0af98d680553048d.1491597120.git.jcody@r= edhat.com --- 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 7eda9a4..6f21145 100644 --- a/block.c +++ b/block.c @@ -192,6 +192,11 @@ void path_combine(char *dest, int dest_size, } } =20 +void bdrv_set_read_only(BlockDriverState *bs, bool read_only) +{ + bs->read_only =3D 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 *opti= ons, int flags, return -EINVAL; } =20 - bs->read_only =3D true; /* no write support yet */ + bdrv_set_read_only(bs, true); /* no write support yet */ =20 ret =3D 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 *option= s, int flags, return -EINVAL; } =20 - bs->read_only =3D true; + bdrv_set_read_only(bs, true); =20 /* read header */ ret =3D 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 *option= s, int flags, } =20 block_module_load_one("dmg-bz2"); - bs->read_only =3D true; + bdrv_set_read_only(bs, true); =20 s->n_chunks =3D 0; s->offsets =3D s->lengths =3D s->sectors =3D s->sectorcounts =3D 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 *o= ptions, int flags, goto failed_open; } =20 - bs->read_only =3D (s->snap !=3D NULL); + bdrv_set_read_only(bs, (s->snap !=3D NULL)); =20 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 *op= tions, int flags, s->current_cluster=3D0xffffffff; =20 /* read only is the default for safety */ - bs->read_only =3D true; + bdrv_set_read_only(bs, true); s->qcow =3D NULL; s->qcow_filename =3D NULL; s->fat2 =3D NULL; @@ -1173,7 +1173,7 @@ static int vvfat_open(BlockDriverState *bs, QDict *op= tions, int flags, if (ret < 0) { goto fail; } - bs->read_only =3D false; + bdrv_set_read_only(bs, false); } =20 bs->total_sectors =3D cyls * heads * secs; diff --git a/include/block/block.h b/include/block/block.h index 466de49..99d49f2 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -434,6 +434,7 @@ int bdrv_is_allocated_above(BlockDriverState *top, Bloc= kDriverState *base, int64_t sector_num, int nb_sectors, int *pnum); =20 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); --=20 2.9.3