[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 17/20] migration: introduce save_zero_page_to_file
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PULL 17/20] migration: introduce save_zero_page_to_file |
Date: |
Wed, 22 Aug 2018 14:00:47 +0200 |
From: Xiao Guangrong <address@hidden>
It will be used by the compression threads
Reviewed-by: Peter Xu <address@hidden>
Signed-off-by: Xiao Guangrong <address@hidden>
Reviewed-by: Juan Quintela <address@hidden>
Signed-off-by: Juan Quintela <address@hidden>
---
migration/ram.c | 42 +++++++++++++++++++++++++++++++-----------
1 file changed, 31 insertions(+), 11 deletions(-)
diff --git a/migration/ram.c b/migration/ram.c
index 9d2ec247ec..8ffa0a6d55 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1672,29 +1672,49 @@ static void migration_bitmap_sync(RAMState *rs)
}
/**
- * save_zero_page: send the zero page to the stream
+ * save_zero_page_to_file: send the zero page to the file
*
- * Returns the number of pages written.
+ * Returns the size of data written to the file, 0 means the page is not
+ * a zero page
*
* @rs: current RAM state
+ * @file: the file where the data is saved
* @block: block that contains the page we want to send
* @offset: offset inside the block for the page
*/
-static int save_zero_page(RAMState *rs, RAMBlock *block, ram_addr_t offset)
+static int save_zero_page_to_file(RAMState *rs, QEMUFile *file,
+ RAMBlock *block, ram_addr_t offset)
{
uint8_t *p = block->host + offset;
- int pages = -1;
+ int len = 0;
if (is_zero_range(p, TARGET_PAGE_SIZE)) {
+ len += save_page_header(rs, file, block, offset | RAM_SAVE_FLAG_ZERO);
+ qemu_put_byte(file, 0);
+ len += 1;
+ }
+ return len;
+}
+
+/**
+ * save_zero_page: send the zero page to the stream
+ *
+ * Returns the number of pages written.
+ *
+ * @rs: current RAM state
+ * @block: block that contains the page we want to send
+ * @offset: offset inside the block for the page
+ */
+static int save_zero_page(RAMState *rs, RAMBlock *block, ram_addr_t offset)
+{
+ int len = save_zero_page_to_file(rs, rs->f, block, offset);
+
+ if (len) {
ram_counters.duplicate++;
- ram_counters.transferred +=
- save_page_header(rs, rs->f, block, offset | RAM_SAVE_FLAG_ZERO);
- qemu_put_byte(rs->f, 0);
- ram_counters.transferred += 1;
- pages = 1;
+ ram_counters.transferred += len;
+ return 1;
}
-
- return pages;
+ return -1;
}
static void ram_release_pages(const char *rbname, uint64_t offset, int pages)
--
2.17.1
- [Qemu-devel] [PULL 11/20] migration: poll the cm event while wait RDMA work request completion, (continued)
- [Qemu-devel] [PULL 11/20] migration: poll the cm event while wait RDMA work request completion, Juan Quintela, 2018/08/22
- [Qemu-devel] [PULL 12/20] migration: implement the shutdown for RDMA QIOChannel, Juan Quintela, 2018/08/22
- [Qemu-devel] [PULL 10/20] migration: invoke qio_channel_yield only when qemu_in_coroutine(), Juan Quintela, 2018/08/22
- [Qemu-devel] [PULL 14/20] migration: poll the cm event for destination qemu, Juan Quintela, 2018/08/22
- [Qemu-devel] [PULL 05/20] migration: disable RDMA WRITE after postcopy started, Juan Quintela, 2018/08/22
- [Qemu-devel] [PULL 09/20] migration: implement io_set_aio_fd_handler function for RDMA QIOChannel, Juan Quintela, 2018/08/22
- [Qemu-devel] [PULL 07/20] migration: implement bi-directional RDMA QIOChannel, Juan Quintela, 2018/08/22
- [Qemu-devel] [PULL 16/20] migration: fix counting normal page for compression, Juan Quintela, 2018/08/22
- [Qemu-devel] [PULL 13/20] tests/migration-test: Silence the kvm_hv message by default, Juan Quintela, 2018/08/22
- [Qemu-devel] [PULL 15/20] migration: do not wait for free thread, Juan Quintela, 2018/08/22
- [Qemu-devel] [PULL 17/20] migration: introduce save_zero_page_to_file,
Juan Quintela <=
- [Qemu-devel] [PULL 18/20] migration: drop the return value of do_compress_ram_page, Juan Quintela, 2018/08/22
- [Qemu-devel] [PULL 19/20] migration: move handle of zero page to the thread, Juan Quintela, 2018/08/22
- [Qemu-devel] [PULL 20/20] migration: hold the lock only if it is really needed, Juan Quintela, 2018/08/22
- Re: [Qemu-devel] [PULL 00/20] Migration pull requset, Peter Maydell, 2018/08/24