mirror of https://github.com/proxmox/mirror_qemu
migration/rdma: Unfold hook_ram_load()
There is only one flag called with: RAM_CONTROL_BLOCK_REG. Reviewed-by: Li Zhijian <lizhijian@fujitsu.com> Signed-off-by: Juan Quintela <quintela@redhat.com> Message-ID: <20231011203527.9061-6-quintela@redhat.com>master
parent
f6d6c089b7
commit
a6323300e8
|
@ -298,16 +298,6 @@ void qemu_fflush(QEMUFile *f)
|
||||||
f->iovcnt = 0;
|
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,
|
int ram_control_save_page(QEMUFile *f, ram_addr_t block_offset,
|
||||||
ram_addr_t offset, size_t size)
|
ram_addr_t offset, size_t size)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,20 +29,12 @@
|
||||||
#include "exec/cpu-common.h"
|
#include "exec/cpu-common.h"
|
||||||
#include "io/channel.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
|
* Constants used by ram_control_* hooks
|
||||||
*/
|
*/
|
||||||
#define RAM_CONTROL_SETUP 0
|
#define RAM_CONTROL_SETUP 0
|
||||||
#define RAM_CONTROL_ROUND 1
|
#define RAM_CONTROL_ROUND 1
|
||||||
#define RAM_CONTROL_FINISH 3
|
#define RAM_CONTROL_FINISH 3
|
||||||
#define RAM_CONTROL_BLOCK_REG 4
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function allows override of where the RAM page
|
* This function allows override of where the RAM page
|
||||||
|
@ -54,7 +46,6 @@ typedef int (QEMURamSaveFunc)(QEMUFile *f,
|
||||||
size_t size);
|
size_t size);
|
||||||
|
|
||||||
typedef struct QEMUFileHooks {
|
typedef struct QEMUFileHooks {
|
||||||
QEMURamHookFunc *hook_ram_load;
|
|
||||||
QEMURamSaveFunc *save_page;
|
QEMURamSaveFunc *save_page;
|
||||||
} QEMUFileHooks;
|
} QEMUFileHooks;
|
||||||
|
|
||||||
|
@ -124,8 +115,6 @@ void qemu_fflush(QEMUFile *f);
|
||||||
void qemu_file_set_blocking(QEMUFile *f, bool block);
|
void qemu_file_set_blocking(QEMUFile *f, bool block);
|
||||||
int qemu_file_get_to_fd(QEMUFile *f, int fd, size_t size);
|
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
|
/* Whenever this is found in the data stream, the flags
|
||||||
* will be passed to ram_control_load_hook in the incoming-migration
|
* will be passed to ram_control_load_hook in the incoming-migration
|
||||||
* side. This lets before_ram_iterate/after_ram_iterate add
|
* side. This lets before_ram_iterate/after_ram_iterate add
|
||||||
|
|
|
@ -4025,8 +4025,10 @@ static int ram_load_precopy(QEMUFile *f)
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ram_control_load_hook(f, RAM_CONTROL_BLOCK_REG,
|
ret = rdma_block_notification_handle(f, block->idstr);
|
||||||
block->idstr);
|
if (ret < 0) {
|
||||||
|
qemu_file_set_error(f, ret);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
error_report("Unknown ramblock \"%s\", cannot "
|
error_report("Unknown ramblock \"%s\", cannot "
|
||||||
"accept migration", id);
|
"accept migration", id);
|
||||||
|
|
|
@ -3799,22 +3799,23 @@ err:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Destination:
|
/* Destination:
|
||||||
* Called via a ram_control_load_hook during the initial RAM load section which
|
* Called during the initial RAM load section which lists the
|
||||||
* lists the RAMBlocks by name. This lets us know the order of the RAMBlocks
|
* RAMBlocks by name. This lets us know the order of the RAMBlocks on
|
||||||
* on the source.
|
* the source. We've already built our local RAMBlock list, but not
|
||||||
* We've already built our local RAMBlock list, but not yet sent the list to
|
* yet sent the list to the source.
|
||||||
* the source.
|
|
||||||
*/
|
*/
|
||||||
static int
|
int rdma_block_notification_handle(QEMUFile *f, const char *name)
|
||||||
rdma_block_notification_handle(QEMUFile *f, const char *name)
|
|
||||||
{
|
{
|
||||||
RDMAContext *rdma;
|
|
||||||
QIOChannelRDMA *rioc = QIO_CHANNEL_RDMA(qemu_file_get_ioc(f));
|
|
||||||
int curr;
|
int curr;
|
||||||
int found = -1;
|
int found = -1;
|
||||||
|
|
||||||
|
if (!migrate_rdma()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
RCU_READ_LOCK_GUARD();
|
RCU_READ_LOCK_GUARD();
|
||||||
rdma = qatomic_rcu_read(&rioc->rdmain);
|
QIOChannelRDMA *rioc = QIO_CHANNEL_RDMA(qemu_file_get_ioc(f));
|
||||||
|
RDMAContext *rdma = qatomic_rcu_read(&rioc->rdmain);
|
||||||
|
|
||||||
if (!rdma) {
|
if (!rdma) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -3840,18 +3841,6 @@ rdma_block_notification_handle(QEMUFile *f, const char *name)
|
||||||
return 0;
|
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)
|
int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags)
|
||||||
{
|
{
|
||||||
if (!migrate_rdma() || migration_in_postcopy()) {
|
if (!migrate_rdma() || migration_in_postcopy()) {
|
||||||
|
@ -3997,7 +3986,6 @@ err:
|
||||||
}
|
}
|
||||||
|
|
||||||
static const QEMUFileHooks rdma_read_hooks = {
|
static const QEMUFileHooks rdma_read_hooks = {
|
||||||
.hook_ram_load = rdma_load_hook,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const QEMUFileHooks rdma_write_hooks = {
|
static const QEMUFileHooks rdma_write_hooks = {
|
||||||
|
|
|
@ -27,6 +27,7 @@ void rdma_start_incoming_migration(const char *host_port, Error **errp);
|
||||||
int qemu_rdma_registration_handle(QEMUFile *f);
|
int qemu_rdma_registration_handle(QEMUFile *f);
|
||||||
int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags);
|
int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags);
|
||||||
int qemu_rdma_registration_stop(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
|
#else
|
||||||
static inline
|
static inline
|
||||||
int qemu_rdma_registration_handle(QEMUFile *f) { return 0; }
|
int qemu_rdma_registration_handle(QEMUFile *f) { return 0; }
|
||||||
|
@ -34,5 +35,7 @@ static inline
|
||||||
int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags) { return 0; }
|
int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags) { return 0; }
|
||||||
static inline
|
static inline
|
||||||
int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags) { return 0; }
|
int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags) { return 0; }
|
||||||
|
static inline
|
||||||
|
int rdma_block_notification_handle(QEMUFile *f, const char *name) { return 0; }
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue