From nobody Tue Feb 10 03:44:22 2026 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: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1492747091779137.82744092139353; Thu, 20 Apr 2017 20:58:11 -0700 (PDT) Received: from localhost ([::1]:56970 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Phx-00077R-8W for importer@patchew.org; Thu, 20 Apr 2017 23:58:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58551) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1PgB-0005cG-8g for qemu-devel@nongnu.org; Thu, 20 Apr 2017 23:56:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1PgA-0003fR-BQ for qemu-devel@nongnu.org; Thu, 20 Apr 2017 23:56:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47812) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1Pg7-0003eQ-QC; Thu, 20 Apr 2017 23:56:16 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 82EEF3DE42; Fri, 21 Apr 2017 03:56:14 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-35.pek2.redhat.com [10.72.8.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FEDF17966; Fri, 21 Apr 2017 03:56:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 82EEF3DE42 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 82EEF3DE42 From: Fam Zheng To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 11:55:47 +0800 Message-Id: <20170421035606.448-2-famz@redhat.com> In-Reply-To: <20170421035606.448-1-famz@redhat.com> References: <20170421035606.448-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 21 Apr 2017 03:56:14 +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 v14 01/20] block: Add, parse and store "force-shared-write" option 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, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Fam Zheng Reviewed-by: Kevin Wolf --- block.c | 9 +++++++++ include/block/block.h | 2 ++ include/block/block_int.h | 1 + 3 files changed, 12 insertions(+) diff --git a/block.c b/block.c index 1e668fb..f5c4e97 100644 --- a/block.c +++ b/block.c @@ -763,6 +763,7 @@ static void bdrv_inherited_options(int *child_flags, QD= ict *child_options, * the parent. */ qdict_copy_default(child_options, parent_options, BDRV_OPT_CACHE_DIREC= T); qdict_copy_default(child_options, parent_options, BDRV_OPT_CACHE_NO_FL= USH); + qdict_copy_default(child_options, parent_options, BDRV_OPT_FORCE_SHARE= D_WRITE); =20 /* Inherit the read-only option from the parent if it's not set */ qdict_copy_default(child_options, parent_options, BDRV_OPT_READ_ONLY); @@ -871,6 +872,7 @@ static void bdrv_backing_options(int *child_flags, QDic= t *child_options, * which is only applied on the top level (BlockBackend) */ qdict_copy_default(child_options, parent_options, BDRV_OPT_CACHE_DIREC= T); qdict_copy_default(child_options, parent_options, BDRV_OPT_CACHE_NO_FL= USH); + qdict_copy_default(child_options, parent_options, BDRV_OPT_FORCE_SHARE= D_WRITE); =20 /* backing files always opened read-only */ qdict_set_default_str(child_options, BDRV_OPT_READ_ONLY, "on"); @@ -1115,6 +1117,11 @@ QemuOptsList bdrv_runtime_opts =3D { .type =3D QEMU_OPT_STRING, .help =3D "discard operation (ignore/off, unmap/on)", }, + { + .name =3D BDRV_OPT_FORCE_SHARED_WRITE, + .type =3D QEMU_OPT_BOOL, + .help =3D "always accept other writers (default: off)", + }, { /* end of list */ } }, }; @@ -1154,6 +1161,8 @@ static int bdrv_open_common(BlockDriverState *bs, Blo= ckBackend *file, drv =3D bdrv_find_format(driver_name); assert(drv !=3D NULL); =20 + bs->force_shared_write =3D qemu_opt_get_bool(opts, BDRV_OPT_FORCE_SHAR= ED_WRITE, false); + if (file !=3D NULL) { filename =3D blk_bs(file)->filename; } else { diff --git a/include/block/block.h b/include/block/block.h index 5ddc0cf..d3afb75 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -109,6 +109,8 @@ typedef struct HDGeometry { #define BDRV_OPT_CACHE_NO_FLUSH "cache.no-flush" #define BDRV_OPT_READ_ONLY "read-only" #define BDRV_OPT_DISCARD "discard" +#define BDRV_OPT_FORCE_SHARED_WRITE \ + "force-shared-write" =20 =20 #define BDRV_SECTOR_BITS 9 diff --git a/include/block/block_int.h b/include/block/block_int.h index 59400bd..fb81692 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -518,6 +518,7 @@ struct BlockDriverState { bool valid_key; /* if true, a valid encryption key has been set */ bool sg; /* if true, the device is a /dev/sg* */ bool probed; /* if true, format was probed rather than specified */ + bool force_shared_write; /* if true, always allow shared write perm. */ =20 BlockDriver *drv; /* NULL means no media */ void *opaque; --=20 2.9.3