[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 35/38] migration/ram: Merge save_zero_page functions
From: |
Juan Quintela |
Subject: |
[PULL 35/38] migration/ram: Merge save_zero_page functions |
Date: |
Tue, 17 Oct 2023 10:30:00 +0200 |
From: Fabiano Rosas <farosas@suse.de>
We don't need to do this in two pieces. One single function makes it
easier to grasp, specially since it removes the indirection on the
return value handling.
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-ID: <20231011184604.32364-7-farosas@suse.de>
---
migration/ram.c | 46 +++++++++++++---------------------------------
1 file changed, 13 insertions(+), 33 deletions(-)
diff --git a/migration/ram.c b/migration/ram.c
index 229cad5c74..c844151ee9 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1137,32 +1137,6 @@ void ram_release_page(const char *rbname, uint64_t
offset)
ram_discard_range(rbname, offset, TARGET_PAGE_SIZE);
}
-/**
- * save_zero_page_to_file: send the zero page to the file
- *
- * Returns the size of data written to the file, 0 means the page is not
- * a zero page
- *
- * @pss: current PSS channel
- * @block: block that contains the page we want to send
- * @offset: offset inside the block for the page
- */
-static int save_zero_page_to_file(PageSearchStatus *pss, RAMBlock *block,
- ram_addr_t offset)
-{
- uint8_t *p = block->host + offset;
- QEMUFile *file = pss->pss_channel;
- int len = 0;
-
- if (buffer_is_zero(p, TARGET_PAGE_SIZE)) {
- len += save_page_header(pss, file, block, offset | RAM_SAVE_FLAG_ZERO);
- qemu_put_byte(file, 0);
- len += 1;
- ram_release_page(block->idstr, offset);
- }
- return len;
-}
-
/**
* save_zero_page: send the zero page to the stream
*
@@ -1176,12 +1150,19 @@ static int save_zero_page_to_file(PageSearchStatus
*pss, RAMBlock *block,
static int save_zero_page(RAMState *rs, PageSearchStatus *pss, RAMBlock *block,
ram_addr_t offset)
{
- int len = save_zero_page_to_file(pss, block, offset);
+ uint8_t *p = block->host + offset;
+ QEMUFile *file = pss->pss_channel;
+ int len = 0;
- if (!len) {
- return -1;
+ if (!buffer_is_zero(p, TARGET_PAGE_SIZE)) {
+ return 0;
}
+ len += save_page_header(pss, file, block, offset | RAM_SAVE_FLAG_ZERO);
+ qemu_put_byte(file, 0);
+ len += 1;
+ ram_release_page(block->idstr, offset);
+
stat64_add(&mig_stats.zero_pages, 1);
ram_transferred_add(len);
@@ -1195,7 +1176,7 @@ static int save_zero_page(RAMState *rs, PageSearchStatus
*pss, RAMBlock *block,
XBZRLE_cache_unlock();
}
- return 1;
+ return len;
}
/*
@@ -2152,9 +2133,8 @@ static int ram_save_target_page_legacy(RAMState *rs,
PageSearchStatus *pss)
return 1;
}
- res = save_zero_page(rs, pss, block, offset);
- if (res > 0) {
- return res;
+ if (save_zero_page(rs, pss, block, offset)) {
+ return 1;
}
/*
--
2.41.0
- [PULL 18/38] migration/rdma: Unfold hook_ram_load(), (continued)
- [PULL 18/38] migration/rdma: Unfold hook_ram_load(), Juan Quintela, 2023/10/17
- [PULL 14/38] migration: Create migrate_rdma(), Juan Quintela, 2023/10/17
- [PULL 20/38] qemu-file: Remove QEMUFileHooks, Juan Quintela, 2023/10/17
- [PULL 25/38] migration/rdma: Declare for index variables local, Juan Quintela, 2023/10/17
- [PULL 24/38] migration/rdma: Use i as for index instead of idx, Juan Quintela, 2023/10/17
- [PULL 26/38] migration/rdma: Remove all "ret" variables that are used only once, Juan Quintela, 2023/10/17
- [PULL 22/38] migration/rdma: Remove qemu_ prefix from exported functions, Juan Quintela, 2023/10/17
- [PULL 29/38] multifd: fix counters in multifd_send_thread, Juan Quintela, 2023/10/17
- [PULL 31/38] migration/ram: Refactor precopy ram loading code, Juan Quintela, 2023/10/17
- [PULL 32/38] migration/ram: Remove RAMState from xbzrle_cache_zero_page, Juan Quintela, 2023/10/17
- [PULL 35/38] migration/ram: Merge save_zero_page functions,
Juan Quintela <=
- [PULL 34/38] migration/ram: Move xbzrle zero page handling into save_zero_page, Juan Quintela, 2023/10/17
- [PULL 36/38] migration/multifd: Remove direct "socket" references, Juan Quintela, 2023/10/17
- [PULL 33/38] migration/ram: Stop passing QEMUFile around in save_zero_page, Juan Quintela, 2023/10/17
- [PULL 30/38] multifd: reset next_packet_len after sending pages, Juan Quintela, 2023/10/17
- [PULL 37/38] migration/multifd: Unify multifd_send_thread error paths, Juan Quintela, 2023/10/17
- [PULL 38/38] migration/multifd: Clarify Error usage in multifd_channel_connect, Juan Quintela, 2023/10/17
- Re: [PULL 00/38] Migration 20231017 patches, Stefan Hajnoczi, 2023/10/17