migration/savevm: move non SaveStateEntry condition check out of iteration
cover migration/savevm: move non SaveStateEntry condition check out of iteration
qemu_savevm_state_complete_precopy() iterates SaveStateEntry and does proper tasks for migration.
For each iteration, in_postcopy and iterable_only would be checked to see whether it should skip. Since these two conditions are not SaveStateEntry specific, it is proper to move the check out of iteration.
These three patches prepare the code and move the condition check out of the iteration.
Wei Yang (3):
migration/savevm: flush file for iterable_only case migration/savevm: split qemu_savevm_state_complete_precopy() into two
parts
migration/savevm: move non SaveStateEntry condition check out of
iteration
migration/savevm.c | 68 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 18 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/3 migration/savevm: flush file for iterable_only case
It would be proper to flush file even for iterable_only case.
--- migration/savevm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
migration/savevm.c +2 -1
@@ -1292,7 +1292,7 @@ int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only, }if (iterable_only) { -return 0 ; + goto flush; } vmdesc =qjson_new ();
@@ -1353,6 +1353,7 @@ int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only, }qjson_destroy (vmdesc); +flush:qemu_fflush (f);return 0 ; }
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH 1/3] migration/savevm: flush file for iterable_only case
Quoted 3 lines · * Wei Yang ([email protected]) wrote:
It would be proper to flush file even for
iterable_onlycase.Signed-off-by Wei Yang <[email protected]>
OK, I don't think this is actually necessary; but it's safe. We only really need the flush at the end of the file, and in the non-iterable-only case it's not the end of the file.
Since it makes your next change simpler,
Quoted 28 lines
--- migration/savevm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)migration/savevm.c +2
-1@@ -1292,7 +1292,7 @@ int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only, }if (iterable_only) { -return 0 ; + goto flush; } vmdesc =qjson_new ();@@ -1353,6 +1353,7 @@ int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only, }qjson_destroy (vmdesc); +flush:qemu_fflush (f);return 0 ; }Signature · 1 line
2.17.1
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] [PATCH 1/3] migration/savevm: flush file for iterable_only case
Quoted 10 lines · Dr. David Alan Gilbert
Quoted 3 lines · * Wei Yang ([email protected]) wrote:
It would be proper to flush file even for
iterable_onlycase.Signed-off-by Wei Yang <[email protected]>OK, I don't think this is actually necessary; but it's safe. We only really need the flush at the end of the file, and in the non-iterable-only case it's not the end of the file.
Since it makes your next change simpler,
Yep, you are so kind.
Quoted 33 lines
Reviewed-by Dr. David Alan Gilbert <[email protected]>Quoted 28 lines
--- migration/savevm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)migration/savevm.c +2
-1@@ -1292,7 +1292,7 @@ int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only, }if (iterable_only) { -return 0 ; + goto flush; } vmdesc =qjson_new ();@@ -1353,6 +1353,7 @@ int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only, }qjson_destroy (vmdesc); +flush:qemu_fflush (f);return 0 ; }Signature · 1 line
2.17.1--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Signature · 2 lines
Wei Yang Help you, Help me
PATCH 2/3 migration/savevm: split qemu_savevm_state_complete_precopy() into two parts
In reply to Wei YangThis is a preparation patch for further cleanup.
No functional change, just wrap two major part of qemu_savevm_state_complete_precopy() into function.
--- migration/savevm.c | 66 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 17 deletions(-)
migration/savevm.c +49 -17
@@ -1246,23 +1246,12 @@ void qemu_savevm_state_complete_postcopy(QEMUFile *f)qemu_fflush (f); } -int qemu_savevm_state_complete_precopy (QEMUFile *f,bool iterable_only, -bool inactivate_disks) +static +int qemu_savevm_state_complete_precopy_iterable (QEMUFile *f,bool in_postcopy, +bool iterable_only) { -QJSON *vmdesc; -int vmdesc_len;SaveStateEntry *se;int ret; -bool in_postcopy =migration_in_postcopy (); -Error *local_err =NULL ; - -if (precopy_notify (PRECOPY_NOTIFY_COMPLETE , &local_err)) { -error_report_err (local_err); - } - -trace_savevm_state_complete_precopy (); - -cpu_synchronize_all_states (); QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { if (!se->ops ||
@@ -1291,9 +1280,18 @@ int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only, } } -if (iterable_only) { - goto flush; - } +return 0 ; +} + +static +int qemu_savevm_state_complete_precopy_non_iterable (QEMUFile *f, +bool in_postcopy, +bool inactivate_disks) +{ +QJSON *vmdesc; +int vmdesc_len; +SaveStateEntry *se; +int ret; vmdesc =qjson_new ();json_prop_int (vmdesc,"page_size" ,qemu_target_page_size ());
@@ -1353,6 +1351,40 @@ int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only, }qjson_destroy (vmdesc); +return 0 ; +} + +int qemu_savevm_state_complete_precopy (QEMUFile *f,bool iterable_only, +bool inactivate_disks) +{ +int ret; +Error *local_err =NULL ; +bool in_postcopy =migration_in_postcopy (); + +if (precopy_notify (PRECOPY_NOTIFY_COMPLETE , &local_err)) { +error_report_err (local_err); + } + +trace_savevm_state_complete_precopy (); + +cpu_synchronize_all_states (); + + ret =qemu_savevm_state_complete_precopy_iterable (f, in_postcopy, + iterable_only); +if (ret) { +return ret; + } + +if (iterable_only) { + goto flush; + } + + ret =qemu_savevm_state_complete_precopy_non_iterable (f, in_postcopy, + inactivate_disks); +if (ret) { +return ret; + } + flush:qemu_fflush (f);return 0 ;
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH 2/3] migration/savevm: split qemu_savevm_state_complete_precopy() into two parts
Quoted 6 lines · * Wei Yang ([email protected]) wrote:
This is a preparation patch for further cleanup.
No functional change, just wrap two major part of
qemu_savevm_state_complete_precopy()into function.Signed-off-by Wei Yang <[email protected]>
Quoted 101 lines
--- migration/savevm.c | 66 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 17 deletions(-)migration/savevm.c +49
-17@@ -1246,23 +1246,12 @@ void qemu_savevm_state_complete_postcopy(QEMUFile *f)qemu_fflush (f); } -int qemu_savevm_state_complete_precopy (QEMUFile *f,bool iterable_only, -bool inactivate_disks) +static +int qemu_savevm_state_complete_precopy_iterable (QEMUFile *f,bool in_postcopy, +bool iterable_only) { -QJSON *vmdesc; -int vmdesc_len;SaveStateEntry *se;int ret; -bool in_postcopy =migration_in_postcopy (); -Error *local_err =NULL ; - -if (precopy_notify (PRECOPY_NOTIFY_COMPLETE , &local_err)) { -error_report_err (local_err); - } - -trace_savevm_state_complete_precopy (); - -cpu_synchronize_all_states (); QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { if (!se->ops ||@@ -1291,9 +1280,18 @@ int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only, } } -if (iterable_only) { - goto flush; - } +return 0 ; +} + +static +int qemu_savevm_state_complete_precopy_non_iterable (QEMUFile *f, +bool in_postcopy, +bool inactivate_disks) +{ +QJSON *vmdesc; +int vmdesc_len; +SaveStateEntry *se; +int ret; vmdesc =qjson_new ();json_prop_int (vmdesc,"page_size" ,qemu_target_page_size ());@@ -1353,6 +1351,40 @@ int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only, }qjson_destroy (vmdesc); +return 0 ; +} + +int qemu_savevm_state_complete_precopy (QEMUFile *f,bool iterable_only, +bool inactivate_disks) +{ +int ret; +Error *local_err =NULL ; +bool in_postcopy =migration_in_postcopy (); + +if (precopy_notify (PRECOPY_NOTIFY_COMPLETE , &local_err)) { +error_report_err (local_err); + } + +trace_savevm_state_complete_precopy (); + +cpu_synchronize_all_states (); + + ret =qemu_savevm_state_complete_precopy_iterable (f, in_postcopy, + iterable_only); +if (ret) { +return ret; + } + +if (iterable_only) { + goto flush; + } + + ret =qemu_savevm_state_complete_precopy_non_iterable (f, in_postcopy, + inactivate_disks); +if (ret) { +return ret; + } + flush:qemu_fflush (f);return 0 ;Signature · 1 line
2.17.1
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 3/3 migration/savevm: move non SaveStateEntry condition check out of iteration
In reply to Wei Yangin_postcopy and iterable_only are not SaveStateEntry specific, it would be more proper to check them out of iteration.
--- migration/savevm.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
migration/savevm.c +6 -7
@@ -1247,8 +1247,7 @@ void qemu_savevm_state_complete_postcopy(QEMUFile *f) }static -int qemu_savevm_state_complete_precopy_iterable (QEMUFile *f,bool in_postcopy, -bool iterable_only) +int qemu_savevm_state_complete_precopy_iterable (QEMUFile *f,bool in_postcopy) {SaveStateEntry *se;int ret;
@@ -1257,7 +1256,6 @@ int qemu_savevm_state_complete_precopy_iterable(QEMUFile *f, bool in_postcopy,if (!se->ops || (in_postcopy && se->ops->has_postcopy && se->ops->has_postcopy (se->opaque)) || - (in_postcopy && !iterable_only) || !se->ops->save_live_complete_precopy) {continue ; }
@@ -1369,10 +1367,11 @@ int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only,cpu_synchronize_all_states (); - ret =qemu_savevm_state_complete_precopy_iterable (f, in_postcopy, - iterable_only); -if (ret) { -return ret; +if (!in_postcopy || iterable_only) { + ret =qemu_savevm_state_complete_precopy_iterable (f, in_postcopy); +if (ret) { +return ret; + } }if (iterable_only) {
Signature · 1 line
2.17.1
Quoted 4 lines · * Wei Yang ([email protected]) wrote:
in_postcopyanditerable_onlyare not SaveStateEntry specific, it would be more proper to check them out of iteration.Signed-off-by Wei Yang <[email protected]>
Worth it just to make that big if statement simpler!
Quoted 45 lines
--- migration/savevm.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)migration/savevm.c +6
-7@@ -1247,8 +1247,7 @@ void qemu_savevm_state_complete_postcopy(QEMUFile *f) }static -int qemu_savevm_state_complete_precopy_iterable (QEMUFile *f,bool in_postcopy, -bool iterable_only) +int qemu_savevm_state_complete_precopy_iterable (QEMUFile *f,bool in_postcopy) {SaveStateEntry *se;int ret;@@ -1257,7 +1256,6 @@ int qemu_savevm_state_complete_precopy_iterable(QEMUFile *f, bool in_postcopy,if (!se->ops || (in_postcopy && se->ops->has_postcopy && se->ops->has_postcopy (se->opaque)) || - (in_postcopy && !iterable_only) || !se->ops->save_live_complete_precopy) {continue ; }@@ -1369,10 +1367,11 @@ int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only,cpu_synchronize_all_states (); - ret =qemu_savevm_state_complete_precopy_iterable (f, in_postcopy, - iterable_only); -if (ret) { -return ret; +if (!in_postcopy || iterable_only) { + ret =qemu_savevm_state_complete_precopy_iterable (f, in_postcopy); +if (ret) { +return ret; + } }if (iterable_only) {Signature · 1 line
2.17.1
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 8 lines · Dr. David Alan Gilbert
Quoted 4 lines · * Wei Yang ([email protected]) wrote:
in_postcopyanditerable_onlyare not SaveStateEntry specific, it would be more proper to check them out of iteration.Signed-off-by Wei Yang <[email protected]>Worth it just to make that big if statement simpler!
Yep, the original one looks a little hard to understand.
Thanks for your comment.
Quoted 50 lines
Reviewed-by Dr. David Alan Gilbert <[email protected]>Quoted 45 lines
--- migration/savevm.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)migration/savevm.c +6
-7@@ -1247,8 +1247,7 @@ void qemu_savevm_state_complete_postcopy(QEMUFile *f) }static -int qemu_savevm_state_complete_precopy_iterable (QEMUFile *f,bool in_postcopy, -bool iterable_only) +int qemu_savevm_state_complete_precopy_iterable (QEMUFile *f,bool in_postcopy) {SaveStateEntry *se;int ret;@@ -1257,7 +1256,6 @@ int qemu_savevm_state_complete_precopy_iterable(QEMUFile *f, bool in_postcopy,if (!se->ops || (in_postcopy && se->ops->has_postcopy && se->ops->has_postcopy (se->opaque)) || - (in_postcopy && !iterable_only) || !se->ops->save_live_complete_precopy) {continue ; }@@ -1369,10 +1367,11 @@ int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only,cpu_synchronize_all_states (); - ret =qemu_savevm_state_complete_precopy_iterable (f, in_postcopy, - iterable_only); -if (ret) { -return ret; +if (!in_postcopy || iterable_only) { + ret =qemu_savevm_state_complete_precopy_iterable (f, in_postcopy); +if (ret) { +return ret; + } }if (iterable_only) {Signature · 1 line
2.17.1--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Signature · 2 lines
Wei Yang Help you, Help me
Quoted 10 lines · * Wei Yang ([email protected]) wrote:
qemu_savevm_state_complete_precopy()iterates SaveStateEntry and does proper tasks for migration.For each iteration,
in_postcopyanditerable_onlywould be checked to see whether it should skip. Since these two conditions are not SaveStateEntry specific, it is proper to move the check out of iteration.These three patches prepare the code and move the condition check out of the iteration.
Queued
Quoted 8 lines
Wei Yang (3):
migration/savevm: flush file foriterable_onlycase migration/savevm: splitqemu_savevm_state_complete_precopy()into two
parts
migration/savevm: move non SaveStateEntry condition check out of
iteration
Quoted 7 lines
migration/savevm.c | 68 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 18 deletions(-)Signature · 1 line
2.17.1
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK