[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 26/65] migration/rdma: Replace dangerous macro CHECK_ERROR_STATE()
|
From: |
Juan Quintela |
|
Subject: |
[PULL 26/65] migration/rdma: Replace dangerous macro CHECK_ERROR_STATE() |
|
Date: |
Wed, 11 Oct 2023 11:21:24 +0200 |
From: Markus Armbruster <armbru@redhat.com>
Hiding return statements in macros is a bad idea. Use a function
instead, and open code the return part.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Li Zhijian <lizhijian@fujitsu.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-ID: <20230928132019.2544702-20-armbru@redhat.com>
---
migration/rdma.c | 43 +++++++++++++++++++++++++++----------------
1 file changed, 27 insertions(+), 16 deletions(-)
diff --git a/migration/rdma.c b/migration/rdma.c
index 18be228e3b..30e2c817f2 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -85,18 +85,6 @@
*/
static uint32_t known_capabilities = RDMA_CAPABILITY_PIN_ALL;
-#define CHECK_ERROR_STATE() \
- do { \
- if (rdma->error_state) { \
- if (!rdma->error_reported) { \
- error_report("RDMA is in an error state waiting migration" \
- " to abort!"); \
- rdma->error_reported = true; \
- } \
- return rdma->error_state; \
- } \
- } while (0)
-
/*
* A work request ID is 64-bits and we split up these bits
* into 3 parts:
@@ -451,6 +439,16 @@ typedef struct QEMU_PACKED {
uint64_t chunks; /* how many sequential chunks to register */
} RDMARegister;
+static int check_error_state(RDMAContext *rdma)
+{
+ if (rdma->error_state && !rdma->error_reported) {
+ error_report("RDMA is in an error state waiting migration"
+ " to abort!");
+ rdma->error_reported = true;
+ }
+ return rdma->error_state;
+}
+
static void register_to_network(RDMAContext *rdma, RDMARegister *reg)
{
RDMALocalBlock *local_block;
@@ -3268,7 +3266,10 @@ static int qemu_rdma_save_page(QEMUFile *f, ram_addr_t
block_offset,
return -EIO;
}
- CHECK_ERROR_STATE();
+ ret = check_error_state(rdma);
+ if (ret) {
+ return ret;
+ }
qemu_fflush(f);
@@ -3574,7 +3575,10 @@ static int qemu_rdma_registration_handle(QEMUFile *f)
return -EIO;
}
- CHECK_ERROR_STATE();
+ ret = check_error_state(rdma);
+ if (ret) {
+ return ret;
+ }
local = &rdma->local_ram_blocks;
do {
@@ -3878,6 +3882,7 @@ static int qemu_rdma_registration_start(QEMUFile *f,
{
QIOChannelRDMA *rioc = QIO_CHANNEL_RDMA(qemu_file_get_ioc(f));
RDMAContext *rdma;
+ int ret;
if (migration_in_postcopy()) {
return 0;
@@ -3889,7 +3894,10 @@ static int qemu_rdma_registration_start(QEMUFile *f,
return -EIO;
}
- CHECK_ERROR_STATE();
+ ret = check_error_state(rdma);
+ if (ret) {
+ return ret;
+ }
trace_qemu_rdma_registration_start(flags);
qemu_put_be64(f, RAM_SAVE_FLAG_HOOK);
@@ -3920,7 +3928,10 @@ static int qemu_rdma_registration_stop(QEMUFile *f,
return -EIO;
}
- CHECK_ERROR_STATE();
+ ret = check_error_state(rdma);
+ if (ret) {
+ return ret;
+ }
qemu_fflush(f);
ret = qemu_rdma_drain_cq(rdma);
--
2.41.0
- [PULL 28/65] migration/rdma: Fix qemu_get_cm_event_timeout() to always set error, (continued)
- [PULL 28/65] migration/rdma: Fix qemu_get_cm_event_timeout() to always set error, Juan Quintela, 2023/10/11
- [PULL 23/65] migration/rdma: Fix or document problematic uses of errno, Juan Quintela, 2023/10/11
- [PULL 24/65] migration/rdma: Ditch useless numeric error codes in error messages, Juan Quintela, 2023/10/11
- [PULL 31/65] migration/rdma: Fix rdma_getaddrinfo() error checking, Juan Quintela, 2023/10/11
- [PULL 34/65] migration/rdma: Replace int error_state by bool errored, Juan Quintela, 2023/10/11
- [PULL 33/65] migration/rdma: Dumb down remaining int error values to -1, Juan Quintela, 2023/10/11
- [PULL 22/65] migration/rdma: Use bool for two RDMAContext flags, Juan Quintela, 2023/10/11
- [PULL 25/65] migration/rdma: Fix io_writev(), io_readv() methods to obey contract, Juan Quintela, 2023/10/11
- [PULL 29/65] migration/rdma: Drop dead qemu_rdma_data_init() code for !@host_port, Juan Quintela, 2023/10/11
- [PULL 30/65] migration/rdma: Fix QEMUFileHooks method return values, Juan Quintela, 2023/10/11
- [PULL 26/65] migration/rdma: Replace dangerous macro CHECK_ERROR_STATE(),
Juan Quintela <=
- [PULL 32/65] migration/rdma: Return -1 instead of negative errno code, Juan Quintela, 2023/10/11
- [PULL 27/65] migration/rdma: Fix qemu_rdma_broken_ipv6_kernel() to set error, Juan Quintela, 2023/10/11
- [PULL 37/65] migration/rdma: Plug a memory leak and improve a message, Juan Quintela, 2023/10/11
- [PULL 36/65] migration/rdma: Check negative error values the same way everywhere, Juan Quintela, 2023/10/11
- [PULL 35/65] migration/rdma: Drop superfluous assignments to @ret, Juan Quintela, 2023/10/11
- [PULL 38/65] migration/rdma: Delete inappropriate error_report() in macro ERROR(), Juan Quintela, 2023/10/11
- [PULL 41/65] migration/rdma: Drop "@errp is clear" guards around error_setg(), Juan Quintela, 2023/10/11
- [PULL 43/65] migration/rdma: Convert qemu_rdma_exchange_send() to Error, Juan Quintela, 2023/10/11
- [PULL 39/65] migration/rdma: Retire macro ERROR(), Juan Quintela, 2023/10/11
- [PULL 44/65] migration/rdma: Convert qemu_rdma_exchange_get_response() to Error, Juan Quintela, 2023/10/11