From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54192) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5bZa-0002ai-MD for qemu-devel@nongnu.org; Thu, 18 Jun 2015 11:17:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z5bZW-0004t5-2k for qemu-devel@nongnu.org; Thu, 18 Jun 2015 11:17:46 -0400 Message-ID: <5582E104.1090504@gmail.com> Date: Thu, 18 Jun 2015 23:17:24 +0800 From: Wen Congyang MIME-Version: 1.0 References: <1434617361-17778-1-git-send-email-wency@cn.fujitsu.com> <1434617361-17778-7-git-send-email-wency@cn.fujitsu.com> <20150618124729.GD25387@stefanha-thinkpad.redhat.com> In-Reply-To: <20150618124729.GD25387@stefanha-thinkpad.redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH COLO-Block v6 06/16] Don't allow a disk use backing reference target List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi , Wen Congyang Cc: Kevin Wolf , Fam Zheng , Lai Jiangshan , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , Max Reitz , Gonglei , Stefan Hajnoczi , Paolo Bonzini , Yang Hongyang , "Dr. David Alan Gilbert" , zhanghailiang At 2015/6/18 20:47, Stefan Hajnoczi Wrote: > On Thu, Jun 18, 2015 at 04:49:11PM +0800, Wen Congyang wrote: >> Signed-off-by: Wen Congyang >> Signed-off-by: zhanghailiang >> Signed-off-by: Gonglei >> --- >> block.c | 9 +++++++++ >> 1 file changed, 9 insertions(+) >> >> diff --git a/block.c b/block.c >> index d1ed227..0b41af4 100644 >> --- a/block.c >> +++ b/block.c >> @@ -1294,6 +1294,14 @@ static int bdrv_open_backing_reference_file(BlockDriverState *bs, >> } >> >> backing_hd = blk_bs(backing_blk); >> + /* Don't allow a disk use backing reference target */ >> + ret = blk_attach_dev(backing_hd->blk, bs); >> + if (ret < 0) { >> + error_setg(errp, "backing_hd %s is used by the other device model", >> + backing_name); >> + goto free_exit; >> + } > > Can you explain the purpose of this patch? > > I'm not sure blk_attach_dev() is the appropriate API. It is only used > by emulated devices but not by the run-time NBD server, for example. > This means you are not preventing all other users from accessing this > BDS. > > The op blockers mechanism is normally used to prevent operations on a > BDS. See bdrv_op_is_blocked() and bdrv_op_block(). NBD server will write to this BDS(backing reference target). So I cannot use bdrv_op_block(). If some emulated devices also write to it, the data will be broken. The purpose is that: this BDS cannot be attached, and any emulated devices will meet some erros if it tries to attach to this BDS. Thanks Wen Congyang > > Stefan >