virtio-net: fix tx queue size for !vhost-user
Current code segfaults when no nic peer is specified.
Fix it up - fall back to default queue size.
Fixes: 9b02e1618c
("virtio-net: enable configurable tx queue size")
Cc: Wei Wang <wei.w.wang@intel.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
83f3c70919
commit
2eef278b9e
@ -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)
|
static int peer_attach(VirtIONet *n, int index)
|
||||||
{
|
{
|
||||||
NetClientState *nc = qemu_get_subqueue(n->nic, 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\"");
|
error_report("Defaulting to \"bh\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
n->net_conf.tx_queue_size = MIN(virtio_net_max_tx_queue_size(n),
|
||||||
* Currently, backends other than vhost-user don't support 1024 queue
|
n->net_conf.tx_queue_size);
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < n->max_queues; i++) {
|
for (i = 0; i < n->max_queues; i++) {
|
||||||
virtio_net_add_queue(n, i);
|
virtio_net_add_queue(n, i);
|
||||||
|
Loading…
Reference in New Issue
Block a user