Skip to contentSkip to conversation

virtio-user: fix backend selection if stat fails

PATCH Superseded Adrian Moreno 4 participants 7 messages Oct 20, 2020 Network drivers

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

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

Fixes f908b22ea47a ("net/virtio: move backend type selection to ethdev")
---
 drivers/net/virtio/virtio_user_ethdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_user_ethdev.c +3 -2
index 042665bc0..ce74d08ab 100644
@@ -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
Tested-by on v1 1/1
#1 lore raw

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 fails

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")
---
 drivers/net/virtio/virtio_user_ethdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_user_ethdev.c +3 -3
index 042665bc0..ce74d08ab 100644
@@ -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

#2 lore raw
In reply to Adrian Moreno
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")
---
 drivers/net/virtio/virtio_user_ethdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_user_ethdev.c +0 -0
index 042665bc0..ce74d08ab 100644

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)) {
#3 lore raw
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")
---
 drivers/net/virtio/virtio_user_ethdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_user_ethdev.c +0 -0
index 042665bc0..ce74d08ab 100644
@@ -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 -1
 	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'

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)) {
#4 lore raw
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")
---
 drivers/net/virtio/virtio_user_ethdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_user_ethdev.c +0 -0
index 042665bc0..ce74d08ab 100644
@@ -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 -1
 	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 3 lines

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.

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_UNKNOWN otherwise 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)) {
#5 lore raw
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")
---
 drivers/net/virtio/virtio_user_ethdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_user_ethdev.c +0 -0
index 042665bc0..ce74d08ab 100644

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
Quoted 3 lines

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.

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_UNKNOWN otherwise 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)) {
#6 lore raw
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")
---
 drivers/net/virtio/virtio_user_ethdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_user_ethdev.c +0 -0
index 042665bc0..ce74d08ab 100644
@@ -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 -1
 	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'

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.

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_UNKNOWN otherwise 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