Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
migration/rdma: Unfold hook_ram_load()
There is only one flag called with: RAM_CONTROL_BLOCK_REG.

Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20230509120700.78359-6-quintela@redhat.com>
  • Loading branch information
Juan Quintela committed May 30, 2023
1 parent 05aa178 commit 07bd317
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 43 deletions.
10 changes: 0 additions & 10 deletions migration/qemu-file.c
Expand Up @@ -303,16 +303,6 @@ void qemu_fflush(QEMUFile *f)
f->iovcnt = 0;
}

void ram_control_load_hook(QEMUFile *f, uint64_t flags, void *data)
{
if (f->hooks && f->hooks->hook_ram_load) {
int ret = f->hooks->hook_ram_load(f, flags, data);
if (ret < 0) {
qemu_file_set_error(f, ret);
}
}
}

int ram_control_save_page(QEMUFile *f, ram_addr_t block_offset,
ram_addr_t offset, size_t size)
{
Expand Down
11 changes: 0 additions & 11 deletions migration/qemu-file.h
Expand Up @@ -29,20 +29,12 @@
#include "exec/cpu-common.h"
#include "io/channel.h"

/*
* This function provides hooks around different
* stages of RAM migration.
* 'data' is call specific data associated with the 'flags' value
*/
typedef int (QEMURamHookFunc)(QEMUFile *f, uint64_t flags, void *data);

/*
* Constants used by ram_control_* hooks
*/
#define RAM_CONTROL_SETUP 0
#define RAM_CONTROL_ROUND 1
#define RAM_CONTROL_FINISH 3
#define RAM_CONTROL_BLOCK_REG 4

/*
* This function allows override of where the RAM page
Expand All @@ -54,7 +46,6 @@ typedef int (QEMURamSaveFunc)(QEMUFile *f,
size_t size);

typedef struct QEMUFileHooks {
QEMURamHookFunc *hook_ram_load;
QEMURamSaveFunc *save_page;
} QEMUFileHooks;

Expand Down Expand Up @@ -128,8 +119,6 @@ void qemu_fflush(QEMUFile *f);
void qemu_file_set_blocking(QEMUFile *f, bool block);
int qemu_file_get_to_fd(QEMUFile *f, int fd, size_t size);

void ram_control_load_hook(QEMUFile *f, uint64_t flags, void *data);

/* Whenever this is found in the data stream, the flags
* will be passed to ram_control_load_hook in the incoming-migration
* side. This lets before_ram_iterate/after_ram_iterate add
Expand Down
6 changes: 4 additions & 2 deletions migration/ram.c
Expand Up @@ -3975,8 +3975,10 @@ static int ram_load_precopy(QEMUFile *f)
ret = -EINVAL;
}
}
ram_control_load_hook(f, RAM_CONTROL_BLOCK_REG,
block->idstr);
ret = rdma_block_notification_handle(f, block->idstr);
if (ret < 0) {
qemu_file_set_error(f, ret);
}
} else {
error_report("Unknown ramblock \"%s\", cannot "
"accept migration", id);
Expand Down
29 changes: 9 additions & 20 deletions migration/rdma.c
Expand Up @@ -3811,20 +3811,22 @@ int qemu_rdma_registration_handle(QEMUFile *f)
}

/* Destination:
* Called via a ram_control_load_hook during the initial RAM load section which
* lists the RAMBlocks by name. This lets us know the order of the RAMBlocks
* on the source.
* We've already built our local RAMBlock list, but not yet sent the list to
* the source.
* Called during the initial RAM load section which lists the
* RAMBlocks by name. This lets us know the order of the RAMBlocks on
* the source. We've already built our local RAMBlock list, but not
* yet sent the list to the source.
*/
static int
rdma_block_notification_handle(QEMUFile *f, const char *name)
int rdma_block_notification_handle(QEMUFile *f, const char *name)
{
RDMAContext *rdma;
QIOChannelRDMA *rioc = QIO_CHANNEL_RDMA(qemu_file_get_ioc(f));
int curr;
int found = -1;

if (!migrate_rdma()) {
return 0;
}

RCU_READ_LOCK_GUARD();
rdma = qatomic_rcu_read(&rioc->rdmain);

Expand Down Expand Up @@ -3852,18 +3854,6 @@ rdma_block_notification_handle(QEMUFile *f, const char *name)
return 0;
}

static int rdma_load_hook(QEMUFile *f, uint64_t flags, void *data)
{
switch (flags) {
case RAM_CONTROL_BLOCK_REG:
return rdma_block_notification_handle(f, data);

default:
/* Shouldn't be called with any other values */
abort();
}
}

int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags)
{
QIOChannelRDMA *rioc = QIO_CHANNEL_RDMA(qemu_file_get_ioc(f));
Expand Down Expand Up @@ -4002,7 +3992,6 @@ int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags)
}

static const QEMUFileHooks rdma_read_hooks = {
.hook_ram_load = rdma_load_hook,
};

static const QEMUFileHooks rdma_write_hooks = {
Expand Down
2 changes: 2 additions & 0 deletions migration/rdma.h
Expand Up @@ -27,9 +27,11 @@ void rdma_start_incoming_migration(const char *host_port, Error **errp);
int qemu_rdma_registration_handle(QEMUFile *f);
int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags);
int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags);
int rdma_block_notification_handle(QEMUFile *f, const char *name);
#else
int qemu_rdma_registration_handle(QEMUFile *f) { return 0; }
int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags) { return 0; }
int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags) { return 0; }
int rdma_block_notification_handle(QEMUFile *f, const char *name) { return 0; }
#endif
#endif

0 comments on commit 07bd317

Please sign in to comment.