qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/4] Net patches
@ 2019-05-17  9:06 Jason Wang
  2019-05-17  9:06 ` [Qemu-devel] [PULL 1/4] vhost_net: don't set backend for the uninitialized virtqueue Jason Wang
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Jason Wang @ 2019-05-17  9:06 UTC (permalink / raw)
  To: qemu-devel, peter.maydell; +Cc: Jason Wang

The following changes since commit d8276573da58e8ce78dab8c46dd660efd664bcb7:

  Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20190510' into staging (2019-05-16 13:15:08 +0100)

are available in the git repository at:

  https://github.com/jasowang/qemu.git tags/net-pull-request

for you to fetch changes up to 78e4f446d2569210a8558946b2321f9ff2ef47f6:

  net/colo-compare.c: Fix a crash in COLO Primary. (2019-05-17 17:00:12 +0800)

----------------------------------------------------------------

----------------------------------------------------------------
Chris Kenna (1):
      e1000: Never increment the RX undersize count register

Jason Wang (1):
      vhost_net: don't set backend for the uninitialized virtqueue

Lukas Straub (1):
      net/colo-compare.c: Fix a crash in COLO Primary.

Stefano Garzarella (1):
      net/slirp: fix the IPv6 prefix length error message

 hw/net/e1000.c             |  1 -
 hw/net/vhost_net.c         | 10 ++++++++++
 hw/virtio/virtio.c         |  5 +++++
 include/hw/virtio/virtio.h |  1 +
 net/colo-compare.c         |  3 +--
 net/slirp.c                |  3 ++-
 6 files changed, 19 insertions(+), 4 deletions(-)



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 1/4] vhost_net: don't set backend for the uninitialized virtqueue
  2019-05-17  9:06 [Qemu-devel] [PULL 0/4] Net patches Jason Wang
@ 2019-05-17  9:06 ` Jason Wang
  2019-05-17  9:06 ` [Qemu-devel] [PULL 2/4] e1000: Never increment the RX undersize count register Jason Wang
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Jason Wang @ 2019-05-17  9:06 UTC (permalink / raw)
  To: qemu-devel, peter.maydell; +Cc: Jason Wang

We used to set backend unconditionally, this won't work for some
guests (e.g windows driver) who may not initialize all virtqueues. For
kernel backend, this will fail since it may try to validate the rings
during setting backend.

Fixing this by simply skipping the backend set when we find desc is
not ready.

Reviewed-by: Michael S. Tsirkin<mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 hw/net/vhost_net.c         | 10 ++++++++++
 hw/virtio/virtio.c         |  5 +++++
 include/hw/virtio/virtio.h |  1 +
 3 files changed, 16 insertions(+)

diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index be3cc88..a6b7190 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -244,6 +244,11 @@ static int vhost_net_start_one(struct vhost_net *net,
         qemu_set_fd_handler(net->backend, NULL, NULL, NULL);
         file.fd = net->backend;
         for (file.index = 0; file.index < net->dev.nvqs; ++file.index) {
+            if (!virtio_queue_enabled(dev, net->dev.vq_index +
+                                      file.index)) {
+                /* Queue might not be ready for start */
+                continue;
+            }
             r = vhost_net_set_backend(&net->dev, &file);
             if (r < 0) {
                 r = -errno;
@@ -256,6 +261,11 @@ fail:
     file.fd = -1;
     if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) {
         while (file.index-- > 0) {
+            if (!virtio_queue_enabled(dev, net->dev.vq_index +
+                                      file.index)) {
+                /* Queue might not be ready for start */
+                continue;
+            }
             int r = vhost_net_set_backend(&net->dev, &file);
             assert(r >= 0);
         }
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 2626a89..28056a7 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2318,6 +2318,11 @@ hwaddr virtio_queue_get_desc_addr(VirtIODevice *vdev, int n)
     return vdev->vq[n].vring.desc;
 }
 
+bool virtio_queue_enabled(VirtIODevice *vdev, int n)
+{
+    return virtio_queue_get_desc_addr(vdev, n) != 0;
+}
+
 hwaddr virtio_queue_get_avail_addr(VirtIODevice *vdev, int n)
 {
     return vdev->vq[n].vring.avail;
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index ce95162..7140381 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -282,6 +282,7 @@ typedef struct VirtIORNGConf VirtIORNGConf;
                       VIRTIO_F_IOMMU_PLATFORM, false)
 
 hwaddr virtio_queue_get_desc_addr(VirtIODevice *vdev, int n);
+bool virtio_queue_enabled(VirtIODevice *vdev, int n);
 hwaddr virtio_queue_get_avail_addr(VirtIODevice *vdev, int n);
 hwaddr virtio_queue_get_used_addr(VirtIODevice *vdev, int n);
 hwaddr virtio_queue_get_desc_size(VirtIODevice *vdev, int n);
-- 
2.5.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 2/4] e1000: Never increment the RX undersize count register
  2019-05-17  9:06 [Qemu-devel] [PULL 0/4] Net patches Jason Wang
  2019-05-17  9:06 ` [Qemu-devel] [PULL 1/4] vhost_net: don't set backend for the uninitialized virtqueue Jason Wang
