Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
migration/rdma: Create rdma_control_save_page()
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>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20230509120700.78359-7-quintela@redhat.com>
  • Loading branch information
Juan Quintela committed May 30, 2023
1 parent 07bd317 commit af93423
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 35 deletions.
20 changes: 0 additions & 20 deletions migration/qemu-file.c
Expand Up @@ -303,26 +303,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
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 @@ -129,8 +119,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
Expand Up @@ -1147,8 +1147,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
20 changes: 19 additions & 1 deletion migration/rdma.c
Expand Up @@ -3319,6 +3319,25 @@ static int qemu_rdma_save_page(QEMUFile *f, ram_addr_t block_offset,
return ret;
}

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 @@ -3995,7 +4014,6 @@ static const QEMUFileHooks rdma_read_hooks = {
};

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


Expand Down
6 changes: 6 additions & 0 deletions migration/rdma.h
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,10 +30,14 @@ 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
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; }
int rdma_control_save_page(QEMUFile *f, ram_addr_t block_offset,
ram_addr_t offset, size_t size) { return false; }
#endif
#endif

0 comments on commit af93423

Please sign in to comment.