From patchwork Fri Jun 29 16:43:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 168222 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5A92DB6FA4 for ; Sat, 30 Jun 2012 03:16:14 +1000 (EST) Received: from localhost ([::1]:56288 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SkeJU-0006dl-QU for incoming@patchwork.ozlabs.org; Fri, 29 Jun 2012 12:44:56 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52074) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SkeIx-0005KZ-ER for qemu-devel@nongnu.org; Fri, 29 Jun 2012 12:44:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SkeIr-00056t-F8 for qemu-devel@nongnu.org; Fri, 29 Jun 2012 12:44:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38896) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SkeIr-00056C-7N for qemu-devel@nongnu.org; Fri, 29 Jun 2012 12:44:17 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q5TGiBLH013379 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 29 Jun 2012 12:44:12 -0400 Received: from trasno.mitica (ovpn-116-23.ams2.redhat.com [10.36.116.23]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q5TGi4Fi027488; Fri, 29 Jun 2012 12:44:09 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 29 Jun 2012 18:43:54 +0200 Message-Id: <0c51f43d7a82fedca550f9dc149edff2952b8fe1.1340987905.git.quintela@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Orit Wasserman , Benoit Hudzia , Aidan Shribman , Petter Svard Subject: [Qemu-devel] [PATCH 03/13] Add save_block_hdr function 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: Orit Wasserman Signed-off-by: Benoit Hudzia Signed-off-by: Petter Svard Signed-off-by: Aidan Shribman Signed-off-by: Orit Wasserman Signed-off-by: Juan Quintela --- arch_init.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/arch_init.c b/arch_init.c index 81c2e54..cfa1af2 100644 --- a/arch_init.c +++ b/arch_init.c @@ -161,6 +161,18 @@ static int is_dup_page(uint8_t *page) return 1; } +static void save_block_hdr(QEMUFile *f, RAMBlock *block, ram_addr_t offset, + int cont, int flag) +{ + qemu_put_be64(f, offset | cont | flag); + if (!cont) { + qemu_put_byte(f, strlen(block->idstr)); + qemu_put_buffer(f, (uint8_t *)block->idstr, + strlen(block->idstr)); + } + +} + static RAMBlock *last_block; static ram_addr_t last_offset; @@ -187,21 +199,11 @@ static int ram_save_block(QEMUFile *f) p = memory_region_get_ram_ptr(mr) + offset; if (is_dup_page(p)) { - qemu_put_be64(f, offset | cont | RAM_SAVE_FLAG_COMPRESS); - if (!cont) { - qemu_put_byte(f, strlen(block->idstr)); - qemu_put_buffer(f, (uint8_t *)block->idstr, - strlen(block->idstr)); - } + save_block_hdr(f, block, offset, cont, RAM_SAVE_FLAG_COMPRESS); qemu_put_byte(f, *p); bytes_sent = 1; } else { - qemu_put_be64(f, offset | cont | RAM_SAVE_FLAG_PAGE); - if (!cont) { - qemu_put_byte(f, strlen(block->idstr)); - qemu_put_buffer(f, (uint8_t *)block->idstr, - strlen(block->idstr)); - } + save_block_hdr(f, block, offset, cont, RAM_SAVE_FLAG_PAGE); qemu_put_buffer(f, p, TARGET_PAGE_SIZE); bytes_sent = TARGET_PAGE_SIZE; }