From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: Li Zhijian <lizhijian@fujitsu.com>,
Samuel Zhang <guoqing.zhang@amd.com>,
Fabiano Rosas <farosas@suse.de>,
peterx@redhat.com, Jack Wang <jinpu.wang@ionos.com>,
Juraj Marcin <jmarcin@redhat.com>,
Yanfei Xu <yanfei.xu@bytedance.com>
Subject: [PATCH 04/10] migration/rdma: Drop RDMALocalBlock.is_ram_block
Date: Mon, 17 Aug 2026 16:24:18 -0400 [thread overview]
Message-ID: <20260817202424.2901438-5-peterx@redhat.com> (raw)
In-Reply-To: <20260817202424.2901438-1-peterx@redhat.com>
This is guaranteed to be true. There seems to have support for some
dynamically allocated buffers but it was never really supported. Remove
dead code.
As a side effect, this patch closes a report by removing the buggy code
completely.
Reported-by: Tristan (@TristanInSec)
Closes: https://gitlab.com/qemu-project/qemu/-/work_items/4006
Signed-off-by: Peter Xu <peterx@redhat.com>
---
migration/rdma.c | 73 ++++++++++++++----------------------------------
1 file changed, 21 insertions(+), 52 deletions(-)
diff --git a/migration/rdma.c b/migration/rdma.c
index ffae0a887f..354935433c 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -196,7 +196,6 @@ typedef struct RDMALocalBlock {
uint32_t remote_rkey; /* rkeys for non-chunk-level registration */
int index; /* which block are we */
unsigned int src_index; /* (Only used on dest) */
- bool is_ram_block;
int nb_chunks;
unsigned long *transit_bitmap;
unsigned long *unregister_bitmap;
@@ -441,14 +440,12 @@ static void register_to_network(RDMAContext *rdma, RDMARegister *reg)
RDMALocalBlock *local_block;
local_block = &rdma->local_ram_blocks.block[reg->current_index];
- if (local_block->is_ram_block) {
- /*
- * current_addr as passed in is an address in the local ram_addr_t
- * space, we need to translate this for the destination
- */
- reg->key.current_addr -= local_block->offset;
- reg->key.current_addr += rdma->dest_blocks[reg->current_index].offset;
- }
+ /*
+ * current_addr as passed in is an address in the local ram_addr_t
+ * space, we need to translate this for the destination
+ */
+ reg->key.current_addr -= local_block->offset;
+ reg->key.current_addr += rdma->dest_blocks[reg->current_index].offset;
reg->key.current_addr = htonll(reg->key.current_addr);
reg->current_index = htonl(reg->current_index);
reg->chunks = htonll(reg->chunks);
@@ -585,8 +582,6 @@ static void rdma_add_block(RDMAContext *rdma, const char *block_name,
bitmap_clear(block->unregister_bitmap, 0, block->nb_chunks);
block->remote_keys = g_new0(uint32_t, block->nb_chunks);
- block->is_ram_block = local->init ? false : true;
-
if (rdma->blockmap) {
g_hash_table_insert(rdma->blockmap, (void *)(uintptr_t)block_offset, block);
}
@@ -1767,19 +1762,10 @@ retry:
chunk = ram_chunk_index(block->local_host_addr,
(uint8_t *)(uintptr_t)sge.addr);
chunk_start = ram_chunk_start(block, chunk);
+ chunks = length / chunk_size;
- if (block->is_ram_block) {
- chunks = length / chunk_size;
-
- if (chunks && ((length % chunk_size) == 0)) {
- chunks--;
- }
- } else {
- chunks = block->length / chunk_size;
-
- if (chunks && ((block->length % chunk_size) == 0)) {
- chunks--;
- }
+ if (chunks && ((length % chunk_size) == 0)) {
+ chunks--;
}
trace_rdma_write_one_top(chunks + 1,
@@ -1804,7 +1790,7 @@ retry:
}
}
- if (!rdma->pin_all || !block->is_ram_block) {
+ if (!rdma->pin_all) {
if (!block->remote_keys[chunk]) {
/*
* This chunk has not yet been registered, so first check to see
@@ -1853,11 +1839,7 @@ retry:
* Otherwise, tell other side to register.
*/
reg.current_index = current_index;
- if (block->is_ram_block) {
- reg.key.current_addr = current_addr;
- } else {
- reg.key.chunk = chunk;
- }
+ reg.key.current_addr = current_addr;
reg.chunks = chunks;
trace_rdma_write_one_sendreg(chunk, sge.length, current_index,
@@ -3408,30 +3390,17 @@ int rdma_registration_handle(QEMUFile *f)
goto err;
}
block = &(rdma->local_ram_blocks.block[reg->current_index]);
- if (block->is_ram_block) {
- if (block->offset > reg->key.current_addr) {
- error_report("rdma: bad register address for block %s"
- " offset: %" PRIx64 " current_addr: %" PRIx64,
- block->block_name, block->offset,
- reg->key.current_addr);
- goto err;
- }
- host_addr = (block->local_host_addr +
- (reg->key.current_addr - block->offset));
- chunk = ram_chunk_index(block->local_host_addr,
- (uint8_t *) host_addr);
- } else {
- chunk = reg->key.chunk;
- host_addr = block->local_host_addr +
- (reg->key.chunk * migrate_rdma_chunk_size());
- /* Check for particularly bad chunk value */
- if (host_addr < (void *)block->local_host_addr) {
- error_report("rdma: bad chunk for block %s"
- " chunk: %" PRIx64,
- block->block_name, reg->key.chunk);
- goto err;
- }
+ if (block->offset > reg->key.current_addr) {
+ error_report("rdma: bad register address for block %s"
+ " offset: %" PRIx64 " current_addr: %" PRIx64,
+ block->block_name, block->offset,
+ reg->key.current_addr);
+ goto err;
}
+ host_addr = (block->local_host_addr +
+ (reg->key.current_addr - block->offset));
+ chunk = ram_chunk_index(block->local_host_addr,
+ (uint8_t *) host_addr);
chunk_start = ram_chunk_start(block, chunk);
chunk_end = ram_chunk_end(block, chunk + reg->chunks);
/* avoid "-Waddress-of-packed-member" warning */
--
2.54.0
next prev parent reply other threads:[~2026-08-17 20:26 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-17 20:24 [PATCH 00/10] migration/rdma: Fixes or drops Peter Xu
2026-08-17 20:24 ` [PATCH 01/10] migration/rdma: Introduce RDMA_CONTROL_NUM Peter Xu
2026-08-19 10:35 ` Jinpu Wang
2026-08-17 20:24 ` [PATCH 02/10] migration/rdma: Remove unregister code Peter Xu
2026-08-18 11:57 ` Yanfei Xu
2026-08-18 13:01 ` Peter Xu
2026-08-18 13:57 ` Yanfei Xu
2026-08-18 14:43 ` Peter Xu
2026-08-19 3:55 ` Yanfei Xu
2026-08-19 10:52 ` Jinpu Wang
2026-08-19 12:01 ` Jinpu Wang
2026-08-19 12:47 ` Peter Xu
2026-08-19 13:20 ` Jinpu Wang
2026-08-17 20:24 ` [PATCH 03/10] migration/rdma: Stick with rdma_ prefix for all tracepoints Peter Xu
2026-08-19 11:39 ` Jinpu Wang
2026-08-17 20:24 ` Peter Xu [this message]
2026-08-19 12:43 ` [PATCH 04/10] migration/rdma: Drop RDMALocalBlock.is_ram_block Jinpu Wang
2026-08-19 14:49 ` Peter Xu
2026-08-17 20:24 ` [PATCH 05/10] migration/rdma: Drop RDMALocalBlock.unregister_bitmap Peter Xu
2026-08-19 12:44 ` Jinpu Wang
2026-08-17 20:24 ` [PATCH 06/10] migration/rdma: Drop RDMARegister.key.chunk Peter Xu
2026-08-19 12:48 ` Jinpu Wang
2026-08-17 20:24 ` [PATCH 07/10] migration/rdma: Sanity check RDMA_CONTROL_REGISTER_REQUEST on buflen Peter Xu
2026-08-19 12:52 ` Jinpu Wang
2026-08-17 20:24 ` [PATCH 08/10] migration/rdma: Sanity check RDMA_CONTROL_REGISTER_REQUEST chunks Peter Xu
2026-08-19 13:00 ` Jinpu Wang
2026-08-17 20:24 ` [PATCH 09/10] migration/rdma: Sanity check upper bound of register MR address Peter Xu
2026-08-19 13:09 ` Jinpu Wang
2026-08-17 20:24 ` [PATCH 10/10] migration/rdma: Sanity check compress request ranges Peter Xu
2026-08-19 13:10 ` Jinpu Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260817202424.2901438-5-peterx@redhat.com \
--to=peterx@redhat.com \
--cc=farosas@suse.de \
--cc=guoqing.zhang@amd.com \
--cc=jinpu.wang@ionos.com \
--cc=jmarcin@redhat.com \
--cc=lizhijian@fujitsu.com \
--cc=qemu-devel@nongnu.org \
--cc=yanfei.xu@bytedance.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.