[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RFC 08/14] vhost: add vhost_dev stop callback
From: |
marcandre . lureau |
Subject: |
[Qemu-devel] [PATCH RFC 08/14] vhost: add vhost_dev stop callback |
Date: |
Wed, 9 Sep 2015 01:10:00 +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 | 13 +++++++++++++
include/hw/virtio/vhost.h | 4 ++++
2 files changed, 17 insertions(+)
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index ea15220..f977e2d 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -134,6 +134,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;
@@ -163,6 +175,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
net->dev.nvqs = 2;
net->dev.vqs = net->vqs;
+ net->dev.stop = vhost_net_backend_stop;
r = vhost_dev_init(&net->dev, options->opaque,
options->backend_type);
diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
index ab1dcac..48efd87 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;
@@ -59,6 +61,8 @@ struct vhost_dev {
const VhostOps *vhost_ops;
void *opaque;
struct vhost_log *log;
+ /* backend request to stop */
+ vhost_stop stop;
};
int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
--
2.4.3
- [Qemu-devel] [PATCH RFC 00/14] vhost-user: shutdown and reconnection, marcandre . lureau, 2015/09/08
- [Qemu-devel] [PATCH RFC 02/14] vhost-user: remove useless is_server field, marcandre . lureau, 2015/09/08
- [Qemu-devel] [PATCH RFC 01/14] vhost-user: Add ability to know vhost-user backend disconnection, marcandre . lureau, 2015/09/08
- [Qemu-devel] [PATCH RFC 03/14] qemu-char: avoid potential double-free, marcandre . lureau, 2015/09/08
- [Qemu-devel] [PATCH RFC 04/14] qemu-char: remove all msgfds on disconnect, marcandre . lureau, 2015/09/08
- [Qemu-devel] [PATCH RFC 05/14] qemu-char: make tcp_chr_disconnect() reentrant-safe, marcandre . lureau, 2015/09/08
- [Qemu-devel] [PATCH RFC 07/14] virtio-net: enable tx notification if up and vhost started, marcandre . lureau, 2015/09/08
- [Qemu-devel] [PATCH RFC 06/14] vhost-net: keep VIRTIO_NET_F_STATUS for vhost-user, marcandre . lureau, 2015/09/08
- [Qemu-devel] [PATCH RFC 08/14] vhost: add vhost_dev stop callback,
marcandre . lureau <=
- [Qemu-devel] [PATCH RFC 09/14] vhost-user: add vhost_user to hold the chr, marcandre . lureau, 2015/09/08
- [Qemu-devel] [PATCH RFC 10/14] qemu-char: add qemu_chr_free(), marcandre . lureau, 2015/09/08
- [Qemu-devel] [PATCH RFC 12/14] vhost-user: add shutdown support, marcandre . lureau, 2015/09/08
- [Qemu-devel] [PATCH RFC 11/14] vhost-user: add slave-fd support, marcandre . lureau, 2015/09/08
- [Qemu-devel] [PATCH RFC 13/14] qemu-char: Add qemu_chr_disconnect to close a fd accepted by listen fd, marcandre . lureau, 2015/09/08
- [Qemu-devel] [PATCH RFC 14/14] test: start vhost-user reconnect test, marcandre . lureau, 2015/09/08