[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 22/26] migration: Add Error** argument to xbzrle_init()
From: |
Peter Xu |
Subject: |
[PULL 22/26] migration: Add Error** argument to xbzrle_init() |
Date: |
Tue, 23 Apr 2024 18:38:09 -0400 |
From: Cédric Le Goater <clg@redhat.com>
Since the return value (-ENOMEM) is 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-14-clg@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
---
migration/ram.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/migration/ram.c b/migration/ram.c
index 26ce11a337..70797ef5d8 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2727,44 +2727,41 @@ int ram_discard_range(const char *rbname, uint64_t
start, size_t length)
* For every allocation, we will try not to crash the VM if the
* allocation failed.
*/
-static int xbzrle_init(void)
+static bool xbzrle_init(Error **errp)
{
- Error *local_err = NULL;
-
if (!migrate_xbzrle()) {
- return 0;
+ return true;
}
XBZRLE_cache_lock();
XBZRLE.zero_target_page = g_try_malloc0(TARGET_PAGE_SIZE);
if (!XBZRLE.zero_target_page) {
- error_report("%s: Error allocating zero page", __func__);
+ error_setg(errp, "%s: Error allocating zero page", __func__);
goto err_out;
}
XBZRLE.cache = cache_init(migrate_xbzrle_cache_size(),
- TARGET_PAGE_SIZE, &local_err);
+ TARGET_PAGE_SIZE, errp);
if (!XBZRLE.cache) {
- error_report_err(local_err);
goto free_zero_page;
}
XBZRLE.encoded_buf = g_try_malloc0(TARGET_PAGE_SIZE);
if (!XBZRLE.encoded_buf) {
- error_report("%s: Error allocating encoded_buf", __func__);
+ error_setg(errp, "%s: Error allocating encoded_buf", __func__);
goto free_cache;
}
XBZRLE.current_buf = g_try_malloc(TARGET_PAGE_SIZE);
if (!XBZRLE.current_buf) {
- error_report("%s: Error allocating current_buf", __func__);
+ error_setg(errp, "%s: Error allocating current_buf", __func__);
goto free_encoded_buf;
}
/* We are all good */
XBZRLE_cache_unlock();
- return 0;
+ return true;
free_encoded_buf:
g_free(XBZRLE.encoded_buf);
@@ -2777,7 +2774,7 @@ free_zero_page:
XBZRLE.zero_target_page = NULL;
err_out:
XBZRLE_cache_unlock();
- return -ENOMEM;
+ return false;
}
static bool ram_state_init(RAMState **rsp, Error **errp)
@@ -2904,7 +2901,8 @@ static int ram_init_all(RAMState **rsp)
return -1;
}
- if (xbzrle_init()) {
+ if (!xbzrle_init(&local_err)) {
+ error_report_err(local_err);
ram_state_cleanup(rsp);
return -1;
}
--
2.44.0
- [PULL 08/26] tests/qtest/migration: Add negative tests to validate migration QAPIs, (continued)
- [PULL 08/26] tests/qtest/migration: Add negative tests to validate migration QAPIs, Peter Xu, 2024/04/23
- [PULL 06/26] tests/qtest/migration: Add channels parameter in migrate_qmp, Peter Xu, 2024/04/23
- [PULL 17/26] migration: Add Error** argument to .load_setup() handler, Peter Xu, 2024/04/23
- [PULL 10/26] s390/stattrib: Add Error** argument to set_migrationmode() handler, Peter Xu, 2024/04/23
- [PULL 25/26] migration/multifd: solve zero page causing multiple page faults, Peter Xu, 2024/04/23
- [PULL 05/26] tests/qtest/migration: Add migrate_set_ports into migrate_qmp to update migration port value, Peter Xu, 2024/04/23
- [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 <=
- [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, 2024/04/23
- Re: [PULL 00/26] Migration 20240423 patches, Richard Henderson, 2024/04/24