migration: Update error description outside migration.c
cover migration: Update error description outside migration.c
Hi everyone,
This patchset aims to cover code paths in the source code where a migration is marked as failed via MIGRATION_STATUS_FAILED, however the failure exists outside of migration.c, and without a call for migrate_set_error at this place.
This patchset has been split out from the patchset sent before which covered cases of such gaps in migration.c aswell.
Previous patchset:
https://lists.gnu.org/archive/html/qemu-devel/2023-05/msg04463.html
Regards,
Tejus
Tejus GK (2):
migration/vmstate: Introduce vmstate_save_state_with_err
migration: Update error description outside migration.c
include/migration/vmstate.h | 4 +++- migration/savevm.c | 19 +++++++++++++++---- migration/vmstate.c | 19 +++++++++++++------ 3 files changed, 31 insertions(+), 11 deletions(-)
Signature · 1 line
2.22.3
RFC 1/2 migration/vmstate: Introduce vmstate_save_state_with_err
Currently, a few code paths exist in the function vmstate_save_state_v, which ultimately leads to a migration failure. However, an update in the current MigrationState for the error description is never done.
vmstate.c somehow doesn't seem to allow the use of migrate_set_error due
to some dependencies for unit tests. Hence, this patch introduces a new
function vmstate_save_state_with_err, which will eventually propagate
the error message to savevm.c where a migrate_set_error call can be
eventually done.
--- include/migration/vmstate.h | 4 +++- migration/savevm.c | 2 +- migration/vmstate.c | 12 +++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-)
include/migration/vmstate.h +3 -1
@@ -1194,9 +1194,11 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, int version_id);int vmstate_save_state (QEMUFile *f,const VMStateDescription *vmsd,void *opaque,JSONWriter *vmdesc); +int vmstate_save_state_with_err (QEMUFile *f,const VMStateDescription *vmsd, +void *opaque,JSONWriter *vmdesc,Error **errp);int vmstate_save_state_v (QEMUFile *f,const VMStateDescription *vmsd,void *opaque,JSONWriter *vmdesc, -int version_id); +int version_id,Error **errp);bool vmstate_save_needed (const VMStateDescription *vmsd,void *opaque);
migration/savevm.c +1 -1
@@ -1000,7 +1000,7 @@ static int vmstate_save(QEMUFile *f, SaveStateEntry *se, JSONWriter *vmdesc)if (!se->vmsd) {vmstate_save_old_style (f, se, vmdesc); }else { - ret =vmstate_save_state (f, se->vmsd, se->opaque, vmdesc); + ret =vmstate_save_state_with_err (f, se->vmsd, se->opaque, vmdesc, &local_err);if (ret) {return ret; }
migration/vmstate.c +9 -3
@@ -315,11 +315,17 @@ bool vmstate_save_needed(const VMStateDescription *vmsd, void *opaque)int vmstate_save_state (QEMUFile *f,const VMStateDescription *vmsd,void *opaque,JSONWriter *vmdesc_id) { -return vmstate_save_state_v (f, vmsd, opaque, vmdesc_id, vmsd->version_id); +return vmstate_save_state_v (f, vmsd, opaque, vmdesc_id, vmsd->version_id,NULL ); +} + +int vmstate_save_state_with_err (QEMUFile *f,const VMStateDescription *vmsd, +void *opaque,JSONWriter *vmdesc_id,Error **errp) +{ +return vmstate_save_state_v (f, vmsd, opaque, vmdesc_id, vmsd->version_id, errp); }int vmstate_save_state_v (QEMUFile *f,const VMStateDescription *vmsd, -void *opaque,JSONWriter *vmdesc,int version_id) +void *opaque,JSONWriter *vmdesc,int version_id,Error **errp) {int ret =0 ;const VMStateField *field = vmsd->fields;
@@ -377,7 +383,7 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd, }else if (field->flags &VMS_VSTRUCT ) { ret =vmstate_save_state_v (f, field->vmsd, curr_elem, vmdesc_loop, - field->struct_version_id); + field->struct_version_id, errp); }else { ret = field->info->put (f, curr_elem, size, field, vmdesc_loop);
Signature · 1 line
2.22.3
RFC 2/2 migration: Update error description outside migration.c
In reply to Tejus GKA few code paths exist in the source code,where a migration is marked as failed via MIGRATION_STATUS_FAILED, but the failure happens
outside of migration.c
In such cases, an error_report() call is made, however the current
MigrationState is never updated with the error description, and hence
clients like libvirt never know the actual reason for the failure.
This patch covers such cases outside of migration.c and updates the
error description at the appropriate places.
--- migration/savevm.c | 17 ++++++++++++++--- migration/vmstate.c | 7 ++++--- 2 files changed, 18 insertions(+), 6 deletions(-)
migration/savevm.c +14 -3
@@ -979,6 +979,8 @@ static void save_section_footer(QEMUFile *f, SaveStateEntry *se)static int vmstate_save (QEMUFile *f,SaveStateEntry *se,JSONWriter *vmdesc) {int ret; +Error *local_err =NULL ; +MigrationState *s =migrate_get_current ();if ((!se->ops || !se->ops->save_state) && !se->vmsd) {return 0 ;
@@ -1002,6 +1004,8 @@ static int vmstate_save(QEMUFile *f, SaveStateEntry *se, JSONWriter *vmdesc) }else { ret =vmstate_save_state_with_err (f, se->vmsd, se->opaque, vmdesc, &local_err);if (ret) { +migrate_set_error (s, local_err); +error_report_err (local_err);return ret; } }
@@ -1068,10 +1072,14 @@ void qemu_savevm_send_open_return_path(QEMUFile *f)int qemu_savevm_send_packaged (QEMUFile *f,const uint8_t *buf,size_t len) {uint32_t tmp; +MigrationState *ms =migrate_get_current (); +Error *local_err =NULL ;if (len >MAX_VM_CMD_PACKAGED_SIZE ) { -error_report ("%s: Unreasonably large packaged state: %zu" , +error_setg (&local_err,"%s: Unreasonably large packaged state: %zu" , __func__, len); +migrate_set_error (ms, local_err); +error_report_err (local_err);return -1 ; }
@@ -1475,8 +1483,11 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,* bdrv_activate_all() on the other end won't fail. */ ret =bdrv_inactivate_all ();if (ret) { -error_report ("%s: bdrv_inactivate_all() failed (%d)" , - __func__, ret); +Error *local_err =NULL ; +error_setg (&local_err,"%s: bdrv_inactivate_all() failed (%d)" , + __func__, ret); +migrate_set_error (ms, local_err); +error_report_err (local_err);qemu_file_set_error (f, ret);return ret; }
migration/vmstate.c +4 -3
@@ -14,6 +14,7 @@#include "migration.h" #include "migration/vmstate.h" #include "savevm.h" +#include "qapi/error.h" #include "qapi/qmp/json-writer.h" #include "qemu-file.h" #include "qemu/bitops.h"
@@ -336,7 +337,7 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd, ret = vmsd->pre_save (opaque);trace_vmstate_save_state_pre_save_res (vmsd->name, ret);if (ret) { -error_report ("pre-save failed: %s" , vmsd->name); +error_setg (errp,"pre-save failed: %s" , vmsd->name);return ret; } }
@@ -389,8 +390,8 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd, vmdesc_loop); }if (ret) { -error_report ("Save of field %s/%s failed" , - vmsd->name, field->name); +error_setg (errp,"Save of field %s/%s failed" , + vmsd->name, field->name);if (vmsd->post_save) { vmsd->post_save (opaque); }
Signature · 1 line
2.22.3
Quoted 16 lines · Tejus GK
Hi everyone,
This patchset aims to cover code paths in the source code where a migration is marked as failed via
MIGRATION_STATUS_FAILED, however the failure exists outside ofmigration.c, and without a call formigrate_set_errorat this place.This patchset has been split out from the patchset sent before which covered cases of such gaps in
migration.caswell.Previous patchset:
https://lists.gnu.org/archive/html/qemu-devel/2023-05/msg04463.htmlRegards,
Tejus
Quoted 9 lines
Tejus GK (2):
migration/vmstate: Introducevmstate_save_state_with_err
migration: Update error description outsidemigration.cinclude/migration/vmstate.h | 4 +++- migration/savevm.c | 19 +++++++++++++++---- migration/vmstate.c | 19 +++++++++++++------ 3 files changed, 31 insertions(+), 11 deletions(-)
Hi everyone,
Apologies for the delayed ping. Can someone please review this patchset?
Regards,
Tejus
Quoted 7 lines · Tejus GK
Hi everyone,
This patchset aims to cover code paths in the source code where a migration is marked as failed via
MIGRATION_STATUS_FAILED, however the failure exists outside ofmigration.c, and without a call formigrate_set_errorat this place.
Quoted 5 lines
This patchset has been split out from the patchset sent before which covered cases of such gaps in
migration.caswell.Previous patchset:
https://lists.gnu.org/archive/html/qemu-devel/2023-05/msg04463.html
Signature · 1 line
Peter Xu