migration: Remove QEMUFileHooks
v2 cover migration: Remove QEMUFileHooks
Hi
Changes in v2:
- rebased on top of migration-20230428 pull (second try)
- several of the patches on the PULL request
- make clean that we don't use rdma code when we don't use rdma
- create migrate_rdma() to check if we are in rdma migration.
There is no hope for this code. I am trying to cleanup the rest of rdma calls, but the code is convoluted as hell. And it lies with the ram counters as crazy.
Please review.
In this series (v1):
- QEMUFileHooks only had a single user, RDMA migration. Just remove the hooks and create stubs for when RDMA is not compiled in.
- This implies that we have to move all the operations from migration/qemu-file.c to migration/rdma.c.
- I now we can still simplify rdma_control_save_page(), but I don't have an easy setup for testing.
- Yes, the goal of the whole operations is to be able to move ram_file_limit from qemu-file to migration.c.
Please review.
Thanks, Juan.
Juan Quintela (16):
migration: Create migrate_rdma()
migration/rdma: Unfold ram_control_before_iterate() migration/rdma: Unfold ram_control_after_iterate() migration/rdma: simplify ram_control_load_hook() migration/rdma: Don't pass the QIOChannelRDMA as an opaque migration/rdma: We can calculate the rioc from the QEMUFile migration/rdma: It makes no sense to recive that flag without RDMA
migration: Make RAM_SAVE_FLAG_HOOK a normal case entry migration/rdma: Remove all uses of RAM_CONTROL_HOOK migration/rdma: Unfold hook_ram_load()
migration/rdma: Make ram_control_save_page() use exported interfaces migration/rdma: Create rdma_control_save_page()
qemu-file: Remove QEMUFileHooks
migration/rdma: Move rdma constants from qemu-file.h to rdma.h migration/rdma: Remove qemu_ prefix from exported functions migration/rdma: If we are in postcopy don't do anything
migration/migration.h | 3 + migration/options.c | 7 ++ migration/options.h | 1 + migration/qemu-file.c | 77 +------------------- migration/qemu-file.h | 51 -------------- migration/ram.c | 60 +++++++++++----- migration/rdma.c | 155 ++++++++++++++++++++++------------------- migration/rdma.h | 36 ++++++++++ migration/trace-events | 28 ++++---- 9 files changed, 186 insertions(+), 232 deletions(-)
Signature · 1 line
2.40.0
PATCH v2 1/16 migration: Create migrate_rdma()
Helper to say if we are doing a migration over rdma.
--- migration/migration.h | 3 +++ migration/options.c | 7 +++++++ migration/options.h | 1 + migration/rdma.c | 4 +++- 4 files changed, 14 insertions(+), 1 deletion(-)
migration/migration.h +3 -0
@@ -432,6 +432,9 @@ struct MigrationState {/* QEMU_VM_VMDESCRIPTION content filled for all non-iterable devices. */ JSONWriter *vmdesc; + +/* Is this a rdma migration */ +bool rdma_migration; };void migrate_set_state (int *state,int old_state,int new_state);
migration/options.c +7 -0
@@ -349,6 +349,13 @@ bool migrate_postcopy(void)return migrate_postcopy_ram () ||migrate_dirty_bitmaps (); } +bool migrate_rdma (void ) +{ +MigrationState *s =migrate_get_current (); + +return s->rdma_migration; +} +bool migrate_tls (void ) {MigrationState *s =migrate_get_current ();
migration/options.h +1 -0
@@ -61,6 +61,7 @@ bool migrate_zero_copy_send(void);bool migrate_multifd_flush_after_each_section (void );bool migrate_postcopy (void ); +bool migrate_rdma (void );bool migrate_tls (void );/* capabilities helpers */
migration/rdma.c +3 -1
@@ -4119,6 +4119,7 @@ void rdma_start_incoming_migration(const char *host_port, Error **errp)int ret;RDMAContext *rdma;Error *local_err =NULL ; +MigrationState *s =migrate_get_current ();trace_rdma_start_incoming_migration ();
@@ -4149,7 +4150,7 @@ void rdma_start_incoming_migration(const char *host_port, Error **errp) }trace_rdma_start_incoming_migration_after_rdma_listen (); - + s->rdma_migration = true;qemu_set_fd_handler (rdma->channel->fd, rdma_accept_incoming_migration,NULL , (void *)(intptr_t )rdma);return ;
@@ -4225,6 +4226,7 @@ void rdma_start_outgoing_migration(void *opaque,trace_rdma_start_outgoing_migration_after_rdma_connect (); + s->rdma_migration = true; s->to_dst_file =qemu_fopen_rdma (rdma,"wb" );migrate_fd_connect (s,NULL );return ;
Signature · 1 line
2.40.0
Re: [PATCH v2 01/16] migration: Create migrate_rdma()
Quoted 76 lines · Juan Quintela
Helper to say if we are doing a migration over rdma.
Signed-off-by Juan Quintela <[email protected]>--- migration/migration.h | 3 +++ migration/options.c | 7 +++++++ migration/options.h | 1 + migration/rdma.c | 4 +++- 4 files changed, 14 insertions(+), 1 deletion(-)migration/migration.h +3
-0@@ -432,6 +432,9 @@ struct MigrationState {/* QEMU_VM_VMDESCRIPTION content filled for all non-iterable devices. */ JSONWriter *vmdesc; + +/* Is this a rdma migration */ +bool rdma_migration; };void migrate_set_state (int *state,int old_state,int new_state);migration/options.c +7
-0@@ -349,6 +349,13 @@ bool migrate_postcopy(void)return migrate_postcopy_ram () ||migrate_dirty_bitmaps (); } +bool migrate_rdma (void ) +{ +MigrationState *s =migrate_get_current (); + +return s->rdma_migration; +} +bool migrate_tls (void ) {MigrationState *s =migrate_get_current ();migration/options.h +1
-0@@ -61,6 +61,7 @@ bool migrate_zero_copy_send(void);bool migrate_multifd_flush_after_each_section (void );bool migrate_postcopy (void ); +bool migrate_rdma (void );bool migrate_tls (void );/* capabilities helpers */ migration/rdma.c +2
-1@@ -4119,6 +4119,7 @@ void rdma_start_incoming_migration(const char *host_port, Error **errp)int ret;RDMAContext *rdma;Error *local_err =NULL ; +MigrationState *s =migrate_get_current ();trace_rdma_start_incoming_migration ();@@ -4149,7 +4150,7 @@ void rdma_start_incoming_migration(const char *host_port, Error **errp) }trace_rdma_start_incoming_migration_after_rdma_listen (); - + s->rdma_migration = true;qemu_set_fd_handler (rdma->channel->fd, rdma_accept_incoming_migration,NULL , (void *)(intptr_t )rdma);return ;
migration/rdma.c void rdma_start_outgoing_migration(void *opaque, · line 4232
Quoted 7 lines
migration/rdma.c +1
-0@@ -4225,6 +4226,7 @@ void rdma_start_outgoing_migration(void *opaque,trace_rdma_start_outgoing_migration_after_rdma_connect (); + s->rdma_migration = true; s->to_dst_file =qemu_fopen_rdma (rdma,"wb" );migrate_fd_connect (s,NULL );return ;
Is the "MigrationState" allocated freshly for every incoming or outgoing migration ? If it is reused, then something needs to set 's->rdma_migration = false' in non-RDMA code paths.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH v2 01/16] migration: Create migrate_rdma()
Quoted 7 lines · Daniel P. Berrangé
Quoted 1 line · Juan Quintela
Helper to say if we are doing a migration over rdma.
Is the "MigrationState" allocated freshly for every incoming or outgoing migration ? If it is reused, then something needs to set '
s->rdma_migration= false' in non-RDMA code paths.
for (i = 0; i < 1000; i++)
printf("never trust memory, check the code.\n");You are right, the function that we call is:migrate_init()
but we clear each statistic by hand, not a memset().
And now I have to review that we are not missing any other field to reset.
Thanks, Juan.
PATCH v2 2/16 migration/rdma: Unfold ram_control_before_iterate()
In reply to Juan QuintelaOnce there:
- Remove unused data parameter
- unfold it in its callers.
- change all callers to call qemu_rdma_registration_start()
--- migration/qemu-file.c | 13 +------------ migration/qemu-file.h | 2 -- migration/ram.c | 16 +++++++++++++--- migration/rdma.c | 8 +++++--- migration/rdma.h | 6 ++++++ 5 files changed, 25 insertions(+), 20 deletions(-)
migration/qemu-file.c +1 -12
@@ -30,6 +30,7 @@#include "qemu-file.h" #include "trace.h" #include "qapi/error.h" +#include "rdma.h" #define IO_BUF_SIZE 32768#define MAX_IOV_SIZE MIN_CONST(IOV_MAX, 64)
@@ -314,18 +315,6 @@ void qemu_fflush(QEMUFile *f) f->iovcnt =0 ; } -void ram_control_before_iterate (QEMUFile *f,uint64_t flags) -{ -int ret =0 ; - -if (f->hooks && f->hooks->before_ram_iterate) { - ret = f->hooks->before_ram_iterate (f, flags,NULL ); -if (ret <0 ) { -qemu_file_set_error (f, ret); - } - } -} -void ram_control_after_iterate (QEMUFile *f,uint64_t flags) {int ret =0 ;
migration/qemu-file.h +0 -2
@@ -56,7 +56,6 @@ typedef size_t (QEMURamSaveFunc)(QEMUFile *f, uint64_t *bytes_sent); typedef struct QEMUFileHooks { - QEMURamHookFunc *before_ram_iterate; QEMURamHookFunc *after_ram_iterate; QEMURamHookFunc *hook_ram_load; QEMURamSaveFunc *save_page;
@@ -150,7 +149,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_before_iterate (QEMUFile *f,uint64_t flags);void ram_control_after_iterate (QEMUFile *f,uint64_t flags);void ram_control_load_hook (QEMUFile *f,uint64_t flags,void *data);
migration/ram.c +13 -3
@@ -58,6 +58,7 @@#include "qemu/iov.h" #include "multifd.h" #include "sysemu/runstate.h" +#include "rdma.h" #include "options.h" #include "hw/boards.h" /* for machine_dump_guest_core() */
@@ -3277,7 +3278,10 @@ static int ram_save_setup(QEMUFile *f, void *opaque) } } -ram_control_before_iterate (f,RAM_CONTROL_SETUP ); + ret =qemu_rdma_registration_start (f,RAM_CONTROL_SETUP ); +if (ret <0 ) { +qemu_file_set_error (f, ret); + }ram_control_after_iterate (f,RAM_CONTROL_SETUP ); migration_ops =g_malloc0 (sizeof (MigrationOps));
@@ -3337,7 +3341,10 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)/* Read version before ram_list.blocks */ smp_rmb (); -ram_control_before_iterate (f,RAM_CONTROL_ROUND ); + ret =qemu_rdma_registration_start (f,RAM_CONTROL_ROUND ); +if (ret <0 ) { +qemu_file_set_error (f, ret); + } t0 =qemu_clock_get_ns (QEMU_CLOCK_REALTIME ); i =0 ;
@@ -3442,7 +3449,10 @@ static int ram_save_complete(QEMUFile *f, void *opaque)migration_bitmap_sync_precopy (rs); } -ram_control_before_iterate (f,RAM_CONTROL_FINISH ); + ret =qemu_rdma_registration_start (f,RAM_CONTROL_FINISH ); +if (ret <0 ) { +qemu_file_set_error (f, ret); + }/* try transferring iterative blocks of memory */
migration/rdma.c +5 -3
@@ -3860,12 +3860,15 @@ static int rdma_load_hook(QEMUFile *f, uint64_t flags, void *data) } } -static int qemu_rdma_registration_start (QEMUFile *f, -uint64_t flags,void *data) +int qemu_rdma_registration_start (QEMUFile *f,uint64_t flags) {QIOChannelRDMA *rioc =QIO_CHANNEL_RDMA (qemu_file_get_ioc (f));RDMAContext *rdma; +if (!migrate_rdma ()) { +return 0 ; + } +RCU_READ_LOCK_GUARD (); rdma =qatomic_rcu_read (&rioc->rdmaout);if (!rdma) {
@@ -4004,7 +4007,6 @@ static const QEMUFileHooks rdma_read_hooks = { };static const QEMUFileHooks rdma_write_hooks = { - .before_ram_iterate = qemu_rdma_registration_start, .after_ram_iterate = qemu_rdma_registration_stop, .save_page = qemu_rdma_save_page, };
migration/rdma.h +6 -0
@@ -22,4 +22,10 @@ void rdma_start_outgoing_migration(void *opaque, const char *host_port,void rdma_start_incoming_migration (const char *host_port,Error **errp); + +#ifdef CONFIG_RDMA +int qemu_rdma_registration_start (QEMUFile *f,uint64_t flags); +#else +int qemu_rdma_registration_start (QEMUFile *f,uint64_t flags) {return 0 ; } +#endif #endif
Signature · 1 line
2.40.0
PATCH v2 3/16 migration/rdma: Unfold ram_control_after_iterate()
In reply to Juan QuintelaOnce there:
- Remove unused data parameter
- unfold it in its callers
- change all callers to call qemu_rdma_registration_stop()
--- migration/qemu-file.c | 12 ------------ migration/qemu-file.h | 2 -- migration/ram.c | 17 ++++++++++++++--- migration/rdma.c | 8 +++++--- migration/rdma.h | 2 ++ 5 files changed, 21 insertions(+), 20 deletions(-)
migration/qemu-file.c +0 -12
@@ -315,18 +315,6 @@ void qemu_fflush(QEMUFile *f) f->iovcnt =0 ; } -void ram_control_after_iterate (QEMUFile *f,uint64_t flags) -{ -int ret =0 ; - -if (f->hooks && f->hooks->after_ram_iterate) { - ret = f->hooks->after_ram_iterate (f, flags,NULL ); -if (ret <0 ) { -qemu_file_set_error (f, ret); - } - } -} -void ram_control_load_hook (QEMUFile *f,uint64_t flags,void *data) {int ret = -EINVAL ;
migration/qemu-file.h +0 -2
@@ -56,7 +56,6 @@ typedef size_t (QEMURamSaveFunc)(QEMUFile *f, uint64_t *bytes_sent);typedef struct QEMUFileHooks { -QEMURamHookFunc *after_ram_iterate;QEMURamHookFunc *hook_ram_load;QEMURamSaveFunc *save_page; }QEMUFileHooks ;
@@ -149,7 +148,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_after_iterate (QEMUFile *f,uint64_t flags);void ram_control_load_hook (QEMUFile *f,uint64_t flags,void *data);/* Whenever this is found in the data stream, the flags
migration/ram.c +14 -3
@@ -3282,7 +3282,11 @@ static int ram_save_setup(QEMUFile *f, void *opaque)if (ret <0 ) {qemu_file_set_error (f, ret); } -ram_control_after_iterate (f,RAM_CONTROL_SETUP ); + + ret =qemu_rdma_registration_stop (f,RAM_CONTROL_SETUP ); +if (ret <0 ) { +qemu_file_set_error (f, ret); + } migration_ops =g_malloc0 (sizeof (MigrationOps)); migration_ops->ram_save_target_page = ram_save_target_page_legacy;
@@ -3401,7 +3405,10 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)* Must occur before EOS (or any QEMUFile operation) * because of RDMA protocol. */ -ram_control_after_iterate (f,RAM_CONTROL_ROUND ); + ret =qemu_rdma_registration_stop (f,RAM_CONTROL_ROUND ); +if (ret <0 ) { +qemu_file_set_error (f, ret); + } out: if (ret >= 0
@@ -3474,7 +3481,11 @@ static int ram_save_complete(QEMUFile *f, void *opaque)qemu_mutex_unlock (&rs->bitmap_mutex);flush_compressed_data (rs); -ram_control_after_iterate (f,RAM_CONTROL_FINISH ); + +int ret =qemu_rdma_registration_stop (f,RAM_CONTROL_FINISH ); +if (ret <0 ) { +qemu_file_set_error (f, ret); + } }if (ret <0 ) {
migration/rdma.c +5 -3
@@ -3892,14 +3892,17 @@ int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags)* Inform dest that dynamic registrations are done for now. * First, flush writes, if any. */ -static int qemu_rdma_registration_stop (QEMUFile *f, -uint64_t flags,void *data) +int qemu_rdma_registration_stop (QEMUFile *f,uint64_t flags) {QIOChannelRDMA *rioc =QIO_CHANNEL_RDMA (qemu_file_get_ioc (f));RDMAContext *rdma;RDMAControlHeader head = { .len =0 , .repeat =1 };int ret =0 ; +if (!migrate_rdma ()) { +return 0 ; + } +RCU_READ_LOCK_GUARD (); rdma =qatomic_rcu_read (&rioc->rdmaout);if (!rdma) {
@@ -4007,7 +4010,6 @@ static const QEMUFileHooks rdma_read_hooks = { };static const QEMUFileHooks rdma_write_hooks = { - .after_ram_iterate = qemu_rdma_registration_stop, .save_page = qemu_rdma_save_page, };
migration/rdma.h +2 -0
@@ -25,7 +25,9 @@ void rdma_start_incoming_migration(const char *host_port, Error **errp);#ifdef CONFIG_RDMA int qemu_rdma_registration_start (QEMUFile *f,uint64_t flags); +int qemu_rdma_registration_stop (QEMUFile *f,uint64_t flags);#else int qemu_rdma_registration_start (QEMUFile *f,uint64_t flags) {return 0 ; } +int qemu_rdma_registration_stop (QEMUFile *f,uint64_t flags) {return 0 ; }#endif #endif
Signature · 1 line
2.40.0
PATCH v2 4/16 migration/rdma: simplify ram_control_load_hook()
In reply to Juan Quintela--- migration/qemu-file.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
migration/qemu-file.c +2 -4
@@ -317,10 +317,8 @@ void qemu_fflush(QEMUFile *f)void ram_control_load_hook (QEMUFile *f,uint64_t flags,void *data) { -int ret = -EINVAL ; -if (f->hooks && f->hooks->hook_ram_load) { - ret = f->hooks->hook_ram_load (f, flags, data); +int ret = f->hooks->hook_ram_load (f, flags, data);if (ret <0 ) {qemu_file_set_error (f, ret); }
@@ -330,7 +328,7 @@ void ram_control_load_hook(QEMUFile *f, uint64_t flags, void *data)* that expects there to be a hook on the destination. */ if (flags ==RAM_CONTROL_HOOK ) { -qemu_file_set_error (f, ret); +qemu_file_set_error (f, -EINVAL ); } } }
Signature · 1 line
2.40.0
PATCH v2 5/16 migration/rdma: Don't pass the QIOChannelRDMA as an opaque
In reply to Juan QuintelaWe can calculate it from the QEMUFile like the caller.
--- migration/rdma.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
migration/rdma.c +3 -3
@@ -3527,7 +3527,7 @@ static int dest_ram_sort_func(const void *a, const void *b)* * Keep doing this until the source tells us to stop. */ -static int qemu_rdma_registration_handle (QEMUFile *f,void *opaque) +static int qemu_rdma_registration_handle (QEMUFile *f) {RDMAControlHeader reg_resp = { .len =sizeof (RDMARegisterResult), .type =RDMA_CONTROL_REGISTER_RESULT ,
@@ -3539,7 +3539,7 @@ static int qemu_rdma_registration_handle(QEMUFile *f, void *opaque) };RDMAControlHeader blocks = { .type =RDMA_CONTROL_RAM_BLOCKS_RESULT , .repeat =1 }; -QIOChannelRDMA *rioc =QIO_CHANNEL_RDMA (opaque); +QIOChannelRDMA *rioc =QIO_CHANNEL_RDMA (qemu_file_get_ioc (f));RDMAContext *rdma;RDMALocalBlocks *local;RDMAControlHeader head;
@@ -3852,7 +3852,7 @@ static int rdma_load_hook(QEMUFile *f, uint64_t flags, void *data)return rdma_block_notification_handle (rioc, data);case RAM_CONTROL_HOOK : -return qemu_rdma_registration_handle (f, rioc); +return qemu_rdma_registration_handle (f);default :/* Shouldn't be called with any other values */
Signature · 1 line
2.40.0
Re: [PATCH v2 05/16] migration/rdma: Don't pass the QIOChannelRDMA as an opaque
Quoted 6 lines · Juan Quintela
We can calculate it from the QEMUFile like the caller.
Signed-off-by Juan Quintela <[email protected]>--- migration/rdma.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
PATCH v2 6/16 migration/rdma: We can calculate the rioc from the QEMUFile
In reply to Juan Quintela--- migration/rdma.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
migration/rdma.c +3 -3
@@ -3811,9 +3811,10 @@ out:* the source. */ static int -rdma_block_notification_handle (QIOChannelRDMA *rioc,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 found =-1 ;
@@ -3846,10 +3847,9 @@ rdma_block_notification_handle(QIOChannelRDMA *rioc, const char *name)static int rdma_load_hook (QEMUFile *f,uint64_t flags,void *data) { -QIOChannelRDMA *rioc =QIO_CHANNEL_RDMA (qemu_file_get_ioc (f));switch (flags) {case RAM_CONTROL_BLOCK_REG : -return rdma_block_notification_handle (rioc, data); +return rdma_block_notification_handle (f, data);case RAM_CONTROL_HOOK :return qemu_rdma_registration_handle (f);
Signature · 1 line
2.40.0
PATCH v2 7/16 migration/rdma: It makes no sense to recive that flag without RDMA
In reply to Juan QuintelaThis could only happen if the source send RAM_SAVE_FLAG_HOOK (i.e. rdma) and destination don't have CONFIG_RDMA.
--- migration/qemu-file.c | 8 -------- 1 file changed, 8 deletions(-)
migration/qemu-file.c +0 -8
@@ -322,14 +322,6 @@ void ram_control_load_hook(QEMUFile *f, uint64_t flags, void *data)if (ret <0 ) {qemu_file_set_error (f, ret); } - }else { -/* -* Hook is a hook specifically requested by the source sending a flag -* that expects there to be a hook on the destination. -*/ -if (flags ==RAM_CONTROL_HOOK ) { -qemu_file_set_error (f, -EINVAL ); - } } }
Signature · 1 line
2.40.0
PATCH v2 8/16 migration: Make RAM_SAVE_FLAG_HOOK a normal case entry
In reply to Juan QuintelaFixes this commit, clearly a bad merge after a rebase or similar, it should have been its own case since that point.
commit 5b0e9dd46fbda5152566a4a26fd96bc0d0452bf7
Author: Peter Lieven <[email protected]> Date: Tue Jun 24 11:32:36 2014 +0200
migration: catch unknown flag combinations in ram_load
--- migration/ram.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
migration/ram.c +5 -7
@@ -4466,14 +4466,12 @@ static int ram_load_precopy(QEMUFile *f)multifd_recv_sync_main (); }break ; +case RAM_SAVE_FLAG_HOOK : +ram_control_load_hook (f,RAM_CONTROL_HOOK ,NULL ); +break ;default : -if (flags &RAM_SAVE_FLAG_HOOK ) { -ram_control_load_hook (f,RAM_CONTROL_HOOK ,NULL ); - }else { -error_report ("Unknown combination of migration flags: 0x%x" , - flags); - ret = -EINVAL ; - } +error_report ("Unknown combination of migration flags: 0x%x" , flags); + ret = -EINVAL ; }if (!ret) { ret =qemu_file_get_error (f);
Signature · 1 line
2.40.0
PATCH v2 9/16 migration/rdma: Remove all uses of RAM_CONTROL_HOOK
In reply to Juan QuintelaInstead of going trhough ram_control_load_hook(), call qemu_rdma_registration_handle() directly.
--- migration/qemu-file.h | 1 - migration/ram.c | 5 ++++- migration/rdma.c | 9 +++++---- migration/rdma.h | 2 ++ 4 files changed, 11 insertions(+), 6 deletions(-)
migration/qemu-file.h +0 -1
@@ -41,7 +41,6 @@ typedef int (QEMURamHookFunc)(QEMUFile *f, uint64_t flags, void *data);*/ #define RAM_CONTROL_SETUP 0#define RAM_CONTROL_ROUND 1 -#define RAM_CONTROL_HOOK 2#define RAM_CONTROL_FINISH 3#define RAM_CONTROL_BLOCK_REG 4
migration/ram.c +4 -1
@@ -4467,7 +4467,10 @@ static int ram_load_precopy(QEMUFile *f) }break ;case RAM_SAVE_FLAG_HOOK : -ram_control_load_hook (f,RAM_CONTROL_HOOK ,NULL ); + ret =qemu_rdma_registration_handle (f); +if (ret <0 ) { +qemu_file_set_error (f, ret); + }break ;default :error_report ("Unknown combination of migration flags: 0x%x" , flags);
migration/rdma.c +5 -4
@@ -3527,7 +3527,7 @@ static int dest_ram_sort_func(const void *a, const void *b)* * Keep doing this until the source tells us to stop. */ -static int qemu_rdma_registration_handle (QEMUFile *f) +int qemu_rdma_registration_handle (QEMUFile *f) {RDMAControlHeader reg_resp = { .len =sizeof (RDMARegisterResult), .type =RDMA_CONTROL_REGISTER_RESULT ,
@@ -3554,6 +3554,10 @@ static int qemu_rdma_registration_handle(QEMUFile *f)int count =0 ;int i =0 ; +if (!migrate_rdma ()) { +return 0 ; + } +RCU_READ_LOCK_GUARD (); rdma =qatomic_rcu_read (&rioc->rdmain);
@@ -3851,9 +3855,6 @@ static int rdma_load_hook(QEMUFile *f, uint64_t flags, void *data)case RAM_CONTROL_BLOCK_REG :return rdma_block_notification_handle (f, data); -case RAM_CONTROL_HOOK : -return qemu_rdma_registration_handle (f); -default :/* Shouldn't be called with any other values */ abort ();
migration/rdma.h +2 -0
@@ -24,9 +24,11 @@ void rdma_start_incoming_migration(const char *host_port, Error **errp);#ifdef CONFIG_RDMA +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);#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 ; }#endif
Signature · 1 line
2.40.0
PATCH v2 10/16 migration/rdma: Unfold hook_ram_load()
In reply to Juan QuintelaThere is only one flag called with: RAM_CONTROL_BLOCK_REG.
--- migration/qemu-file.c | 10 ---------- migration/qemu-file.h | 11 ----------- migration/ram.c | 6 ++++-- migration/rdma.c | 29 +++++++++-------------------- migration/rdma.h | 2 ++ 5 files changed, 15 insertions(+), 43 deletions(-)
migration/qemu-file.c +0 -10
@@ -315,16 +315,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); - } - } -} -size_t ram_control_save_page (QEMUFile *f,ram_addr_t block_offset,ram_addr_t offset,size_t size,uint64_t *bytes_sent)
migration/qemu-file.h +0 -11
@@ -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
@@ -55,7 +47,6 @@ typedef size_t (QEMURamSaveFunc)(QEMUFile *f, uint64_t *bytes_sent);typedef struct QEMUFileHooks { -QEMURamHookFunc *hook_ram_load;QEMURamSaveFunc *save_page; }QEMUFileHooks ;
@@ -147,8 +138,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
migration/ram.c +4 -2
@@ -4418,8 +4418,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);
migration/rdma.c +9 -20
@@ -3808,20 +3808,22 @@ out: }/* 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);
@@ -3849,18 +3851,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));
@@ -4007,7 +3997,6 @@ err: }static const QEMUFileHooks rdma_read_hooks = { - .hook_ram_load = rdma_load_hook, };static const QEMUFileHooks rdma_write_hooks = {
migration/rdma.h +2 -0
@@ -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
Signature · 1 line
2.40.0
PATCH v2 11/16 migration/rdma: Make ram_control_save_page() use exported interfaces
In reply to Juan Quintela--- migration/qemu-file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
migration/qemu-file.c +1 -1
@@ -323,7 +323,7 @@ size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset,int ret = f->hooks->save_page (f, block_offset, offset, size, bytes_sent);if (ret !=RAM_SAVE_CONTROL_NOT_SUPP ) { - f->rate_limit_used += size; +qemu_file_acct_rate_limit (f, size); } if (ret != RAM_SAVE_CONTROL_DELAYED &&
Signature · 1 line
2.40.0
PATCH v2 12/16 migration/rdma: Create rdma_control_save_page()
In reply to Juan QuintelaThe 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().
--- migration/qemu-file.c | 26 -------------------------- migration/qemu-file.h | 14 -------------- migration/ram.c | 4 ++-- migration/rdma.c | 26 +++++++++++++++++++++++++- migration/rdma.h | 8 ++++++++ 5 files changed, 35 insertions(+), 43 deletions(-)
migration/qemu-file.c +0 -26
@@ -315,32 +315,6 @@ void qemu_fflush(QEMUFile *f) f->iovcnt =0 ; } -size_t ram_control_save_page (QEMUFile *f,ram_addr_t block_offset, -ram_addr_t offset,size_t size, -uint64_t *bytes_sent) -{ -if (f->hooks && f->hooks->save_page) { -int ret = f->hooks->save_page (f, block_offset, - offset, size, bytes_sent); -if (ret !=RAM_SAVE_CONTROL_NOT_SUPP ) { -qemu_file_acct_rate_limit (f, size); - } - -if (ret !=RAM_SAVE_CONTROL_DELAYED && - ret !=RAM_SAVE_CONTROL_NOT_SUPP ) { -if (bytes_sent && *bytes_sent >0 ) { -qemu_file_credit_transfer (f, *bytes_sent); - }else 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.
migration/qemu-file.h +0 -14
@@ -36,18 +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 size_t (QEMURamSaveFunc )(QEMUFile *f, -ram_addr_t block_offset, -ram_addr_t offset, -size_t size, -uint64_t *bytes_sent); -typedef struct QEMUFileHooks { -QEMURamSaveFunc *save_page; }QEMUFileHooks ;QEMUFile *qemu_file_new_input (QIOChannel *ioc);
@@ -148,9 +137,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 -size_t ram_control_save_page (QEMUFile *f,ram_addr_t block_offset, -ram_addr_t offset,size_t size, -uint64_t *bytes_sent);QIOChannel *qemu_file_get_ioc (QEMUFile *file);#endif
migration/ram.c +2 -2
@@ -1342,8 +1342,8 @@ static bool control_save_page(PageSearchStatus *pss, RAMBlock *block,int ret; *pages =-1 ; - ret =ram_control_save_page (pss->pss_channel, block->offset, offset, -TARGET_PAGE_SIZE , &bytes_xmit); + ret =rdma_control_save_page (pss->pss_channel, block->offset, offset, +TARGET_PAGE_SIZE , &bytes_xmit);if (ret ==RAM_SAVE_CONTROL_NOT_SUPP ) {return false; }
migration/rdma.c +25 -1
@@ -3315,6 +3315,31 @@ err:return ret; } +size_t rdma_control_save_page (QEMUFile *f,ram_addr_t block_offset, +ram_addr_t offset,size_t size, +uint64_t *bytes_sent) +{ +if (!migrate_rdma ()) { +return RAM_SAVE_CONTROL_NOT_SUPP ; + } + +int ret =qemu_rdma_save_page (f, block_offset, offset, size, bytes_sent); +if (ret !=RAM_SAVE_CONTROL_NOT_SUPP ) { +qemu_file_acct_rate_limit (f, size); + } + +if (ret !=RAM_SAVE_CONTROL_DELAYED && + ret !=RAM_SAVE_CONTROL_NOT_SUPP ) { +if (bytes_sent && *bytes_sent >0 ) { +qemu_file_credit_transfer (f, *bytes_sent); + }else 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)
@@ -4000,7 +4025,6 @@ static const QEMUFileHooks rdma_read_hooks = { };static const QEMUFileHooks rdma_write_hooks = { - .save_page = qemu_rdma_save_page, };
migration/rdma.h +8 -0
@@ -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);
@@ -28,10 +30,16 @@ 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); +size_t rdma_control_save_page (QEMUFile *f,ram_addr_t block_offset, +ram_addr_t offset,size_t size, +uint64_t *bytes_sent);#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 ; } +size_t rdma_control_save_page (QEMUFile *f,ram_addr_t block_offset, +ram_addr_t offset,size_t size, +uint64_t *bytes_sent) {return false; }#endif #endif
Signature · 1 line
2.40.0
PATCH v2 13/16 qemu-file: Remove QEMUFileHooks
In reply to Juan QuintelaThe only user was rdma, and its use is gone.
--- migration/qemu-file.c | 6 ------ migration/qemu-file.h | 4 ---- migration/rdma.c | 9 --------- 3 files changed, 19 deletions(-)
migration/qemu-file.c +0 -6
@@ -36,7 +36,6 @@#define MAX_IOV_SIZE MIN_CONST(IOV_MAX, 64)struct QEMUFile { -const QEMUFileHooks *hooks;QIOChannel *ioc;bool is_writable;
@@ -160,11 +159,6 @@ QEMUFile *qemu_file_new_input(QIOChannel *ioc)return qemu_file_new_impl (ioc, false); } -void qemu_file_set_hooks (QEMUFile *f,const QEMUFileHooks *hooks) -{ - f->hooks = hooks; -} -/* * Get last error for stream f with optional Error* *
migration/qemu-file.h +0 -4
@@ -36,12 +36,8 @@#define RAM_CONTROL_ROUND 1#define RAM_CONTROL_FINISH 3 -typedef struct QEMUFileHooks { -}QEMUFileHooks ; -QEMUFile *qemu_file_new_input (QIOChannel *ioc);QEMUFile *qemu_file_new_output (QIOChannel *ioc); -void qemu_file_set_hooks (QEMUFile *f,const QEMUFileHooks *hooks);int qemu_fclose (QEMUFile *f);/*
migration/rdma.c +0 -9
@@ -4021,13 +4021,6 @@ err:return ret; } -static const QEMUFileHooks rdma_read_hooks = { -}; - -static const QEMUFileHooks rdma_write_hooks = { -}; - -static void qio_channel_rdma_finalize (Object *obj) {QIOChannelRDMA *rioc =QIO_CHANNEL_RDMA (obj);
@@ -4086,12 +4079,10 @@ static QEMUFile *qemu_fopen_rdma(RDMAContext *rdma, const char *mode) rioc->file =qemu_file_new_output (QIO_CHANNEL (rioc)); rioc->rdmaout = rdma; rioc->rdmain = rdma->return_path; -qemu_file_set_hooks (rioc->file, &rdma_write_hooks); }else { rioc->file =qemu_file_new_input (QIO_CHANNEL (rioc)); rioc->rdmain = rdma; rioc->rdmaout = rdma->return_path; -qemu_file_set_hooks (rioc->file, &rdma_read_hooks); }return rioc->file;
Signature · 1 line
2.40.0
PATCH v2 14/16 migration/rdma: Move rdma constants from qemu-file.h to rdma.h
In reply to Juan Quintela--- migration/qemu-file.h | 17 ----------------- migration/ram.c | 2 +- migration/rdma.h | 16 ++++++++++++++++ 3 files changed, 17 insertions(+), 18 deletions(-)
migration/qemu-file.h +0 -17
@@ -29,13 +29,6 @@#include "exec/cpu-common.h" #include "io/channel.h" -/* -* Constants used by ram_control_* hooks -*/ -#define RAM_CONTROL_SETUP 0 -#define RAM_CONTROL_ROUND 1 -#define RAM_CONTROL_FINISH 3 -QEMUFile *qemu_file_new_input (QIOChannel *ioc);QEMUFile *qemu_file_new_output (QIOChannel *ioc);int qemu_fclose (QEMUFile *f);
@@ -123,16 +116,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); -/* 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 -* transport-specific sections to the RAM migration data. -*/ -#define RAM_SAVE_FLAG_HOOK 0x80 - -#define RAM_SAVE_CONTROL_NOT_SUPP -1000 -#define RAM_SAVE_CONTROL_DELAYED -2000 -QIOChannel *qemu_file_get_ioc (QEMUFile *file);#endif
migration/ram.c +1 -1
@@ -86,7 +86,7 @@#define RAM_SAVE_FLAG_EOS 0x10#define RAM_SAVE_FLAG_CONTINUE 0x20#define RAM_SAVE_FLAG_XBZRLE 0x40 -/* 0x80 is reserved in qemu-file.h for RAM_SAVE_FLAG_HOOK */ +/* 0x80 is reserved in rdma.h for RAM_SAVE_FLAG_HOOK */ #define RAM_SAVE_FLAG_COMPRESS_PAGE 0x100#define RAM_SAVE_FLAG_MULTIFD_FLUSH 0x200/* We can't use any flag that is bigger than 0x200 */
migration/rdma.h +16 -0
@@ -24,6 +24,22 @@ void rdma_start_outgoing_migration(void *opaque, const char *host_port,void rdma_start_incoming_migration (const char *host_port,Error **errp); +/* +* Constants used by rdma return codes +*/ +#define RAM_CONTROL_SETUP 0 +#define RAM_CONTROL_ROUND 1 +#define RAM_CONTROL_FINISH 3 + +/* +* Whenever this is found in the data stream, the flags +* will be passed to rdma functions in the incoming-migration +* side. +*/ +#define RAM_SAVE_FLAG_HOOK 0x80 + +#define RAM_SAVE_CONTROL_NOT_SUPP -1000 +#define RAM_SAVE_CONTROL_DELAYED -2000#ifdef CONFIG_RDMA int qemu_rdma_registration_handle (QEMUFile *f);
Signature · 1 line
2.40.0
PATCH v2 15/16 migration/rdma: Remove qemu_ prefix from exported functions
In reply to Juan QuintelaFunctions are long enough even without this.
--- migration/ram.c | 14 +++++++------- migration/rdma.c | 40 +++++++++++++++++++--------------------- migration/rdma.h | 12 ++++++------ migration/trace-events | 28 ++++++++++++++-------------- 4 files changed, 46 insertions(+), 48 deletions(-)
migration/ram.c +7 -7
@@ -3278,12 +3278,12 @@ static int ram_save_setup(QEMUFile *f, void *opaque) } } - ret =qemu_rdma_registration_start (f,RAM_CONTROL_SETUP ); + ret =rdma_registration_start (f,RAM_CONTROL_SETUP );if (ret <0 ) {qemu_file_set_error (f, ret); } - ret =qemu_rdma_registration_stop (f,RAM_CONTROL_SETUP ); + ret =rdma_registration_stop (f,RAM_CONTROL_SETUP );if (ret <0 ) {qemu_file_set_error (f, ret); }
@@ -3345,7 +3345,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)/* Read version before ram_list.blocks */ smp_rmb (); - ret =qemu_rdma_registration_start (f,RAM_CONTROL_ROUND ); + ret =rdma_registration_start (f,RAM_CONTROL_ROUND );if (ret <0 ) {qemu_file_set_error (f, ret); }
@@ -3405,7 +3405,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)* Must occur before EOS (or any QEMUFile operation) * because of RDMA protocol. */ - ret =qemu_rdma_registration_stop (f,RAM_CONTROL_ROUND ); + ret =rdma_registration_stop (f,RAM_CONTROL_ROUND );if (ret <0 ) {qemu_file_set_error (f, ret); }
@@ -3456,7 +3456,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque)migration_bitmap_sync_precopy (rs); } - ret =qemu_rdma_registration_start (f,RAM_CONTROL_FINISH ); + ret =rdma_registration_start (f,RAM_CONTROL_FINISH );if (ret <0 ) {qemu_file_set_error (f, ret); }
@@ -3482,7 +3482,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque)flush_compressed_data (rs); -int ret =qemu_rdma_registration_stop (f,RAM_CONTROL_FINISH ); +int ret =rdma_registration_stop (f,RAM_CONTROL_FINISH );if (ret <0 ) {qemu_file_set_error (f, ret); }
@@ -4469,7 +4469,7 @@ static int ram_load_precopy(QEMUFile *f) }break ;case RAM_SAVE_FLAG_HOOK : - ret =qemu_rdma_registration_handle (f); + ret =rdma_registration_handle (f);if (ret <0 ) {qemu_file_set_error (f, ret); }
migration/rdma.c +19 -21
@@ -3552,7 +3552,7 @@ static int dest_ram_sort_func(const void *a, const void *b)* * Keep doing this until the source tells us to stop. */ -int qemu_rdma_registration_handle (QEMUFile *f) +int rdma_registration_handle (QEMUFile *f) {RDMAControlHeader reg_resp = { .len =sizeof (RDMARegisterResult), .type =RDMA_CONTROL_REGISTER_RESULT ,
@@ -3594,7 +3594,7 @@ int qemu_rdma_registration_handle(QEMUFile *f) local = &rdma->local_ram_blocks; do { - trace_qemu_rdma_registration_handle_wait(); + trace_rdma_registration_handle_wait(); ret = qemu_rdma_exchange_recv(rdma, &head, RDMA_CONTROL_NONE);
@@ -3614,9 +3614,9 @@ int qemu_rdma_registration_handle(QEMUFile *f) comp = (RDMACompress *) rdma->wr_data[idx].control_curr;network_to_compress (comp); -trace_qemu_rdma_registration_handle_compress (comp->length, - comp->block_idx, - comp->offset); +trace_rdma_registration_handle_compress (comp->length, + comp->block_idx, + comp->offset);if (comp->block_idx >= rdma->local_ram_blocks.nb_blocks) { error_report("rdma: 'compress' bad block index %u (vs %d)", (unsigned int)comp->block_idx,
@@ -3633,11 +3633,11 @@ int qemu_rdma_registration_handle(QEMUFile *f)break ;case RDMA_CONTROL_REGISTER_FINISHED : -trace_qemu_rdma_registration_handle_finished (); +trace_rdma_registration_handle_finished (); goto out;case RDMA_CONTROL_RAM_BLOCKS_REQUEST : -trace_qemu_rdma_registration_handle_ram_blocks (); +trace_rdma_registration_handle_ram_blocks ();/* Sort our local RAM Block list so it's the same as the source, * we can do this since we've filled in a src_index in the list
@@ -3677,7 +3677,7 @@ int qemu_rdma_registration_handle(QEMUFile *f) rdma->dest_blocks[i].length = local->block[i].length;dest_block_to_network (&rdma->dest_blocks[i]); - trace_qemu_rdma_registration_handle_ram_blocks_loop( + trace_rdma_registration_handle_ram_blocks_loop( local->block[i].block_name, local->block[i].offset, local->block[i].length,
@@ -3699,7 +3699,7 @@ int qemu_rdma_registration_handle(QEMUFile *f)break ;case RDMA_CONTROL_REGISTER_REQUEST : -trace_qemu_rdma_registration_handle_register (head.repeat); +trace_rdma_registration_handle_register (head.repeat); reg_resp.repeat = head.repeat; registers = (RDMARegister *) rdma->wr_data[idx].control_curr;
@@ -3713,7 +3713,7 @@ int qemu_rdma_registration_handle(QEMUFile *f) reg_result = &results[count]; -trace_qemu_rdma_registration_handle_register_loop (count, +trace_rdma_registration_handle_register_loop (count, reg->current_index, reg->key.current_addr, reg->chunks);if (reg->current_index >= rdma->local_ram_blocks.nb_blocks) {
@@ -3765,8 +3765,7 @@ int qemu_rdma_registration_handle(QEMUFile *f) reg_result->host_addr = (uintptr_t )block->local_host_addr; -trace_qemu_rdma_registration_handle_register_rkey ( - reg_result->rkey); +trace_rdma_registration_handle_register_rkey (reg_result->rkey);result_to_network (reg_result); }
@@ -3780,7 +3779,7 @@ int qemu_rdma_registration_handle(QEMUFile *f) }break ;case RDMA_CONTROL_UNREGISTER_REQUEST : -trace_qemu_rdma_registration_handle_unregister (head.repeat); +trace_rdma_registration_handle_unregister (head.repeat); unreg_resp.repeat = head.repeat; registers = (RDMARegister *) rdma->wr_data[idx].control_curr;
@@ -3788,7 +3787,7 @@ int qemu_rdma_registration_handle(QEMUFile *f) reg = ®isters[count];network_to_register (reg); -trace_qemu_rdma_registration_handle_unregister_loop (count, +trace_rdma_registration_handle_unregister_loop (count, reg->current_index, reg->key.chunk); block = &(rdma->local_ram_blocks.block[reg->current_index]);
@@ -3804,8 +3803,7 @@ int qemu_rdma_registration_handle(QEMUFile *f) rdma->total_registrations--; -trace_qemu_rdma_registration_handle_unregister_success ( - reg->key.chunk); +trace_rdma_registration_handle_unregister_success (reg->key.chunk); } ret =qemu_rdma_post_send_control (rdma,NULL , &unreg_resp);
@@ -3876,7 +3874,7 @@ int rdma_block_notification_handle(QEMUFile *f, const char *name)return 0 ; } -int qemu_rdma_registration_start (QEMUFile *f,uint64_t flags) +int rdma_registration_start (QEMUFile *f,uint64_t flags) {QIOChannelRDMA *rioc =QIO_CHANNEL_RDMA (qemu_file_get_ioc (f));RDMAContext *rdma;
@@ -3897,7 +3895,7 @@ int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags)return 0 ; } -trace_qemu_rdma_registration_start (flags); +trace_rdma_registration_start (flags);qemu_put_be64 (f,RAM_SAVE_FLAG_HOOK );qemu_fflush (f);
@@ -3908,7 +3906,7 @@ int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags)* Inform dest that dynamic registrations are done for now. * First, flush writes, if any. */ -int qemu_rdma_registration_stop (QEMUFile *f,uint64_t flags) +int rdma_registration_stop (QEMUFile *f,uint64_t flags) {QIOChannelRDMA *rioc =QIO_CHANNEL_RDMA (qemu_file_get_ioc (f));RDMAContext *rdma;
@@ -3944,7 +3942,7 @@ int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags)int reg_result_idx, i, nb_dest_blocks; head.type =RDMA_CONTROL_RAM_BLOCKS_REQUEST ; -trace_qemu_rdma_registration_stop_ram (); +trace_rdma_registration_stop_ram ();/* * Make sure that we parallelize the pinning on both sides.
@@ -4006,7 +4004,7 @@ int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags) } } -trace_qemu_rdma_registration_stop (flags); +trace_rdma_registration_stop (flags); head.type =RDMA_CONTROL_REGISTER_FINISHED ; ret =qemu_rdma_exchange_send (rdma, &head,NULL ,NULL ,NULL ,NULL );
migration/rdma.h +6 -6
@@ -42,17 +42,17 @@ void rdma_start_incoming_migration(const char *host_port, Error **errp);#define RAM_SAVE_CONTROL_DELAYED -2000#ifdef CONFIG_RDMA -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_registration_handle (QEMUFile *f); +int rdma_registration_start (QEMUFile *f,uint64_t flags); +int rdma_registration_stop (QEMUFile *f,uint64_t flags);int rdma_block_notification_handle (QEMUFile *f,const char *name);size_t rdma_control_save_page (QEMUFile *f,ram_addr_t block_offset,ram_addr_t offset,size_t size,uint64_t *bytes_sent);#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_registration_handle (QEMUFile *f) {return 0 ; } +int rdma_registration_start (QEMUFile *f,uint64_t flags) {return 0 ; } +int rdma_registration_stop (QEMUFile *f,uint64_t flags) {return 0 ; }int rdma_block_notification_handle (QEMUFile *f,const char *name) {return 0 ; } size_t rdma_control_save_page(QEMUFile *f, ram_addr_t block_offset, ram_addr_t offset, size_t size,
migration/trace-events +14 -14
@@ -221,20 +221,6 @@ qemu_rdma_post_send_control(const char *desc) "CONTROL: sending %s.." qemu_rdma_register_and_get_keys(uint64_t len, void *start) "Registering %" PRIu64 " bytes @ %p" qemu_rdma_register_odp_mr(const char *name) "Try to register On-Demand Paging memory region: %s" qemu_rdma_advise_mr(const char *name, uint32_t len, uint64_t addr, const char *res) "Try to advise block %s prefetch at %" PRIu32 "@0x%" PRIx64 ": %s" -qemu_rdma_registration_handle_compress(int64_t length, int index, int64_t offset) "Zapping zero chunk: %" PRId64 " bytes, index %d, offset %" PRId64 -qemu_rdma_registration_handle_finished(void) "" -qemu_rdma_registration_handle_ram_blocks(void) "" -qemu_rdma_registration_handle_ram_blocks_loop(const char *name, uint64_t offset, uint64_t length, void *local_host_addr, unsigned int src_index) "%s: @0x%" PRIx64 "/%" PRIu64 " host:@%p src_index: %u" -qemu_rdma_registration_handle_register(int requests) "%d requests" -qemu_rdma_registration_handle_register_loop(int req, int index, uint64_t addr, uint64_t chunks) "Registration request (%d): index %d, current_addr %" PRIu64 " chunks: %" PRIu64 -qemu_rdma_registration_handle_register_rkey(int rkey) "0x%x" -qemu_rdma_registration_handle_unregister(int requests) "%d requests" -qemu_rdma_registration_handle_unregister_loop(int count, int index, uint64_t chunk) "Unregistration request (%d): index %d, chunk %" PRIu64 -qemu_rdma_registration_handle_unregister_success(uint64_t chunk) "%" PRIu64 -qemu_rdma_registration_handle_wait(void) "" -qemu_rdma_registration_start(uint64_t flags) "%" PRIu64 -qemu_rdma_registration_stop(uint64_t flags) "%" PRIu64 -qemu_rdma_registration_stop_ram(void) "" qemu_rdma_resolve_host_trying(const char *host, const char *ip) "Trying %s => %s" qemu_rdma_signal_unregister_append(uint64_t chunk, int pos) "Appending unregister chunk %" PRIu64 " at position %d" qemu_rdma_signal_unregister_already(uint64_t chunk) "Unregister chunk %" PRIu64 " already in queue"
@@ -253,6 +239,20 @@ qemu_rdma_write_one_zero(uint64_t chunk, int len, int index, int64_t offset) "En rdma_add_block(const char *block_name, int block, uint64_t addr, uint64_t offset, uint64_t len, uint64_t end, uint64_t bits, int chunks) "Added Block: '%s':%d, addr: %" PRIu64 ", offset: %" PRIu64 " length: %" PRIu64 " end: %" PRIu64 " bits %" PRIu64 " chunks %d" rdma_block_notification_handle(const char *name, int index) "%s at %d" rdma_delete_block(void *block, uint64_t addr, uint64_t offset, uint64_t len, uint64_t end, uint64_t bits, int chunks) "Deleted Block: %p, addr: %" PRIu64 ", offset: %" PRIu64 " length: %" PRIu64 " end: %" PRIu64 " bits %" PRIu64 " chunks %d" +rdma_registration_handle_compress(int64_t length, int index, int64_t offset) "Zapping zero chunk: %" PRId64 " bytes, index %d, offset %" PRId64 +rdma_registration_handle_finished(void) "" +rdma_registration_handle_ram_blocks(void) "" +rdma_registration_handle_ram_blocks_loop(const char *name, uint64_t offset, uint64_t length, void *local_host_addr, unsigned int src_index) "%s: @0x%" PRIx64 "/%" PRIu64 " host:@%p src_index: %u" +rdma_registration_handle_register(int requests) "%d requests" +rdma_registration_handle_register_loop(int req, int index, uint64_t addr, uint64_t chunks) "Registration request (%d): index %d, current_addr %" PRIu64 " chunks: %" PRIu64 +rdma_registration_handle_register_rkey(int rkey) "0x%x" +rdma_registration_handle_unregister(int requests) "%d requests" +rdma_registration_handle_unregister_loop(int count, int index, uint64_t chunk) "Unregistration request (%d): index %d, chunk %" PRIu64 +rdma_registration_handle_unregister_success(uint64_t chunk) "%" PRIu64 +rdma_registration_handle_wait(void) "" +rdma_registration_start(uint64_t flags) "%" PRIu64 +rdma_registration_stop(uint64_t flags) "%" PRIu64 +rdma_registration_stop_ram(void) "" rdma_start_incoming_migration(void) "" rdma_start_incoming_migration_after_dest_init(void) "" rdma_start_incoming_migration_after_rdma_listen(void) ""
Signature · 1 line
2.40.0
PATCH v2 16/16 migration/rdma: If we are in postcopy don't do anything
In reply to Juan Quintela--- migration/rdma.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
migration/rdma.c +12 -12
@@ -3243,10 +3243,6 @@ static size_t qemu_rdma_save_page(QEMUFile *f,CHECK_ERROR_STATE (); -if (migration_in_postcopy ()) { -return RAM_SAVE_CONTROL_NOT_SUPP ; - } -qemu_fflush (f);/*
@@ -3323,6 +3319,10 @@ size_t rdma_control_save_page(QEMUFile *f, ram_addr_t block_offset,return RAM_SAVE_CONTROL_NOT_SUPP ; } +if (migration_in_postcopy ()) { +return RAM_SAVE_CONTROL_NOT_SUPP ; + } +int ret =qemu_rdma_save_page (f, block_offset, offset, size, bytes_sent);if (ret !=RAM_SAVE_CONTROL_NOT_SUPP ) {qemu_file_acct_rate_limit (f, size);
@@ -3883,6 +3883,10 @@ int rdma_registration_start(QEMUFile *f, uint64_t flags)return 0 ; } +if (migration_in_postcopy ()) { +return 0 ; + } +RCU_READ_LOCK_GUARD (); rdma =qatomic_rcu_read (&rioc->rdmaout);if (!rdma) {
@@ -3891,10 +3895,6 @@ int rdma_registration_start(QEMUFile *f, uint64_t flags)CHECK_ERROR_STATE (); -if (migration_in_postcopy ()) { -return 0 ; - } -trace_rdma_registration_start (flags);qemu_put_be64 (f,RAM_SAVE_FLAG_HOOK );qemu_fflush (f);
@@ -3917,6 +3917,10 @@ int rdma_registration_stop(QEMUFile *f, uint64_t flags)return 0 ; } +if (migration_in_postcopy ()) { +return 0 ; + } +RCU_READ_LOCK_GUARD (); rdma =qatomic_rcu_read (&rioc->rdmaout);if (!rdma) {
@@ -3925,10 +3929,6 @@ int rdma_registration_stop(QEMUFile *f, uint64_t flags)CHECK_ERROR_STATE (); -if (migration_in_postcopy ()) { -return 0 ; - } -qemu_fflush (f); ret =qemu_rdma_drain_cq (f, rdma);
Signature · 1 line
2.40.0