On Mon, Jul 15, 2013 at 12:55:05PM +0200, Peter Lieven wrote:
> @@ -114,16 +115,29 @@ static void blk_mig_unlock(void)
>  static void blk_send(QEMUFile *f, BlkMigBlock * blk)
>  {
>      int len;
> +    uint64_t flags = BLK_MIG_FLAG_DEVICE_BLOCK;
> +
> +    if (migrate_zero_blocks() && buffer_is_zero(blk->buf, BLOCK_SIZE)) {
[...]
> +bool migrate_zero_blocks(void)
> +{
> +    MigrationState *s;
> +
> +    s = migrate_get_current();
> +
> +    return s->enabled_capabilities[MIGRATION_CAPABILITY_ZERO_BLOCKS];
> +}

blk_send() is called without locks held.  It would be safer and cleaner
to stash bool migrate_zero_blocks in BlkMigBlock in init_blk_migration()
instead of accessing migrate_get_current() without locks held.

This eliminates the assumption that accessing migrate_get_current() is
safe without locks.

Besides this locking issue I'm happy with the code.

Stefan

Reply via email to