From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UzgNj-0002Kq-Bj for qemu-devel@nongnu.org; Thu, 18 Jul 2013 01:04:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UzgNd-0002XC-Ce for qemu-devel@nongnu.org; Thu, 18 Jul 2013 01:03:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34022) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UzgNd-0002X2-67 for qemu-devel@nongnu.org; Thu, 18 Jul 2013 01:03:53 -0400 Date: Thu, 18 Jul 2013 13:03:30 +0800 From: Stefan Hajnoczi Message-ID: <20130718050330.GA26971@stefanha-thinkpad.redhat.com> References: <1373885705-13722-1-git-send-email-pl@kamp.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1373885705-13722-1-git-send-email-pl@kamp.de> Subject: Re: [Qemu-devel] [PATCHv3] block-migration: efficiently encode zero blocks List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Lieven Cc: kwolf@redhat.com, pbonzini@redhat.com, owasserm@redhat.com, qemu-devel@nongnu.org, quintela@redhat.com 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