Create setup/cleanup methods for migration incoming side
v4 cover Create setup/cleanup methods for migration incoming side
Hi
Changes from v4:
- make sure that we call save_cleanup() in postocpy (dave).
Please, review.
[v3]
- rename htab_cleanup htab_save_cleanup (dave)
- loaded_data was needed because caller can need it (dave)
- improve error message (dave)
Please, review.
[v2]
- Kevin detected that I didn't called load_cleanup(), fix it.
- Be consistent and change the naming of the functions so they are all:
qemu_savevm_state_* or qemu_loadvm_state*
- the traces still used the all names of _begin, instead of _setup, fix that.
Please, review.
Later, Juan.
PD: Yes, now that the includes are internal, we coauld rename
"qemu_savevm_state_" to something shorter, like `savevm_". The same for the loadvm counterparts. But I am not doing any such changes soon, too much churn for so little gain.
[v1]
This series make:
- use of cleanup/save methods generic, not only for save_live methods
- create the equivalent methods for the load side (load_setup/cleanup)
- Make ram use this methods to see how/when they are used.
Stefan, Kevin, this were the methods that you asked for the block.c migration, right? Please, comment if they are enough for you.
Juan Quintela (5):
migration: Rename save_live_setup() to save_setup()
migration: Rename cleanup() to save_cleanup()
migration: Create load_setup()/cleanup() methods
migration: Convert ram to use new load_setup()/load_cleanup()
migration: Make compression_threads use save/load_setup/cleanup()
hw/ppc/spapr.c | 6 ++--- include/migration/register.h | 6 +++-- migration/block.c | 4 +-- migration/colo.c | 2 +- migration/migration.c | 10 +------ migration/ram.c | 63 +++++++++++++++++++++++++++++++------------- migration/ram.h | 6 ----- migration/savevm.c | 61 +++++++++++++++++++++++++++++++++++------- migration/savevm.h | 3 ++- migration/trace-events | 4 ++- 10 files changed, 113 insertions(+), 52 deletions(-)
Signature · 1 line
2.9.4
PATCH v4 1/5 migration: Rename save_live_setup() to save_setup()
We are going to use it now for more than save live regions. Once there rename qemu_savevm_state_begin() to qemu_savevm_state_setup().
--- hw/ppc/spapr.c | 2 +- include/migration/register.h | 2 +- migration/block.c | 2 +- migration/colo.c | 2 +- migration/migration.c | 2 +- migration/ram.c | 2 +- migration/savevm.c | 12 ++++++------ migration/savevm.h | 2 +- migration/trace-events | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-)
hw/ppc/spapr.c +1 -1
@@ -1869,7 +1869,7 @@ static void htab_cleanup(void *opaque) }static SaveVMHandlers savevm_htab_handlers = { - .save_live_setup = htab_save_setup, + .save_setup = htab_save_setup, .save_live_iterate = htab_save_iterate, .save_live_complete_precopy = htab_save_complete, .cleanup = htab_cleanup,
include/migration/register.h +1 -1
@@ -33,7 +33,7 @@ typedef struct SaveVMHandlers {int (*save_live_iterate)(QEMUFile *f,void *opaque);/* This runs outside the iothread lock! */ -int (*save_live_setup)(QEMUFile *f,void *opaque); +int (*save_setup)(QEMUFile *f,void *opaque); void (*save_live_pending)(QEMUFile *f, void *opaque, uint64_t threshold_size, uint64_t *non_postcopiable_pending,
migration/block.c +1 -1
@@ -1004,7 +1004,7 @@ static bool block_is_active(void *opaque) }static SaveVMHandlers savevm_block_handlers = { - .save_live_setup = block_save_setup, + .save_setup = block_save_setup, .save_live_iterate = block_save_iterate, .save_live_complete_precopy = block_save_complete, .save_live_pending = block_save_pending,
migration/colo.c +1 -1
@@ -350,7 +350,7 @@ static int colo_do_checkpoint_transaction(MigrationState *s,/* Disable block migration */ migrate_set_block_enabled (false, &local_err);qemu_savevm_state_header (fb); -qemu_savevm_state_begin (fb); +qemu_savevm_state_setup (fb);qemu_mutex_lock_iothread ();qemu_savevm_state_complete_precopy (fb, false, false);qemu_mutex_unlock_iothread ();
migration/migration.c +1 -1
@@ -1840,7 +1840,7 @@ static void *migration_thread(void *opaque)qemu_savevm_send_postcopy_advise (s->to_dst_file); } -qemu_savevm_state_begin (s->to_dst_file); +qemu_savevm_state_setup (s->to_dst_file); s->setup_time =qemu_clock_get_ms (QEMU_CLOCK_HOST ) - setup_start; migrate_set_state(&s->state, MIGRATION_STATUS_SETUP,
migration/ram.c +1 -1
@@ -2623,7 +2623,7 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) }static SaveVMHandlers savevm_ram_handlers = { - .save_live_setup = ram_save_setup, + .save_setup = ram_save_setup, .save_live_iterate = ram_save_iterate, .save_live_complete_postcopy = ram_save_complete, .save_live_complete_precopy = ram_save_complete,
migration/savevm.c +6 -6
@@ -596,7 +596,7 @@ int register_savevm_live(DeviceState *dev, se->opaque = opaque; se->vmsd =NULL ;/* if this is a live_savem then set is_ram */ -if (ops->save_live_setup !=NULL ) { +if (ops->save_setup !=NULL ) { se->is_ram =1 ; }
@@ -955,14 +955,14 @@ void qemu_savevm_state_header(QEMUFile *f) } } -void qemu_savevm_state_begin (QEMUFile *f) +void qemu_savevm_state_setup (QEMUFile *f) {SaveStateEntry *se;int ret; -trace_savevm_state_begin (); +trace_savevm_state_setup (); QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { -if (!se->ops || !se->ops->save_live_setup) { +if (!se->ops || !se->ops->save_setup) {continue ; }if (se->ops && se->ops->is_active) {
@@ -972,7 +972,7 @@ void qemu_savevm_state_begin(QEMUFile *f) }save_section_header (f, se,QEMU_VM_SECTION_START ); - ret = se->ops->save_live_setup (f, se->opaque); + ret = se->ops->save_setup (f, se->opaque);save_section_footer (f, se);if (ret <0 ) {qemu_file_set_error (f, ret);
@@ -1241,7 +1241,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)qemu_mutex_unlock_iothread ();qemu_savevm_state_header (f); -qemu_savevm_state_begin (f); +qemu_savevm_state_setup (f);qemu_mutex_lock_iothread ();while (qemu_file_get_error (f) ==0 ) {
migration/savevm.h +1 -1
@@ -30,7 +30,7 @@#define QEMU_VM_SECTION_FOOTER 0x7ebool qemu_savevm_state_blocked (Error **errp); -void qemu_savevm_state_begin (QEMUFile *f); +void qemu_savevm_state_setup (QEMUFile *f);void qemu_savevm_state_header (QEMUFile *f);int qemu_savevm_state_iterate (QEMUFile *f,bool postcopy);void qemu_savevm_state_cleanup (void );
migration/trace-events +1 -1
@@ -32,7 +32,7 @@ savevm_send_open_return_path(void) "" savevm_send_ping(uint32_t val) "%x" savevm_send_postcopy_listen(void) "" savevm_send_postcopy_run(void) "" -savevm_state_begin(void) "" +savevm_state_setup(void) "" savevm_state_header(void) "" savevm_state_iterate(void) "" savevm_state_cleanup(void) ""
Signature · 1 line
2.9.4
PATCH v4 2/5 migration: Rename cleanup() to save_cleanup()
In reply to Juan QuintelaWe need a cleanup for loads, so we rename here to be consistent.
--
Rename htab_cleanup to htap_save_cleanup as dave suggestion
--- hw/ppc/spapr.c | 4 ++-- include/migration/register.h | 2 +- migration/block.c | 2 +- migration/ram.c | 2 +- migration/savevm.c | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-)
hw/ppc/spapr.c +2 -2
@@ -1861,7 +1861,7 @@ static int htab_load(QEMUFile *f, void *opaque, int version_id)return 0 ; } -static void htab_cleanup (void *opaque) +static void htab_save_cleanup (void *opaque) {sPAPRMachineState *spapr = opaque;
@@ -1872,7 +1872,7 @@ static SaveVMHandlers savevm_htab_handlers = { .save_setup = htab_save_setup, .save_live_iterate = htab_save_iterate, .save_live_complete_precopy = htab_save_complete, - .cleanup = htab_cleanup, + .save_cleanup = htab_save_cleanup, .load_state = htab_load, };
include/migration/register.h +1 -1
@@ -18,7 +18,7 @@ typedef struct SaveVMHandlers {/* This runs inside the iothread lock. */ SaveStateHandler *save_state; -void (*cleanup)(void *opaque); +void (*save_cleanup)(void *opaque);int (*save_live_complete_postcopy)(QEMUFile *f,void *opaque);int (*save_live_complete_precopy)(QEMUFile *f,void *opaque);
migration/block.c +1 -1
@@ -1009,7 +1009,7 @@ static SaveVMHandlers savevm_block_handlers = { .save_live_complete_precopy = block_save_complete, .save_live_pending = block_save_pending, .load_state = block_load, - .cleanup = block_migration_cleanup, + .save_cleanup = block_migration_cleanup, .is_active = block_is_active, };
migration/ram.c +1 -1
@@ -2629,7 +2629,7 @@ static SaveVMHandlers savevm_ram_handlers = { .save_live_complete_precopy = ram_save_complete, .save_live_pending = ram_save_pending, .load_state = ram_load, - .cleanup = ram_migration_cleanup, + .save_cleanup = ram_migration_cleanup, };void ram_mig_init (void )
migration/savevm.c +2 -2
@@ -1215,8 +1215,8 @@ void qemu_savevm_state_cleanup(void)trace_savevm_state_cleanup (); QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { -if (se->ops && se->ops->cleanup) { - se->ops->cleanup (se->opaque); +if (se->ops && se->ops->save_cleanup) { + se->ops->save_cleanup (se->opaque); } } }
Signature · 1 line
2.9.4
PATCH v4 3/5 migration: Create load_setup()/cleanup() methods
In reply to Juan QuintelaWe need to do things at load time and at cleanup time.
--
Move the printing of the error message so we can print the device giving the error.
Add call to postcopy stuff
--- include/migration/register.h | 2 ++ migration/savevm.c | 45 +++++++++++++++++++++++++++++++++++++++++++- migration/savevm.h | 1 + migration/trace-events | 2 ++ 4 files changed, 49 insertions(+), 1 deletion(-)
include/migration/register.h +2 -0
@@ -39,6 +39,8 @@ typedef struct SaveVMHandlers {uint64_t *non_postcopiable_pending, uint64_t *postcopiable_pending);LoadStateHandler *load_state; +int (*load_setup)(QEMUFile *f,void *opaque); +int (*load_cleanup)(void *opaque); } SaveVMHandlers; int register_savevm_live(DeviceState *dev,
migration/savevm.c +44 -1
69 lines not on this page · raw message
migration/savevm.h +1 -0
@@ -53,5 +53,6 @@ void qemu_savevm_send_postcopy_ram_discard(QEMUFile *f, const char *name, uint64_t *length_list);int qemu_loadvm_state (QEMUFile *f); +void qemu_loadvm_state_cleanup (void );#endif
migration/trace-events +2 -0
@@ -7,6 +7,8 @@ qemu_loadvm_state_section_partend(uint32_t section_id) "%u" qemu_loadvm_state_post_main(int ret) "%d" qemu_loadvm_state_section_startfull(uint32_t section_id, const char *idstr, uint32_t instance_id, uint32_t version_id) "%u(%s) %u %u" qemu_savevm_send_packaged(void) "" +loadvm_state_setup(void) "" +loadvm_state_cleanup(void) "" loadvm_handle_cmd_packaged(unsigned int length) "%u" loadvm_handle_cmd_packaged_main(int ret) "%d" loadvm_handle_cmd_packaged_received(int ret) "%d"
Signature · 1 line
2.9.4
Re: [Qemu-devel] [PATCH v4 3/5] migration: Create load_setup()/cleanup() methods
Quoted 34 lines · * Juan Quintela ([email protected]) wrote:
We need to do things at load time and at cleanup time.
Signed-off-by Juan Quintela <[email protected]>--
Move the printing of the error message so we can print the device giving the error.
Add call to postcopy stuff--- include/migration/register.h | 2 ++ migration/savevm.c | 45 +++++++++++++++++++++++++++++++++++++++++++- migration/savevm.h | 1 + migration/trace-events | 2 ++ 4 files changed, 49 insertions(+), 1 deletion(-)include/migration/register.h +2
-0@@ -39,6 +39,8 @@ typedef struct SaveVMHandlers {uint64_t *non_postcopiable_pending, uint64_t *postcopiable_pending);LoadStateHandler *load_state; +int (*load_setup)(QEMUFile *f,void *opaque); +int (*load_cleanup)(void *opaque); } SaveVMHandlers; int register_savevm_live(DeviceState *dev,migration/savevm.c +0
-0
migration/savevm.c static void *postcopy_ram_listen_thread(void *opaque) · line 1544
Quoted 5 lines
migration/savevm.c +1
-1@@ -1541,7 +1541,7 @@ static void *postcopy_ram_listen_thread(void *opaque)* got a bad migration state). */ migration_incoming_state_destroy (); - +qemu_loadvm_state_cleanup ();
Is that order right? It seems wrong to call the cleanup code after MIS is destroyed.
(The precopy path seems to call mis_destroy at the end of process_incoming_migration_bh which is much later).
Dave
Quoted 93 lines
migration/savevm.c +43
-0return NULL ; }@@ -1901,6 +1901,44 @@ qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis)return 0 ; } +static int qemu_loadvm_state_setup (QEMUFile *f) +{ +SaveStateEntry *se; +int ret; + +trace_loadvm_state_setup (); + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { +if (!se->ops || !se->ops->load_setup) { +continue ; + } +if (se->ops && se->ops->is_active) { +if (!se->ops->is_active (se->opaque)) { +continue ; + } + } + + ret = se->ops->load_setup (f, se->opaque); +if (ret <0 ) { +qemu_file_set_error (f, ret); +error_report ("Load state of device %s failed" , se->idstr); +return ret; + } + } +return 0 ; +} + +void qemu_loadvm_state_cleanup (void ) +{ +SaveStateEntry *se; + +trace_loadvm_state_cleanup (); + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { +if (se->ops && se->ops->load_cleanup) { + se->ops->load_cleanup (se->opaque); + } + } +} +static int qemu_loadvm_state_main (QEMUFile *f,MigrationIncomingState *mis) {uint8_t section_type;@@ -1973,6 +2011,10 @@ int qemu_loadvm_state(QEMUFile *f)return -ENOTSUP ; } +if (qemu_loadvm_state_setup (f) !=0 ) { +return -EINVAL ; + } +if (migrate_get_current ()->send_configuration) {if (qemu_get_byte (f) !=QEMU_VM_CONFIGURATION ) {error_report ("Configuration section missing" );@@ -2036,6 +2078,7 @@ int qemu_loadvm_state(QEMUFile *f) } } +qemu_loadvm_state_cleanup ();cpu_synchronize_all_post_init ();return ret;migration/savevm.h +1
-0@@ -53,5 +53,6 @@ void qemu_savevm_send_postcopy_ram_discard(QEMUFile *f, const char *name, uint64_t *length_list);int qemu_loadvm_state (QEMUFile *f); +void qemu_loadvm_state_cleanup (void );#endif migration/trace-events +2
-0@@ -7,6 +7,8 @@ qemu_loadvm_state_section_partend(uint32_t section_id) "%u" qemu_loadvm_state_post_main(int ret) "%d" qemu_loadvm_state_section_startfull(uint32_t section_id, const char *idstr, uint32_t instance_id, uint32_t version_id) "%u(%s) %u %u" qemu_savevm_send_packaged(void) "" +loadvm_state_setup(void) "" +loadvm_state_cleanup(void) "" loadvm_handle_cmd_packaged(unsigned int length) "%u" loadvm_handle_cmd_packaged_main(int ret) "%d" loadvm_handle_cmd_packaged_received(int ret) "%d"Signature · 1 line
2.9.4
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] [PATCH v4 3/5] migration: Create load_setup()/cleanup() methods
Quoted 29 lines · Dr. David Alan Gilbert
Quoted 28 lines · * Juan Quintela ([email protected]) wrote:
We need to do things at load time and at cleanup time.
Signed-off-by Juan Quintela <[email protected]>--
Move the printing of the error message so we can print the device giving the error.
Add call to postcopy stuff--- include/migration/register.h | 2 ++ migration/savevm.c | 45 +++++++++++++++++++++++++++++++++++++++++++- migration/savevm.h | 1 + migration/trace-events | 2 ++ 4 files changed, 49 insertions(+), 1 deletion(-)include/migration/register.h +2
-0@@ -39,6 +39,8 @@ typedef struct SaveVMHandlers {uint64_t *non_postcopiable_pending, uint64_t *postcopiable_pending);LoadStateHandler *load_state; +int (*load_setup)(QEMUFile *f,void *opaque); +int (*load_cleanup)(void *opaque); } SaveVMHandlers;
Quoted 16 lines
migration/savevm.c static void *postcopy_ram_listen_thread(void *opaque) · line 1544
Quoted 11 lines
include/migration/register.h +0
-0int register_savevm_live(DeviceState *dev,migration/savevm.c +1
-1@@ -1541,7 +1541,7 @@ static void *postcopy_ram_listen_thread(void *opaque)* got a bad migration state). */ migration_incoming_state_destroy (); - +qemu_loadvm_state_cleanup ();Is that order right? It seems wrong to call the cleanup code after MIS is destroyed.
(The precopy path seems to callmis_destroyat the end ofprocess_incoming_migration_bhwhich is much later).
we can do either way, for now it don't matters.
Once there, it got me thinking that we are doing things in a very "interesting" way on the incoming side:
(postcopy)
postcopy_ram_incoming_cleanup()migration_incoming_state_destroy()qemu_loadvm_state_cleanup()
(Ok, probably it is better to exchange the last two).
But I *think* that we should move the postcopy_ram_incoming_cleanup() inside ram_load_cleanup(), no?
And we don't have a postcopy_ram_incoming_setup() We could put there the mmap of mis->postcopy_tmp_zero_page and mis->largest_page_size, no?
I am trying to understand if the postcopy_ram_incoming_init() can be moved soon, but I think no.
Later, Juan.
Re: [Qemu-devel] [PATCH v4 3/5] migration: Create load_setup()/cleanup() methods
Quoted 54 lines · * Juan Quintela ([email protected]) wrote:
Quoted 29 lines · Dr. David Alan Gilbert
Quoted 28 lines · * Juan Quintela ([email protected]) wrote:
We need to do things at load time and at cleanup time.
Signed-off-by Juan Quintela <[email protected]>--
Move the printing of the error message so we can print the device giving the error.
Add call to postcopy stuff--- include/migration/register.h | 2 ++ migration/savevm.c | 45 +++++++++++++++++++++++++++++++++++++++++++- migration/savevm.h | 1 + migration/trace-events | 2 ++ 4 files changed, 49 insertions(+), 1 deletion(-)include/migration/register.h +2
-0@@ -39,6 +39,8 @@ typedef struct SaveVMHandlers {uint64_t *non_postcopiable_pending, uint64_t *postcopiable_pending);LoadStateHandler *load_state; +int (*load_setup)(QEMUFile *f,void *opaque); +int (*load_cleanup)(void *opaque); } SaveVMHandlers;Quoted 16 lines
migration/savevm.c static void *postcopy_ram_listen_thread(void *opaque) · line 1544
Quoted 11 lines
include/migration/register.h +0
-0int register_savevm_live(DeviceState *dev,migration/savevm.c +1
-1@@ -1541,7 +1541,7 @@ static void *postcopy_ram_listen_thread(void *opaque)* got a bad migration state). */ migration_incoming_state_destroy (); - +qemu_loadvm_state_cleanup ();Is that order right? It seems wrong to call the cleanup code after MIS is destroyed.
(The precopy path seems to callmis_destroyat the end ofprocess_incoming_migration_bhwhich is much later).we can do either way, for now it don't matters.
Once there, it got me thinking that we are doing things in a very "interesting" way on the incoming side:
(postcopy)
Quoted 8 lines
postcopy_ram_incoming_cleanup()migration_incoming_state_destroy()qemu_loadvm_state_cleanup()(Ok, probably it is better to exchange the last two).
But I *think* that we should move the
postcopy_ram_incoming_cleanup()insideram_load_cleanup(), no?
postcopy_ram_incoming_cleanup shuts down a thread that's shared across all RAMBlock's, so I don't think it can all be merged intoram_load_cleanup. You might be able to do the equivalent of thecleanup_range function.
Quoted 2 lines
And we don't have a
postcopy_ram_incoming_setup()We could put there the mmap ofmis->postcopy_tmp_zero_pageandmis->largest_page_size, no?
Again that's a single shared zero page, not per RAMBlock.
Quoted 2 lines
I am trying to understand if the
postcopy_ram_incoming_init()can be moved soon, but I think no.
Dave
Quoted 4 lines
Later, Juan.
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] [PATCH v4 3/5] migration: Create load_setup()/cleanup() methods
Quoted 61 lines · * Dr. David Alan Gilbert ([email protected]) wrote:
Quoted 60 lines · * Juan Quintela ([email protected]) wrote:
Quoted 29 lines · Dr. David Alan Gilbert
Quoted 28 lines · * Juan Quintela ([email protected]) wrote:
We need to do things at load time and at cleanup time.
Signed-off-by Juan Quintela <[email protected]>--
Move the printing of the error message so we can print the device giving the error.
Add call to postcopy stuff--- include/migration/register.h | 2 ++ migration/savevm.c | 45 +++++++++++++++++++++++++++++++++++++++++++- migration/savevm.h | 1 + migration/trace-events | 2 ++ 4 files changed, 49 insertions(+), 1 deletion(-)include/migration/register.h +2
-0@@ -39,6 +39,8 @@ typedef struct SaveVMHandlers {uint64_t *non_postcopiable_pending, uint64_t *postcopiable_pending);LoadStateHandler *load_state; +int (*load_setup)(QEMUFile *f,void *opaque); +int (*load_cleanup)(void *opaque); } SaveVMHandlers;Quoted 16 lines
migration/savevm.c static void *postcopy_ram_listen_thread(void *opaque) · line 1544
Quoted 11 lines
include/migration/register.h +0
-0int register_savevm_live(DeviceState *dev,migration/savevm.c +1
-1@@ -1541,7 +1541,7 @@ static void *postcopy_ram_listen_thread(void *opaque)* got a bad migration state). */ migration_incoming_state_destroy (); - +qemu_loadvm_state_cleanup ();Is that order right? It seems wrong to call the cleanup code after MIS is destroyed.
(The precopy path seems to callmis_destroyat the end ofprocess_incoming_migration_bhwhich is much later).we can do either way, for now it don't matters.
Once there, it got me thinking that we are doing things in a very "interesting" way on the incoming side:
(postcopy)
postcopy_ram_incoming_cleanup()migration_incoming_state_destroy()qemu_loadvm_state_cleanup()(Ok, probably it is better to exchange the last two).
Quoted 7 lines
Quoted 2 lines
But I *think* that we should move the
postcopy_ram_incoming_cleanup()insideram_load_cleanup(), no?
postcopy_ram_incoming_cleanupshuts down a thread that's shared across all RAMBlock's, so I don't think it can all be merged intoram_load_cleanup. You might be able to do the equivalent of thecleanup_rangefunction.
Actually that's wrong, we only call ram_load_cleanup once - because RAM is special and is only register_savevm_live once, not per device.
So yes you probably can do that.
Dave
Quoted 8 lines
Quoted 2 lines
And we don't have a
postcopy_ram_incoming_setup()We could put there the mmap ofmis->postcopy_tmp_zero_pageandmis->largest_page_size, no?Again that's a single shared zero page, not per RAMBlock.
Quoted 2 lines
I am trying to understand if the
postcopy_ram_incoming_init()can be moved soon, but I think no.
Quoted 8 lines
Dave
Quoted 4 lines
Later, Juan.
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Dr. David Alan Gilbert
Reviewed-byRe: [Qemu-devel] [PATCH v4 3/5] migration: Create load_setup()/cleanup() methods
In reply to Juan QuintelaQuoted 47 lines · * Juan Quintela ([email protected]) wrote:
Quoted 29 lines · Dr. David Alan Gilbert
Quoted 28 lines · * Juan Quintela ([email protected]) wrote:
We need to do things at load time and at cleanup time.
Signed-off-by Juan Quintela <[email protected]>--
Move the printing of the error message so we can print the device giving the error.
Add call to postcopy stuff--- include/migration/register.h | 2 ++ migration/savevm.c | 45 +++++++++++++++++++++++++++++++++++++++++++- migration/savevm.h | 1 + migration/trace-events | 2 ++ 4 files changed, 49 insertions(+), 1 deletion(-)include/migration/register.h +2
-0@@ -39,6 +39,8 @@ typedef struct SaveVMHandlers {uint64_t *non_postcopiable_pending, uint64_t *postcopiable_pending);LoadStateHandler *load_state; +int (*load_setup)(QEMUFile *f,void *opaque); +int (*load_cleanup)(void *opaque); } SaveVMHandlers;Quoted 16 lines
migration/savevm.c static void *postcopy_ram_listen_thread(void *opaque) · line 1544
Quoted 11 lines
include/migration/register.h +0
-0int register_savevm_live(DeviceState *dev,migration/savevm.c +1
-1@@ -1541,7 +1541,7 @@ static void *postcopy_ram_listen_thread(void *opaque)* got a bad migration state). */ migration_incoming_state_destroy (); - +qemu_loadvm_state_cleanup ();Is that order right? It seems wrong to call the cleanup code after MIS is destroyed.
(The precopy path seems to callmis_destroyat the end ofprocess_incoming_migration_bhwhich is much later).
Quoted 1 line
we can do either way, for now it don't matters.
OK, yes, for now it doesn't matter, so:
Quoted 14 lines
Once there, it got me thinking that we are doing things in a very "interesting" way on the incoming side:
(postcopy)
postcopy_ram_incoming_cleanup()migration_incoming_state_destroy()qemu_loadvm_state_cleanup()(Ok, probably it is better to exchange the last two).
But I *think* that we should move the
postcopy_ram_incoming_cleanup()insideram_load_cleanup(), no?
Quoted 10 lines
And we don't have a
postcopy_ram_incoming_setup()We could put there the mmap ofmis->postcopy_tmp_zero_pageandmis->largest_page_size, no?I am trying to understand if the
postcopy_ram_incoming_init()can be moved soon, but I think no.Later, Juan.
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH v4 4/5 migration: Convert ram to use new load_setup()/load_cleanup()
In reply to Juan QuintelaOnce there, I rename ram_migration_cleanup() to ram_save_cleanup(). Notice that this is the first pass, and I only passed XBZRLE to the new scheme. Moved decoded_buf to inside XBZRLE struct. As a bonus, I don't have to export xbzrle functions from ram.c.
--
loaded_data pointer was needed because called can change it (dave) spell loaded correctly in comment (dave)
--- migration/migration.c | 3 --- migration/ram.c | 49 ++++++++++++++++++++++++++++++++++++------------- migration/ram.h | 1 - 3 files changed, 36 insertions(+), 17 deletions(-)
migration/migration.c +0 -3
@@ -357,9 +357,6 @@ static void process_incoming_migration_co(void *opaque)migrate_decompress_threads_join ();exit (EXIT_FAILURE ); } - -free_xbzrle_decoded_buf (); - mis->bh =qemu_bh_new (process_incoming_migration_bh, mis);qemu_bh_schedule (mis->bh); }
migration/ram.c +36 -13
91 lines not on this page · raw message
migration/ram.h +0 -1
@@ -47,7 +47,6 @@ void migrate_decompress_threads_join(void);uint64_t ram_pagesize_summary (void );int ram_save_queue_pages (const char *rbname,ram_addr_t start,ram_addr_t len);void acct_update_position (QEMUFile *f,size_t size,bool zero); -void free_xbzrle_decoded_buf (void );void ram_debug_dump_bitmap (unsigned long *todump,bool expected,unsigned long pages);void ram_postcopy_migrated_memory_release (MigrationState *ms);
Signature · 1 line
2.9.4
PATCH v4 5/5 migration: Make compression_threads use save/load_setup/cleanup()
In reply to Juan QuintelaOnce there, be consistent and use
compress_thread_{save,load}_{setup,cleanup}.
--- migration/migration.c | 5 ----- migration/ram.c | 12 ++++++++---- migration/ram.h | 5 ----- 3 files changed, 8 insertions(+), 14 deletions(-)
migration/migration.c +0 -5
@@ -291,7 +291,6 @@ static void process_incoming_migration_bh(void *opaque) }else {runstate_set (global_state_get_runstate ()); } -migrate_decompress_threads_join ();/* * This must happen after any state changes since as soon as an external * observer sees this event they might start to prod at the VM assuming
@@ -354,7 +353,6 @@ static void process_incoming_migration_co(void *opaque)migrate_set_state (&mis->state,MIGRATION_STATUS_ACTIVE ,MIGRATION_STATUS_FAILED );error_report ("load of migration failed: %s" ,strerror (-ret)); -migrate_decompress_threads_join ();exit (EXIT_FAILURE ); } mis->bh =qemu_bh_new (process_incoming_migration_bh, mis);
@@ -365,7 +363,6 @@ void migration_fd_process_incoming(QEMUFile *f) {Coroutine *co =qemu_coroutine_create (process_incoming_migration_co, f); -migrate_decompress_threads_create ();qemu_file_set_blocking (f, false);qemu_coroutine_enter (co); }
@@ -832,7 +829,6 @@ static void migrate_fd_cleanup(void *opaque) }qemu_mutex_lock_iothread (); -migrate_compress_threads_join ();qemu_fclose (s->to_dst_file); s->to_dst_file =NULL ; }
@@ -1995,7 +1991,6 @@ void migrate_fd_connect(MigrationState *s) } } -migrate_compress_threads_create ();qemu_thread_create (&s->thread,"live_migration" , migration_thread, s,QEMU_THREAD_JOINABLE ); s->migration_thread_running = true;
migration/ram.c +8 -4
@@ -306,7 +306,7 @@ static inline void terminate_compression_threads(void) } } -void migrate_compress_threads_join (void ) +static void compress_threads_save_cleanup (void ) {int i, thread_count;
@@ -329,7 +329,7 @@ void migrate_compress_threads_join(void) comp_param =NULL ; } -void migrate_compress_threads_create (void ) +static void compress_threads_save_setup (void ) {int i, thread_count;
@@ -1390,6 +1390,7 @@ static void ram_save_cleanup(void *opaque) }XBZRLE_cache_unlock ();migration_page_queue_free (*rsp); +compress_threads_save_cleanup ();g_free (*rsp); *rsp =NULL ; }
@@ -1923,6 +1924,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) }rcu_read_unlock (); +compress_threads_save_setup ();ram_control_before_iterate (f,RAM_CONTROL_SETUP );ram_control_after_iterate (f,RAM_CONTROL_SETUP );
@@ -2231,7 +2233,7 @@ static void wait_for_decompress_done(void)qemu_mutex_unlock (&decomp_done_lock); } -void migrate_decompress_threads_create (void ) +static void compress_threads_load_setup (void ) {int i, thread_count;
@@ -2255,7 +2257,7 @@ void migrate_decompress_threads_create(void) } } -void migrate_decompress_threads_join (void ) +static void compress_threads_load_cleanup (void ) {int i, thread_count;
@@ -2321,12 +2323,14 @@ static void decompress_data_with_multi_threads(QEMUFile *f,static int ram_load_setup (QEMUFile *f,void *opaque) {xbzrle_load_setup (); +compress_threads_load_setup ();return 0 ; }static int ram_load_cleanup (void *opaque) {xbzrle_load_cleanup (); +compress_threads_load_cleanup ();return 0 ; }
migration/ram.h +0 -5
@@ -39,11 +39,6 @@ int64_t xbzrle_cache_resize(int64_t new_size);uint64_t ram_bytes_remaining (void );uint64_t ram_bytes_total (void ); -void migrate_compress_threads_create (void ); -void migrate_compress_threads_join (void ); -void migrate_decompress_threads_create (void ); -void migrate_decompress_threads_join (void ); -uint64_t ram_pagesize_summary (void );int ram_save_queue_pages (const char *rbname,ram_addr_t start,ram_addr_t len);void acct_update_position (QEMUFile *f,size_t size,bool zero);
Signature · 1 line
2.9.4
Quoted 1 line · * Juan Quintela ([email protected]) wrote:
Hi
Queued.
Quoted 44 lines
Changes from v4:
- make sure that we callsave_cleanup()in postocpy (dave).Please, review.
[v3]
- renamehtab_cleanuphtab_save_cleanup(dave)
-loaded_datawas needed because caller can need it (dave)
- improve error message (dave)Please, review.
[v2]
- Kevin detected that I didn't calledload_cleanup(), fix it.
- Be consistent and change the naming of the functions so they are all:
qemu_savevm_state_* or qemu_loadvm_state*
- the traces still used the all names of_begin, instead of_setup, fix that.Please, review.
Later, Juan.
PD: Yes, now that the includes are internal, we coauld rename
"qemu_savevm_state_" to something shorter, like `savevm_". The same for the loadvm counterparts. But I am not doing any such changes soon, too much churn for so little gain.[v1]
This series make:
- use of cleanup/save methods generic, not only forsave_livemethods
- create the equivalent methods for the load side (load_setup/cleanup)
- Make ram use this methods to see how/when they are used.Stefan, Kevin, this were the methods that you asked for the
block.cmigration, right? Please, comment if they are enough for you.Juan Quintela (5):
migration: Renamesave_live_setup()tosave_setup()
migration: Renamecleanup()tosave_cleanup()
migration: Create load_setup()/cleanup() methods
migration: Convert ram to use new load_setup()/load_cleanup()
migration: Makecompression_threadsuse save/load_setup/cleanup()
Quoted 16 lines
hw/ppc/spapr.c | 6 ++--- include/migration/register.h | 6 +++-- migration/block.c | 4 +-- migration/colo.c | 2 +- migration/migration.c | 10 +------ migration/ram.c | 63 +++++++++++++++++++++++++++++++------------- migration/ram.h | 6 ----- migration/savevm.c | 61 +++++++++++++++++++++++++++++++++++------- migration/savevm.h | 3 ++- migration/trace-events | 4 ++- 10 files changed, 113 insertions(+), 52 deletions(-)Signature · 1 line
2.9.4
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK