mirror of https://github.com/xqemu/xqemu.git
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>
This commit is contained in:
parent
6607ae235b
commit
0c51f43d7a
26
arch_init.c
26
arch_init.c
|
@ -161,6 +161,18 @@ static int is_dup_page(uint8_t *page)
|
||||||
return 1;
|
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 RAMBlock *last_block;
|
||||||
static ram_addr_t last_offset;
|
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;
|
p = memory_region_get_ram_ptr(mr) + offset;
|
||||||
|
|
||||||
if (is_dup_page(p)) {
|
if (is_dup_page(p)) {
|
||||||
qemu_put_be64(f, offset | cont | RAM_SAVE_FLAG_COMPRESS);
|
save_block_hdr(f, block, 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));
|
|
||||||
}
|
|
||||||
qemu_put_byte(f, *p);
|
qemu_put_byte(f, *p);
|
||||||
bytes_sent = 1;
|
bytes_sent = 1;
|
||||||
} else {
|
} else {
|
||||||
qemu_put_be64(f, offset | cont | RAM_SAVE_FLAG_PAGE);
|
save_block_hdr(f, block, 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);
|
qemu_put_buffer(f, p, TARGET_PAGE_SIZE);
|
||||||
bytes_sent = TARGET_PAGE_SIZE;
|
bytes_sent = TARGET_PAGE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue