Skip to content

Commit

Permalink
migration/rdma: Create rdma_control_save_page()
Browse files Browse the repository at this point in the history
The only user of ram_control_save_page() and save_page() hook was
rdma. Just move the function to rdma.c, rename it to
rdma_control_save_page().

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Li Zhijian <lizhijian@fujitsu.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-ID: <20231011203527.9061-7-quintela@redhat.com>
  • Loading branch information
Juan Quintela committed Oct 17, 2023
1 parent a632330 commit e493008
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 35 deletions.
20 changes: 0 additions & 20 deletions migration/qemu-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,26 +298,6 @@ void qemu_fflush(QEMUFile *f)
f->iovcnt = 0;
}

int ram_control_save_page(QEMUFile *f, ram_addr_t block_offset,
ram_addr_t offset, size_t size)
{
if (f->hooks && f->hooks->save_page) {
int ret = f->hooks->save_page(f, block_offset, offset, size);
/*
* RAM_SAVE_CONTROL_* are negative values
*/
if (ret != RAM_SAVE_CONTROL_DELAYED &&
ret != RAM_SAVE_CONTROL_NOT_SUPP) {
if (ret < 0) {
qemu_file_set_error(f, ret);
}
}
return ret;
}

return RAM_SAVE_CONTROL_NOT_SUPP;
}

/*
* Attempt to fill the buffer from the underlying file
* Returns the number of bytes read, or negative value for an error.
Expand Down
12 changes: 0 additions & 12 deletions migration/qemu-file.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,7 @@
#define RAM_CONTROL_ROUND 1
#define RAM_CONTROL_FINISH 3

/*
* This function allows override of where the RAM page
* is saved (such as RDMA, for example.)
*/
typedef int (QEMURamSaveFunc)(QEMUFile *f,
ram_addr_t block_offset,
ram_addr_t offset,
size_t size);

typedef struct QEMUFileHooks {
QEMURamSaveFunc *save_page;
} QEMUFileHooks;

QEMUFile *qemu_file_new_input(QIOChannel *ioc);
Expand Down Expand Up @@ -125,8 +115,6 @@ int qemu_file_get_to_fd(QEMUFile *f, int fd, size_t size);
#define RAM_SAVE_CONTROL_NOT_SUPP -1000
#define RAM_SAVE_CONTROL_DELAYED -2000

int ram_control_save_page(QEMUFile *f, ram_addr_t block_offset,
ram_addr_t offset, size_t size);
QIOChannel *qemu_file_get_ioc(QEMUFile *file);

#endif
4 changes: 2 additions & 2 deletions migration/ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -1197,8 +1197,8 @@ static bool control_save_page(PageSearchStatus *pss, RAMBlock *block,
{
int ret;

ret = ram_control_save_page(pss->pss_channel, block->offset, offset,
TARGET_PAGE_SIZE);
ret = rdma_control_save_page(pss->pss_channel, block->offset, offset,
TARGET_PAGE_SIZE);
if (ret == RAM_SAVE_CONTROL_NOT_SUPP) {
return false;
}
Expand Down
19 changes: 18 additions & 1 deletion migration/rdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -3314,6 +3314,24 @@ static int qemu_rdma_save_page(QEMUFile *f, ram_addr_t block_offset,
return -1;
}

int rdma_control_save_page(QEMUFile *f, ram_addr_t block_offset,
ram_addr_t offset, size_t size)
{
if (!migrate_rdma()) {
return RAM_SAVE_CONTROL_NOT_SUPP;
}

int ret = qemu_rdma_save_page(f, block_offset, offset, size);

if (ret != RAM_SAVE_CONTROL_DELAYED &&
ret != RAM_SAVE_CONTROL_NOT_SUPP) {
if (ret < 0) {
qemu_file_set_error(f, ret);
}
}
return ret;
}

static void rdma_accept_incoming_migration(void *opaque);

static void rdma_cm_poll_handler(void *opaque)
Expand Down Expand Up @@ -3989,7 +4007,6 @@ static const QEMUFileHooks rdma_read_hooks = {
};

static const QEMUFileHooks rdma_write_hooks = {
.save_page = qemu_rdma_save_page,
};


Expand Down
10 changes: 10 additions & 0 deletions migration/rdma.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#ifndef QEMU_MIGRATION_RDMA_H
#define QEMU_MIGRATION_RDMA_H

#include "exec/memory.h"

void rdma_start_outgoing_migration(void *opaque, const char *host_port,
Error **errp);

Expand All @@ -28,6 +30,8 @@ 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);
int rdma_control_save_page(QEMUFile *f, ram_addr_t block_offset,
ram_addr_t offset, size_t size);
#else
static inline
int qemu_rdma_registration_handle(QEMUFile *f) { return 0; }
Expand All @@ -37,5 +41,11 @@ static inline
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; }
static inline
int rdma_control_save_page(QEMUFile *f, ram_addr_t block_offset,
ram_addr_t offset, size_t size)
{
return RAM_SAVE_CONTROL_NOT_SUPP;
}
#endif
#endif

0 comments on commit e493008

Please sign in to comment.