From patchwork Mon Jun 2 12:35:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Gang X-Patchwork-Id: 354856 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8B52D1400D2 for ; Mon, 2 Jun 2014 22:36:07 +1000 (EST) Received: from localhost ([::1]:44701 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrRTB-0007Wn-8O for incoming@patchwork.ozlabs.org; Mon, 02 Jun 2014 08:36:05 -0400 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 Received: from mail-pa0-x234.google.com ([2607:f8b0:400e:c03::234]:48467) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrRSS-0004Xj-Ab; Mon, 02 Jun 2014 08:35:20 -0400 Received: by mail-pa0-f52.google.com with SMTP id bj1so3815096pad.25 for ; Mon, 02 Jun 2014 05:35:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; bh=4TZ2hvpddV1OLthjzbZgdJ1NZzw+sNxTMpyOsqfrjnw=; b=ShW2LeLSlEIZLGuuHx320CZdla7Vz6HuLjZuXTeZdcHskPz8bSwhk2lJgoxT6V3a5s ogdlUC7i+r+610MlNir1PXrDPfmE2MCSVQUmwtJRCdsWgy1wiVQpxwn8SDj0Wy6nHtqE Uq2wk8zM3SzFMjJ6TfrNWFcg/a1Q7IVluLUU4mi/DvJUtqiXn62zbDSEPpySyhvNcNtk Vl9HWAFeurVEKwloNay8O4ISDy8Y+0/dNsWr3xPSXYKhkW6vwrdUJYDBZxa2yrk2WWY9 O9xerUPEEJ387CDGCDqzGA3MubWNx4DdlH4YtAdWU3fRsNMDOw0Wg0TBCn4Pa/4ZueKn Jjcg== X-Received: by 10.66.218.36 with SMTP id pd4mr39909795pac.141.1401712519206; Mon, 02 Jun 2014 05:35:19 -0700 (PDT) Received: from [192.168.1.104] ([223.72.65.106]) by mx.google.com with ESMTPSA id sv10sm20337909pbc.74.2014.06.02.05.35.16 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 02 Jun 2014 05:35:18 -0700 (PDT) Message-ID: <538C6F98.5070005@gmail.com> Date: Mon, 02 Jun 2014 20:35:36 +0800 From: Chen Gang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Michael Tokarev , quintela@redhat.com, arei.gonglei@huawei.com, Eric Blake , dgilbert@redhat.com, owasserm@redhat.com X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c03::234 Cc: QEMU Trivial , QEMU Developers Subject: [Qemu-devel] [PATCH-trivial] arch_init.c: Always be sure that 'encoded_buf' and 'current_buf' are lock protected X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org '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(); }