mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
migration: Change ram_dirty_bitmap_reload() retval to bool
Now we have a Error** passed into the return path thread stack, which is even clearer than an int retval. Change ram_dirty_bitmap_reload() and the callers to use a bool instead to replace errnos. Suggested-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Peter Xu <peterx@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com> Message-ID: <20231017202633.296756-5-peterx@redhat.com>
This commit is contained in:
parent
7bca2bb7bf
commit
88577f3242
3 changed files with 22 additions and 22 deletions
|
@ -4113,10 +4113,11 @@ static int ram_dirty_bitmap_sync_all(MigrationState *s, RAMState *rs)
|
|||
* Read the received bitmap, revert it as the initial dirty bitmap.
|
||||
* This is only used when the postcopy migration is paused but wants
|
||||
* to resume from a middle point.
|
||||
*
|
||||
* Returns true if succeeded, false for errors.
|
||||
*/
|
||||
int ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *block, Error **errp)
|
||||
bool ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *block, Error **errp)
|
||||
{
|
||||
int ret = -EINVAL;
|
||||
/* from_dst_file is always valid because we're within rp_thread */
|
||||
QEMUFile *file = s->rp_state.from_dst_file;
|
||||
g_autofree unsigned long *le_bitmap = NULL;
|
||||
|
@ -4130,7 +4131,7 @@ int ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *block, Error **errp)
|
|||
if (s->state != MIGRATION_STATUS_POSTCOPY_RECOVER) {
|
||||
error_setg(errp, "Reload bitmap in incorrect state %s",
|
||||
MigrationStatus_str(s->state));
|
||||
return -EINVAL;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -4148,24 +4149,23 @@ int ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *block, Error **errp)
|
|||
if (size != local_size) {
|
||||
error_setg(errp, "ramblock '%s' bitmap size mismatch (0x%"PRIx64
|
||||
" != 0x%"PRIx64")", block->idstr, size, local_size);
|
||||
return -EINVAL;
|
||||
return false;
|
||||
}
|
||||
|
||||
size = qemu_get_buffer(file, (uint8_t *)le_bitmap, local_size);
|
||||
end_mark = qemu_get_be64(file);
|
||||
|
||||
ret = qemu_file_get_error(file);
|
||||
if (ret || size != local_size) {
|
||||
error_setg(errp, "read bitmap failed for ramblock '%s': %d"
|
||||
" (size 0x%"PRIx64", got: 0x%"PRIx64")",
|
||||
block->idstr, ret, local_size, size);
|
||||
return -EIO;
|
||||
if (qemu_file_get_error(file) || size != local_size) {
|
||||
error_setg(errp, "read bitmap failed for ramblock '%s': "
|
||||
"(size 0x%"PRIx64", got: 0x%"PRIx64")",
|
||||
block->idstr, local_size, size);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (end_mark != RAMBLOCK_RECV_BITMAP_ENDING) {
|
||||
error_setg(errp, "ramblock '%s' end mark incorrect: 0x%"PRIx64,
|
||||
block->idstr, end_mark);
|
||||
return -EINVAL;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -4197,7 +4197,7 @@ int ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *block, Error **errp)
|
|||
*/
|
||||
migration_rp_kick(s);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int ram_resume_prepare(MigrationState *s, void *opaque)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue