Received: from eggs.gnu.org ([2001:4830:134:3::10]:57983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVLVZ-0007cp-Pu for qemu-devel@nongnu.org; Tue, 10 Mar 2015 10:51:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YVLVW-0001hm-Ej for qemu-devel@nongnu.org; Tue, 10 Mar 2015 10:51:45 -0400 Received: from mx2.parallels.com ([199.115.105.18]:35548) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVLVW-0001hF-9y for qemu-devel@nongnu.org; Tue, 10 Mar 2015 10:51:42 -0400 Date: Tue, 10 Mar 2015 17:51:31 +0300 From: Roman Kagan Message-ID: <20150310145129.GB6015@rkaganb.sw.ru> References: <1425977481-13317-1-git-send-email-den@openvz.org> <1425977481-13317-20-git-send-email-den@openvz.org> <20150310143809.GD6024@rkaganb.sw.ru> <54FF0343.1050102@openvz.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <54FF0343.1050102@openvz.org> Subject: Re: [Qemu-devel] [PATCH 19/27] block/parallels: implement incorrect close detection List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Denis V. Lunev" Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi On Tue, Mar 10, 2015 at 05:44:19PM +0300, Denis V. Lunev wrote: > On 10/03/15 17:38, Roman Kagan wrote: > >On Tue, Mar 10, 2015 at 11:51:13AM +0300, Denis V. Lunev wrote: > >>The software driver must set inuse field in Parallels header to > >>0x746F6E59 when the image is opened in read-write mode. The presence of > >>this magic in the header on open forces image consistency check. > >> > >>There is an unfortunate trick here. We can not check for inuse in > >>parallels_check as this will happen too late. It is possible to do > >>that for simple check, but during the fix this would always report > >>an error as the image was opened in BDRV_O_RDWR mode. Thus we save > >>the flag in BDRVParallelsState for this. > >> > >>On the other hand, nothing should be done to clear inuse in > >>parallels_check. Generic close will do the job right. > >> > >>Signed-off-by: Denis V. Lunev > >>CC: Roman Kagan > >>CC: Kevin Wolf > >>CC: Stefan Hajnoczi > >>--- > >> block/parallels.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ > >> 1 file changed, 50 insertions(+) > >>@@ -462,6 +487,25 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, > >> } > >> s->bat_bitmap = (uint32_t *)(s->header + 1); > >>+ if (le32_to_cpu(ph.inuse) == HEADER_INUSE_MAGIC) { > >>+ /* Image was not closed correctly. The check is mandatory */ > >>+ s->header_unclean = true; > >>+ if ((flags & BDRV_O_RDWR) && !(flags & BDRV_O_CHECK)) { > >>+ error_setg(errp, "parallels: Image was not closed correctly; " > >>+ "cannot be opened read/write"); > >>+ ret = -EACCES; > >-EBUSY? > > > >Otherwise looks ok. > > > >Roman. > error code is the same as one in qcow2 OK then Reviewed-by: Roman Kagan Roman.