Browse Source

Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging

# gpg: Signature made Fri 17 May 2019 10:01:18 BST
# gpg:                using RSA key EF04965B398D6211
# gpg: Good signature from "Jason Wang (Jason Wang on RedHat) <jasowang@redhat.com>" [marginal]
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 215D 46F4 8246 689E C77F  3562 EF04 965B 398D 6211

* remotes/jasowang/tags/net-pull-request:
  net/colo-compare.c: Fix a crash in COLO Primary.
  net/slirp: fix the IPv6 prefix length error message
  e1000: Never increment the RX undersize count register
  vhost_net: don't set backend for the uninitialized virtqueue

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Peter Maydell 6 years ago
parent
commit
e48a748fc8
6 changed files with 19 additions and 4 deletions
  1. 0 1
      hw/net/e1000.c
  2. 10 0
      hw/net/vhost_net.c
  3. 5 0
      hw/virtio/virtio.c
  4. 1 0
      include/hw/virtio/virtio.h
  5. 1 2
      net/colo-compare.c
  6. 2 1
      net/slirp.c

+ 0 - 1
hw/net/e1000.c

@@ -901,7 +901,6 @@ e1000_receive_iov(NetClientState *nc, const struct iovec *iov, int iovcnt)
     if (size < sizeof(min_buf)) {
     if (size < sizeof(min_buf)) {
         iov_to_buf(iov, iovcnt, 0, min_buf, size);
         iov_to_buf(iov, iovcnt, 0, min_buf, size);
         memset(&min_buf[size], 0, sizeof(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_base = filter_buf = min_buf;
         min_iov.iov_len = size = sizeof(min_buf);
         min_iov.iov_len = size = sizeof(min_buf);
         iovcnt = 1;
         iovcnt = 1;

+ 10 - 0
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);
         qemu_set_fd_handler(net->backend, NULL, NULL, NULL);
         file.fd = net->backend;
         file.fd = net->backend;
         for (file.index = 0; file.index < net->dev.nvqs; ++file.index) {
         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);
             r = vhost_net_set_backend(&net->dev, &file);
             if (r < 0) {
             if (r < 0) {
                 r = -errno;
                 r = -errno;
@@ -256,6 +261,11 @@ fail:
     file.fd = -1;
     file.fd = -1;
     if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) {
     if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) {
         while (file.index-- > 0) {
         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);
             int r = vhost_net_set_backend(&net->dev, &file);
             assert(r >= 0);
             assert(r >= 0);
         }
         }

+ 5 - 0
hw/virtio/virtio.c

@@ -2318,6 +2318,11 @@ hwaddr virtio_queue_get_desc_addr(VirtIODevice *vdev, int n)
     return vdev->vq[n].vring.desc;
     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)
 hwaddr virtio_queue_get_avail_addr(VirtIODevice *vdev, int n)
 {
 {
     return vdev->vq[n].vring.avail;
     return vdev->vq[n].vring.avail;

+ 1 - 0
include/hw/virtio/virtio.h

@@ -282,6 +282,7 @@ typedef struct VirtIORNGConf VirtIORNGConf;
                       VIRTIO_F_IOMMU_PLATFORM, false)
                       VIRTIO_F_IOMMU_PLATFORM, false)
 
 
 hwaddr virtio_queue_get_desc_addr(VirtIODevice *vdev, int n);
 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_avail_addr(VirtIODevice *vdev, int n);
 hwaddr virtio_queue_get_used_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);
 hwaddr virtio_queue_get_desc_size(VirtIODevice *vdev, int n);

+ 1 - 2
net/colo-compare.c

@@ -813,9 +813,8 @@ static void colo_compare_handle_event(void *opaque)
         break;
         break;
     }
     }
 
 
-    assert(event_unhandled_count > 0);
-
     qemu_mutex_lock(&event_mtx);
     qemu_mutex_lock(&event_mtx);
+    assert(event_unhandled_count > 0);
     event_unhandled_count--;
     event_unhandled_count--;
     qemu_cond_broadcast(&event_complete_cond);
     qemu_cond_broadcast(&event_complete_cond);
     qemu_mutex_unlock(&event_mtx);
     qemu_mutex_unlock(&event_mtx);

+ 2 - 1
net/slirp.c

@@ -498,7 +498,8 @@ static int net_slirp_init(NetClientState *peer, const char *model,
     }
     }
     if (vprefix6_len < 0 || vprefix6_len > 126) {
     if (vprefix6_len < 0 || vprefix6_len > 126) {
         error_setg(errp,
         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;
         return -1;
     }
     }