diff mbox

[v2,6/8] virtio-net: use virtqueue_error for errors with queue context

Message ID 20170713110237.6712-7-lprosek@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ladi Prosek July 13, 2017, 11:02 a.m. UTC
virtqueue_error includes queue index in the error output and is preferred
for errors that pertain to a virtqueue rather than to the device as a whole.

Signed-off-by: Ladi Prosek <lprosek@redhat.com>
---
 hw/net/virtio-net.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

Comments

Cornelia Huck July 13, 2017, 3 p.m. UTC | #1
On Thu, 13 Jul 2017 13:02:35 +0200
Ladi Prosek <lprosek@redhat.com> wrote:

> virtqueue_error includes queue index in the error output and is preferred
> for errors that pertain to a virtqueue rather than to the device as a whole.
> 
> Signed-off-by: Ladi Prosek <lprosek@redhat.com>
> ---
>  hw/net/virtio-net.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index 5630a9e..b3d0b85 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -970,7 +970,7 @@ static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
>          }
>          if (iov_size(elem->in_sg, elem->in_num) < sizeof(status) ||
>              iov_size(elem->out_sg, elem->out_num) < sizeof(ctrl)) {
> -            virtio_error(vdev, "virtio-net ctrl missing headers");
> +            virtqueue_error(vq, "virtio-net ctrl missing headers");

This does not add much information, as there's just one control queue
anyway, but it doesn't hurt either.

>              virtqueue_detach_element(vq, elem, 0);
>              g_free(elem);
>              break;

Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Stefan Hajnoczi July 14, 2017, 10:30 a.m. UTC | #2
On Thu, Jul 13, 2017 at 01:02:35PM +0200, Ladi Prosek wrote:
> virtqueue_error includes queue index in the error output and is preferred
> for errors that pertain to a virtqueue rather than to the device as a whole.
> 
> Signed-off-by: Ladi Prosek <lprosek@redhat.com>
> ---
>  hw/net/virtio-net.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
diff mbox

Patch

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 5630a9e..b3d0b85 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -970,7 +970,7 @@  static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
         }
         if (iov_size(elem->in_sg, elem->in_num) < sizeof(status) ||
             iov_size(elem->out_sg, elem->out_num) < sizeof(ctrl)) {
-            virtio_error(vdev, "virtio-net ctrl missing headers");
+            virtqueue_error(vq, "virtio-net ctrl missing headers");
             virtqueue_detach_element(vq, elem, 0);
             g_free(elem);
             break;
@@ -1204,20 +1204,20 @@  static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,
         elem = virtqueue_pop(q->rx_vq, sizeof(VirtQueueElement));
         if (!elem) {
             if (i) {
-                virtio_error(vdev, "virtio-net unexpected empty queue: "
-                             "i %zd mergeable %d offset %zd, size %zd, "
-                             "guest hdr len %zd, host hdr len %zd "
-                             "guest features 0x%" PRIx64,
-                             i, n->mergeable_rx_bufs, offset, size,
-                             n->guest_hdr_len, n->host_hdr_len,
-                             vdev->guest_features);
+                virtqueue_error(q->rx_vq, "virtio-net unexpected empty queue: "
+                                "i %zd mergeable %d offset %zd, size %zd, "
+                                "guest hdr len %zd, host hdr len %zd "
+                                "guest features 0x%" PRIx64,
+                                i, n->mergeable_rx_bufs, offset, size,
+                                n->guest_hdr_len, n->host_hdr_len,
+                                vdev->guest_features);
             }
             return -1;
         }
 
         if (elem->in_num < 1) {
-            virtio_error(vdev,
-                         "virtio-net receive queue contains no in buffers");
+            virtqueue_error(q->rx_vq,
+                            "virtio-net receive queue contains no in buffers");
             virtqueue_detach_element(q->rx_vq, elem, 0);
             g_free(elem);
             return -1;
@@ -1333,7 +1333,7 @@  static int32_t virtio_net_flush_tx(VirtIONetQueue *q)
         out_num = elem->out_num;
         out_sg = elem->out_sg;
         if (out_num < 1) {
-            virtio_error(vdev, "virtio-net header not in first element");
+            virtqueue_error(q->tx_vq, "virtio-net header not in first element");
             virtqueue_detach_element(q->tx_vq, elem, 0);
             g_free(elem);
             return -EINVAL;
@@ -1342,7 +1342,7 @@  static int32_t virtio_net_flush_tx(VirtIONetQueue *q)
         if (n->has_vnet_hdr) {
             if (iov_to_buf(out_sg, out_num, 0, &mhdr, n->guest_hdr_len) <
                 n->guest_hdr_len) {
-                virtio_error(vdev, "virtio-net header incorrect");
+                virtqueue_error(q->tx_vq, "virtio-net header incorrect");
                 virtqueue_detach_element(q->tx_vq, elem, 0);
                 g_free(elem);
                 return -EINVAL;