@@ -273,6 +273,14 @@ Once the source has finished migration, rings will be stopped by
the source. No further update must be done before rings are
restarted.
+In postcopy migration the slave is started before all the memory has been
+received from the source host, and care must be taken to avoid accessing pages
+that have yet to be received. The slave opens a 'userfault'-fd and registers
+the memory with it; this fd is then passed back over to the master.
+The master services requests on the userfaultfd for pages that are accessed
+and when the page is available it performs WAKE ioctl's on the userfaultfd
+to wake the stalled slave.
+
IOMMU support
-------------
@@ -326,6 +334,7 @@ Protocol features
#define VHOST_USER_PROTOCOL_F_REPLY_ACK 3
#define VHOST_USER_PROTOCOL_F_MTU 4
#define VHOST_USER_PROTOCOL_F_SLAVE_REQ 5
+#define VHOST_USER_PROTOCOL_F_POSTCOPY 6
Master message types
--------------------
@@ -402,12 +411,17 @@ Master message types
Id: 5
Equivalent ioctl: VHOST_SET_MEM_TABLE
Master payload: memory regions description
+ Slave payload: (postcopy only) memory regions description
Sets the memory map regions on the slave so it can translate the vring
addresses. In the ancillary data there is an array of file descriptors
for each memory mapped region. The size and ordering of the fds matches
the number and ordering of memory regions.
+ When postcopy-listening has been received, SET_MEM_TABLE replies with
+ the bases of the memory mapped regions to the master. It must have mmap'd
+ the regions and enabled userfaultfd on them.
+
* VHOST_USER_SET_LOG_BASE
Id: 6
@@ -580,6 +594,29 @@ Master message types
This request should be send only when VIRTIO_F_IOMMU_PLATFORM feature
has been successfully negotiated.
+ * VHOST_USER_POSTCOPY_ADVISE
+ Id: 23
+ Master payload: N/A
+ Slave payload: userfault fd + u64
+
+ Master advises slave that a migration with postcopy enabled is underway,
+ the slave must open a userfaultfd for later use.
+ Note that at this stage the migration is still in precopy mode.
+
+ * VHOST_USER_POSTCOPY_LISTEN
+ Id: 24
+ Master payload: N/A
+
+ Master advises slave that a transition to postcopy mode has happened.
+
+ * VHOST_USER_POSTCOPY_END
+ Id: 25
+ Slave payload: u64
+
+ Master advises that postcopy migration has now completed. The
+ slave must disable the userfaultfd. The response is an acknowledgement
+ only.
+
Slave message types
-------------------