[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 05/27] Translate offsets to destination address space
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PULL 05/27] Translate offsets to destination address space |
Date: |
Thu, 2 Jul 2015 18:09:53 +0200 |
From: "Dr. David Alan Gilbert" <address@hidden>
The 'offset' field in RDMACompress and 'current_addr' field
in RDMARegister are commented as being offsets within a particular
RAMBlock, however they appear to actually be offsets within the
ram_addr_t space.
The code currently assumes that the offsets on the source/destination
match, this change removes the need for the assumption for these
structures by translating the addresses into the ram_addr_t space of
the destination host.
Note: An alternative would be to change the fields to actually
take the data they're commented for; this would potentially be
simpler but would break stream compatibility for those cases
that currently work.
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
Signed-off-by: Juan Quintela <address@hidden>
---
migration/rdma.c | 31 ++++++++++++++++++++++++-------
1 file changed, 24 insertions(+), 7 deletions(-)
diff --git a/migration/rdma.c b/migration/rdma.c
index 6fa9601..d489012 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -412,7 +412,7 @@ static void network_to_control(RDMAControlHeader *control)
*/
typedef struct QEMU_PACKED {
union QEMU_PACKED {
- uint64_t current_addr; /* offset into the ramblock of the chunk */
+ uint64_t current_addr; /* offset into the ram_addr_t space */
uint64_t chunk; /* chunk to lookup if unregistering */
} key;
uint32_t current_index; /* which ramblock the chunk belongs to */
@@ -420,8 +420,19 @@ typedef struct QEMU_PACKED {
uint64_t chunks; /* how many sequential chunks to register */
} RDMARegister;
-static void register_to_network(RDMARegister *reg)
+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;
+ }
reg->key.current_addr = htonll(reg->key.current_addr);
reg->current_index = htonl(reg->current_index);
reg->chunks = htonll(reg->chunks);
@@ -437,13 +448,19 @@ static void network_to_register(RDMARegister *reg)
typedef struct QEMU_PACKED {
uint32_t value; /* if zero, we will madvise() */
uint32_t block_idx; /* which ram block index */
- uint64_t offset; /* where in the remote ramblock this chunk */
+ uint64_t offset; /* Address in remote ram_addr_t space */
uint64_t length; /* length of the chunk */
} RDMACompress;
-static void compress_to_network(RDMACompress *comp)
+static void compress_to_network(RDMAContext *rdma, RDMACompress *comp)
{
comp->value = htonl(comp->value);
+ /*
+ * comp->offset as passed in is an address in the local ram_addr_t
+ * space, we need to translate this for the destination
+ */
+ comp->offset -= rdma->local_ram_blocks.block[comp->block_idx].offset;
+ comp->offset += rdma->dest_blocks[comp->block_idx].offset;
comp->block_idx = htonl(comp->block_idx);
comp->offset = htonll(comp->offset);
comp->length = htonll(comp->length);
@@ -1296,7 +1313,7 @@ static int qemu_rdma_unregister_waiting(RDMAContext *rdma)
rdma->total_registrations--;
reg.key.chunk = chunk;
- register_to_network(®);
+ register_to_network(rdma, ®);
ret = qemu_rdma_exchange_send(rdma, &head, (uint8_t *) ®,
&resp, NULL, NULL);
if (ret < 0) {
@@ -1917,7 +1934,7 @@ retry:
trace_qemu_rdma_write_one_zero(chunk, sge.length,
current_index, current_addr);
- compress_to_network(&comp);
+ compress_to_network(rdma, &comp);
ret = qemu_rdma_exchange_send(rdma, &head,
(uint8_t *) &comp, NULL, NULL, NULL);
@@ -1944,7 +1961,7 @@ retry:
trace_qemu_rdma_write_one_sendreg(chunk, sge.length, current_index,
current_addr);
- register_to_network(®);
+ register_to_network(rdma, ®);
ret = qemu_rdma_exchange_send(rdma, &head, (uint8_t *) ®,
&resp, ®_result_idx, NULL);
if (ret < 0) {
--
2.4.3
- [Qemu-devel] [PULL v2 00/27] Migration pull request, Juan Quintela, 2015/07/02
- [Qemu-devel] [PULL 01/27] rdma: fix memory leak, Juan Quintela, 2015/07/02
- [Qemu-devel] [PULL 02/27] Only try and read a VMDescription if it should be there, Juan Quintela, 2015/07/02
- [Qemu-devel] [PULL 03/27] rdma typos, Juan Quintela, 2015/07/02
- [Qemu-devel] [PULL 04/27] Store block name in local blocks structure, Juan Quintela, 2015/07/02
- [Qemu-devel] [PULL 07/27] Allow rdma_delete_block to work without the hash, Juan Quintela, 2015/07/02
- [Qemu-devel] [PULL 06/27] Rework ram_control_load_hook to hook during block load, Juan Quintela, 2015/07/02
- [Qemu-devel] [PULL 08/27] Rework ram block hash, Juan Quintela, 2015/07/02
- [Qemu-devel] [PULL 05/27] Translate offsets to destination address space,
Juan Quintela <=
- [Qemu-devel] [PULL 10/27] Sanity check RDMA remote data, Juan Quintela, 2015/07/02
- [Qemu-devel] [PULL 09/27] Sort destination RAMBlocks to be the same as the source, Juan Quintela, 2015/07/02
- [Qemu-devel] [PULL 11/27] Fail more cleanly in mismatched RAM cases, Juan Quintela, 2015/07/02
- [Qemu-devel] [PULL 12/27] Fix older machine type compatibility on power with section footers, Juan Quintela, 2015/07/02
- [Qemu-devel] [PULL 13/27] runstate: Add runstate store, Juan Quintela, 2015/07/02
- [Qemu-devel] [PULL 14/27] runstate: migration allows more transitions now, Juan Quintela, 2015/07/02
- [Qemu-devel] [PULL 15/27] migration: create new section to store global state, Juan Quintela, 2015/07/02
- [Qemu-devel] [PULL 16/27] global_state: Make section optional, Juan Quintela, 2015/07/02
- [Qemu-devel] [PULL 17/27] vmstate: Create optional sections, Juan Quintela, 2015/07/02
- [Qemu-devel] [PULL 20/27] migration: ensure we start in NONE state, Juan Quintela, 2015/07/02