@ 2019-05-17  9:06 ` Jason Wang
  2019-05-17  9:06 ` [Qemu-devel] [PULL 3/4] net/slirp: fix the IPv6 prefix length error message Jason Wang
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Jason Wang @ 2019-05-17  9:06 UTC (permalink / raw)
  To: qemu-devel, peter.maydell; +Cc: Jason Wang, Chris Kenna

From: Chris Kenna <chris.kenna@oracle.com>

In situations where e1000 receives an undersized Ethernet frame,
QEMU increments the emulated "Receive Undersize Count (RUC)"
register when padding the frame.

This is incorrect because this an expected scenario (e.g. with
VLAN tag stripping) and not an error. As such, QEMU should not
increment the emulated RUC.

Fixes: 3b2743017749 ("e1000: Implementing various counters")

Reviewed-by: Mark Kanda <mark.kanda@oracle.com>
Reviewed-by: Bhavesh Davda <bhavesh.davda@oracle.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Chris Kenna <chris.kenna@oracle.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 hw/net/e1000.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index 9b39bcc..121452d 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -901,7 +901,6 @@ e1000_receive_iov(NetClientState *nc, const struct iovec *iov, int iovcnt)
     if (size < sizeof(min_buf)) {
         iov_to_buf(iov, iovcnt, 0, min_buf, size);
         memset(&min_buf[size], 0, sizeof(min_buf) - size);
-        e1000x_inc_reg_if_not_full(s->mac_reg, RUC);
         min_iov.iov_base = filter_buf = min_buf;
         min_iov.iov_len = size = sizeof(min_buf);
         iovcnt = 1;
-- 
2.5.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 3/4] net/slirp: fix the IPv6 prefix length error message
  2019-05-17  9:06 [Qemu-devel] [PULL 0/4] Net patches Jason Wang
  2019-05-17  9:06 ` [Qemu-devel] [PULL 1/4] vhost_net: don't set backend for the uninitialized virtqueue Jason Wang
  2019-05-17  9:06 ` [Qemu-devel] [PULL 2/4] e1000: Never increment the RX undersize count register Jason Wang
