@@ -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) {
@@ -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,