From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:42563) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rq12b-0003hD-T8 for qemu-devel@nongnu.org; Wed, 25 Jan 2012 06:29:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rq12W-0000ej-0D for qemu-devel@nongnu.org; Wed, 25 Jan 2012 06:29:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:9253) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rq12V-0000ed-LR for qemu-devel@nongnu.org; Wed, 25 Jan 2012 06:29:19 -0500 From: Orit Wasserman Date: Wed, 25 Jan 2012 13:26:41 +0200 Message-Id: <1327490809-21393-4-git-send-email-owasserm@redhat.com> In-Reply-To: <1327490809-21393-1-git-send-email-owasserm@redhat.com> References: <1327490809-21393-1-git-send-email-owasserm@redhat.com> Subject: [Qemu-devel] [PATCH v6 03/11] Add save_block_hdr function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: blauwirbel@gmail.com, stefanha@gmail.com, Orit Wasserman , avi@redhat.com, quintela@redhat.com Signed-off-by: Orit Wasserman --- arch_init.c | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-) diff --git a/arch_init.c b/arch_init.c index 34e4e60..1218306 100644 --- a/arch_init.c +++ b/arch_init.c @@ -300,6 +300,16 @@ static void cache_insert(unsigned long addr, uint8_t *pdata) it->it_addr = addr; } +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; @@ -326,21 +336,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.6.5