[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 19/27] block/parallels: implement incorrect clos
From: |
Roman Kagan |
Subject: |
Re: [Qemu-devel] [PATCH 19/27] block/parallels: implement incorrect close detection |
Date: |
Tue, 10 Mar 2015 17:51:31 +0300 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
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 <address@hidden>
> >>CC: Roman Kagan <address@hidden>
> >>CC: Kevin Wolf <address@hidden>
> >>CC: Stefan Hajnoczi <address@hidden>
> >>---
> >> 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 <address@hidden>
Roman.
- Re: [Qemu-devel] [PATCH 23/27] block/parallels: create bat_entry_off helper, (continued)
- [Qemu-devel] [PATCH 06/27] block/parallels: provide _co_readv routine for parallels format driver, Denis V. Lunev, 2015/03/10
- [Qemu-devel] [PATCH 20/27] iotests, parallels: check for incorrectly closed image in tests, Denis V. Lunev, 2015/03/10
- [Qemu-devel] [PATCH 09/27] iotests, parallels: test for write into Parallels image, Denis V. Lunev, 2015/03/10
- [Qemu-devel] [PATCH 27/27] block/parallels: improve image writing performance further, Denis V. Lunev, 2015/03/10
- [Qemu-devel] [PATCH 12/27] parallels: change copyright information in the image header, Denis V. Lunev, 2015/03/10
- [Qemu-devel] [PATCH 19/27] block/parallels: implement incorrect close detection, Denis V. Lunev, 2015/03/10
- [Qemu-devel] [PATCH 13/27] block/parallels: rename catalog_ names to bat_, Denis V. Lunev, 2015/03/10
- [Qemu-devel] [PATCH 04/27] block/parallels: read up to cluster end in one go, Denis V. Lunev, 2015/03/10
- [Qemu-devel] [PATCH 14/27] block/parallels: create bat2sect helper, Denis V. Lunev, 2015/03/10
- [Qemu-devel] [PATCH 05/27] block/parallels: add get_block_status, Denis V. Lunev, 2015/03/10
- [Qemu-devel] [PATCH 15/27] block/parallels: keep BAT bitmap data in little endian in memory, Denis V. Lunev, 2015/03/10
- [Qemu-devel] [PATCH 11/27] iotests, parallels: test for newly created parallels image via qemu-img, Denis V. Lunev, 2015/03/10
- [Qemu-devel] [PATCH 26/27] block/parallels: optimize linear image expansion, Denis V. Lunev, 2015/03/10