migration/rdma: rdma_accept_incoming_migration fix error handling
PATCH 1/1 migration/rdma: rdma_accept_incoming_migration fix error handling
From: "Dr. David Alan Gilbert" <[email protected]>
rdma_accept_incoming_migration is called from an fd handler and can't return an Error * anywhere.
Currently it's leaking Error's in errp/local_err - there's no point putting them in there unless we can report them.
Turn most into fprintf's, and the last into an error_reportf_err where it's coming up from another function.
--- migration/rdma.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
migration/rdma.c +7 -4
@@ -3980,13 +3980,13 @@ static void rdma_accept_incoming_migration(void *opaque)RDMAContext *rdma = opaque;int ret;QEMUFile *f; -Error *local_err =NULL , **errp = &local_err; +Error *local_err =NULL ;trace_qemu_rdma_accept_incoming_migration (); ret =qemu_rdma_accept (rdma);if (ret) { -ERROR (errp,"RDMA Migration initialization failed!" ); +fprintf (stderr,"RDMA ERROR: Migration initialization failed" );return ; }
@@ -3998,13 +3998,16 @@ static void rdma_accept_incoming_migration(void *opaque) f =qemu_fopen_rdma (rdma,"rb" );if (f ==NULL ) { -ERROR (errp,"could not qemu_fopen_rdma!" ); +fprintf (stderr,"RDMA ERROR: could not qemu_fopen_rdma" );qemu_rdma_cleanup (rdma);return ; } rdma->migration_started_on_destination =1 ; -migration_fd_process_incoming (f, errp); +migration_fd_process_incoming (f, &local_err); +if (local_err) { +error_reportf_err (local_err,"RDMA ERROR:" ); + } }void rdma_start_incoming_migration (const char *host_port,Error **errp)
Signature · 1 line
2.24.1
Quoted 22 lines · Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" <[email protected]>
rdma_accept_incoming_migrationis called from an fd handler and can't return an Error * anywhere.
Currently it's leaking Error's in errp/local_err - there's no point putting them in there unless we can report them.Turn most into fprintf's, and the last into an
error_reportf_errwhere it's coming up from another function.Signed-off-by Dr. David Alan Gilbert <[email protected]>--- migration/rdma.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)migration/rdma.c +0
-0@@ -3980,13 +3980,13 @@ static void rdma_accept_incoming_migration(void *opaque)RDMAContext *rdma = opaque;int ret;
migration/rdma.c static void rdma_accept_incoming_migration(void *opaque) · line 3989
Quoted 10 lines
migration/rdma.c +2
-2QEMUFile *f; -Error *local_err =NULL , **errp = &local_err; +Error *local_err =NULL ;trace_qemu_rdma_accept_incoming_migration (); ret =qemu_rdma_accept (rdma);if (ret) { -ERROR (errp,"RDMA Migration initialization failed!" ); +fprintf (stderr,"RDMA ERROR: Migration initialization failed" );
Is there any reason to explictly use stderr instead of the error_reportf_err() below (then we simply jump to that for error paths)? The only difference of error_reportf_err() and stderr should be when there's one HMP, while shall we always suggest to use error_reportf_err() rather than stderr?
Thanks,
Quoted 25 lines
migration/rdma.c +5
-2return ; }@@ -3998,13 +3998,16 @@ static void rdma_accept_incoming_migration(void *opaque) f =qemu_fopen_rdma (rdma,"rb" );if (f ==NULL ) { -ERROR (errp,"could not qemu_fopen_rdma!" ); +fprintf (stderr,"RDMA ERROR: could not qemu_fopen_rdma" );qemu_rdma_cleanup (rdma);return ; } rdma->migration_started_on_destination =1 ; -migration_fd_process_incoming (f, errp); +migration_fd_process_incoming (f, &local_err); +if (local_err) { +error_reportf_err (local_err,"RDMA ERROR:" ); + } }void rdma_start_incoming_migration (const char *host_port,Error **errp)Signature · 1 line
2.24.1
Signature · 1 line
Peter Xu
Quoted 30 lines · * Peter Xu ([email protected]) wrote:
Quoted 29 lines · Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" <[email protected]>
rdma_accept_incoming_migrationis called from an fd handler and can't return an Error * anywhere.
Currently it's leaking Error's in errp/local_err - there's no point putting them in there unless we can report them.Turn most into fprintf's, and the last into an
error_reportf_errwhere it's coming up from another function.Signed-off-by Dr. David Alan Gilbert <[email protected]>--- migration/rdma.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)migration/rdma.c +1
-1@@ -3980,13 +3980,13 @@ static void rdma_accept_incoming_migration(void *opaque)RDMAContext *rdma = opaque;int ret;QEMUFile *f; -Error *local_err =NULL , **errp = &local_err; +Error *local_err =NULL ;trace_qemu_rdma_accept_incoming_migration (); ret =qemu_rdma_accept (rdma);
Quoted 9 lines
migration/rdma.c static void rdma_accept_incoming_migration(void *opaque) · line 3989
Quoted 3 lines
migration/rdma.c +1
-1if (ret) { -ERROR (errp,"RDMA Migration initialization failed!" ); +fprintf (stderr,"RDMA ERROR: Migration initialization failed" );Is there any reason to explictly use stderr instead of the
error_reportf_err()below (then we simply jump to that for error paths)? The only difference oferror_reportf_err()and stderr should be when there's one HMP, while shall we always suggest to useerror_reportf_err()rather than stderr?
Because the error_reportf_err is taking an Error* (from an error reported by migration_fd_process_incoming) where as we don't have an Error* at the earlier points.
Dave
Quoted 23 lines
Thanks,
Quoted 21 lines
migration/rdma.c +5
-2return ; }@@ -3998,13 +3998,16 @@ static void rdma_accept_incoming_migration(void *opaque) f =qemu_fopen_rdma (rdma,"rb" );if (f ==NULL ) { -ERROR (errp,"could not qemu_fopen_rdma!" ); +fprintf (stderr,"RDMA ERROR: could not qemu_fopen_rdma" );qemu_rdma_cleanup (rdma);return ; } rdma->migration_started_on_destination =1 ; -migration_fd_process_incoming (f, errp); +migration_fd_process_incoming (f, &local_err); +if (local_err) { +error_reportf_err (local_err,"RDMA ERROR:" ); + } }
Quoted 8 lines
Quoted 4 lines
migration/rdma.c +0
-0void rdma_start_incoming_migration (const char *host_port,Error **errp)Signature · 1 line
2.24.1Signature · 1 line
Peter Xu
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 41 lines · Dr. David Alan Gilbert
Quoted 30 lines · * Peter Xu ([email protected]) wrote:
Quoted 29 lines · Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" <[email protected]>
rdma_accept_incoming_migrationis called from an fd handler and can't return an Error * anywhere.
Currently it's leaking Error's in errp/local_err - there's no point putting them in there unless we can report them.Turn most into fprintf's, and the last into an
error_reportf_errwhere it's coming up from another function.Signed-off-by Dr. David Alan Gilbert <[email protected]>--- migration/rdma.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)migration/rdma.c +1
-1@@ -3980,13 +3980,13 @@ static void rdma_accept_incoming_migration(void *opaque)RDMAContext *rdma = opaque;int ret;QEMUFile *f; -Error *local_err =NULL , **errp = &local_err; +Error *local_err =NULL ;trace_qemu_rdma_accept_incoming_migration (); ret =qemu_rdma_accept (rdma);Quoted 9 lines
migration/rdma.c static void rdma_accept_incoming_migration(void *opaque) · line 3989
Quoted 3 lines
migration/rdma.c +1
-1if (ret) { -ERROR (errp,"RDMA Migration initialization failed!" ); +fprintf (stderr,"RDMA ERROR: Migration initialization failed" );Is there any reason to explictly use stderr instead of the
error_reportf_err()below (then we simply jump to that for error paths)? The only difference oferror_reportf_err()and stderr should be when there's one HMP, while shall we always suggest to useerror_reportf_err()rather than stderr?
Quoted 3 lines
Because the
error_reportf_erris taking an Error* (from an error reported bymigration_fd_process_incoming) where as we don't have an Error* at the earlier points.
The ERROR() macro in rdma.c created them? Though it also prints to stderr so if we also use the same error_reportf_err() then we can remove that prints to stderr too.
Signature · 1 line
Peter Xu
Quoted 23 lines · Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" <[email protected]>
rdma_accept_incoming_migrationis called from an fd handler and can't return an Error * anywhere.
Currently it's leaking Error's in errp/local_err - there's no point putting them in there unless we can report them.Turn most into fprintf's, and the last into an
error_reportf_errwhere it's coming up from another function.Signed-off-by Dr. David Alan Gilbert <[email protected]>--- migration/rdma.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)migration/rdma.c +0
-0@@ -3980,13 +3980,13 @@ static void rdma_accept_incoming_migration(void *opaque)RDMAContext *rdma = opaque;int ret;QEMUFile *f;
migration/rdma.c static void rdma_accept_incoming_migration(void *opaque) · line 3990
Quoted 10 lines
migration/rdma.c +2
-2-Error *local_err =NULL , **errp = &local_err; +Error *local_err =NULL ;trace_qemu_rdma_accept_incoming_migration (); ret =qemu_rdma_accept (rdma);if (ret) { -ERROR (errp,"RDMA Migration initialization failed!" ); +fprintf (stderr,"RDMA ERROR: Migration initialization failed" );return ;
this should end in "\n" right?
Appart from that.
BTW, I can include the \n when I queue the patch, no need to resend
Quoted 21 lines
migration/rdma.c +5
-2}@@ -3998,13 +3998,16 @@ static void rdma_accept_incoming_migration(void *opaque) f =qemu_fopen_rdma (rdma,"rb" );if (f ==NULL ) { -ERROR (errp,"could not qemu_fopen_rdma!" ); +fprintf (stderr,"RDMA ERROR: could not qemu_fopen_rdma" );qemu_rdma_cleanup (rdma);return ; } rdma->migration_started_on_destination =1 ; -migration_fd_process_incoming (f, errp); +migration_fd_process_incoming (f, &local_err); +if (local_err) { +error_reportf_err (local_err,"RDMA ERROR:" ); + } }void rdma_start_incoming_migration (const char *host_port,Error **errp)
Quoted 30 lines · * Juan Quintela ([email protected]) wrote:
Quoted 29 lines · Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" <[email protected]>
rdma_accept_incoming_migrationis called from an fd handler and can't return an Error * anywhere.
Currently it's leaking Error's in errp/local_err - there's no point putting them in there unless we can report them.Turn most into fprintf's, and the last into an
error_reportf_errwhere it's coming up from another function.Signed-off-by Dr. David Alan Gilbert <[email protected]>--- migration/rdma.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)migration/rdma.c +1
-1@@ -3980,13 +3980,13 @@ static void rdma_accept_incoming_migration(void *opaque)RDMAContext *rdma = opaque;int ret;QEMUFile *f; -Error *local_err =NULL , **errp = &local_err; +Error *local_err =NULL ;trace_qemu_rdma_accept_incoming_migration (); ret =qemu_rdma_accept (rdma);
Quoted 6 lines
migration/rdma.c static void rdma_accept_incoming_migration(void *opaque) · line 3990
Quoted 4 lines
migration/rdma.c +1
-1if (ret) { -ERROR (errp,"RDMA Migration initialization failed!" ); +fprintf (stderr,"RDMA ERROR: Migration initialization failed" );return ;this should end in "\n" right?
Oops thanks; and in the one below.
Quoted 5 lines
Appart from that.
Reviewed-by Juan Quintela <[email protected]>BTW, I can include the \n when I queue the patch, no need to resend
Thanks
Dave
Quoted 21 lines
Quoted 21 lines
migration/rdma.c +5
-2}@@ -3998,13 +3998,16 @@ static void rdma_accept_incoming_migration(void *opaque) f =qemu_fopen_rdma (rdma,"rb" );if (f ==NULL ) { -ERROR (errp,"could not qemu_fopen_rdma!" ); +fprintf (stderr,"RDMA ERROR: could not qemu_fopen_rdma" );qemu_rdma_cleanup (rdma);return ; } rdma->migration_started_on_destination =1 ; -migration_fd_process_incoming (f, errp); +migration_fd_process_incoming (f, &local_err); +if (local_err) { +error_reportf_err (local_err,"RDMA ERROR:" ); + } }
Quoted 1 line
migration/rdma.c static void rdma_accept_incoming_migration(void *opaque) · line 4013
Quoted 1 line
migration/rdma.c +0
-0void rdma_start_incoming_migration (const char *host_port,Error **errp)
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK