@@ -75,6 +75,7 @@ static const char *vhost_message_str[VHOST_USER_MAX] = {
[VHOST_USER_CRYPTO_CLOSE_SESS] = "VHOST_USER_CRYPTO_CLOSE_SESS",
[VHOST_USER_POSTCOPY_ADVISE] = "VHOST_USER_POSTCOPY_ADVISE",
[VHOST_USER_POSTCOPY_LISTEN] = "VHOST_USER_POSTCOPY_LISTEN",
+ [VHOST_USER_POSTCOPY_END] = "VHOST_USER_POSTCOPY_END",
};
static int
@@ -1524,6 +1525,18 @@ vhost_user_set_postcopy_listen(struct virtio_net *dev)
return 0;
}
+static int
+vhost_user_postcopy_end(struct virtio_net *dev)
+{
+ dev->postcopy_listening = 0;
+ if (dev->postcopy_ufd > 0) {
+ close(dev->postcopy_ufd);
+ dev->postcopy_ufd = -1;
+ }
+
+ return 0;
+}
+
/* return bytes# of read on success or negative val on failure. */
static int
read_vhost_message(int sockfd, struct VhostUserMsg *msg)
@@ -1877,6 +1890,14 @@ vhost_user_msg_handler(int vid, int fd)
ret = vhost_user_set_postcopy_listen(dev);
break;
+ case VHOST_USER_POSTCOPY_END:
+ vhost_user_postcopy_end(dev);
+ msg.payload.u64 = 0;
+ msg.size = sizeof(msg.payload.u64);
+ msg.fd_num = 0;
+ send_vhost_reply(fd, &msg);
+ break;
+
default:
ret = -1;
break;