From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46410) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wj76b-0002Jl-Kl for qemu-devel@nongnu.org; Sat, 10 May 2014 09:14:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wj76Q-0005aR-R5 for qemu-devel@nongnu.org; Sat, 10 May 2014 09:14:21 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:57015 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wj76Q-0005aK-GI for qemu-devel@nongnu.org; Sat, 10 May 2014 09:14:10 -0400 Message-ID: <536E2615.7050403@kamp.de> Date: Sat, 10 May 2014 15:13:57 +0200 From: Peter Lieven MIME-Version: 1.0 References: <1399719075-11517-1-git-send-email-pl@kamp.de> <5CA9C66B-507E-4F95-90C8-2850C5552C21@icloud.com> In-Reply-To: <5CA9C66B-507E-4F95-90C8-2850C5552C21@icloud.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH] migration: cache memory region ram ptr List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?6ZmI5qKB?= Cc: pbonzini@redhat.com, quintela@redhat.com, qemu-devel@nongnu.org, dgilbert@redhat.com Am 10.05.2014 13:38, schrieb 陈梁: > Hi, > The patch is correct. There is a small improved point. >> /* In doubt sent page as normal */ >> bytes_sent = -1; >> @@ -990,16 +996,17 @@ static inline void *host_from_stream_offset(QEMUFile *f, >> int flags) >> { >> static RAMBlock *block = NULL; > RAMBlock *block = NULL; This one has to be static as well. Why do you think it should not? Peter > >> + static uint8_t *ram_ptr; >> char id[256]; >> uint8_t len; >> >> if (flags & RAM_SAVE_FLAG_CONTINUE) { >> - if (!block) { >> + if (!block || !ram_ptr) { > if (!ram_ptr) { > > Best regards > ChenLiang > >> fprintf(stderr, "Ack, bad migration stream!\n"); >> return NULL; >> } >> >> - return memory_region_get_ram_ptr(block->mr) + offset; >> + return ram_ptr + offset; >> } >> >> len = qemu_get_byte(f); >> @@ -1007,8 +1014,10 @@ static inline void *host_from_stream_offset(QEMUFile *f, >> id[len] = 0; >> >> QTAILQ_FOREACH(block, &ram_list.blocks, next) { >> - if (!strncmp(id, block->idstr, sizeof(id))) >> - return memory_region_get_ram_ptr(block->mr) + offset; >> + if (!strncmp(id, block->idstr, sizeof(id))) { >> + ram_ptr = memory_region_get_ram_ptr(block->mr); >> + return ram_ptr + offset; >> + } >> } >> >> fprintf(stderr, "Can't find block %s!\n", id); >> -- >> 1.7.9.5 >> >>