From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:52036) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sm3Y0-0004Cq-5U for qemu-devel@nongnu.org; Tue, 03 Jul 2012 09:53:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sm3Xt-0004p6-TT for qemu-devel@nongnu.org; Tue, 03 Jul 2012 09:53:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40322) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sm3Xt-0004oz-LT for qemu-devel@nongnu.org; Tue, 03 Jul 2012 09:53:37 -0400 From: Orit Wasserman Date: Tue, 3 Jul 2012 16:52:47 +0300 Message-Id: <1341323574-23206-7-git-send-email-owasserm@redhat.com> In-Reply-To: <1341323574-23206-1-git-send-email-owasserm@redhat.com> References: <1341323574-23206-1-git-send-email-owasserm@redhat.com> Subject: [Qemu-devel] [PATCH v14 06/13] Add save_block_hdr function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, aliguori@us.ibm.com, quintela@redhat.com, Petter Svard , stefanha@gmail.com, mdroth@linux.vnet.ibm.com, Benoit Hudzia , blauwirbel@gmail.com, Orit Wasserman , chegu_vinod@hp.com, avi@redhat.com, Aidan Shribman , pbonzini@redhat.com, eblake@redhat.com Signed-off-by: Benoit Hudzia Signed-off-by: Petter Svard Signed-off-by: Aidan Shribman Signed-off-by: Orit Wasserman --- arch_init.c | 26 ++++++++++++++------------ 1 files changed, 14 insertions(+), 12 deletions(-) diff --git a/arch_init.c b/arch_init.c index a9e8b74..9dafb6e 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; } -- 1.7.7.6