Am 01.07.2013 um 16:13 schrieb Stefan Hajnoczi <stefa...@redhat.com>:
> On Thu, Jun 27, 2013 at 03:11:32PM +0200, Peter Lieven wrote: > > This patch breaks cross-version blog migration. We need to control > whether or not to use the new BLK_MIG_FLAG_ZERO_BLOCK flag. you are right the upgrade way works, but downgrade not. what is the proposed way to fix this? > >> diff --git a/block-migration.c b/block-migration.c >> index 2fd7699..99b3757 100644 >> --- a/block-migration.c >> +++ b/block-migration.c >> @@ -29,6 +29,7 @@ >> #define BLK_MIG_FLAG_DEVICE_BLOCK 0x01 >> #define BLK_MIG_FLAG_EOS 0x02 >> #define BLK_MIG_FLAG_PROGRESS 0x04 >> +#define BLK_MIG_FLAG_ZERO_BLOCK 0x08 >> >> #define MAX_IS_ALLOCATED_SEARCH 65536 >> >> @@ -114,16 +115,29 @@ static void blk_mig_unlock(void) >> static void blk_send(QEMUFile *f, BlkMigBlock * blk) >> { >> int len; >> + int flags = BLK_MIG_FLAG_DEVICE_BLOCK; >> + >> + if (buffer_is_zero(blk->buf, BLOCK_SIZE)) { >> + flags |= BLK_MIG_FLAG_ZERO_BLOCK; >> + } >> >> /* sector number and flags */ >> qemu_put_be64(f, (blk->sector << BDRV_SECTOR_BITS) >> - | BLK_MIG_FLAG_DEVICE_BLOCK); >> + | flags); > > blk->sector is int64_t and flags is signed int. This conversion will > sign-extend from 32-bit flags up to 64-bits. > > Flags should be uint64_t or at least unsigned so that we don't hit > sign-extension when BLK_MIG_FLAG_x uses the top bit. will fix this. thanks, Peter