[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 4/8] migration: introduce save_zero_page_to_file
From: |
guangrong . xiao |
Subject: |
[Qemu-devel] [PATCH v2 4/8] migration: introduce save_zero_page_to_file |
Date: |
Thu, 19 Jul 2018 20:15:16 +0800 |
From: Xiao Guangrong <address@hidden>
It will be used by the compression threads
Signed-off-by: Xiao Guangrong <address@hidden>
---
migration/ram.c | 40 ++++++++++++++++++++++++++++++----------
1 file changed, 30 insertions(+), 10 deletions(-)
diff --git a/migration/ram.c b/migration/ram.c
index e68b0e6dec..ce6e69b649 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1696,27 +1696,47 @@ static void migration_bitmap_sync(RAMState *rs)
/**
* save_zero_page: send the zero page to the stream
*
- * 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)) {
- 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;
+ len += save_page_header(rs, file, block, offset | RAM_SAVE_FLAG_ZERO);
+ qemu_put_byte(file, 0);
+ len += 1;
}
+ return len;
+}
- return pages;
+/**
+ * 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 += len;
+ return 1;
+ }
+ return -1;
}
static void ram_release_pages(const char *rbname, uint64_t offset, int pages)
--
2.14.4
- Re: [Qemu-devel] [PATCH v2 2/8] migration: fix counting normal page for compression, (continued)
- [Qemu-devel] [PATCH v2 3/8] migration: show the statistics of compression, guangrong . xiao, 2018/07/19
- Re: [Qemu-devel] [PATCH v2 3/8] migration: show the statistics of compression, Peter Xu, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 3/8] migration: show the statistics of compression, Xiao Guangrong, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 3/8] migration: show the statistics of compression, Peter Xu, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 3/8] migration: show the statistics of compression, Xiao Guangrong, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 3/8] migration: show the statistics of compression, Peter Xu, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 3/8] migration: show the statistics of compression, Xiao Guangrong, 2018/07/24
- Re: [Qemu-devel] [PATCH v2 3/8] migration: show the statistics of compression, Dr. David Alan Gilbert, 2018/07/25
- Re: [Qemu-devel] [PATCH v2 3/8] migration: show the statistics of compression, Peter Xu, 2018/07/26
[Qemu-devel] [PATCH v2 4/8] migration: introduce save_zero_page_to_file,
guangrong . xiao <=
[Qemu-devel] [PATCH v2 5/8] migration: drop the return value of do_compress_ram_page, guangrong . xiao, 2018/07/19
[Qemu-devel] [PATCH v2 6/8] migration: move handle of zero page to the thread, guangrong . xiao, 2018/07/19
- Re: [Qemu-devel] [PATCH v2 6/8] migration: move handle of zero page to the thread, Peter Xu, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 6/8] migration: move handle of zero page to the thread, Xiao Guangrong, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 6/8] migration: move handle of zero page to the thread, Peter Xu, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 6/8] migration: move handle of zero page to the thread, Xiao Guangrong, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 6/8] migration: move handle of zero page to the thread, Peter Xu, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 6/8] migration: move handle of zero page to the thread, Xiao Guangrong, 2018/07/24