Skip to contentSkip to conversation

vhost-user: print original request on error

PATCH In review Michael S. Tsirkin 2 participants 4 messages Nov 16, 2015 – Nov 17, 2015

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 vhost-user: print original request on error

When we get an unexpected response, print out
the original request.
Helps debug protocol errors tremendously.

---

Changes from v1: add missing .

 hw/virtio/vhost-user.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/virtio/vhost-user.c +2 -2
index 3404b81..5bc6c45 100644
@@ -121,8 +121,8 @@ static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
 
     r = qemu_chr_fe_read_all(chr, p, size);
     if (r != size) {
-        error_report("Failed to read msg header. Read %d instead of %d.", r,
-                size);
+        error_report("Failed to read msg header. Read %d instead of %d."
+                     " Original request %d.", r, size, msg->request);
         goto fail;
     }
 
Signature · 1 line
MST
#1 lore raw
Quoted 17 lines · Michael S. Tsirkin

When we get an unexpected response, print out
the original request.
Helps debug protocol errors tremendously.

---

Changes from v1: add missing .

 hw/virtio/vhost-user.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/virtio/vhost-user.c +0 -0
index 3404b81..5bc6c45 100644

hw/virtio/vhost-user.c static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg) · line 127

Quoted 9 lines
hw/virtio/vhost-user.c +2 -2
@@ -121,8 +121,8 @@ static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
 
     r = qemu_chr_fe_read_all(chr, p, size);
     if (r != size) {
-        error_report("Failed to read msg header. Read %d instead of %d.", r,
-                size);
+        error_report("Failed to read msg header. Read %d instead of %d."
+                     " Original request %d.", r, size, msg->request);
         goto fail;
     }

Error message style nit: the error message proper (the thing emitted by error_report()) should be a phrase, and it should be short and to the point. It can be followed by hints. Compare:

qemu-system-x86_64: Failed to read msg header. Read 11 instead of 12. Original request 1.

and

qemu-system-x86_64: Failed to read msg header
Read 11 instead of 12 for request 1.

I prefer the latter. The error message proper is short and to the point. The hint adds information, which happens to be useful mainly to developers. Sensible line lengths.

By the way, the error.h API supports this message + hints convention since commit 50b7b00.

See also
Message-ID: <[email protected]>
http://lists.gnu.org/archive/html/qemu-devel/2015-11/msg01662.html

#2 lore raw
Quoted 44 lines · Markus Armbruster
Quoted 17 lines · Michael S. Tsirkin

When we get an unexpected response, print out
the original request.
Helps debug protocol errors tremendously.

---

Changes from v1: add missing .

 hw/virtio/vhost-user.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/virtio/vhost-user.c +0 -0
index 3404b81..5bc6c45 100644

hw/virtio/vhost-user.c static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg) · line 127

Quoted 9 lines
hw/virtio/vhost-user.c +2 -2
@@ -121,8 +121,8 @@ static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
 
     r = qemu_chr_fe_read_all(chr, p, size);
     if (r != size) {
-        error_report("Failed to read msg header. Read %d instead of %d.", r,
-                size);
+        error_report("Failed to read msg header. Read %d instead of %d."
+                     " Original request %d.", r, size, msg->request);
         goto fail;
     }

Error message style nit: the error message proper (the thing emitted by error_report()) should be a phrase, and it should be short and to the point. It can be followed by hints. Compare:

qemu-system-x86_64: Failed to read msg header. Read 11 instead of 12. Original request 1.

and

qemu-system-x86_64: Failed to read msg header
Read 11 instead of 12 for request 1.

I prefer the latter. The error message proper is short and to the point. The hint adds information, which happens to be useful mainly to developers. Sensible line lengths.

Quoted 6 lines

By the way, the error.h API supports this message + hints convention since commit 50b7b00.

See also
Message-ID: <[email protected]>
http://lists.gnu.org/archive/html/qemu-devel/2015-11/msg01662.html

Oh that's nice. There are more cases like this in vhost-user. Let's rework them all past 2.5?

Signature · 1 line
MST
#3 lore raw
Quoted 49 lines · Michael S. Tsirkin
Quoted 48 lines · Markus Armbruster
Quoted 17 lines · Michael S. Tsirkin

When we get an unexpected response, print out
the original request.
Helps debug protocol errors tremendously.

---

Changes from v1: add missing .

 hw/virtio/vhost-user.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/virtio/vhost-user.c +0 -0
index 3404b81..5bc6c45 100644

hw/virtio/vhost-user.c static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg) · line 127

Quoted 9 lines
hw/virtio/vhost-user.c +2 -2
@@ -121,8 +121,8 @@ static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
 
     r = qemu_chr_fe_read_all(chr, p, size);
     if (r != size) {
-        error_report("Failed to read msg header. Read %d instead of %d.", r,
-                size);
+        error_report("Failed to read msg header. Read %d instead of %d."
+                     " Original request %d.", r, size, msg->request);
         goto fail;
     }

Error message style nit: the error message proper (the thing emitted by error_report()) should be a phrase, and it should be short and to the point. It can be followed by hints. Compare:

qemu-system-x86_64: Failed to read msg header. Read 11 instead
of 12. Original request 1.

and

qemu-system-x86_64: Failed to read msg header
Read 11 instead of 12 for request 1.

I prefer the latter. The error message proper is short and to the point. The hint adds information, which happens to be useful mainly to developers. Sensible line lengths.

By the way, the error.h API supports this message + hints convention since commit 50b7b00.

Quoted 6 lines
Quoted 3 lines

See also
Message-ID: <[email protected]>
http://lists.gnu.org/archive/html/qemu-devel/2015-11/msg01662.html

Oh that's nice. There are more cases like this in vhost-user. Let's rework them all past 2.5?

Okay. Several ones in 2.6 is better than just one now :)