From patchwork Tue Jan 3 15:34:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Orit Wasserman X-Patchwork-Id: 134021 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DC189B6F9B for ; Wed, 4 Jan 2012 02:36:06 +1100 (EST) Received: from localhost ([::1]:49451 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ri6PA-0006CA-Oa for incoming@patchwork.ozlabs.org; Tue, 03 Jan 2012 10:36:00 -0500 Received: from eggs.gnu.org ([140.186.70.92]:34590) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ri6Or-0005q1-3l for qemu-devel@nongnu.org; Tue, 03 Jan 2012 10:35:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ri6Ok-0006xM-GY for qemu-devel@nongnu.org; Tue, 03 Jan 2012 10:35:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:62646) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ri6Ok-0006xF-8l for qemu-devel@nongnu.org; Tue, 03 Jan 2012 10:35:34 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q03FZWlJ026657 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 3 Jan 2012 10:35:32 -0500 Received: from dhcp-1-120.tlv.redhat.com (vpn-202-200.tlv.redhat.com [10.35.202.200]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q03FZNnw003527; Tue, 3 Jan 2012 10:35:31 -0500 From: Orit Wasserman To: qemu-devel@nongnu.org Date: Tue, 3 Jan 2012 17:34:33 +0200 Message-Id: <1325604879-15862-4-git-send-email-owasserm@redhat.com> In-Reply-To: <1325604879-15862-1-git-send-email-owasserm@redhat.com> References: <1325604879-15862-1-git-send-email-owasserm@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: blauwirbel@gmail.com, stefanha@gmail.com, Orit Wasserman , quintela@redhat.com Subject: [Qemu-devel] [PATCH v5 3/9] 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 Signed-off-by: Orit Wasserman --- arch_init.c | 30 +++++++++++++++--------------- 1 files changed, 15 insertions(+), 15 deletions(-) diff --git a/arch_init.c b/arch_init.c index 426b34d..e87dfbc 100644 --- a/arch_init.c +++ b/arch_init.c @@ -335,6 +335,17 @@ static void xor_encode(uint8_t *dst, uint8_t *src1, uint8_t *src2) } } +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 int is_dup_page(uint8_t *page, uint8_t ch) { uint32_t val = ch << 24 | ch << 16 | ch << 8 | ch; @@ -377,23 +388,12 @@ static int ram_save_block(QEMUFile *f) p = block->host + offset; if (is_dup_page(p, *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)); - } - qemu_put_buffer(f, p, TARGET_PAGE_SIZE); - bytes_sent = TARGET_PAGE_SIZE; + save_block_hdr(f, block, offset, cont, RAM_SAVE_FLAG_PAGE); + qemu_put_buffer(f, p, TARGET_PAGE_SIZE); + bytes_sent = TARGET_PAGE_SIZE; } break;