mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 01:33:56 -06:00
migration: Make find_dirty_block() return a single parameter
We used to return two bools, just return a single int with the following meaning: old return / again / new return false false PAGE_ALL_CLEAN false true PAGE_TRY_AGAIN true true PAGE_DIRTY_FOUND /* We don't care about again at all */ Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
parent
51efd36faf
commit
31e2ac742b
1 changed files with 22 additions and 15 deletions
|
@ -1546,17 +1546,23 @@ retry:
|
||||||
return pages;
|
return pages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define PAGE_ALL_CLEAN 0
|
||||||
|
#define PAGE_TRY_AGAIN 1
|
||||||
|
#define PAGE_DIRTY_FOUND 2
|
||||||
/**
|
/**
|
||||||
* find_dirty_block: find the next dirty page and update any state
|
* find_dirty_block: find the next dirty page and update any state
|
||||||
* associated with the search process.
|
* associated with the search process.
|
||||||
*
|
*
|
||||||
* Returns true if a page is found
|
* Returns:
|
||||||
|
* PAGE_ALL_CLEAN: no dirty page found, give up
|
||||||
|
* PAGE_TRY_AGAIN: no dirty page found, retry for next block
|
||||||
|
* PAGE_DIRTY_FOUND: dirty page found
|
||||||
*
|
*
|
||||||
* @rs: current RAM state
|
* @rs: current RAM state
|
||||||
* @pss: data about the state of the current dirty page scan
|
* @pss: data about the state of the current dirty page scan
|
||||||
* @again: set to false if the search has scanned the whole of RAM
|
* @again: set to false if the search has scanned the whole of RAM
|
||||||
*/
|
*/
|
||||||
static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, bool *again)
|
static int find_dirty_block(RAMState *rs, PageSearchStatus *pss)
|
||||||
{
|
{
|
||||||
/* Update pss->page for the next dirty bit in ramblock */
|
/* Update pss->page for the next dirty bit in ramblock */
|
||||||
pss_find_next_dirty(pss);
|
pss_find_next_dirty(pss);
|
||||||
|
@ -1567,8 +1573,7 @@ static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, bool *again)
|
||||||
* We've been once around the RAM and haven't found anything.
|
* We've been once around the RAM and haven't found anything.
|
||||||
* Give up.
|
* Give up.
|
||||||
*/
|
*/
|
||||||
*again = false;
|
return PAGE_ALL_CLEAN;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (!offset_in_ramblock(pss->block,
|
if (!offset_in_ramblock(pss->block,
|
||||||
((ram_addr_t)pss->page) << TARGET_PAGE_BITS)) {
|
((ram_addr_t)pss->page) << TARGET_PAGE_BITS)) {
|
||||||
|
@ -1597,13 +1602,10 @@ static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, bool *again)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Didn't find anything this time, but try again on the new block */
|
/* Didn't find anything this time, but try again on the new block */
|
||||||
*again = true;
|
return PAGE_TRY_AGAIN;
|
||||||
return false;
|
|
||||||
} else {
|
} else {
|
||||||
/* Can go around again, but... */
|
/* We've found something */
|
||||||
*again = true;
|
return PAGE_DIRTY_FOUND;
|
||||||
/* We've found something so probably don't need to */
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2562,18 +2564,23 @@ static int ram_find_and_save_block(RAMState *rs)
|
||||||
|
|
||||||
pss_init(pss, rs->last_seen_block, rs->last_page);
|
pss_init(pss, rs->last_seen_block, rs->last_page);
|
||||||
|
|
||||||
do {
|
while (true){
|
||||||
if (!get_queued_page(rs, pss)) {
|
if (!get_queued_page(rs, pss)) {
|
||||||
/* priority queue empty, so just search for something dirty */
|
/* priority queue empty, so just search for something dirty */
|
||||||
bool again = true;
|
int res = find_dirty_block(rs, pss);
|
||||||
if (!find_dirty_block(rs, pss, &again)) {
|
if (res != PAGE_DIRTY_FOUND) {
|
||||||
if (!again) {
|
if (res == PAGE_ALL_CLEAN) {
|
||||||
break;
|
break;
|
||||||
|
} else if (res == PAGE_TRY_AGAIN) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pages = ram_save_host_page(rs, pss);
|
pages = ram_save_host_page(rs, pss);
|
||||||
} while (!pages);
|
if (pages) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rs->last_seen_block = pss->block;
|
rs->last_seen_block = pss->block;
|
||||||
rs->last_page = pss->page;
|
rs->last_page = pss->page;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue