Message ID | 1e9e8749f384425d04c74bc76fc502621e226352.1340910651.git.quintela@redhat.com |
---|---|
State | New |
Headers | show |
On 6/28/2012 11:22 PM, Juan Quintela wrote: > Enable the creation of a method to tell migration if that section is > active and should be migrate. We use it for blk-migration, that is > normally not active. We don't create the method for RAM, as setups > without RAM are very strange O:-) > > Signed-off-by: Juan Quintela <quintela@redhat.com> > --- > block-migration.c | 13 ++++++------- > savevm.c | 15 +++++++++++++++ > vmstate.h | 1 + > 3 files changed, 22 insertions(+), 7 deletions(-) > > diff --git a/block-migration.c b/block-migration.c > index cd8a8dd..6d37dc1 100644 > --- a/block-migration.c > +++ b/block-migration.c > @@ -548,13 +548,6 @@ static int block_save_live(QEMUFile *f, int stage, void *opaque) > DPRINTF("Enter save live stage %d submitted %d transferred %d\n", > stage, block_mig_state.submitted, block_mig_state.transferred); > > - > - if (block_mig_state.blk_enable != 1) { > - /* no need to migrate storage */ > - qemu_put_be64(f, BLK_MIG_FLAG_EOS); > - return 1; > - } > - > if (stage == 1) { > init_blk_migration(f); > > @@ -710,11 +703,17 @@ static void block_set_params(const MigrationParams *params, void *opaque) > block_mig_state.blk_enable |= params->shared; > } > > +static bool block_is_active(void *opaque) > +{ > + return block_mig_state.blk_enable == 1; > +} > + > SaveVMHandlers savevm_block_handlers = { > .set_params = block_set_params, > .save_live_state = block_save_live, > .load_state = block_load, > .cancel = block_migration_cancel, > + .is_active = block_is_active, > }; > > void blk_mig_init(void) > diff --git a/savevm.c b/savevm.c > index 888c5a2..afa0c9e 100644 > --- a/savevm.c > +++ b/savevm.c > @@ -1576,6 +1576,11 @@ int qemu_savevm_state_begin(QEMUFile *f, > if (!se->ops || !se->ops->save_live_state) { > continue; > } > + if (se->ops && se->ops->is_active) { > + if (!se->ops->is_active(se->opaque)) { If we got here then we know for sure that se->ops != NULL,and then nested condition could be simplified to if (se->ops->is_active && !se->ops->is_active(se->opaque)). Same for qemu_savevm_state_iterate() amd qemu_savevm_state_complete() > + continue; > + } > + } > /* Section type */ > qemu_put_byte(f, QEMU_VM_SECTION_START); > qemu_put_be32(f, se->section_id); > @@ -1618,6 +1623,11 @@ int qemu_savevm_state_iterate(QEMUFile *f) > if (!se->ops || !se->ops->save_live_state) { > continue; > } > + if (se->ops && se->ops->is_active) { > + if (!se->ops->is_active(se->opaque)) { > + continue; > + } > + } > if (qemu_file_rate_limit(f)) { > return 0; > } > @@ -1658,6 +1668,11 @@ int qemu_savevm_state_complete(QEMUFile *f) > if (!se->ops || !se->ops->save_live_state) { > continue; > } > + if (se->ops && se->ops->is_active) { > + if (!se->ops->is_active(se->opaque)) { > + continue; > + } > + } > trace_savevm_section_start(); > /* Section type */ > qemu_put_byte(f, QEMU_VM_SECTION_END); > diff --git a/vmstate.h b/vmstate.h > index 1dd42f5..96651a5 100644 > --- a/vmstate.h > +++ b/vmstate.h > @@ -35,6 +35,7 @@ typedef struct SaveVMHandlers { > int (*save_live_state)(QEMUFile *f, int stage, void *opaque); > void (*cancel)(void *opaque); > LoadStateHandler *load_state; > + bool (*is_active)(void *opaque); > } SaveVMHandlers; > > int register_savevm(DeviceState *dev, >
Igor Mitsyanko <i.mitsyanko@gmail.com> wrote: > On 6/28/2012 11:22 PM, Juan Quintela wrote: >> Enable the creation of a method to tell migration if that section is >> active and should be migrate. We use it for blk-migration, that is >> normally not active. We don't create the method for RAM, as setups >> without RAM are very strange O:-) >> >> Signed-off-by: Juan Quintela <quintela@redhat.com> >> @@ -1576,6 +1576,11 @@ int qemu_savevm_state_begin(QEMUFile *f, >> if (!se->ops || !se->ops->save_live_state) { >> continue; >> } >> + if (se->ops && se->ops->is_active) { >> + if (!se->ops->is_active(se->opaque)) { > > If we got here then we know for sure that se->ops != NULL,and then > nested condition could be simplified to if (se->ops->is_active && > !se->ops->is_active(se->opaque)). Same for qemu_savevm_state_iterate() > amd qemu_savevm_state_complete() I tried to maintain consistency with the previous test, i.e. all have the same structure. I am still not sure which one is better :-() The approach that I did put the things in the same order, yours, remove two lines and one && operand. Will think about that one, thanks. Later, Juan.
diff --git a/block-migration.c b/block-migration.c index cd8a8dd..6d37dc1 100644 --- a/block-migration.c +++ b/block-migration.c @@ -548,13 +548,6 @@ static int block_save_live(QEMUFile *f, int stage, void *opaque) DPRINTF("Enter save live stage %d submitted %d transferred %d\n", stage, block_mig_state.submitted, block_mig_state.transferred); - - if (block_mig_state.blk_enable != 1) { - /* no need to migrate storage */ - qemu_put_be64(f, BLK_MIG_FLAG_EOS); - return 1; - } - if (stage == 1) { init_blk_migration(f); @@ -710,11 +703,17 @@ static void block_set_params(const MigrationParams *params, void *opaque) block_mig_state.blk_enable |= params->shared; } +static bool block_is_active(void *opaque) +{ + return block_mig_state.blk_enable == 1; +} + SaveVMHandlers savevm_block_handlers = { .set_params = block_set_params, .save_live_state = block_save_live, .load_state = block_load, .cancel = block_migration_cancel, + .is_active = block_is_active, }; void blk_mig_init(void) diff --git a/savevm.c b/savevm.c index 888c5a2..afa0c9e 100644 --- a/savevm.c +++ b/savevm.c @@ -1576,6 +1576,11 @@ int qemu_savevm_state_begin(QEMUFile *f, if (!se->ops || !se->ops->save_live_state) { continue; } + if (se->ops && se->ops->is_active) { + if (!se->ops->is_active(se->opaque)) { + continue; + } + } /* Section type */ qemu_put_byte(f, QEMU_VM_SECTION_START); qemu_put_be32(f, se->section_id); @@ -1618,6 +1623,11 @@ int qemu_savevm_state_iterate(QEMUFile *f) if (!se->ops || !se->ops->save_live_state) { continue; } + if (se->ops && se->ops->is_active) { + if (!se->ops->is_active(se->opaque)) { + continue; + } + } if (qemu_file_rate_limit(f)) { return 0; } @@ -1658,6 +1668,11 @@ int qemu_savevm_state_complete(QEMUFile *f) if (!se->ops || !se->ops->save_live_state) { continue; } + if (se->ops && se->ops->is_active) { + if (!se->ops->is_active(se->opaque)) { + continue; + } + } trace_savevm_section_start(); /* Section type */ qemu_put_byte(f, QEMU_VM_SECTION_END); diff --git a/vmstate.h b/vmstate.h index 1dd42f5..96651a5 100644 --- a/vmstate.h +++ b/vmstate.h @@ -35,6 +35,7 @@ typedef struct SaveVMHandlers { int (*save_live_state)(QEMUFile *f, int stage, void *opaque); void (*cancel)(void *opaque); LoadStateHandler *load_state; + bool (*is_active)(void *opaque); } SaveVMHandlers; int register_savevm(DeviceState *dev,
Enable the creation of a method to tell migration if that section is active and should be migrate. We use it for blk-migration, that is normally not active. We don't create the method for RAM, as setups without RAM are very strange O:-) Signed-off-by: Juan Quintela <quintela@redhat.com> --- block-migration.c | 13 ++++++------- savevm.c | 15 +++++++++++++++ vmstate.h | 1 + 3 files changed, 22 insertions(+), 7 deletions(-)