From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrRSc-0006ts-JT for qemu-devel@nongnu.org; Mon, 02 Jun 2014 08:35:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WrRSS-0004YV-IN for qemu-devel@nongnu.org; Mon, 02 Jun 2014 08:35:30 -0400 Message-ID: <538C6F98.5070005@gmail.com> Date: Mon, 02 Jun 2014 20:35:36 +0800 From: Chen Gang MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH-trivial] arch_init.c: Always be sure that 'encoded_buf' and 'current_buf' are lock protected List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Tokarev , quintela@redhat.com, arei.gonglei@huawei.com, Eric Blake , dgilbert@redhat.com, owasserm@redhat.com Cc: QEMU Trivial , QEMU Developers 'encoded_buf' and 'current_buf' are lock protected during using in save_xbzrle_page() in ram_save_page(), and during freeing in migration_end(). So recommend to let them lock protected during starting, just like we have done to 'cache'. Signed-off-by: Chen Gang --- arch_init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch_init.c b/arch_init.c index 23044c1..784922c 100644 --- a/arch_init.c +++ b/arch_init.c @@ -783,12 +783,12 @@ static int ram_save_setup(QEMUFile *f, void *opaque) error_report("Error creating cache"); return -1; } - XBZRLE_cache_unlock(); /* We prefer not to abort if there is no memory */ XBZRLE.encoded_buf = g_try_malloc0(TARGET_PAGE_SIZE); if (!XBZRLE.encoded_buf) { error_report("Error allocating encoded_buf"); + XBZRLE_cache_unlock(); return -1; } @@ -797,8 +797,10 @@ static int ram_save_setup(QEMUFile *f, void *opaque) error_report("Error allocating current_buf"); g_free(XBZRLE.encoded_buf); XBZRLE.encoded_buf = NULL; + XBZRLE_cache_unlock(); return -1; } + XBZRLE_cache_unlock(); acct_clear(); } -- 1.7.11.7