[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 08/10] vhost-net: save & restore vring enable state
From: |
marcandre . lureau |
Subject: |
[Qemu-devel] [PATCH 08/10] vhost-net: save & restore vring enable state |
Date: |
Mon, 6 Jun 2016 18:45:06 +0200 |
From: Marc-André Lureau <address@hidden>
A driver may change the vring enable state at run time but vhost-user
backend may not be present (a contrived example is when the backend is
disconnected and the device is reconfigured after driver rebinding)
Restore the vring state when the vhost-user backend is started, so it
can process the ring.
Signed-off-by: Marc-André Lureau <address@hidden>
Tested-by: Yuanhan Liu <address@hidden>
Reviewed-by: Yuanhan Liu <address@hidden>
---
hw/net/vhost_net.c | 11 +++++++++++
include/net/net.h | 1 +
2 files changed, 12 insertions(+)
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index b28881f..50f4dcd 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -329,6 +329,15 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
if (r < 0) {
goto err_start;
}
+
+ if (ncs[i].peer->vring_enable) {
+ /* restore vring enable state */
+ r = vhost_set_vring_enable(ncs[i].peer, ncs[i].peer->vring_enable);
+
+ if (r < 0) {
+ goto err_start;
+ }
+ }
}
return 0;
@@ -422,6 +431,8 @@ int vhost_set_vring_enable(NetClientState *nc, int enable)
VHostNetState *net = get_vhost_net(nc);
const VhostOps *vhost_ops;
+ nc->vring_enable = enable;
+
if (!net) {
return 0;
}
diff --git a/include/net/net.h b/include/net/net.h
index a69e382..a5c5095 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -99,6 +99,7 @@ struct NetClientState {
NetClientDestructor *destructor;
unsigned int queue_index;
unsigned rxfilter_notify_enabled:1;
+ int vring_enable;
QTAILQ_HEAD(NetFilterHead, NetFilterState) filters;
};
--
2.7.4
- [Qemu-devel] [PATCH 03/10] tests/vhost-user-bridge: workaround stale vring base, (continued)
- [Qemu-devel] [PATCH 03/10] tests/vhost-user-bridge: workaround stale vring base, marcandre . lureau, 2016/06/06
- [Qemu-devel] [PATCH 02/10] tests/vhost-user-bridge: add client mode, marcandre . lureau, 2016/06/06
- [Qemu-devel] [PATCH 04/10] qemu-char: add qemu_chr_disconnect to close a fd accepted by listen fd, marcandre . lureau, 2016/06/06
- [Qemu-devel] [PATCH 05/10] vhost-user: disconnect on start failure, marcandre . lureau, 2016/06/06
- [Qemu-devel] [PATCH 07/10] vhost-net: save & restore vhost-user acked features, marcandre . lureau, 2016/06/06
- [Qemu-devel] [PATCH 06/10] vhost-net: do not crash if backend is not present, marcandre . lureau, 2016/06/06
- [Qemu-devel] [PATCH 08/10] vhost-net: save & restore vring enable state,
marcandre . lureau <=
- [Qemu-devel] [PATCH 09/10] tests: append i386 tests, marcandre . lureau, 2016/06/06
- [Qemu-devel] [PATCH 10/10] test: start vhost-user reconnect test, marcandre . lureau, 2016/06/06
- Re: [Qemu-devel] [PATCH 00/10] vhost-user: simple reconnection support, Victor Kaplansky, 2016/06/09