[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [Qemu-stable] [Qemu-devel] [PATCH 2/3] block/qcow2: fix
From: |
Maxim Levitsky |
Subject: |
Re: [Qemu-block] [Qemu-stable] [Qemu-devel] [PATCH 2/3] block/qcow2: fix the corruption when rebasing luks encrypted files |
Date: |
Tue, 10 Sep 2019 14:12:00 +0300 |
On Mon, 2019-09-09 at 12:56 +0200, Kevin Wolf wrote:
> Am 06.09.2019 um 21:17 hat Eric Blake geschrieben:
> > > - assert((offset_in_cluster & ~BDRV_SECTOR_MASK) == 0);
> > > + assert((guest_offset & ~BDRV_SECTOR_MASK) == 0);
> > > + assert((host_offset & ~BDRV_SECTOR_MASK) == 0);
> > > assert((bytes & ~BDRV_SECTOR_MASK) == 0);
> >
> > Pre-existing, but we could use QEMU_IS_ALIGNED(x, BDRV_SECTOR_SIZE) for
> > slightly more legibility than open-coding the bit operation.
> >
> > Neat trick about power-of-2 alignment checks:
> >
> > assert(QEMU_IS_ALIGNED(offset_in_cluster | guest_offset |
> > host_offset | bytes, BDRV_SECTOR_SIZE));
> >
> > gives the same result in one assertion. (I've used it elsewhere in the
> > code base, but I'm not opposed to one assert per variable if you think
> > batching is too dense.)
>
> A possible downside of this is that if a user reports an assertion
> failure, you can't tell any more which of the variables ended up in a
> bad state.
>
> If you're lucky, you can still tell in gdb at least if the bug is
> reproducible, but I wouldn't be surprised if in release builds, half of
> the variables were actually optimised away, so that even this wouldn't
> work.
Agreed. I guess I'll keep the separate asserts anyway after all, even though
I prefer shorter code.
Best regards,
Maxim Levitsky
[Qemu-block] [PATCH 2/3] block/qcow2: fix the corruption when rebasing luks encrypted files, Maxim Levitsky, 2019/09/06
[Qemu-block] [PATCH 3/3] qemu-iotests: test for bz #1745922, Maxim Levitsky, 2019/09/06
Re: [Qemu-block] [Qemu-devel] [PATCH 0/3] Fix qcow2+luks corruption introduced by commit 8ac0f15f335, Maxim Levitsky, 2019/09/06