Skip to content

Commit

Permalink
migration/multifd: Change retval of multifd_queue_page()
Browse files Browse the repository at this point in the history
Using int is an overkill when there're only two options.  Change it to a
boolean.

Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20240202102857.110210-17-peterx@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
  • Loading branch information
xzpeter committed Feb 5, 2024
1 parent 3ab4441 commit d6556d1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions migration/multifd.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,8 @@ static int multifd_send_pages(void)
return 1;
}

int multifd_queue_page(RAMBlock *block, ram_addr_t offset)
/* Returns true if enqueue successful, false otherwise */
bool multifd_queue_page(RAMBlock *block, ram_addr_t offset)
{
MultiFDPages_t *pages = multifd_send_state->pages;
bool changed = false;
Expand All @@ -519,21 +520,21 @@ int multifd_queue_page(RAMBlock *block, ram_addr_t offset)
pages->num++;

if (pages->num < pages->allocated) {
return 1;
return true;
}
} else {
changed = true;
}

if (multifd_send_pages() < 0) {
return -1;
return false;
}

if (changed) {
return multifd_queue_page(block, offset);
}

return 1;
return true;
}

/* Multifd send side hit an error; remember it and prepare to quit */
Expand Down
2 changes: 1 addition & 1 deletion migration/multifd.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ bool multifd_recv_all_channels_created(void);
void multifd_recv_new_channel(QIOChannel *ioc, Error **errp);
void multifd_recv_sync_main(void);
int multifd_send_sync_main(void);
int multifd_queue_page(RAMBlock *block, ram_addr_t offset);
bool multifd_queue_page(RAMBlock *block, ram_addr_t offset);

/* Multifd Compression flags */
#define MULTIFD_FLAG_SYNC (1 << 0)
Expand Down
2 changes: 1 addition & 1 deletion migration/ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ static int ram_save_page(RAMState *rs, PageSearchStatus *pss)

static int ram_save_multifd_page(RAMBlock *block, ram_addr_t offset)
{
if (multifd_queue_page(block, offset) < 0) {
if (!multifd_queue_page(block, offset)) {
return -1;
}
stat64_add(&mig_stats.normal_pages, 1);
Expand Down

0 comments on commit d6556d1

Please sign in to comment.