virtio-user: fix backend selection if stat fails
PATCH 1/1 virtio-user: fix backend selection if stat fails
If stat fails it means the backend must be vhost-user in server mode
Bugzilla ID: 559
--- drivers/net/virtio/virtio_user_ethdev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_user_ethdev.c +3 -2
@@ -560,9 +560,10 @@ virtio_user_backend_type(const char *path)struct stat sb;if (stat (path, &sb) ==-1 ) { -PMD_INIT_LOG (ERR ,"Stat fails: %s (%s)\n" , path, +PMD_INIT_LOG (INFO ,"Stat fails: %s (%s)\n" , path,strerror (errno)); -return VIRTIO_USER_BACKEND_UNKNOWN ; +/* Must be vhost-user in server mode */ +return VIRTIO_USER_BACKEND_VHOST_USER ; }if (S_ISSOCK (sb.st_mode)) {
Signature · 1 line
2.26.2
Best Regards
Jiang yu
Quoted 41 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Adrian Moreno
Sent: Tuesday, October 20, 2020 3:16 PM
To: [email protected]
Cc: Wang, Yinan <[email protected]>; Fu, Patrick <[email protected]>; [email protected]; [email protected]; Maxime Coquelin <[email protected]>; Xia, Chenbo <[email protected]>; Wang, Zhihong <[email protected]>
Subject: [dpdk-dev] [PATCH] virtio-user: fix backend selection if stat failsIf stat fails it means the backend must be vhost-user in server mode
Bugzilla ID: 559
Fixes f908b22ea47a ("net/virtio: move backend type selection to ethdev")Signed-off-by Adrian Moreno <[email protected]>--- drivers/net/virtio/virtio_user_ethdev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/net/virtio/virtio_user_ethdev.c +3
-3@@ -560,9 +560,10 @@ virtio_user_backend_type(const char *path)struct stat sb;if (stat (path, &sb) ==-1 ) { -PMD_INIT_LOG (ERR ,"Stat fails: %s (%s)\n" , path, +PMD_INIT_LOG (INFO ,"Stat fails: %s (%s)\n" , path,strerror (errno)); -return VIRTIO_USER_BACKEND_UNKNOWN ; +/* Must be vhost-user in server mode */ +return VIRTIO_USER_BACKEND_VHOST_USER ; }if (S_ISSOCK (sb.st_mode)) { --2.26.2
Quoted 16 lines · Adrian Moreno
If stat fails it means the backend must be vhost-user in server mode
Bugzilla ID: 559
Fixes f908b22ea47a ("net/virtio: move backend type selection to ethdev")Signed-off-by Adrian Moreno <[email protected]>--- drivers/net/virtio/virtio_user_ethdev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/net/virtio/virtio_user_ethdev.c +0
-0
drivers/net/virtio/virtio_user_ethdev.c virtio_user_backend_type(const char *path) · line 564
Quoted 6 lines
drivers/net/virtio/virtio_user_ethdev.c +1
-1@@ -560,9 +560,10 @@ virtio_user_backend_type(const char *path)struct stat sb;if (stat (path, &sb) ==-1 ) { -PMD_INIT_LOG (ERR ,"Stat fails: %s (%s)\n" , path, +PMD_INIT_LOG (INFO ,"Stat fails: %s (%s)\n" , path,strerror (errno));
It may be accurate, but a 'fail' in the logs can be confusing for users when it is an INFO log and normal operation. Suggest to reword to something softer like 'Unable to stat' or 'Not able to get file status'
Quoted 7 lines
drivers/net/virtio/virtio_user_ethdev.c +2
-1-return VIRTIO_USER_BACKEND_UNKNOWN ; +/* Must be vhost-user in server mode */ +return VIRTIO_USER_BACKEND_VHOST_USER ; }if (S_ISSOCK (sb.st_mode)) {
Quoted 19 lines · Kevin Traynor
Quoted 18 lines · Adrian Moreno
If stat fails it means the backend must be vhost-user in server mode
Bugzilla ID: 559
Fixes f908b22ea47a ("net/virtio: move backend type selection to ethdev")Signed-off-by Adrian Moreno <[email protected]>--- drivers/net/virtio/virtio_user_ethdev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/net/virtio/virtio_user_ethdev.c +0
-0@@ -560,9 +560,10 @@ virtio_user_backend_type(const char *path)struct stat sb;
Quoted 8 lines
drivers/net/virtio/virtio_user_ethdev.c virtio_user_backend_type(const char *path) · line 564
Quoted 4 lines
drivers/net/virtio/virtio_user_ethdev.c +1
-1if (stat (path, &sb) ==-1 ) { -PMD_INIT_LOG (ERR ,"Stat fails: %s (%s)\n" , path, +PMD_INIT_LOG (INFO ,"Stat fails: %s (%s)\n" , path,strerror (errno));It may be accurate, but a 'fail' in the logs can be confusing for users when it is an INFO log and normal operation. Suggest to reword to something softer like 'Unable to stat' or 'Not able to get file status'
We may want to:
- only return VIRTIO_USER_BACKEND_VHOST_USER if -ENOENT, and log that we assume this is Vhost-user backend in server mode at INFO level.
- return VIRTIO_USER_BACKEND_UNKNOWN otherwise and print an error message with the strerror(errno).
What do you think?
Quoted 8 lines
Quoted 7 lines
drivers/net/virtio/virtio_user_ethdev.c +2
-1-return VIRTIO_USER_BACKEND_UNKNOWN ; +/* Must be vhost-user in server mode */ +return VIRTIO_USER_BACKEND_VHOST_USER ; }if (S_ISSOCK (sb.st_mode)) {
Quoted 32 lines · Maxime Coquelin
Quoted 19 lines · Kevin Traynor
Quoted 18 lines · Adrian Moreno
If stat fails it means the backend must be vhost-user in server mode
Bugzilla ID: 559
Fixes f908b22ea47a ("net/virtio: move backend type selection to ethdev")Signed-off-by Adrian Moreno <[email protected]>--- drivers/net/virtio/virtio_user_ethdev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/net/virtio/virtio_user_ethdev.c +0
-0@@ -560,9 +560,10 @@ virtio_user_backend_type(const char *path)struct stat sb;Quoted 8 lines
drivers/net/virtio/virtio_user_ethdev.c virtio_user_backend_type(const char *path) · line 564
Quoted 4 lines
drivers/net/virtio/virtio_user_ethdev.c +1
-1if (stat (path, &sb) ==-1 ) { -PMD_INIT_LOG (ERR ,"Stat fails: %s (%s)\n" , path, +PMD_INIT_LOG (INFO ,"Stat fails: %s (%s)\n" , path,strerror (errno));It may be accurate, but a 'fail' in the logs can be confusing for users when it is an INFO log and normal operation. Suggest to reword to something softer like 'Unable to stat' or 'Not able to get file status'
Quoted 3 lines
We may want to:
- only returnVIRTIO_USER_BACKEND_VHOST_USERif-ENOENT, and log that we assume this is Vhost-user backend in server mode at INFO level.
It will mean that sometimes the backend type is logged and sometimes not, but maybe you make a distinction because there is an assumption being made in this case?
Quoted 3 lines
- return
VIRTIO_USER_BACKEND_UNKNOWNotherwise and print an error message with the strerror(errno).
yes, it seems better like that.
Quoted 10 lines
What do you think?
Quoted 8 lines
Quoted 7 lines
drivers/net/virtio/virtio_user_ethdev.c +2
-1-return VIRTIO_USER_BACKEND_UNKNOWN ; +/* Must be vhost-user in server mode */ +return VIRTIO_USER_BACKEND_VHOST_USER ; }if (S_ISSOCK (sb.st_mode)) {
Quoted 33 lines · Kevin Traynor
Quoted 32 lines · Maxime Coquelin
Quoted 27 lines · Kevin Traynor
Quoted 16 lines · Adrian Moreno
If stat fails it means the backend must be vhost-user in server mode
Bugzilla ID: 559
Fixes f908b22ea47a ("net/virtio: move backend type selection to ethdev")Signed-off-by Adrian Moreno <[email protected]>--- drivers/net/virtio/virtio_user_ethdev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/net/virtio/virtio_user_ethdev.c +0
-0drivers/net/virtio/virtio_user_ethdev.c virtio_user_backend_type(const char *path) · line 564
Quoted 6 lines
drivers/net/virtio/virtio_user_ethdev.c +1
-1@@ -560,9 +560,10 @@ virtio_user_backend_type(const char *path)struct stat sb;if (stat (path, &sb) ==-1 ) { -PMD_INIT_LOG (ERR ,"Stat fails: %s (%s)\n" , path, +PMD_INIT_LOG (INFO ,"Stat fails: %s (%s)\n" , path,strerror (errno));It may be accurate, but a 'fail' in the logs can be confusing for users when it is an INFO log and normal operation. Suggest to reword to something softer like 'Unable to stat' or 'Not able to get file status'
Quoted 7 lines
Quoted 3 lines
We may want to:
- only returnVIRTIO_USER_BACKEND_VHOST_USERif-ENOENT, and log that we assume this is Vhost-user backend in server mode at INFO level.It will mean that sometimes the backend type is logged and sometimes not, but maybe you make a distinction because there is an assumption being made in this case?
I agree it would make sense to log at INFO level for all backend types.
Quoted 17 lines
Quoted 3 lines
- return
VIRTIO_USER_BACKEND_UNKNOWNotherwise and print an error message with the strerror(errno).yes, it seems better like that.
Quoted 10 lines
What do you think?
Quoted 8 lines
Quoted 7 lines
drivers/net/virtio/virtio_user_ethdev.c +2
-1-return VIRTIO_USER_BACKEND_UNKNOWN ; +/* Must be vhost-user in server mode */ +return VIRTIO_USER_BACKEND_VHOST_USER ; }if (S_ISSOCK (sb.st_mode)) {
Quoted 40 lines · Maxime Coquelin
Quoted 37 lines · Kevin Traynor
Quoted 35 lines · Maxime Coquelin
Quoted 19 lines · Kevin Traynor
Quoted 18 lines · Adrian Moreno
If stat fails it means the backend must be vhost-user in server mode
Bugzilla ID: 559
Fixes f908b22ea47a ("net/virtio: move backend type selection to ethdev")Signed-off-by Adrian Moreno <[email protected]>--- drivers/net/virtio/virtio_user_ethdev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/net/virtio/virtio_user_ethdev.c +0
-0@@ -560,9 +560,10 @@ virtio_user_backend_type(const char *path)struct stat sb;Quoted 8 lines
drivers/net/virtio/virtio_user_ethdev.c virtio_user_backend_type(const char *path) · line 564
Quoted 4 lines
drivers/net/virtio/virtio_user_ethdev.c +1
-1if (stat (path, &sb) ==-1 ) { -PMD_INIT_LOG (ERR ,"Stat fails: %s (%s)\n" , path, +PMD_INIT_LOG (INFO ,"Stat fails: %s (%s)\n" , path,strerror (errno));It may be accurate, but a 'fail' in the logs can be confusing for users when it is an INFO log and normal operation. Suggest to reword to something softer like 'Unable to stat' or 'Not able to get file status'
We may want to:
- only returnVIRTIO_USER_BACKEND_VHOST_USERif-ENOENT, and log that we assume this is Vhost-user backend in server mode at INFO level.
Quoted 12 lines
Quoted 3 lines
It will mean that sometimes the backend type is logged and sometimes not, but maybe you make a distinction because there is an assumption being made in this case?
I agree it would make sense to log at INFO level for all backend types.
Quoted 6 lines
Quoted 3 lines
- return
VIRTIO_USER_BACKEND_UNKNOWNotherwise and print an error message with the strerror(errno).yes, it seems better like that.
Thanks Maxime and Kevin for your feedback and Jiang for testing. I'll send a v2 addressing the comments.
Quoted 12 lines
Quoted 11 lines
Quoted 10 lines
What do you think?
Quoted 8 lines
Quoted 7 lines
drivers/net/virtio/virtio_user_ethdev.c +2
-1-return VIRTIO_USER_BACKEND_UNKNOWN ; +/* Must be vhost-user in server mode */ +return VIRTIO_USER_BACKEND_VHOST_USER ; }if (S_ISSOCK (sb.st_mode)) {
Signature · 1 line
Adrián Moreno