From patchwork Wed Jan 13 10:40:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 566883 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 5D17A140317 for ; Wed, 13 Jan 2016 21:45:14 +1100 (AEDT) Received: from localhost ([::1]:36455 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJIvQ-0003NN-A0 for incoming@patchwork.ozlabs.org; Wed, 13 Jan 2016 05:45:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52404) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJIrf-0004pm-Qq for qemu-devel@nongnu.org; Wed, 13 Jan 2016 05:41:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aJIre-0002Gs-To for qemu-devel@nongnu.org; Wed, 13 Jan 2016 05:41:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34929) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJIre-0002GK-OP for qemu-devel@nongnu.org; Wed, 13 Jan 2016 05:41:18 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 601FCB8BAF; Wed, 13 Jan 2016 10:41:18 +0000 (UTC) Received: from localhost ([10.3.113.5]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0DAfGis001535; Wed, 13 Jan 2016 05:41:17 -0500 From: Amit Shah To: qemu list Date: Wed, 13 Jan 2016 16:10:46 +0530 Message-Id: <063e760a5f52d9b82946956e7046828b524727af.1452681449.git.amit.shah@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Amit Shah , Peter Maydell , "Dr. David Alan Gilbert" , Juan Quintela Subject: [Qemu-devel] [PULL 5/6] Use qemu_get_buffer_in_place for xbzrle data 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 From: "Dr. David Alan Gilbert" Avoid a data copy (if we're lucky) in the xbzrle code. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Reviewed-by: Amit Shah Message-Id: <1450266458-3178-6-git-send-email-dgilbert@redhat.com> Signed-off-by: Amit Shah --- migration/ram.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 102d1f2..994552c 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2088,10 +2088,12 @@ static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host) { unsigned int xh_len; int xh_flags; + uint8_t *loaded_data; if (!xbzrle_decoded_buf) { xbzrle_decoded_buf = g_malloc(TARGET_PAGE_SIZE); } + loaded_data = xbzrle_decoded_buf; /* extract RLE header */ xh_flags = qemu_get_byte(f); @@ -2107,10 +2109,10 @@ static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host) return -1; } /* load data and decode */ - qemu_get_buffer(f, xbzrle_decoded_buf, xh_len); + qemu_get_buffer_in_place(f, &loaded_data, xh_len); /* decode RLE */ - if (xbzrle_decode_buffer(xbzrle_decoded_buf, xh_len, host, + if (xbzrle_decode_buffer(loaded_data, xh_len, host, TARGET_PAGE_SIZE) == -1) { error_report("Failed to load XBZRLE page - decode error!"); return -1;