[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 20/21] virtio-net: fix tx queue size for !vhost-user
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 20/21] virtio-net: fix tx queue size for !vhost-user |
Date: |
Mon, 3 Jul 2017 22:45:56 +0300 |
Current code segfaults when no nic peer is specified.
Fix it up - fall back to default queue size.
Fixes: 9b02e1618cf26a ("virtio-net: enable configurable tx queue size")
Cc: Wei Wang <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
hw/net/virtio-net.c | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index a1fc0db..5630a9e 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -498,6 +498,24 @@ static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, int
mergeable_rx_bufs,
}
}
+static int virtio_net_max_tx_queue_size(VirtIONet *n)
+{
+ NetClientState *peer = n->nic_conf.peers.ncs[0];
+
+ /*
+ * Backends other than vhost-user don't support max queue size.
+ */
+ if (!peer) {
+ return VIRTIO_NET_TX_QUEUE_DEFAULT_SIZE;
+ }
+
+ if (peer->info->type != NET_CLIENT_DRIVER_VHOST_USER) {
+ return VIRTIO_NET_TX_QUEUE_DEFAULT_SIZE;
+ }
+
+ return VIRTQUEUE_MAX_SIZE;
+}
+
static int peer_attach(VirtIONet *n, int index)
{
NetClientState *nc = qemu_get_subqueue(n->nic, index);
@@ -1964,14 +1982,8 @@ static void virtio_net_device_realize(DeviceState *dev,
Error **errp)
error_report("Defaulting to \"bh\"");
}
- /*
- * Currently, backends other than vhost-user don't support 1024 queue
- * size.
- */
- if (n->net_conf.tx_queue_size == VIRTQUEUE_MAX_SIZE &&
- n->nic_conf.peers.ncs[0]->info->type != NET_CLIENT_DRIVER_VHOST_USER) {
- n->net_conf.tx_queue_size = VIRTIO_NET_TX_QUEUE_DEFAULT_SIZE;
- }
+ n->net_conf.tx_queue_size = MIN(virtio_net_max_tx_queue_size(n),
+ n->net_conf.tx_queue_size);
for (i = 0; i < n->max_queues; i++) {
virtio_net_add_queue(n, i);
--
MST
- [Qemu-devel] [PULL 09/21] pci: Convert to realize, (continued)
- [Qemu-devel] [PULL 09/21] pci: Convert to realize, Michael S. Tsirkin, 2017/07/03
- [Qemu-devel] [PULL 10/21] pci: Convert shpc_init() to Error, Michael S. Tsirkin, 2017/07/03
- [Qemu-devel] [PULL 11/21] i386/kvm/pci-assign: Fix return type of verify_irqchip_kernel(), Michael S. Tsirkin, 2017/07/03
- [Qemu-devel] [PULL 12/21] i386/kvm/pci-assign: Use errp directly rather than local_err, Michael S. Tsirkin, 2017/07/03
- [Qemu-devel] [PULL 15/21] hw/acpi: remove dead acpi code, Michael S. Tsirkin, 2017/07/03
- [Qemu-devel] [PULL 14/21] fw_cfg: move setting of FW_CFG_VERSION_DMA bit to fw_cfg_init1(), Michael S. Tsirkin, 2017/07/03
- [Qemu-devel] [PULL 13/21] fw_cfg: don't map the fw_cfg IO ports in fw_cfg_io_realize(), Michael S. Tsirkin, 2017/07/03
- [Qemu-devel] [PULL 16/21] intel_iommu: fix migration breakage on mr switch, Michael S. Tsirkin, 2017/07/03
- [Qemu-devel] [PULL 17/21] vhost: ensure vhost_ops are set before calling iotlb callback, Michael S. Tsirkin, 2017/07/03
- [Qemu-devel] [PULL 18/21] vhost-user: unregister slave req handler at cleanup time, Michael S. Tsirkin, 2017/07/03
- [Qemu-devel] [PULL 20/21] virtio-net: fix tx queue size for !vhost-user,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 21/21] i386/acpi: update expected acpi files, Michael S. Tsirkin, 2017/07/03
- [Qemu-devel] [PULL 19/21] tests: Add unit tests for the VM Generation ID feature, Michael S. Tsirkin, 2017/07/03
- Re: [Qemu-devel] [PULL 19/21] tests: Add unit tests for the VM Generation ID feature, Peter Maydell, 2017/07/11
- Re: [Qemu-devel] [PULL 19/21] tests: Add unit tests for the VM Generation ID feature, Ben Warren, 2017/07/11
- Re: [Qemu-devel] [PULL 19/21] tests: Add unit tests for the VM Generation ID feature, Peter Maydell, 2017/07/11
- Re: [Qemu-devel] [PULL 19/21] tests: Add unit tests for the VM Generation ID feature, Peter Maydell, 2017/07/11
- Re: [Qemu-devel] [PULL 19/21] tests: Add unit tests for the VM Generation ID feature, Michael S. Tsirkin, 2017/07/11
- Re: [Qemu-devel] [PULL 19/21] tests: Add unit tests for the VM Generation ID feature, Peter Maydell, 2017/07/11
- Re: [Qemu-devel] [PULL 19/21] tests: Add unit tests for the VM Generation ID feature, Laszlo Ersek, 2017/07/11
- Re: [Qemu-devel] [PULL 19/21] tests: Add unit tests for the VM Generation ID feature, Ben Warren, 2017/07/11