[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 29/41] vhost_net: use the function qemu_get_peer
From: |
Michael S. Tsirkin |
Subject: |
[PULL v2 29/41] vhost_net: use the function qemu_get_peer |
Date: |
Sat, 4 Jul 2020 14:30:39 -0400 |
From: Cindy Lu <lulu@redhat.com>
user the qemu_get_peer to replace the old process
Signed-off-by: Cindy Lu <lulu@redhat.com>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Message-Id: <20200701145538.22333-3-lulu@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
---
hw/net/vhost_net.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 6b82803fa7..4096d64aaf 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -306,7 +306,9 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(dev)));
VirtioBusState *vbus = VIRTIO_BUS(qbus);
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus);
+ struct vhost_net *net;
int r, e, i;
+ NetClientState *peer;
if (!k->set_guest_notifiers) {
error_report("binding does not support guest notifiers");
@@ -314,9 +316,9 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
}
for (i = 0; i < total_queues; i++) {
- struct vhost_net *net;
- net = get_vhost_net(ncs[i].peer);
+ peer = qemu_get_peer(ncs, i);
+ net = get_vhost_net(peer);
vhost_net_set_vq_index(net, i * 2);
/* Suppress the masking guest notifiers on vhost user
@@ -335,15 +337,16 @@ int vhost_net_start(VirtIODevice *dev, NetClientState
*ncs,
}
for (i = 0; i < total_queues; i++) {
- r = vhost_net_start_one(get_vhost_net(ncs[i].peer), dev);
+ peer = qemu_get_peer(ncs, i);
+ r = vhost_net_start_one(get_vhost_net(peer), dev);
if (r < 0) {
goto err_start;
}
- if (ncs[i].peer->vring_enable) {
+ if (peer->vring_enable) {
/* restore vring enable state */
- r = vhost_set_vring_enable(ncs[i].peer, ncs[i].peer->vring_enable);
+ r = vhost_set_vring_enable(peer, peer->vring_enable);
if (r < 0) {
goto err_start;
@@ -355,7 +358,8 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
err_start:
while (--i >= 0) {
- vhost_net_stop_one(get_vhost_net(ncs[i].peer), dev);
+ peer = qemu_get_peer(ncs , i);
+ vhost_net_stop_one(get_vhost_net(peer), dev);
}
e = k->set_guest_notifiers(qbus->parent, total_queues * 2, false);
if (e < 0) {
--
MST
- [PULL v2 18/41] pc: Support for virtio-mem-pci, (continued)
- [PULL v2 18/41] pc: Support for virtio-mem-pci, Michael S. Tsirkin, 2020/07/04
- [PULL v2 19/41] virtio-mem: Allow notifiers for size changes, Michael S. Tsirkin, 2020/07/04
- [PULL v2 20/41] virtio-pci: Send qapi events when the virtio-mem size changes, Michael S. Tsirkin, 2020/07/04
- [PULL v2 22/41] virtio-mem: Add trace events, Michael S. Tsirkin, 2020/07/04
- [PULL v2 23/41] virtio-mem: Exclude unplugged memory during migration, Michael S. Tsirkin, 2020/07/04
- [PULL v2 24/41] numa: Auto-enable NUMA when any memory devices are possible, Michael S. Tsirkin, 2020/07/04
- [PULL v2 25/41] tests/acpi: remove stale allowed tables, Michael S. Tsirkin, 2020/07/04
- [PULL v2 27/41] MAINTAINERS: add VT-d entry, Michael S. Tsirkin, 2020/07/04
- [PULL v2 26/41] docs: vhost-user: add Virtio status protocol feature, Michael S. Tsirkin, 2020/07/04
- [PULL v2 28/41] net: introduce qemu_get_peer, Michael S. Tsirkin, 2020/07/04
- [PULL v2 29/41] vhost_net: use the function qemu_get_peer,
Michael S. Tsirkin <=
- [PULL v2 30/41] virtio-bus: introduce queue_enabled method, Michael S. Tsirkin, 2020/07/04
- [PULL v2 31/41] virtio-pci: implement queue_enabled method, Michael S. Tsirkin, 2020/07/04
- [PULL v2 32/41] vhost: check the existence of vhost_set_iotlb_callback, Michael S. Tsirkin, 2020/07/04
- [PULL v2 33/41] vhost: introduce new VhostOps vhost_dev_start, Michael S. Tsirkin, 2020/07/04
- [PULL v2 34/41] vhost: implement vhost_dev_start method, Michael S. Tsirkin, 2020/07/04
- [PULL v2 35/41] vhost: introduce new VhostOps vhost_vq_get_addr, Michael S. Tsirkin, 2020/07/04
- [PULL v2 36/41] vhost: implement vhost_vq_get_addr method, Michael S. Tsirkin, 2020/07/04