Received: from eggs.gnu.org ([2001:4830:134:3::10]:57271) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCN36-0002ZL-Fr for qemu-devel@nongnu.org; Mon, 13 Jun 2016 04:16:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCN30-0000jQ-Gi for qemu-devel@nongnu.org; Mon, 13 Jun 2016 04:16:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40997) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCN30-0000jA-Ad for qemu-devel@nongnu.org; Mon, 13 Jun 2016 04:16:38 -0400 References: <20160609155617.6650-1-anthony.perard@citrix.com> From: Paolo Bonzini Message-ID: <7faa3e52-4957-90dc-5060-581c3c6a3cc3@redhat.com> Date: Mon, 13 Jun 2016 10:16:30 +0200 MIME-Version: 1.0 In-Reply-To: <20160609155617.6650-1-anthony.perard@citrix.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] exec: Fix qemu_ram_block_from_host for Xen List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony PERARD , qemu-devel@nongnu.org Cc: xen-devel@lists.xen.org, Stefano Stabellini , Peter Crosthwaite , Richard Henderson On 09/06/2016 17:56, Anthony PERARD wrote: > Since f615f39 (exec: remove ram_addr argument from > qemu_ram_block_from_host), migration under Xen is likely to fail, with a > SEGV of QEMU. But the commit only reveal a bug with the calculation of > the offset value in qemu_ram_block_from_host(). > > This patch calculates the offset from the ram_addr as > qemu_ram_addr_from_host() will later calculate the ram_addr from the > offset. > > Signed-off-by: Anthony PERARD > --- > exec.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/exec.c b/exec.c > index f2c9e37..f13106d 100644 > --- a/exec.c > +++ b/exec.c > @@ -1935,7 +1935,7 @@ RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset, > ram_addr = xen_ram_addr_from_mapcache(ptr); > block = qemu_get_ram_block(ram_addr); > if (block) { > - *offset = (host - block->host); > + *offset = ram_addr - block->offset; > } > rcu_read_unlock(); > return block; > Acked-by: Paolo Bonzini Feel free to send a pull request yourself! Thanks, and sorry for the breakage. Indeed the broken code comes from commit 422148d3e56c3c9a07c0cf36c1e0a0b76f09c357. Paolo