[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH for 8.0 11/13] virtio-net: save inflight descriptors at vhost
From: |
Eugenio Pérez |
Subject: |
[RFC PATCH for 8.0 11/13] virtio-net: save inflight descriptors at vhost shutdown |
Date: |
Mon, 5 Dec 2022 18:04:34 +0100 |
So they can be migrated in virtio-net
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
hw/net/vhost_net.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 043058ff43..480f4ac0a1 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -21,6 +21,7 @@
#include "standard-headers/linux/vhost_types.h"
#include "hw/virtio/virtio-net.h"
+#include "hw/virtio/vhost-vdpa.h" /* TODO remove me */
#include "net/vhost_net.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
@@ -319,6 +320,7 @@ static void vhost_net_stop_one(struct vhost_net *net,
VirtIODevice *dev)
{
struct vhost_vring_file file = { .fd = -1 };
+ VirtIONet *n = VIRTIO_NET(dev);
if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) {
for (file.index = 0; file.index < net->dev.nvqs; ++file.index) {
@@ -329,6 +331,26 @@ static void vhost_net_stop_one(struct vhost_net *net,
if (net->nc->info->poll) {
net->nc->info->poll(net->nc, true);
}
+
+ for (size_t i = 0; i < net->dev.nvqs; ++i) {
+ struct vhost_vdpa *v = net->dev.opaque;
+
+ if (net->dev.nvqs != 2) {
+ continue;
+ }
+
+ if (!v->shadow_vqs_enabled) {
+ continue;
+ }
+
+ n->vqs[i].rx_inflight = vhost_svq_save_inflight(
+ g_ptr_array_index(v->shadow_vqs, 0),
+ &n->vqs[i].rx_inflight_num);
+ n->vqs[i].tx_inflight = vhost_svq_save_inflight(
+ g_ptr_array_index(v->shadow_vqs, 1),
+ &n->vqs[i].tx_inflight_num);
+ }
+
vhost_dev_stop(&net->dev, dev, false);
if (net->nc->info->stop) {
net->nc->info->stop(net->nc);
--
2.31.1
- [RFC PATCH for 8.0 04/13] vhost: add vhost_svq_save_inflight, (continued)
- [RFC PATCH for 8.0 04/13] vhost: add vhost_svq_save_inflight, Eugenio Pérez, 2022/12/05
- [RFC PATCH for 8.0 07/13] virtio: refactor qemu_put_virtqueue_element, Eugenio Pérez, 2022/12/05
- [RFC PATCH for 8.0 05/13] virtio: Specify uint32_t as VirtQueueElementOld members type, Eugenio Pérez, 2022/12/05
- [RFC PATCH for 8.0 06/13] virtio: refactor qemu_get_virtqueue_element, Eugenio Pérez, 2022/12/05
- [RFC PATCH for 8.0 10/13] virtio-net: Migrate vhost inflight descriptors, Eugenio Pérez, 2022/12/05
- [RFC PATCH for 8.0 12/13] vhost: expose vhost_svq_add_element, Eugenio Pérez, 2022/12/05
- [RFC PATCH for 8.0 11/13] virtio-net: save inflight descriptors at vhost shutdown,
Eugenio Pérez <=
- [RFC PATCH for 8.0 09/13] virtio: add vmstate_virtqueue_element_old, Eugenio Pérez, 2022/12/05
- [RFC PATCH for 8.0 08/13] virtio: expose VirtQueueElementOld, Eugenio Pérez, 2022/12/05
- [RFC PATCH for 8.0 13/13] vdpa: Recover inflight descriptors, Eugenio Pérez, 2022/12/05
- Re: [RFC PATCH for 8.0 00/13] vDPA-net inflight descriptors migration with SVQ, Jason Wang, 2022/12/06