libxl: report correct errno from virNetSocketNewConnectTCP on migration
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 25 lines · Ian Campbell
saved_errnois never written to in this function after it is initialised and it is only used to log the failure from virNetSocketNewConnectTCP masking the real errno from that function.Drop
saved_errnoand use errno itself.Signed-off-by Ian Campbell <[email protected]>--- src/libxl/libxl_migration.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)src/libxl/libxl_migration.c +0
-1@@ -480,7 +480,6 @@ libxlDomainMigrationPerform(libxlDriverPrivatePtr driver,virURIPtr uri =NULL ;virNetSocketPtr sock;int sockfd =-1 ; -int saved_errno =EINVAL ;int ret =-1 ;/* parse dst host:port from uri */
src/libxl/libxl_migration.c libxlDomainMigrationPerform(libxlDriverPrivatePtr driver, · line 501
Quoted 8 lines
src/libxl/libxl_migration.c +1
-1@@ -496,7 +495,7 @@ libxlDomainMigrationPerform(libxlDriverPrivatePtr driver,if (virNetSocketNewConnectTCP (hostname, portstr,AF_UNSPEC , &sock) <0 ) { -virReportSystemError (saved_errno, +virReportSystemError (errno,_ ("unable to connect to '%s:%s'" ), hostname, portstr); goto cleanup;
In fact, virNetSocketNewConnectTCP itself returns meaningful message on error. I think this overwriting should be dropped completely.
Michal
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 23 lines · Michal Privoznik
Quoted 22 lines · Ian Campbell
saved_errnois never written to in this function after it is initialised and it is only used to log the failure from virNetSocketNewConnectTCP masking the real errno from that function.Drop
saved_errnoand use errno itself.Signed-off-by Ian Campbell <[email protected]>--- src/libxl/libxl_migration.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)src/libxl/libxl_migration.c +0
-1@@ -480,7 +480,6 @@ libxlDomainMigrationPerform(libxlDriverPrivatePtr driver,virURIPtr uri =NULL ;virNetSocketPtr sock;int sockfd =-1 ; -int saved_errno =EINVAL ;int ret =-1 ;
Quoted 13 lines
src/libxl/libxl_migration.c libxlDomainMigrationPerform(libxlDriverPrivatePtr driver, · line 501
Quoted 11 lines
src/libxl/libxl_migration.c +1
-1/* parse dst host:port from uri */ @@ -496,7 +495,7 @@ libxlDomainMigrationPerform(libxlDriverPrivatePtr driver,if (virNetSocketNewConnectTCP (hostname, portstr,AF_UNSPEC , &sock) <0 ) { -virReportSystemError (saved_errno, +virReportSystemError (errno,_ ("unable to connect to '%s:%s'" ), hostname, portstr); goto cleanup;In fact, virNetSocketNewConnectTCP itself returns meaningful message on error. I think this overwriting should be dropped completely.
Agreed. How about the following patch?
Regards,
Jim
Quoted 1 line
From
a30c493bd9e20c9a7a423789a202c444a5eba344Mon Sep 17 00:00:00 2001
From: Jim Fehlig <[email protected]>
Date: Thu, 3 Sep 2015 10:14:20 -0600
Subject: [PATCH] libxl: don't overwrite error from virNetSocketNewConnectTCP()
Remove redundant error reporting libxlDomainMigrationPerform(). virNetSocketNewConnectTCP() is perfectly capable of reporting sensible errors.
--- src/libxl/libxl_migration.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
src/libxl/libxl_migration.c +1 -5
@@ -487,12 +487,8 @@ libxlDomainMigrationPerform(libxlDriverPrivatePtr driver,/* socket connect to dst host:port */ if (virNetSocketNewConnectTCP (hostname, portstr,AF_UNSPEC , - &sock) <0 ) { -virReportSystemError (saved_errno, -_ ("unable to connect to '%s:%s'" ), - hostname, portstr); + &sock) <0 ) goto cleanup; - }if (virNetSocketSetBlocking (sock, true) <0 ) {virObjectUnref (sock);
Signature · 1 line
2.5.0
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 9 lines · Jim Fehlig
Agreed. How about the following patch?
Quoted 1 line
From
a30c493bd9e20c9a7a423789a202c444a5eba344Mon Sep 17 00:00:00 2001From: Jim Fehlig<[email protected]>
Date: Thu, 3 Sep 2015 10:14:20 -0600
Subject: [PATCH] libxl: don't overwrite error fromvirNetSocketNewConnectTCP()Remove redundant error reporting
libxlDomainMigrationPerform().
FYI, I've changed s/reporting/reporting in/ in the commit message.
Regards,
Jim
Quoted 4 lines
virNetSocketNewConnectTCP()is perfectly capable of reporting sensible errors.Signed-off-by Jim Fehlig<[email protected]>
Quoted 11 lines · Jim Fehlig
From
a30c493bd9e20c9a7a423789a202c444a5eba344Mon Sep 17 00:00:00 2001
From: Jim Fehlig <[email protected]>
Date: Thu, 3 Sep 2015 10:14:20 -0600
Subject: [PATCH] libxl: don't overwrite error fromvirNetSocketNewConnectTCP()Remove redundant error reporting
libxlDomainMigrationPerform().virNetSocketNewConnectTCP()is perfectly capable of reporting sensible errors.Signed-off-by Jim Fehlig <[email protected]>
FWIW: Acked-by: Ian Campbell <[email protected]>
Quoted 22 lines · Jim Fehlig
Agreed. How about the following patch?
Quoted 1 line
From
a30c493bd9e20c9a7a423789a202c444a5eba344Mon Sep 17 00:00:00 2001From: Jim Fehlig<[email protected]>
Date: Thu, 3 Sep 2015 10:14:20 -0600
Subject: [PATCH] libxl: don't overwrite error fromvirNetSocketNewConnectTCP()Remove redundant error reporting
libxlDomainMigrationPerform().virNetSocketNewConnectTCP()is perfectly capable of reporting sensible errors.Signed-off-by Jim Fehlig<[email protected]>--- src/libxl/libxl_migration.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)src/libxl/libxl_migration.c +0
-0
src/libxl/libxl_migration.c libxlDomainMigrationPerform(libxlDriverPrivatePtr driver, · line 495
Quoted 10 lines
src/libxl/libxl_migration.c +1
-5@@ -487,12 +487,8 @@ libxlDomainMigrationPerform(libxlDriverPrivatePtr driver,/* socket connect to dst host:port */ if (virNetSocketNewConnectTCP (hostname, portstr,AF_UNSPEC , - &sock) <0 ) { -virReportSystemError (saved_errno, -_ ("unable to connect to '%s:%s'" ), - hostname, portstr); + &sock) <0 ) goto cleanup; - }
I should try compiling before sending patches:
libxl/libxl_migration.c:475:9: error: unused variable 'saved_errno' [-Werror=unused-variable]
int saved_errno = EINVAL;
I posted a working V2:
https://www.redhat.com/archives/libvir-list/2015-September/msg00107.html
Regards,
Jim