[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 21/26] migration: Add Error** argument to ram_state_init()
From: |
Peter Xu |
Subject: |
[PULL 21/26] migration: Add Error** argument to ram_state_init() |
Date: |
Tue, 23 Apr 2024 18:38:08 -0400 |
From: Cédric Le Goater <clg@redhat.com>
Since the return value not exploited, follow the recommendations of
qapi/error.h and change it to a bool
Signed-off-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20240320064911.545001-13-clg@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
---
migration/ram.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/migration/ram.c b/migration/ram.c
index bade3e9281..26ce11a337 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2780,13 +2780,13 @@ err_out:
return -ENOMEM;
}
-static int ram_state_init(RAMState **rsp)
+static bool ram_state_init(RAMState **rsp, Error **errp)
{
*rsp = g_try_new0(RAMState, 1);
if (!*rsp) {
- error_report("%s: Init ramstate fail", __func__);
- return -1;
+ error_setg(errp, "%s: Init ramstate fail", __func__);
+ return false;
}
qemu_mutex_init(&(*rsp)->bitmap_mutex);
@@ -2802,7 +2802,7 @@ static int ram_state_init(RAMState **rsp)
(*rsp)->migration_dirty_pages = (*rsp)->ram_bytes_total >>
TARGET_PAGE_BITS;
ram_state_reset(*rsp);
- return 0;
+ return true;
}
static void ram_list_init_bitmaps(void)
@@ -2897,7 +2897,10 @@ out_unlock:
static int ram_init_all(RAMState **rsp)
{
- if (ram_state_init(rsp)) {
+ Error *local_err = NULL;
+
+ if (!ram_state_init(rsp, &local_err)) {
+ error_report_err(local_err);
return -1;
}
@@ -3624,7 +3627,11 @@ void ram_handle_zero(void *host, uint64_t size)
static void colo_init_ram_state(void)
{
- ram_state_init(&ram_state);
+ Error *local_err = NULL;
+
+ if (!ram_state_init(&ram_state, &local_err)) {
+ error_report_err(local_err);
+ }
}
/*
--
2.44.0
- [PULL 12/26] migration: Always report an error in block_save_setup(), (continued)
- [PULL 12/26] migration: Always report an error in block_save_setup(), Peter Xu, 2024/04/23
- [PULL 14/26] migration: Add Error** argument to vmstate_save(), Peter Xu, 2024/04/23
- [PULL 09/26] tests/qtest/migration: Fix typo for vsock in SocketAddress_to_str, Peter Xu, 2024/04/23
- [PULL 11/26] vfio: Always report an error in vfio_save_setup(), Peter Xu, 2024/04/23
- [PULL 22/26] migration: Add Error** argument to xbzrle_init(), Peter Xu, 2024/04/23
- [PULL 03/26] tests/qtest/migration: Replace migrate_get_connect_uri inplace of migrate_get_socket_address, Peter Xu, 2024/04/23
- [PULL 15/26] migration: Add Error** argument to qemu_savevm_state_setup(), Peter Xu, 2024/04/23
- [PULL 18/26] memory: Add Error** argument to .log_global_start() handler, Peter Xu, 2024/04/23
- [PULL 23/26] migration: Modify ram_init_bitmaps() to report dirty tracking errors, Peter Xu, 2024/04/23
- [PULL 20/26] memory: Add Error** argument to the global_dirty_log routines, Peter Xu, 2024/04/23
- [PULL 21/26] migration: Add Error** argument to ram_state_init(),
Peter Xu <=
- Re: [PULL 00/26] Migration 20240423 patches, Richard Henderson, 2024/04/24