From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59958) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UzhIq-0005Zz-4I for qemu-devel@nongnu.org; Thu, 18 Jul 2013 02:03:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UzhIn-0004HQ-Mj for qemu-devel@nongnu.org; Thu, 18 Jul 2013 02:03:00 -0400 Received: from mx.ipv6.kamp.de ([2a02:248:0:51::16]:33409 helo=mx01.kamp.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1UzhIn-0004HI-Cw for qemu-devel@nongnu.org; Thu, 18 Jul 2013 02:02:57 -0400 Message-ID: <51E78512.2090407@kamp.de> Date: Thu, 18 Jul 2013 08:02:58 +0200 From: Peter Lieven MIME-Version: 1.0 References: <1373885705-13722-1-git-send-email-pl@kamp.de> <20130718050330.GA26971@stefanha-thinkpad.redhat.com> In-Reply-To: <20130718050330.GA26971@stefanha-thinkpad.redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCHv3] block-migration: efficiently encode zero blocks List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: kwolf@redhat.com, pbonzini@redhat.com, owasserm@redhat.com, qemu-devel@nongnu.org, quintela@redhat.com On 18.07.2013 07:03, Stefan Hajnoczi wrote: > 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. Thank you, I will sent a v4 shortly. I have to rebase it anyway. Peter