[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 07/18] vhost: add vhost_dev stop callback
From: |
marcandre . lureau |
Subject: |
[Qemu-devel] [PATCH 07/18] vhost: add vhost_dev stop callback |
Date: |
Fri, 1 Apr 2016 13:16:17 +0200 |
From: Marc-André Lureau <address@hidden>
vhost backend may want to stop the device, for example if it wants to
restart itself (translates to a link down for vhost-net).
Signed-off-by: Marc-André Lureau <address@hidden>
---
hw/net/vhost_net.c | 14 ++++++++++++++
include/hw/virtio/vhost.h | 4 ++++
2 files changed, 18 insertions(+)
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 6e1032f..1e4710d 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -131,6 +131,18 @@ static int vhost_net_get_fd(NetClientState *backend)
}
}
+static void vhost_net_backend_stop(struct vhost_dev *dev)
+{
+ struct vhost_net *net = container_of(dev, struct vhost_net, dev);
+ NetClientState *nc = net->nc;
+ NetClientState *peer = nc->peer;
+
+ peer->link_down = 1;
+ if (peer->info->link_status_changed) {
+ peer->info->link_status_changed(peer);
+ }
+}
+
struct vhost_net *vhost_net_init(VhostNetOptions *options)
{
int r;
@@ -165,6 +177,8 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
net->dev.vq_index = net->nc->queue_index * net->dev.nvqs;
}
+ net->dev.stop = vhost_net_backend_stop;
+
r = vhost_dev_init(&net->dev, options->opaque,
options->backend_type);
if (r < 0) {
diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
index b60d758..859be64 100644
--- a/include/hw/virtio/vhost.h
+++ b/include/hw/virtio/vhost.h
@@ -35,6 +35,8 @@ struct vhost_log {
vhost_log_chunk_t *log;
};
+typedef void (*vhost_stop)(struct vhost_dev *dev);
+
struct vhost_memory;
struct vhost_dev {
MemoryListener memory_listener;
@@ -61,6 +63,8 @@ struct vhost_dev {
void *opaque;
struct vhost_log *log;
QLIST_ENTRY(vhost_dev) entry;
+ /* backend request to stop */
+ vhost_stop stop;
};
int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
--
2.5.5
- [Qemu-devel] [PATCH 00/18] RFCv2: vhost-user: shutdown and reconnection, marcandre . lureau, 2016/04/01
- [Qemu-devel] [PATCH 01/18] tests: append i386 tests, marcandre . lureau, 2016/04/01
- [Qemu-devel] [PATCH 02/18] char: lower reconnect error to trace event, marcandre . lureau, 2016/04/01
- [Qemu-devel] [PATCH 03/18] char: use a trace for when the char is waiting, marcandre . lureau, 2016/04/01
- [Qemu-devel] [PATCH 04/18] char: add wait support for reconnect, marcandre . lureau, 2016/04/01
- [Qemu-devel] [PATCH 05/18] vhost-user: check reconnect comes with wait, marcandre . lureau, 2016/04/01
- [Qemu-devel] [PATCH 07/18] vhost: add vhost_dev stop callback,
marcandre . lureau <=
- [Qemu-devel] [PATCH 08/18] vhost-user: add vhost_user to hold the chr, marcandre . lureau, 2016/04/01
- [Qemu-devel] [PATCH 06/18] vhost-user: add ability to know vhost-user backend disconnection, marcandre . lureau, 2016/04/01
- [Qemu-devel] [PATCH 09/18] qemu-char: add qemu_chr_disconnect to close a fd accepted by listen fd, marcandre . lureau, 2016/04/01
- [Qemu-devel] [PATCH 10/18] vhost-user: add slave-fd support, marcandre . lureau, 2016/04/01
- [Qemu-devel] [PATCH 11/18] vhost-user: add shutdown support, marcandre . lureau, 2016/04/01