aboutsummaryrefslogtreecommitdiff
path: root/arch_init.c
diff options
context:
space:
mode:
authorOrit Wasserman <owasserm@redhat.com>2012-06-19 18:43:14 +0300
committerJuan Quintela <quintela@redhat.com>2012-06-29 13:18:28 +0200
commit0c51f43d7a82fedca550f9dc149edff2952b8fe1 (patch)
treeeaee5074ff70cc1590b7add79ffa4a1ded451605 /arch_init.c
parent6607ae235bbc8c8c23159c21f545e7622489a236 (diff)
downloadqemu-0c51f43d7a82fedca550f9dc149edff2952b8fe1.zip
qemu-0c51f43d7a82fedca550f9dc149edff2952b8fe1.tar.gz
qemu-0c51f43d7a82fedca550f9dc149edff2952b8fe1.tar.bz2
Add save_block_hdr function
Signed-off-by: Benoit Hudzia <benoit.hudzia@sap.com> Signed-off-by: Petter Svard <petters@cs.umu.se> Signed-off-by: Aidan Shribman <aidan.shribman@sap.com> Signed-off-by: Orit Wasserman <owasserm@redhat.com>
Diffstat (limited to 'arch_init.c')
-rw-r--r--arch_init.c26
1 files 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;
}