aboutsummaryrefslogtreecommitdiff
path: root/contrib/libvhost-user
diff options
context:
space:
mode:
authorDr. David Alan Gilbert <dgilbert@redhat.com>2018-03-12 17:21:06 +0000
committerMichael S. Tsirkin <mst@redhat.com>2018-03-20 05:03:28 +0200
commit6864a7b5aced6d8d9b287b92db8d7a996ea2e8a3 (patch)
tree84755be6b91f51835ef5ad85247ba0c7e045617b /contrib/libvhost-user
parentf82c11165ffaa1a8f3f0488fb4075a818a4efdaf (diff)
vhost+postcopy: Transmit 'listen' to slave
Notify the vhost-user slave on reception of the 'postcopy-listen' event from the source. Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'contrib/libvhost-user')
-rw-r--r--contrib/libvhost-user/libvhost-user.c19
-rw-r--r--contrib/libvhost-user/libvhost-user.h2
2 files changed, 21 insertions, 0 deletions
diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/libvhost-user.c
index 9e31f47b7a..e53b1953df 100644
--- a/contrib/libvhost-user/libvhost-user.c
+++ b/contrib/libvhost-user/libvhost-user.c
@@ -98,6 +98,7 @@ vu_request_to_string(unsigned int req)
REQ(VHOST_USER_GET_CONFIG),
REQ(VHOST_USER_SET_CONFIG),
REQ(VHOST_USER_POSTCOPY_ADVISE),
+ REQ(VHOST_USER_POSTCOPY_LISTEN),
REQ(VHOST_USER_MAX),
};
#undef REQ
@@ -932,6 +933,22 @@ out:
}
static bool
+vu_set_postcopy_listen(VuDev *dev, VhostUserMsg *vmsg)
+{
+ vmsg->payload.u64 = -1;
+ vmsg->size = sizeof(vmsg->payload.u64);
+
+ if (dev->nregions) {
+ vu_panic(dev, "Regions already registered at postcopy-listen");
+ return true;
+ }
+ dev->postcopy_listening = true;
+
+ vmsg->flags = VHOST_USER_VERSION | VHOST_USER_REPLY_MASK;
+ vmsg->payload.u64 = 0; /* Success */
+ return true;
+}
+static bool
vu_process_message(VuDev *dev, VhostUserMsg *vmsg)
{
int do_reply = 0;
@@ -1004,6 +1021,8 @@ vu_process_message(VuDev *dev, VhostUserMsg *vmsg)
break;
case VHOST_USER_POSTCOPY_ADVISE:
return vu_set_postcopy_advise(dev, vmsg);
+ case VHOST_USER_POSTCOPY_LISTEN:
+ return vu_set_postcopy_listen(dev, vmsg);
default:
vmsg_close_fds(vmsg);
vu_panic(dev, "Unhandled request: %d", vmsg->request);
diff --git a/contrib/libvhost-user/libvhost-user.h b/contrib/libvhost-user/libvhost-user.h
index 074b7860f6..ed505cf0c1 100644
--- a/contrib/libvhost-user/libvhost-user.h
+++ b/contrib/libvhost-user/libvhost-user.h
@@ -86,6 +86,7 @@ typedef enum VhostUserRequest {
VHOST_USER_CREATE_CRYPTO_SESSION = 26,
VHOST_USER_CLOSE_CRYPTO_SESSION = 27,
VHOST_USER_POSTCOPY_ADVISE = 28,
+ VHOST_USER_POSTCOPY_LISTEN = 29,
VHOST_USER_MAX
} VhostUserRequest;
@@ -285,6 +286,7 @@ struct VuDev {
/* Postcopy data */
int postcopy_ufd;
+ bool postcopy_listening;
};
typedef struct VuVirtqElement {