[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 11/18] vhost-user: add shutdown support
From: |
marcandre . lureau |
Subject: |
[Qemu-devel] [PATCH 11/18] vhost-user: add shutdown support |
Date: |
Fri, 1 Apr 2016 13:16:21 +0200 |
From: Marc-André Lureau <address@hidden>
Signed-off-by: Marc-André Lureau <address@hidden>
---
docs/specs/vhost-user.txt | 15 +++++++++++++++
hw/virtio/vhost-user.c | 16 ++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/docs/specs/vhost-user.txt b/docs/specs/vhost-user.txt
index 8a635fa..60d6d13 100644
--- a/docs/specs/vhost-user.txt
+++ b/docs/specs/vhost-user.txt
@@ -487,3 +487,18 @@ Message types
request to the master. It is passed in the ancillary data.
This message is only sent if VHOST_USER_PROTOCOL_F_SLAVE_CHANNEL
feature is available.
+
+Slave message types
+-------------------
+
+ * VHOST_USER_SLAVE_SHUTDOWN:
+ Id: 1
+ Master payload: N/A
+ Slave payload: u64
+
+ Request the master to shutdown the slave. A 0 reply is for
+ success, in which case the slave may close all connections
+ immediately and quit. A non-zero reply cancels the request.
+
+ Before a reply comes, the master may make other requests in
+ order to flush or sync state.
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 890c1bd..f91baee 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -67,6 +67,8 @@ typedef enum VhostUserRequest {
typedef enum VhostUserSlaveRequest {
VHOST_USER_SLAVE_NONE = 0,
+ VHOST_USER_SLAVE_SHUTDOWN = 1,
+
VHOST_USER_SLAVE_MAX
} VhostUserSlaveRequest;
@@ -539,6 +541,20 @@ static void slave_read(void *opaque)
}
switch (msg.request) {
+ case VHOST_USER_SLAVE_SHUTDOWN: {
+ uint64_t success = 1; /* 0 is for success */
+ if (dev->stop) {
+ dev->stop(dev);
+ success = 0;
+ }
+ msg.payload.u64 = success;
+ msg.size = sizeof(msg.payload.u64);
+ size = send(u->slave_fd, &msg, VHOST_USER_HDR_SIZE + msg.size, 0);
+ if (size != VHOST_USER_HDR_SIZE + msg.size) {
+ error_report("Failed to write reply.");
+ }
+ break;
+ }
default:
error_report("Received unexpected msg type.");
}
--
2.5.5
- [Qemu-devel] [PATCH 03/18] char: use a trace for when the char is waiting, (continued)
- [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, 2016/04/01
- [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 <=
Re: [Qemu-devel] [PATCH 11/18] vhost-user: add shutdown support, Yuanhan Liu, 2016/04/28
[Qemu-devel] [PATCH 12/18] vhost-user: disconnect on start failure, marcandre . lureau, 2016/04/01
[Qemu-devel] [PATCH 15/18] vhost-net: save & restore vring enable state, marcandre . lureau, 2016/04/01