@ 2019-05-17  9:06 ` Jason Wang
  2019-05-17  9:06 ` [Qemu-devel] [PULL 4/4] net/colo-compare.c: Fix a crash in COLO Primary Jason Wang
  2019-05-17 14:46 ` [Qemu-devel] [PULL 0/4] Net patches Peter Maydell
  4 siblings, 0 replies; 6+ messages in thread
From: Jason Wang @ 2019-05-17  9:06 UTC (permalink / raw)
  To: qemu-devel, peter.maydell; +Cc: Jason Wang, Stefano Garzarella

From: Stefano Garzarella <sgarzare@redhat.com>

Reword and add a missing parentheses at the end of the
error message.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 net/slirp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/slirp.c b/net/slirp.c
index 95934fb..b34cb29 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -498,7 +498,8 @@ static int net_slirp_init(NetClientState *peer, const char *model,
     }
     if (vprefix6_len < 0 || vprefix6_len > 126) {
         error_setg(errp,
-                   "Invalid prefix provided (prefix len must be in range 0-126");
+                   "Invalid IPv6 prefix provided "
+                   "(IPv6 prefix length must be between 0 and 126)");
         return -1;
     }
 
-- 
2.5.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 4/4] net/colo-compare.c: Fix a crash in COLO Primary.
  2019-05-17  9:06 [Qemu-devel] [PULL 0/4] Net patches Jason Wang
                   ` (2 preceding siblings ...)
  2019-05-17  9:06 ` [Qemu-devel] [PULL 3/4] net/slirp: fix the IPv6 prefix length error message Jason Wang
@ 2019-05-17  9:06 ` Jason Wang
  2019-05-17 14:46 ` [Qemu-devel] [PULL 0/4] Net patches Peter Maydell
  4 siblings, 0 replies; 6+ messages in thread
From: Jason Wang @ 2019-05-17  9:06 UTC (permalink / raw)
  To: qemu-devel, peter.maydell; +Cc: Jason Wang, Lukas Straub

From: Lukas Straub <lukasstraub2@web.de>

Because event_unhandled_count may be accessed concurrently, it needs
to be protected by taking the lock. However the assert is outside the
lock, probably causing it to read garbage and aborting Qemu erroneously.

The Bug only happens when running Qemu in COLO mode.

This Patch fixes the following bug: https://bugs.launchpad.net/qemu/+bug/1824622

Signed-off-by: Lukas Straub <lukasstraub2@web.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Zhang Chen <chen.zhang@intel.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 net/colo-compare.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/colo-compare.c b/net/colo-compare.c
index bf10526..fcb4911 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -813,9 +813,8 @@ static void colo_compare_handle_event(void *opaque)
         break;
     }
 
-    assert(event_unhandled_count > 0);
-
     qemu_mutex_lock(&event_mtx);
+    assert(event_unhandled_count > 0);
     event_unhandled_count--;
     qemu_cond_broadcast(&event_complete_cond);
     qemu_mutex_unlock(&event_mtx);
-- 
2.5.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PULL 0/4] Net patches
  2019-05-17  9:06 [Qemu-devel] [PULL 0/4] Net patches Jason Wang
                   ` (3 preceding siblings ...)
  2019-05-17  9:06 ` [Qemu-devel] [PULL 4/4] net/colo-compare.c: Fix a crash in COLO Primary Jason Wang
@ 2019-05-17 14:46 ` Peter Maydell
  4 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2019-05-17 14:46 UTC (permalink / raw)
  To: Jason Wang; +Cc: QEMU Developers

On Fri, 17 May 2019 at 10:07, Jason Wang <jasowang@redhat.com> wrote:
>
> The following changes since commit d8276573da58e8ce78dab8c46dd660efd664bcb7:
>
>   Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20190510' into staging (2019-05-16 13:15:08 +0100)
>
> are available in the git repository at:
>
>   https://github.com/jasowang/qemu.git tags/net-pull-request
>
> for you to fetch changes up to 78e4f446d2569210a8558946b2321f9ff2ef47f6:
>
>   net/colo-compare.c: Fix a crash in COLO Primary. (2019-05-17 17:00:12 +0800)
>
> ----------------------------------------------------------------
>
> ----------------------------------------------------------------


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/4.1
for any user-visible changes.

-- PMM


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-05-17 14:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-17  9:06 [Qemu-devel] [PULL 0/4] Net patches Jason Wang
2019-05-17  9:06 ` [Qemu-devel] [PULL 1/4] vhost_net: don't set backend for the uninitialized virtqueue Jason Wang
2019-05-17  9:06 ` [Qemu-devel] [PULL 2/4] e1000: Never increment the RX undersize count register Jason Wang
2019-05-17  9:06 ` [Qemu-devel] [PULL 3/4] net/slirp: fix the IPv6 prefix length error message Jason Wang
2019-05-17  9:06 ` [Qemu-devel] [PULL 4/4] net/colo-compare.c: Fix a crash in COLO Primary Jason Wang
2019-05-17 14:46 ` [Qemu-devel] [PULL 0/4] Net patches Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).