aboutsummaryrefslogtreecommitdiff
path: root/hw/virtio-net.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2013-03-26 16:16:43 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2013-03-26 16:16:43 -0500
commit404e7a4f4af753bd2aef649adf79e7434fb6dc31 (patch)
tree43a43089f2e5cab27bd5d514ba2e9753d9c760af /hw/virtio-net.c
parent18501ae6e825d8da72369fd091018ef71071bd87 (diff)
parent6214e73cc5b75a4f8d89a70d71727edfa47a81b3 (diff)
Merge remote-tracking branch 'mst/tags/for_anthony' into staging
virtio,pci,qom Work by Alex to support VGA assignment, pci and virtio fixes by Stefan, Jason and myself, and a new qmp event for hotplug support by myself. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> # gpg: Signature made Tue 26 Mar 2013 02:02:24 PM CDT using RSA key ID D28D5469 # gpg: Can't check signature: public key not found # By Alex Williamson (13) and others # Via Michael S. Tsirkin * mst/tags/for_anthony: (23 commits) pcie: Add endpoint capability initialization wrapper roms: switch oldnoconfig to olddefconfig pcie: Mangle types to match topology pci: Create and use API to determine root buses pci: Create pci_bus_is_express helper pci: Q35, Root Ports, and Switches create PCI Express buses pci: Allow PCI bus creation interfaces to specify the type of bus pci: Move PCI and PCIE type defines pci: Create and register a new PCI Express TypeInfo exec: assert that RAMBlock size is non-zero pci: refuse empty ROM files pci_bridge: Remove duplicate IRQ swizzle function pci_bridge: Use a default map_irq function pci: Fix INTx routing notifier recursion pci_bridge: drop formatting from source pci_bridge: factor out common code pci: Teach PCI Bridges about VGA routing pci: Add PCI VGA helpers virtio-pci: guest notifier mask without non-irqfd virtio-net: remove layout assumptions for mq ctrl ...
Diffstat (limited to 'hw/virtio-net.c')
-rw-r--r--hw/virtio-net.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 4bb49eb545..5917740d9d 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -528,13 +528,14 @@ static int virtio_net_handle_vlan_table(VirtIONet *n, uint8_t cmd,
}
static int virtio_net_handle_mq(VirtIONet *n, uint8_t cmd,
- VirtQueueElement *elem)
+ struct iovec *iov, unsigned int iov_cnt)
{
- struct virtio_net_ctrl_mq s;
+ struct virtio_net_ctrl_mq mq;
+ size_t s;
+ uint16_t queues;
- if (elem->out_num != 2 ||
- elem->out_sg[1].iov_len != sizeof(struct virtio_net_ctrl_mq)) {
- error_report("virtio-net ctrl invalid steering command");
+ s = iov_to_buf(iov, iov_cnt, 0, &mq, sizeof(mq));
+ if (s != sizeof(mq)) {
return VIRTIO_NET_ERR;
}
@@ -542,16 +543,16 @@ static int virtio_net_handle_mq(VirtIONet *n, uint8_t cmd,
return VIRTIO_NET_ERR;
}
- memcpy(&s, elem->out_sg[1].iov_base, sizeof(struct virtio_net_ctrl_mq));
+ queues = lduw_p(&mq.virtqueue_pairs);
- if (s.virtqueue_pairs < VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN ||
- s.virtqueue_pairs > VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX ||
- s.virtqueue_pairs > n->max_queues ||
+ if (queues < VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN ||
+ queues > VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX ||
+ queues > n->max_queues ||
!n->multiqueue) {
return VIRTIO_NET_ERR;
}
- n->curr_queues = s.virtqueue_pairs;
+ n->curr_queues = queues;
/* stop the backend before changing the number of queues to avoid handling a
* disabled queue */
virtio_net_set_status(&n->vdev, n->vdev.status);
@@ -589,7 +590,7 @@ static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
} else if (ctrl.class == VIRTIO_NET_CTRL_VLAN) {
status = virtio_net_handle_vlan_table(n, ctrl.cmd, iov, iov_cnt);
} else if (ctrl.class == VIRTIO_NET_CTRL_MQ) {
- status = virtio_net_handle_mq(n, ctrl.cmd, &elem);
+ status = virtio_net_handle_mq(n, ctrl.cmd, iov, iov_cnt);
}
s = iov_from_buf(elem.in_sg, elem.in_num, 0, &status, sizeof(status));