Skip to contentSkip to conversation

docs: Migration design documents

PATCH Superseded Paul Durrant 4 participants 10 messages Jan 28, 2020

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover docs: Migration design documents

Patch #1 was standalone in v2 and is unmodified in v3.

Paul Durrant (2):
docs/designs: Add a design document for non-cooperative live migration docs/designs: Add a design document for migration of xenstore data

 docs/designs/non-cooperative-migration.md | 259 ++++++++++++++++++++++
 docs/designs/xenstore-migration.md        | 122 ++++++++++
 2 files changed, 381 insertions(+)
 create mode 100644 docs/designs/non-cooperative-migration.md
 create mode 100644 docs/designs/xenstore-migration.md
Signature · 7 lines
2.20.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw

PATCH v3 1/2 docs/designs: Add a design document for non-cooperative live migration

It has become apparent to some large cloud providers that the current model of cooperative migration of guests under Xen is not usable as it relies on software running inside the guest, which is likely beyond the provider's control.
This patch introduces a proposal for non-cooperative live migration, designed not to rely on any guest-side software.

---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Wei Liu <[email protected]>

v2:
- Use the term 'non-cooperative' instead of 'transparent'
- Replace 'trust in' with 'reliance on' when referring to guest-side software

---
 docs/designs/non-cooperative-migration.md | 259 ++++++++++++++++++++++
 1 file changed, 259 insertions(+)
 create mode 100644 docs/designs/non-cooperative-migration.md
docs/designs/non-cooperative-migration.md new file +259 -0
new file mode 100644
index 0000000000..f38d664c34
@@ -0,0 +1,259 @@
+# Non-Cooperative Migration of Guests on Xen
+
+## Background
+
+The normal model of migration in Xen is driven by the guest because it was
+originally implemented for PV guests, where the guest must be aware it is
+running under Xen and is hence expected to co-operate. This model dates from
+an era when it was assumed that the host administrator had control of at least
+the privileged software running in the guest (i.e. the guest kernel) which may
+still be true in an enterprise deployment but is not generally true in a cloud
+environment. The aim of this design is to provide a model which is purely host
+driven, requiring no co-operation from the software running in the
+guest, and is thus suitable for cloud scenarios.
+
+PV guests are out of scope for this project because, as is outlined above, they
+have a symbiotic relationship with the hypervisor and therefore a certain level
+of co-operation can be assumed.
+HVM guests can already be migrated on Xen without guest co-operation but only
+if they don’t have PV drivers installed[1] or are in power state S3. The
+reason for not expecting co-operation if the guest is in S3 is obvious, but the
+reason co-operation is expected if PV drivers are installed is due to the
+nature of PV protocols.
+
+## Xenstore Nodes and Domain ID
+
+The PV driver model consists of a *frontend* and a *backend*. The frontend runs
+inside the guest domain and the backend runs inside a *service domain* which
+may or may not domain 0. The frontend and backend typically pass data via
+memory pages which are shared between the two domains, but this channel of
+communication is generally established using xenstore (the store protocol
+itself being an exception to this for obvious chicken-and-egg reasons).
+
+Typical protocol establishment is based on use of two separate xenstore
+*areas*. If we consider PV drivers for the *netif* protocol (i.e. class vif)
+and assume the guest has domid X, the service domain has domid Y, and the vif
+has index Z then the frontend area will reside under the parent node:
+
+`/local/domain/Y/device/vif/Z`
+
+All backends, by convention, typically reside under parent node:
+
+`/local/domain/X/backend`
+
+and the normal backend area for vif Z would be:
+
+`/local/domain/X/backend/vif/Y/Z`
+
+but this should not be assumed.
+
+The toolstack will place two nodes in the frontend area to explicitly locate
+the backend:
+
+    * `backend`: the fully qualified xenstore path of the backend area
+    * `backend-id`: the domid of the service domain
+
+and similarly two nodes in the backend area to locate the frontend area:
+
+    * `frontend`: the fully qualified xenstore path of the frontend area
+    * `frontend-id`: the domid of the guest domain
+
+
+The guest domain only has write permission to the frontend area and similarly
+the service domain only has write permission to the backend area, but both ends
+have read permission to both areas.
+
+Under both frontend and backend areas is a node called *state*. This is key to
+protocol establishment. Upon PV device creation the toolstack will set the
+value of both state nodes to 1 (XenbusStateInitialising[2]). This should cause
+enumeration of appropriate devices in both the guest and service domains. The
+backend device, once it has written any necessary protocol specific information
+into the xenstore backend area (to be read by the frontend driver) will update
+the backend state node to 2 (XenbusStateInitWait). From this point on PV
+protocols differ slightly; the following illustration is true of the netif
+protocol.
+Upon seeing a backend state value of 2, the frontend driver will then read the
+protocol specific information, write details of grant references (for shared
+pages) and event channel ports (for signalling) that it has created, and set
+the state node in the frontend area to 4 (XenbusStateConnected). Upon see this
+frontend state, the backend driver will then read the grant references (mapping
+the shared pages) and event channel ports (opening its end of them) and set the
+state node in the backend area to 4. Protocol establishment is now complete and
+the frontend and backend start to pass data.
+
+Because the domid of both ends of a PV protocol forms a key part of negotiating
+the data plane for that protocol (because it is encoded into both xenstore
+nodes and node paths), and because guest’s own domid and the domid of the
+service domain are visible to the guest in xenstore (and hence may cached
+internally), and neither are necessarily preserved during migration, it is
+hence necessary to have the co-operation of the frontend in re-negotiating the
+protocol using the new domid after migration.
+Moreover the backend-id value will be used by the frontend driver in setting up
+grant table entries and event channels to communicate with the service domain,
+so the co-operation of the guest is required to re-establish these in the new
+host environment after migration.
+
+Thus if we are to change the model and support migration of a guest with PV
+drivers, without the co-operation of the frontend driver code, the paths and
+values in both the frontend and backend xenstore areas must remain unchanged
+and valid in the new host environment, and the grant table entries and event
+channels must be preserved (and remain operational once guest execution is
+resumed).
+Because the service domain’s domid is used directly by the guest in setting
+up grant entries and event channels, the backend drivers in the new host
+environment must be provided by service domain with the same domid. Also,
+because the guest can sample its own domid from the frontend area and use it in
+hypercalls (e.g. HVMOP_set_param) rather than DOMID_SELF, the guest domid must
+also be preserved to maintain the ABI.
+
+Furthermore, it will necessary to modify backend drivers to re-establish
+communication with frontend drivers without perturbing the content of the
+backend area or requiring any changes to the values of the xenstore state nodes.
+
+## Other Para-Virtual State
+
+### Shared Rings
+
+Because the console and store protocol shared pages are actually part of the
+guest memory image (in an E820 reserved region just below 4G) then the content
+will get migrated as part of the guest memory image. Hence no additional code
+is require to prevent any guest visible change in the content.
+
+### Shared Info
+
+There is already a record defined in *LibXenCtrl Domain Image Format* [3]
+called `SHARED_INFO` which simply contains a complete copy of the domain’s
+shared info page. It is not currently incuded in an HVM (type `0x0002`)
+migration stream. It may be feasible to include it as an optional record
+but it is not clear that the content of the shared info page ever needs
+to be preserved for an HVM guest.
+For a PV guest the `arch_shared_info` sub-structure contains important
+information about the guest’s P2M, but this information is not relevant for
+an HVM guest where the P2M is not directly manipulated via the guest. The other
+state contained in the `shared_info` structure relates the domain wall-clock
+(the state of which should already be transferred by the `RTC` HVM context
+information which contained in the `HVM_CONTEXT` save record) and some event
+channel state (particularly if using the *2l* protocol). Event channel state
+will need to be fully transferred if we are not going to require the guest
+co-operation to re-open the channels and so it should be possible to re-build a
+shared info page for an HVM guest from such other state.
+Note that the shared info page also contains an array of `XEN_LEGACY_MAX_VCPUS`
+(32) `vcpu_info` structures. A domain may nominate a different guest physical
+address to use for the vcpu info. This is mandatory for if a domain wants to
+use more than 32 vCPUs and optional for legacy vCPUs. This mapping is not
+currently transferred in the migration state so this will either need to be
+added into an existing save record, or an additional type of save record will
+be needed.
+
+### Xenstore Watches
+
+As mentioned above, no domain Xenstore state is currently transferred in the
+migration stream. There is a record defined in *LibXenLight Domain Image
+Format* [4] called `EMULATOR_XENSTORE_DATA` for transferring Xenstore nodes
+relating to emulators but no record type is defined for nodes relating to the
+domain itself, nor for registered *watches*. A XenStore watch is a mechanism
+used by PV frontend and backend drivers to request a notification if the value
+of a particular node (e.g. the other end’s state node) changes, so it is
+important that watches continue to function after a migration. One or more new
+save records will therefore be required to transfer Xenstore state. It will
+also be necessary to extend the *store* protocol[5] with mechanisms to allow
+the toolstack to acquire the list of watches that the guest has registered and
+for the toolstack to register a watch on behalf of a domain.
+
+### Event channels
+
+Event channels are essentially the para-virtual equivalent of interrupts. They
+are an important part of post PV protocols. Normally a frontend driver creates
+an *inter-domain* event channel between its own domain and the domain running
+the backend, which it discovers using the `backend-id` node in Xenstore (see
+above), by making a `EVTCHNOP_alloc_unbound` hypercall. This hypercall
+allocates an event channel object in the hypervisor and assigns a *local port*
+number which is then written into the frontend area in Xenstore. The backend
+driver then reads this port number and *binds* to the event channel by
+specifying it, and the value of `frontend-id`, as *remote domain* and *remote
+port* (respectively) to a `EVTCHNOP_bind_interdomain` hypercall. Once
+connection is established in this fashion frontend and backend drivers can use
+the event channel as a *mailbox* to notify each other when a shared ring has
+been updated with new requests or response structures.
+Currently no event channel state is preserved on migration, requiring frontend
+and backend drivers to create and bind a complete new set of event channels in
+order to re-establish a protocol connection. Hence, one or more new save
+records will be required to transfer event channel state in order to avoid the
+need for explicit action by frontend drivers running in the guest. Note that
+the local port numbers need to preserved in this state as they are the only
+context the guest has to refer to the hypervisor event channel objects.
+ Note also that the PV *store* (Xenstore access) and *console* protocols also
+rely on event channels which are set up by the toolstack. Normally, early in
+migration, the toolstack running on the remote host would set up a new pair of
+event channels for these protocols in the destination domain. These may not be
+assigned the same local port numbers as the protocols running in the source
+domain. For non-cooperative migration these channels must either be created with
+fixed port numbers, or their creation must be avoided and instead be included
+in the general event channel state record(s).
+
+### Grant table
+
+The grant table is essentially the para-virtual equivalent of an IOMMU. For
+example, the shared rings of a PV protocol are *granted* by a frontend driver
+to the backend driver by allocating *grant entries* in the guest’s table,
+filling in details of the memory pages and then writing the *grant references*
+(the index values of the grant entries) into Xenstore. The grant references of
+the protocol buffers themselves are typically written directly into the request
+structures passed via a shared ring.
+The guest is responsible for managing its own grant table. No hypercall is
+required to grant a memory page to another domain. It is sufficient to find an
+unused grant entry and set bits in the entry to give read and/or write access
+to a remote domain also specified in the entry along with the page frame
+number. Thus the layout and content of the grant table logically forms part of
+the guest state.
+Currently no grant table state is migrated, requiring a guest to separately
+maintain any state that it wishes to persist elsewhere in its memory image and
+then restore it after migration. Thus to avoid the need for such explicit
+action by the guest, one or more new save records will be required to migrate
+the contents of the grant table.
+
+# Outline Proposal
+
+* PV backend drivers will be modified to unilaterally re-establish connection
+to a frontend if the backend state node is restored with value 4
+(XenbusStateConnected)[6].
+* The toolstack should be modified to allow domid to be randomized on initial
+creation or default migration, but make it identical to the source domain on
+non-cooperative migration. Non-Cooperative migration will have to be denied if the
+domid is unavailable on the target host, but randomization of domid on creation
+should hopefully minimize the likelihood of this. Non-Cooperative migration to
+localhost will clearly not be possible. Patches have already been sent to
+`xen-devel` to make this change[7].
+* `xenstored` should be modified to implement the new mechanisms needed. See
+*Other Para-Virtual State* above. A further design document will propose
+additional protocol messages.
+* Within the migration stream extra save records will be defined as required.
+See *Other Para-Virtual State* above. A further design document will propose
+modifications to the LibXenLight and LibXenCtrl Domain Image Formats.
+* An option should be added to the toolstack to initiate a non-cooperative
+migration, instead of the (default) potentially co-operative migration.
+Essentially this should skip the check to see if PV drivers and migrate as if
+there are none present, but also enabling the extra save records. Note that at
+least some of the extra records should only form part of a non-cooperative
+migration stream. For example, migrating event channel state would be counter
+productive in a normal migration as this will essentially leak event channel
+objects at the receiving end. Others, such as grant table state, could
+potentially harmlessly form part of a normal migration stream.
+
+* * *
+[1] PV drivers are deemed to be installed if the HVM parameter
+*HVM_PARAM_CALLBACK_IRQ* has been set to a non-zero value.
+
+[2] See https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=xen/include/public/io/xenbus.h
+
+[3] See https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=docs/specs/libxc-migration-stream.pandoc
+
+[4] See https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=docs/specs/libxl-migration-stream.pandoc
+
+[5] See https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=docs/misc/xenstore.txt
+
+[6] `xen-blkback` and `xen-netback` have already been modified in Linux to do
+this.
+
+[7] See https://lists.xenproject.org/archives/html/xen-devel/2020-01/msg00632.html
+
Signature · 7 lines
2.20.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#2 lore raw

Re: [Xen-devel] [PATCH v3 1/2] docs/designs: Add a design document for non-cooperative live migration

Thanks for writing this up. I skimmed through it. It looks sensible.

Quoted 40 lines · Paul Durrant

It has become apparent to some large cloud providers that the current model of cooperative migration of guests under Xen is not usable as it relies on software running inside the guest, which is likely beyond the provider's control.
This patch introduces a proposal for non-cooperative live migration, designed not to rely on any guest-side software.

---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Wei Liu <[email protected]>

v2:
- Use the term 'non-cooperative' instead of 'transparent'
- Replace 'trust in' with 'reliance on' when referring to guest-side software

---
 docs/designs/non-cooperative-migration.md | 259 ++++++++++++++++++++++
 1 file changed, 259 insertions(+)
 create mode 100644 docs/designs/non-cooperative-migration.md
docs/designs/non-cooperative-migration.md new file +7 -0
new file mode 100644
index 0000000000..f38d664c34
@@ -0,0 +1,259 @@
+# Non-Cooperative Migration of Guests on Xen
+
+## Background
+
+The normal model of migration in Xen is driven by the guest because it was
+originally implemented for PV guests, where the guest must be aware it is
+running under Xen and is hence expected to co-operate. This model dates from

docs/designs/non-cooperative-migration.md line 17

Quoted 10 lines
docs/designs/non-cooperative-migration.md new file +10 -0
+an era when it was assumed that the host administrator had control of at least
+the privileged software running in the guest (i.e. the guest kernel) which may
+still be true in an enterprise deployment but is not generally true in a cloud
+environment. The aim of this design is to provide a model which is purely host
+driven, requiring no co-operation from the software running in the
+guest, and is thus suitable for cloud scenarios.
+
+PV guests are out of scope for this project because, as is outlined above, they
+have a symbiotic relationship with the hypervisor and therefore a certain level
+of co-operation can be assumed.

Missing newline here?

docs/designs/non-cooperative-migration.md line 28

Quoted 11 lines
docs/designs/non-cooperative-migration.md new file +11 -0
+HVM guests can already be migrated on Xen without guest co-operation but only
+if they don’t have PV drivers installed[1] or are in power state S3. The
+reason for not expecting co-operation if the guest is in S3 is obvious, but the
+reason co-operation is expected if PV drivers are installed is due to the
+nature of PV protocols.
+
+## Xenstore Nodes and Domain ID
+
+The PV driver model consists of a *frontend* and a *backend*. The frontend runs
+inside the guest domain and the backend runs inside a *service domain* which
+may or may not domain 0. The frontend and backend typically pass data via

"may or may not _be_ domain 0"

docs/designs/non-cooperative-migration.md line 36

Quoted 8 lines
docs/designs/non-cooperative-migration.md new file +8 -0
+memory pages which are shared between the two domains, but this channel of
+communication is generally established using xenstore (the store protocol
+itself being an exception to this for obvious chicken-and-egg reasons).
+
+Typical protocol establishment is based on use of two separate xenstore
+*areas*. If we consider PV drivers for the *netif* protocol (i.e. class vif)
+and assume the guest has domid X, the service domain has domid Y, and the vif
+has index Z then the frontend area will reside under the parent node:

The term "parent" shows up first time in this document. What does it mean in Xen's context?

Quoted 28 lines
docs/designs/non-cooperative-migration.md new file +28 -0
+
+`/local/domain/Y/device/vif/Z`
+
+All backends, by convention, typically reside under parent node:
+
+`/local/domain/X/backend`
+
+and the normal backend area for vif Z would be:
+
+`/local/domain/X/backend/vif/Y/Z`
+
+but this should not be assumed.
+
+The toolstack will place two nodes in the frontend area to explicitly locate
+the backend:
+
+    * `backend`: the fully qualified xenstore path of the backend area
+    * `backend-id`: the domid of the service domain
+
+and similarly two nodes in the backend area to locate the frontend area:
+
+    * `frontend`: the fully qualified xenstore path of the frontend area
+    * `frontend-id`: the domid of the guest domain
+
+
+The guest domain only has write permission to the frontend area and similarly
+the service domain only has write permission to the backend area, but both ends
+have read permission to both areas.

docs/designs/non-cooperative-migration.md line 74

Quoted 10 lines
docs/designs/non-cooperative-migration.md new file +10 -0
+
+Under both frontend and backend areas is a node called *state*. This is key to
+protocol establishment. Upon PV device creation the toolstack will set the
+value of both state nodes to 1 (XenbusStateInitialising[2]). This should cause
+enumeration of appropriate devices in both the guest and service domains. The
+backend device, once it has written any necessary protocol specific information
+into the xenstore backend area (to be read by the frontend driver) will update
+the backend state node to 2 (XenbusStateInitWait). From this point on PV
+protocols differ slightly; the following illustration is true of the netif
+protocol.

Missing newline?

Quoted 6 lines
docs/designs/non-cooperative-migration.md new file +6 -0
+Upon seeing a backend state value of 2, the frontend driver will then read the
+protocol specific information, write details of grant references (for shared
+pages) and event channel ports (for signalling) that it has created, and set
+the state node in the frontend area to 4 (XenbusStateConnected). Upon see this
+frontend state, the backend driver will then read the grant references (mapping
+the shared pages) and event channel ports (opening its end of them) and set the

docs/designs/non-cooperative-migration.md line 90

Quoted 10 lines
docs/designs/non-cooperative-migration.md new file +10 -0
+state node in the backend area to 4. Protocol establishment is now complete and
+the frontend and backend start to pass data.
+
+Because the domid of both ends of a PV protocol forms a key part of negotiating
+the data plane for that protocol (because it is encoded into both xenstore
+nodes and node paths), and because guest’s own domid and the domid of the
+service domain are visible to the guest in xenstore (and hence may cached
+internally), and neither are necessarily preserved during migration, it is
+hence necessary to have the co-operation of the frontend in re-negotiating the
+protocol using the new domid after migration.

Add newline here?

docs/designs/non-cooperative-migration.md line 101

Quoted 11 lines
docs/designs/non-cooperative-migration.md new file +11 -0
+Moreover the backend-id value will be used by the frontend driver in setting up
+grant table entries and event channels to communicate with the service domain,
+so the co-operation of the guest is required to re-establish these in the new
+host environment after migration.
+
+Thus if we are to change the model and support migration of a guest with PV
+drivers, without the co-operation of the frontend driver code, the paths and
+values in both the frontend and backend xenstore areas must remain unchanged
+and valid in the new host environment, and the grant table entries and event
+channels must be preserved (and remain operational once guest execution is
+resumed).

Add newline here?

Quoted 13 lines
docs/designs/non-cooperative-migration.md new file +13 -0
+Because the service domain’s domid is used directly by the guest in setting
+up grant entries and event channels, the backend drivers in the new host
+environment must be provided by service domain with the same domid. Also,
+because the guest can sample its own domid from the frontend area and use it in
+hypercalls (e.g. HVMOP_set_param) rather than DOMID_SELF, the guest domid must
+also be preserved to maintain the ABI.
+
+Furthermore, it will necessary to modify backend drivers to re-establish
+communication with frontend drivers without perturbing the content of the
+backend area or requiring any changes to the values of the xenstore state nodes.
+
+## Other Para-Virtual State
+

docs/designs/non-cooperative-migration.md line 124

Quoted 10 lines
docs/designs/non-cooperative-migration.md new file +10 -0
+### Shared Rings
+
+Because the console and store protocol shared pages are actually part of the
+guest memory image (in an E820 reserved region just below 4G) then the content
+will get migrated as part of the guest memory image. Hence no additional code
+is require to prevent any guest visible change in the content.
+
+### Shared Info
+
+There is already a record defined in *LibXenCtrl Domain Image Format* [3]

LibXenCtrl -> libxenctrl

docs/designs/non-cooperative-migration.md line 129

Quoted 5 lines
docs/designs/non-cooperative-migration.md new file +5 -0
+called `SHARED_INFO` which simply contains a complete copy of the domain’s
+shared info page. It is not currently incuded in an HVM (type `0x0002`)
+migration stream. It may be feasible to include it as an optional record
+but it is not clear that the content of the shared info page ever needs
+to be preserved for an HVM guest.

Add newline?

docs/designs/non-cooperative-migration.md line 139

Quoted 10 lines
docs/designs/non-cooperative-migration.md new file +10 -0
+For a PV guest the `arch_shared_info` sub-structure contains important
+information about the guest’s P2M, but this information is not relevant for
+an HVM guest where the P2M is not directly manipulated via the guest. The other
+state contained in the `shared_info` structure relates the domain wall-clock
+(the state of which should already be transferred by the `RTC` HVM context
+information which contained in the `HVM_CONTEXT` save record) and some event
+channel state (particularly if using the *2l* protocol). Event channel state
+will need to be fully transferred if we are not going to require the guest
+co-operation to re-open the channels and so it should be possible to re-build a
+shared info page for an HVM guest from such other state.

Add newline here?

docs/designs/non-cooperative-migration.md line 151

Quoted 12 lines
docs/designs/non-cooperative-migration.md new file +12 -0
+Note that the shared info page also contains an array of `XEN_LEGACY_MAX_VCPUS`
+(32) `vcpu_info` structures. A domain may nominate a different guest physical
+address to use for the vcpu info. This is mandatory for if a domain wants to
+use more than 32 vCPUs and optional for legacy vCPUs. This mapping is not
+currently transferred in the migration state so this will either need to be
+added into an existing save record, or an additional type of save record will
+be needed.
+
+### Xenstore Watches
+
+As mentioned above, no domain Xenstore state is currently transferred in the
+migration stream. There is a record defined in *LibXenLight Domain Image

LibXenLight -> libxenlight

Quoted 16 lines
docs/designs/non-cooperative-migration.md new file +16 -0
+Format* [4] called `EMULATOR_XENSTORE_DATA` for transferring Xenstore nodes
+relating to emulators but no record type is defined for nodes relating to the
+domain itself, nor for registered *watches*. A XenStore watch is a mechanism
+used by PV frontend and backend drivers to request a notification if the value
+of a particular node (e.g. the other end’s state node) changes, so it is
+important that watches continue to function after a migration. One or more new
+save records will therefore be required to transfer Xenstore state. It will
+also be necessary to extend the *store* protocol[5] with mechanisms to allow
+the toolstack to acquire the list of watches that the guest has registered and
+for the toolstack to register a watch on behalf of a domain.
+
+### Event channels
+
+Event channels are essentially the para-virtual equivalent of interrupts. They
+are an important part of post PV protocols. Normally a frontend driver creates
+an *inter-domain* event channel between its own domain and the domain running

docs/designs/non-cooperative-migration.md line 177

Quoted 10 lines
docs/designs/non-cooperative-migration.md new file +10 -0
+the backend, which it discovers using the `backend-id` node in Xenstore (see
+above), by making a `EVTCHNOP_alloc_unbound` hypercall. This hypercall
+allocates an event channel object in the hypervisor and assigns a *local port*
+number which is then written into the frontend area in Xenstore. The backend
+driver then reads this port number and *binds* to the event channel by
+specifying it, and the value of `frontend-id`, as *remote domain* and *remote
+port* (respectively) to a `EVTCHNOP_bind_interdomain` hypercall. Once
+connection is established in this fashion frontend and backend drivers can use
+the event channel as a *mailbox* to notify each other when a shared ring has
+been updated with new requests or response structures.

Missing newline here.

Quoted 15 lines
docs/designs/non-cooperative-migration.md new file +15 -0
+Currently no event channel state is preserved on migration, requiring frontend
+and backend drivers to create and bind a complete new set of event channels in
+order to re-establish a protocol connection. Hence, one or more new save
+records will be required to transfer event channel state in order to avoid the
+need for explicit action by frontend drivers running in the guest. Note that
+the local port numbers need to preserved in this state as they are the only
+context the guest has to refer to the hypervisor event channel objects.
+ Note also that the PV *store* (Xenstore access) and *console* protocols also
+rely on event channels which are set up by the toolstack. Normally, early in
+migration, the toolstack running on the remote host would set up a new pair of
+event channels for these protocols in the destination domain. These may not be
+assigned the same local port numbers as the protocols running in the source
+domain. For non-cooperative migration these channels must either be created with
+fixed port numbers, or their creation must be avoided and instead be included
+in the general event channel state record(s).

docs/designs/non-cooperative-migration.md line 202

Quoted 10 lines
docs/designs/non-cooperative-migration.md new file +10 -0
+
+### Grant table
+
+The grant table is essentially the para-virtual equivalent of an IOMMU. For
+example, the shared rings of a PV protocol are *granted* by a frontend driver
+to the backend driver by allocating *grant entries* in the guest’s table,
+filling in details of the memory pages and then writing the *grant references*
+(the index values of the grant entries) into Xenstore. The grant references of
+the protocol buffers themselves are typically written directly into the request
+structures passed via a shared ring.

Missing newline.

docs/designs/non-cooperative-migration.md line 208

Quoted 6 lines
docs/designs/non-cooperative-migration.md new file +6 -0
+The guest is responsible for managing its own grant table. No hypercall is
+required to grant a memory page to another domain. It is sufficient to find an
+unused grant entry and set bits in the entry to give read and/or write access
+to a remote domain also specified in the entry along with the page frame
+number. Thus the layout and content of the grant table logically forms part of
+the guest state.

Missing newline.

docs/designs/non-cooperative-migration.md line 219

Quoted 11 lines
docs/designs/non-cooperative-migration.md new file +11 -0
+Currently no grant table state is migrated, requiring a guest to separately
+maintain any state that it wishes to persist elsewhere in its memory image and
+then restore it after migration. Thus to avoid the need for such explicit
+action by the guest, one or more new save records will be required to migrate
+the contents of the grant table.
+
+# Outline Proposal
+
+* PV backend drivers will be modified to unilaterally re-establish connection
+to a frontend if the backend state node is restored with value 4
+(XenbusStateConnected)[6].

Missing newline.

docs/designs/non-cooperative-migration.md line 232

Quoted 13 lines
docs/designs/non-cooperative-migration.md new file +13 -0
+* The toolstack should be modified to allow domid to be randomized on initial
+creation or default migration, but make it identical to the source domain on
+non-cooperative migration. Non-Cooperative migration will have to be denied if the
+domid is unavailable on the target host, but randomization of domid on creation
+should hopefully minimize the likelihood of this. Non-Cooperative migration to
+localhost will clearly not be possible. Patches have already been sent to
+`xen-devel` to make this change[7].
+* `xenstored` should be modified to implement the new mechanisms needed. See
+*Other Para-Virtual State* above. A further design document will propose
+additional protocol messages.
+* Within the migration stream extra save records will be defined as required.
+See *Other Para-Virtual State* above. A further design document will propose
+modifications to the LibXenLight and LibXenCtrl Domain Image Formats.

LibXenLight and LibXenCtrl should be fixed.

docs/designs/non-cooperative-migration.md line 245

Quoted 13 lines
docs/designs/non-cooperative-migration.md new file +13 -0
+* An option should be added to the toolstack to initiate a non-cooperative
+migration, instead of the (default) potentially co-operative migration.
+Essentially this should skip the check to see if PV drivers and migrate as if
+there are none present, but also enabling the extra save records. Note that at
+least some of the extra records should only form part of a non-cooperative
+migration stream. For example, migrating event channel state would be counter
+productive in a normal migration as this will essentially leak event channel
+objects at the receiving end. Others, such as grant table state, could
+potentially harmlessly form part of a normal migration stream.
+
+* * *
+[1] PV drivers are deemed to be installed if the HVM parameter
+*HVM_PARAM_CALLBACK_IRQ* has been set to a non-zero value.

I think this is just an approximation, but it should be good enough in practice.

Quoted 17 lines
docs/designs/non-cooperative-migration.md new file +14 -0
+
+[2] See https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=xen/include/public/io/xenbus.h
+
+[3] See https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=docs/specs/libxc-migration-stream.pandoc
+
+[4] See https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=docs/specs/libxl-migration-stream.pandoc
+
+[5] See https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=docs/misc/xenstore.txt
+
+[6] `xen-blkback` and `xen-netback` have already been modified in Linux to do
+this.
+
+[7] See https://lists.xenproject.org/archives/html/xen-devel/2020-01/msg00632.html
+
Signature · 1 line
2.20.1

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw

Re: [Xen-devel] [PATCH v3 1/2] docs/designs: Add a design document for non-cooperative live migration

Quoted 73 lines

-----Original Message-----
From: Wei Liu <[email protected]>
Sent: 28 January 2020 13:41
To: Durrant, Paul <[email protected]>
Cc: [email protected]; Andrew Cooper <[email protected]>; George Dunlap <[email protected]>; Ian Jackson <[email protected]>; Jan Beulich <[email protected]>; Julien Grall <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Stefano Stabellini <[email protected]>; Wei Liu <[email protected]>
Subject: Re: [PATCH v3 1/2] docs/designs: Add a design document for non- cooperative live migration

Thanks for writing this up. I skimmed through it. It looks sensible.

Quoted 22 lines · Paul Durrant

It has become apparent to some large cloud providers that the current model of cooperative migration of guests under Xen is not usable as it relies on software running inside the guest, which is likely beyond the provider's control.
This patch introduces a proposal for non-cooperative live migration, designed not to rely on any guest-side software.

---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Wei Liu <[email protected]>

v2:
- Use the term 'non-cooperative' instead of 'transparent'
- Replace 'trust in' with 'reliance on' when referring to guest-side software

Review

Quoted 6 lines
---
 docs/designs/non-cooperative-migration.md | 259 ++++++++++++++++++++++
 1 file changed, 259 insertions(+)
 create mode 100644 docs/designs/non-cooperative-migration.md
(quoted diff) +0 -0

b/docs/designs/non-cooperative-migration.md

docs/designs/non-cooperative-migration.md line 5

Quoted 10 lines

new file mode 100644
index 0000000000..f38d664c34

docs/designs/non-cooperative-migration.md new file +5 -0
@@ -0,0 +1,259 @@
+# Non-Cooperative Migration of Guests on Xen
+
+## Background
+
+The normal model of migration in Xen is driven by the guest because it

was

docs/designs/non-cooperative-migration.md line 6

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+originally implemented for PV guests, where the guest must be aware it

is

docs/designs/non-cooperative-migration.md line 7

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+running under Xen and is hence expected to co-operate. This model dates

from

docs/designs/non-cooperative-migration.md line 8

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+an era when it was assumed that the host administrator had control of

at least

docs/designs/non-cooperative-migration.md line 9

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+the privileged software running in the guest (i.e. the guest kernel)

which may

docs/designs/non-cooperative-migration.md line 10

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+still be true in an enterprise deployment but is not generally true in

a cloud

docs/designs/non-cooperative-migration.md line 11

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+environment. The aim of this design is to provide a model which is

purely host

docs/designs/non-cooperative-migration.md

Quoted 4 lines
docs/designs/non-cooperative-migration.md new file +4 -0
+driven, requiring no co-operation from the software running in the
+guest, and is thus suitable for cloud scenarios.
+
+PV guests are out of scope for this project because, as is outlined

above, they

Quoted 6 lines

docs/designs/non-cooperative-migration.md line 16

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+have a symbiotic relationship with the hypervisor and therefore a

certain level

docs/designs/non-cooperative-migration.md line 17

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+of co-operation can be assumed.

Missing newline here?

Yep.

Quoted 14 lines

docs/designs/non-cooperative-migration.md line 18

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+HVM guests can already be migrated on Xen without guest co-operation

but only

docs/designs/non-cooperative-migration.md line 19

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+if they don’t have PV drivers installed[1] or are in power state S3.

The

docs/designs/non-cooperative-migration.md line 20

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+reason for not expecting co-operation if the guest is in S3 is obvious,

but the

docs/designs/non-cooperative-migration.md line 21

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+reason co-operation is expected if PV drivers are installed is due to

the

docs/designs/non-cooperative-migration.md

Quoted 5 lines
docs/designs/non-cooperative-migration.md new file +5 -0
+nature of PV protocols.
+
+## Xenstore Nodes and Domain ID
+
+The PV driver model consists of a *frontend* and a *backend*. The

frontend runs

Quoted 7 lines

docs/designs/non-cooperative-migration.md line 27

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+inside the guest domain and the backend runs inside a *service domain*

which

docs/designs/non-cooperative-migration.md line 28

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+may or may not domain 0. The frontend and backend typically pass data

via

"may or may not _be_ domain 0"

Ack.

Quoted 9 lines

docs/designs/non-cooperative-migration.md line 29

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+memory pages which are shared between the two domains, but this channel

of

docs/designs/non-cooperative-migration.md line 30

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+communication is generally established using xenstore (the store

protocol

docs/designs/non-cooperative-migration.md

Quoted 4 lines
docs/designs/non-cooperative-migration.md new file +4 -0
+itself being an exception to this for obvious chicken-and-egg reasons).
+
+Typical protocol establishment is based on use of two separate xenstore
+*areas*. If we consider PV drivers for the *netif* protocol (i.e. class

vif)

Quoted 7 lines

docs/designs/non-cooperative-migration.md line 35

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+and assume the guest has domid X, the service domain has domid Y, and

the vif

docs/designs/non-cooperative-migration.md line 36

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+has index Z then the frontend area will reside under the parent node:

The term "parent" shows up first time in this document. What does it mean in Xen's context?

I'd hope it's well known that xenstore is hierarchical. I can add a short explanation if you think it’s needed.

Quoted 45 lines
Quoted 4 lines
docs/designs/non-cooperative-migration.md new file +4 -0
+
+`/local/domain/Y/device/vif/Z`
+
+All backends, by convention, typically reside under parent node:

docs/designs/non-cooperative-migration.md

Quoted 10 lines
docs/designs/non-cooperative-migration.md new file +10 -0
+
+`/local/domain/X/backend`
+
+and the normal backend area for vif Z would be:
+
+`/local/domain/X/backend/vif/Y/Z`
+
+but this should not be assumed.
+
+The toolstack will place two nodes in the frontend area to explicitly

locate

docs/designs/non-cooperative-migration.md

Quoted 6 lines
docs/designs/non-cooperative-migration.md new file +6 -0
+the backend:
+
+    * `backend`: the fully qualified xenstore path of the backend area
+    * `backend-id`: the domid of the service domain
+
+and similarly two nodes in the backend area to locate the frontend

area:

docs/designs/non-cooperative-migration.md line 58

Quoted 2 lines
docs/designs/non-cooperative-migration.md new file +2 -0
+
+    * `frontend`: the fully qualified xenstore path of the frontend

area

docs/designs/non-cooperative-migration.md

Quoted 4 lines
docs/designs/non-cooperative-migration.md new file +4 -0
+    * `frontend-id`: the domid of the guest domain
+
+
+The guest domain only has write permission to the frontend area and

similarly

docs/designs/non-cooperative-migration.md line 63

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+the service domain only has write permission to the backend area, but

both ends

docs/designs/non-cooperative-migration.md

Quoted 3 lines
docs/designs/non-cooperative-migration.md new file +3 -0
+have read permission to both areas.
+
+Under both frontend and backend areas is a node called *state*. This is

key to

docs/designs/non-cooperative-migration.md line 67

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+protocol establishment. Upon PV device creation the toolstack will set

the

docs/designs/non-cooperative-migration.md line 68

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+value of both state nodes to 1 (XenbusStateInitialising[2]). This

should cause

docs/designs/non-cooperative-migration.md line 69

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+enumeration of appropriate devices in both the guest and service

domains. The

docs/designs/non-cooperative-migration.md line 70

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+backend device, once it has written any necessary protocol specific

information

docs/designs/non-cooperative-migration.md line 71

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+into the xenstore backend area (to be read by the frontend driver) will
Quoted 9 lines

update

docs/designs/non-cooperative-migration.md line 72

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+the backend state node to 2 (XenbusStateInitWait). From this point on

PV

docs/designs/non-cooperative-migration.md line 73

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+protocols differ slightly; the following illustration is true of the

netif

docs/designs/non-cooperative-migration.md line 74

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+protocol.

Missing newline?

Yes. I'll fix all the paragraph breaks.

Quoted 23 lines

docs/designs/non-cooperative-migration.md line 75

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+Upon seeing a backend state value of 2, the frontend driver will then

read the

docs/designs/non-cooperative-migration.md line 76

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+protocol specific information, write details of grant references (for

shared

docs/designs/non-cooperative-migration.md line 77

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+pages) and event channel ports (for signalling) that it has created,

and set

docs/designs/non-cooperative-migration.md line 78

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+the state node in the frontend area to 4 (XenbusStateConnected). Upon

see this

docs/designs/non-cooperative-migration.md line 79

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+frontend state, the backend driver will then read the grant references

(mapping

docs/designs/non-cooperative-migration.md line 80

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+the shared pages) and event channel ports (opening its end of them) and

set the

docs/designs/non-cooperative-migration.md line 81

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+state node in the backend area to 4. Protocol establishment is now

complete and

docs/designs/non-cooperative-migration.md

Quoted 3 lines
docs/designs/non-cooperative-migration.md new file +3 -0
+the frontend and backend start to pass data.
+
+Because the domid of both ends of a PV protocol forms a key part of

negotiating

docs/designs/non-cooperative-migration.md line 85

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+the data plane for that protocol (because it is encoded into both

xenstore

docs/designs/non-cooperative-migration.md line 86

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+nodes and node paths), and because guest’s own domid and the domid of

the

docs/designs/non-cooperative-migration.md line 87

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+service domain are visible to the guest in xenstore (and hence may
Quoted 9 lines

cached

docs/designs/non-cooperative-migration.md line 88

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+internally), and neither are necessarily preserved during migration, it

is

docs/designs/non-cooperative-migration.md line 89

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+hence necessary to have the co-operation of the frontend in re-

negotiating the

docs/designs/non-cooperative-migration.md line 90

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+protocol using the new domid after migration.

Add newline here?

Yeah... looks like the tool I exported from is a bit buggy.

Quoted 51 lines

docs/designs/non-cooperative-migration.md line 91

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+Moreover the backend-id value will be used by the frontend driver in

setting up

docs/designs/non-cooperative-migration.md line 92

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+grant table entries and event channels to communicate with the service

domain,

docs/designs/non-cooperative-migration.md line 93

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+so the co-operation of the guest is required to re-establish these in

the new

docs/designs/non-cooperative-migration.md

Quoted 3 lines
docs/designs/non-cooperative-migration.md new file +3 -0
+host environment after migration.
+
+Thus if we are to change the model and support migration of a guest

with PV

docs/designs/non-cooperative-migration.md line 97

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+drivers, without the co-operation of the frontend driver code, the

paths and

docs/designs/non-cooperative-migration.md line 98

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+values in both the frontend and backend xenstore areas must remain

unchanged

docs/designs/non-cooperative-migration.md line 99

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+and valid in the new host environment, and the grant table entries and

event

docs/designs/non-cooperative-migration.md line 100

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+channels must be preserved (and remain operational once guest execution

is

docs/designs/non-cooperative-migration.md line 101

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+resumed).

Add newline here?

docs/designs/non-cooperative-migration.md line 102

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+Because the service domain’s domid is used directly by the guest in

setting

docs/designs/non-cooperative-migration.md line 103

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+up grant entries and event channels, the backend drivers in the new

host

docs/designs/non-cooperative-migration.md line 104

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+environment must be provided by service domain with the same domid.

Also,

docs/designs/non-cooperative-migration.md line 105

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+because the guest can sample its own domid from the frontend area and

use it in

docs/designs/non-cooperative-migration.md line 106

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+hypercalls (e.g. HVMOP_set_param) rather than DOMID_SELF, the guest

domid must

docs/designs/non-cooperative-migration.md

Quoted 3 lines
docs/designs/non-cooperative-migration.md new file +3 -0
+also be preserved to maintain the ABI.
+
+Furthermore, it will necessary to modify backend drivers to re-

establish

docs/designs/non-cooperative-migration.md line 110

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+communication with frontend drivers without perturbing the content of

the

docs/designs/non-cooperative-migration.md line 111

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+backend area or requiring any changes to the values of the xenstore

state nodes.

docs/designs/non-cooperative-migration.md

Quoted 6 lines
docs/designs/non-cooperative-migration.md new file +6 -0
+
+## Other Para-Virtual State
+
+### Shared Rings
+
+Because the console and store protocol shared pages are actually part

of the

docs/designs/non-cooperative-migration.md line 118

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+guest memory image (in an E820 reserved region just below 4G) then the

content

docs/designs/non-cooperative-migration.md line 119

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+will get migrated as part of the guest memory image. Hence no

additional code

Quoted 9 lines

docs/designs/non-cooperative-migration.md

Quoted 5 lines
docs/designs/non-cooperative-migration.md new file +5 -0
+is require to prevent any guest visible change in the content.
+
+### Shared Info
+
+There is already a record defined in *LibXenCtrl Domain Image Format*

[3]

LibXenCtrl -> libxenctrl

Now that there's a patch to change it, yes :-)

Quoted 49 lines

docs/designs/non-cooperative-migration.md line 125

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+called `SHARED_INFO` which simply contains a complete copy of the

domain’s

docs/designs/non-cooperative-migration.md line 127

Quoted 2 lines
docs/designs/non-cooperative-migration.md new file +2 -0
+shared info page. It is not currently incuded in an HVM (type `0x0002`)
+migration stream. It may be feasible to include it as an optional

record

docs/designs/non-cooperative-migration.md line 129

Quoted 2 lines
docs/designs/non-cooperative-migration.md new file +2 -0
+but it is not clear that the content of the shared info page ever needs
+to be preserved for an HVM guest.

Add newline?

docs/designs/non-cooperative-migration.md line 131

Quoted 2 lines
docs/designs/non-cooperative-migration.md new file +2 -0
+For a PV guest the `arch_shared_info` sub-structure contains important
+information about the guest’s P2M, but this information is not relevant

for

docs/designs/non-cooperative-migration.md line 132

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+an HVM guest where the P2M is not directly manipulated via the guest.

The other

docs/designs/non-cooperative-migration.md line 133

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+state contained in the `shared_info` structure relates the domain wall-

clock

docs/designs/non-cooperative-migration.md line 134

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+(the state of which should already be transferred by the `RTC` HVM

context

docs/designs/non-cooperative-migration.md line 135

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+information which contained in the `HVM_CONTEXT` save record) and some

event

docs/designs/non-cooperative-migration.md line 136

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+channel state (particularly if using the *2l* protocol). Event channel

state

docs/designs/non-cooperative-migration.md line 137

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+will need to be fully transferred if we are not going to require the

guest

docs/designs/non-cooperative-migration.md line 138

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+co-operation to re-open the channels and so it should be possible to

re-build a

docs/designs/non-cooperative-migration.md line 139

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+shared info page for an HVM guest from such other state.

Add newline here?

docs/designs/non-cooperative-migration.md line 140

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+Note that the shared info page also contains an array of

XEN_LEGACY_MAX_VCPUS

docs/designs/non-cooperative-migration.md line 141

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+(32) `vcpu_info` structures. A domain may nominate a different guest

physical

docs/designs/non-cooperative-migration.md line 142

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+address to use for the vcpu info. This is mandatory for if a domain

wants to

docs/designs/non-cooperative-migration.md line 143

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+use more than 32 vCPUs and optional for legacy vCPUs. This mapping is

not

docs/designs/non-cooperative-migration.md line 144

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+currently transferred in the migration state so this will either need

to be

docs/designs/non-cooperative-migration.md line 145

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+added into an existing save record, or an additional type of save

record will

docs/designs/non-cooperative-migration.md

Quoted 5 lines
docs/designs/non-cooperative-migration.md new file +5 -0
+be needed.
+
+### Xenstore Watches
+
+As mentioned above, no domain Xenstore state is currently transferred

in the

Quoted 5 lines

docs/designs/non-cooperative-migration.md line 151

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+migration stream. There is a record defined in *LibXenLight Domain

Image

LibXenLight -> libxenlight

Same here.

Quoted 144 lines

docs/designs/non-cooperative-migration.md line 152

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+Format* [4] called `EMULATOR_XENSTORE_DATA` for transferring Xenstore

nodes

docs/designs/non-cooperative-migration.md line 153

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+relating to emulators but no record type is defined for nodes relating

to the

docs/designs/non-cooperative-migration.md line 154

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+domain itself, nor for registered *watches*. A XenStore watch is a

mechanism

docs/designs/non-cooperative-migration.md line 155

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+used by PV frontend and backend drivers to request a notification if

the value

docs/designs/non-cooperative-migration.md line 156

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+of a particular node (e.g. the other end’s state node) changes, so it

is

docs/designs/non-cooperative-migration.md line 157

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+important that watches continue to function after a migration. One or

more new

docs/designs/non-cooperative-migration.md line 158

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+save records will therefore be required to transfer Xenstore state. It

will

docs/designs/non-cooperative-migration.md line 159

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+also be necessary to extend the *store* protocol[5] with mechanisms to

allow

docs/designs/non-cooperative-migration.md line 160

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+the toolstack to acquire the list of watches that the guest has

registered and

docs/designs/non-cooperative-migration.md

Quoted 5 lines
docs/designs/non-cooperative-migration.md new file +5 -0
+for the toolstack to register a watch on behalf of a domain.
+
+### Event channels
+
+Event channels are essentially the para-virtual equivalent of

interrupts. They

docs/designs/non-cooperative-migration.md line 166

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+are an important part of post PV protocols. Normally a frontend driver

creates

docs/designs/non-cooperative-migration.md line 167

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+an *inter-domain* event channel between its own domain and the domain

running

docs/designs/non-cooperative-migration.md line 168

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+the backend, which it discovers using the `backend-id` node in Xenstore

(see

docs/designs/non-cooperative-migration.md line 170

Quoted 2 lines
docs/designs/non-cooperative-migration.md new file +2 -0
+above), by making a `EVTCHNOP_alloc_unbound` hypercall. This hypercall
+allocates an event channel object in the hypervisor and assigns a

*local port*

docs/designs/non-cooperative-migration.md line 171

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+number which is then written into the frontend area in Xenstore. The

backend

docs/designs/non-cooperative-migration.md line 173

Quoted 2 lines
docs/designs/non-cooperative-migration.md new file +2 -0
+driver then reads this port number and *binds* to the event channel by
+specifying it, and the value of `frontend-id`, as *remote domain* and

*remote

docs/designs/non-cooperative-migration.md line 175

Quoted 2 lines
docs/designs/non-cooperative-migration.md new file +2 -0
+port* (respectively) to a `EVTCHNOP_bind_interdomain` hypercall. Once
+connection is established in this fashion frontend and backend drivers

can use

docs/designs/non-cooperative-migration.md line 176

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+the event channel as a *mailbox* to notify each other when a shared

ring has

docs/designs/non-cooperative-migration.md line 177

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+been updated with new requests or response structures.

Missing newline here.

docs/designs/non-cooperative-migration.md line 178

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+Currently no event channel state is preserved on migration, requiring

frontend

docs/designs/non-cooperative-migration.md line 179

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+and backend drivers to create and bind a complete new set of event

channels in

docs/designs/non-cooperative-migration.md line 180

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+order to re-establish a protocol connection. Hence, one or more new

save

docs/designs/non-cooperative-migration.md line 181

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+records will be required to transfer event channel state in order to

avoid the

docs/designs/non-cooperative-migration.md line 182

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+need for explicit action by frontend drivers running in the guest. Note

that

docs/designs/non-cooperative-migration.md line 183

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+the local port numbers need to preserved in this state as they are the

only

docs/designs/non-cooperative-migration.md line 185

Quoted 2 lines
docs/designs/non-cooperative-migration.md new file +2 -0
+context the guest has to refer to the hypervisor event channel objects.
+ Note also that the PV *store* (Xenstore access) and *console*

protocols also

docs/designs/non-cooperative-migration.md line 186

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+rely on event channels which are set up by the toolstack. Normally,

early in

docs/designs/non-cooperative-migration.md line 187

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+migration, the toolstack running on the remote host would set up a new

pair of

docs/designs/non-cooperative-migration.md line 188

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+event channels for these protocols in the destination domain. These may

not be

docs/designs/non-cooperative-migration.md line 189

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+assigned the same local port numbers as the protocols running in the

source

docs/designs/non-cooperative-migration.md line 190

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+domain. For non-cooperative migration these channels must either be

created with

docs/designs/non-cooperative-migration.md line 191

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+fixed port numbers, or their creation must be avoided and instead be

included

docs/designs/non-cooperative-migration.md

Quoted 5 lines
docs/designs/non-cooperative-migration.md new file +5 -0
+in the general event channel state record(s).
+
+### Grant table
+
+The grant table is essentially the para-virtual equivalent of an IOMMU.

For

docs/designs/non-cooperative-migration.md line 197

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+example, the shared rings of a PV protocol are *granted* by a frontend

driver

docs/designs/non-cooperative-migration.md line 198

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+to the backend driver by allocating *grant entries* in the guest’s

table,

docs/designs/non-cooperative-migration.md line 199

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+filling in details of the memory pages and then writing the *grant

references*

docs/designs/non-cooperative-migration.md line 200

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+(the index values of the grant entries) into Xenstore. The grant

references of

docs/designs/non-cooperative-migration.md line 201

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+the protocol buffers themselves are typically written directly into the

request

docs/designs/non-cooperative-migration.md line 202

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+structures passed via a shared ring.

Missing newline.

docs/designs/non-cooperative-migration.md line 203

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+The guest is responsible for managing its own grant table. No hypercall

is

docs/designs/non-cooperative-migration.md line 204

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+required to grant a memory page to another domain. It is sufficient to

find an

docs/designs/non-cooperative-migration.md line 205

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+unused grant entry and set bits in the entry to give read and/or write

access

docs/designs/non-cooperative-migration.md line 206

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+to a remote domain also specified in the entry along with the page

frame

docs/designs/non-cooperative-migration.md line 207

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+number. Thus the layout and content of the grant table logically forms

part of

docs/designs/non-cooperative-migration.md line 208

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+the guest state.

Missing newline.

docs/designs/non-cooperative-migration.md line 209

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+Currently no grant table state is migrated, requiring a guest to

separately

docs/designs/non-cooperative-migration.md line 210

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+maintain any state that it wishes to persist elsewhere in its memory

image and

docs/designs/non-cooperative-migration.md line 211

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+then restore it after migration. Thus to avoid the need for such

explicit

docs/designs/non-cooperative-migration.md line 212

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+action by the guest, one or more new save records will be required to

migrate

docs/designs/non-cooperative-migration.md

Quoted 5 lines
docs/designs/non-cooperative-migration.md new file +5 -0
+the contents of the grant table.
+
+# Outline Proposal
+
+* PV backend drivers will be modified to unilaterally re-establish

connection

docs/designs/non-cooperative-migration.md line 219

Quoted 2 lines
docs/designs/non-cooperative-migration.md new file +2 -0
+to a frontend if the backend state node is restored with value 4
+(XenbusStateConnected)[6].

Missing newline.

docs/designs/non-cooperative-migration.md line 220

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+* The toolstack should be modified to allow domid to be randomized on

initial

docs/designs/non-cooperative-migration.md line 221

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+creation or default migration, but make it identical to the source

domain on

docs/designs/non-cooperative-migration.md line 222

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+non-cooperative migration. Non-Cooperative migration will have to be

denied if the

docs/designs/non-cooperative-migration.md line 223

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+domid is unavailable on the target host, but randomization of domid on

creation

docs/designs/non-cooperative-migration.md line 224

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+should hopefully minimize the likelihood of this. Non-Cooperative

migration to

docs/designs/non-cooperative-migration.md line 225

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+localhost will clearly not be possible. Patches have already been sent

to

docs/designs/non-cooperative-migration.md line 227

Quoted 2 lines
docs/designs/non-cooperative-migration.md new file +2 -0
+`xen-devel` to make this change[7].
+* `xenstored` should be modified to implement the new mechanisms

needed. See

docs/designs/non-cooperative-migration.md line 228

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+*Other Para-Virtual State* above. A further design document will

propose

Quoted 9 lines

docs/designs/non-cooperative-migration.md line 230

Quoted 2 lines
docs/designs/non-cooperative-migration.md new file +2 -0
+additional protocol messages.
+* Within the migration stream extra save records will be defined as

required.

docs/designs/non-cooperative-migration.md line 231

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+See *Other Para-Virtual State* above. A further design document will

propose

docs/designs/non-cooperative-migration.md line 232

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+modifications to the LibXenLight and LibXenCtrl Domain Image Formats.

LibXenLight and LibXenCtrl should be fixed.

Yes.

Quoted 13 lines

docs/designs/non-cooperative-migration.md line 233

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+* An option should be added to the toolstack to initiate a non-

cooperative

docs/designs/non-cooperative-migration.md line 235

Quoted 2 lines
docs/designs/non-cooperative-migration.md new file +2 -0
+migration, instead of the (default) potentially co-operative migration.
+Essentially this should skip the check to see if PV drivers and migrate

as if

docs/designs/non-cooperative-migration.md line 236

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+there are none present, but also enabling the extra save records. Note

that at

docs/designs/non-cooperative-migration.md line 237

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+least some of the extra records should only form part of a non-

cooperative

docs/designs/non-cooperative-migration.md line 238

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+migration stream. For example, migrating event channel state would be

counter

docs/designs/non-cooperative-migration.md line 239

Quoted 1 line
docs/designs/non-cooperative-migration.md new file +1 -0
+productive in a normal migration as this will essentially leak event

channel

Quoted 10 lines

docs/designs/non-cooperative-migration.md line 245

Quoted 6 lines
docs/designs/non-cooperative-migration.md new file +6 -0
+objects at the receiving end. Others, such as grant table state, could
+potentially harmlessly form part of a normal migration stream.
+
+* * *
+[1] PV drivers are deemed to be installed if the HVM parameter
+*HVM_PARAM_CALLBACK_IRQ* has been set to a non-zero value.

I think this is just an approximation, but it should be good enough in practice.

This is just description of the test as it stands. Personally I don't like it because I think the callback via should be killed with fire, but alas it is ABI. However other mechanisms for guests to get events notifications in HVM guests have existed for a while so I wouldn't actually view it as a reliable test. E.g. I can happily avoid registering the callback via in the Windows PV drivers without loss of functionality.

Paul

Quoted 14 lines

docs/designs/non-cooperative-migration.md line 247

Quoted 2 lines
docs/designs/non-cooperative-migration.md new file +2 -0
+
+[2] See

https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=xen/include/public/io/x
enbus.h

docs/designs/non-cooperative-migration.md line 249

Quoted 2 lines
docs/designs/non-cooperative-migration.md new file +2 -0
+
+[3] See

https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=docs/specs/libxc-
migration-stream.pandoc

docs/designs/non-cooperative-migration.md line 251

Quoted 2 lines
docs/designs/non-cooperative-migration.md new file +2 -0
+
+[4] See

https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=docs/specs/libxl-
migration-stream.pandoc

docs/designs/non-cooperative-migration.md line 253

Quoted 2 lines
docs/designs/non-cooperative-migration.md new file +2 -0
+
+[5] See
Quoted 12 lines

https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=docs/misc/xenstore.txt

docs/designs/non-cooperative-migration.md line 255

Quoted 2 lines
docs/designs/non-cooperative-migration.md new file +2 -0
+
+[6] `xen-blkback` and `xen-netback` have already been modified in Linux

to do

docs/designs/non-cooperative-migration.md

Quoted 3 lines
docs/designs/non-cooperative-migration.md new file +3 -0
+this.
+
+[7] See https://lists.xenproject.org/archives/html/xen-devel/2020-

01/msg00632.html

Quoted 4 lines
docs/designs/non-cooperative-migration.md new file +1 -1
+
--

2.20.1

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw

Re: [Xen-devel] [PATCH v3 1/2] docs/designs: Add a design document for non-cooperative live migration

On Tue, Jan 28, 2020 at 03:47:02PM +0000, Durrant, Paul wrote:
[...]

Quoted 14 lines
Quoted 14 lines
Quoted 2 lines

+memory pages which are shared between the two domains, but this channel

of

Quoted 1 line

+communication is generally established using xenstore (the store

protocol

docs/designs/non-cooperative-migration.md

Quoted 4 lines
docs/designs/non-cooperative-migration.md new file +4 -0
+itself being an exception to this for obvious chicken-and-egg reasons).
+
+Typical protocol establishment is based on use of two separate xenstore
+*areas*. If we consider PV drivers for the *netif* protocol (i.e. class

vif)

Quoted 1 line

+and assume the guest has domid X, the service domain has domid Y, and

the vif

Quoted 1 line

+has index Z then the frontend area will reside under the parent node:

Quoted 7 lines
Quoted 3 lines

The term "parent" shows up first time in this document. What does it mean in Xen's context?

I'd hope it's well known that xenstore is hierarchical. I can add a short explanation if you think it’s needed.

I think it is just me -- I have recently been reading Hyper-V's TLFS for far too long, which says "parent partition" everywhere.

It would be good if you say "parent xenstore node" or something, but that's not a must for me. Your clarification here is good enough for me.

[...]

Quoted 11 lines
Quoted 10 lines

docs/designs/non-cooperative-migration.md line 245

Quoted 6 lines
docs/designs/non-cooperative-migration.md new file +6 -0
+objects at the receiving end. Others, such as grant table state, could
+potentially harmlessly form part of a normal migration stream.
+
+* * *
+[1] PV drivers are deemed to be installed if the HVM parameter
+*HVM_PARAM_CALLBACK_IRQ* has been set to a non-zero value.

I think this is just an approximation, but it should be good enough in practice.

Quoted 7 lines

This is just description of the test as it stands. Personally I don't like it because I think the callback via should be killed with fire, but alas it is ABI. However other mechanisms for guests to get events notifications in HVM guests have existed for a while so I wouldn't actually view it as a reliable test. E.g. I can happily avoid registering the callback via in the Windows PV drivers without loss of functionality.

A more sophisticated test would be to actually watch xenstore to see if there is ever any interaction between frontend or backend? That would require more code for sure...

On a related note, the hypervisor callback mechanism has infected other type-1 hypervisors (Hyper-V, ACRN) so it is too late to change anything now...

Wei.

Quoted 29 lines

Paul

Quoted 26 lines
Quoted 2 lines

+
+[2] See

https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=xen/include/public/io/x
enbus.h

Quoted 2 lines

+
+[3] See

https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=docs/specs/libxc-
migration-stream.pandoc

Quoted 2 lines

+
+[4] See

https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=docs/specs/libxl-
migration-stream.pandoc

Quoted 2 lines

+
+[5] See

https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=docs/misc/xenstore.txt

Quoted 2 lines

+
+[6] xen-blkback and xen-netback have already been modified in Linux

to do

docs/designs/non-cooperative-migration.md

Quoted 3 lines
docs/designs/non-cooperative-migration.md new file +3 -0
+this.
+
+[7] See https://lists.xenproject.org/archives/html/xen-devel/2020-

01/msg00632.html

Quoted 4 lines

+
--
2.20.1

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#5 lore raw

PATCH v3 2/2 docs/designs: Add a design document for migration of xenstore data

In reply to Paul Durrant

This patch details proposes extra migration data and xenstore protocol extensions to support non-cooperative live migration of guests.

---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Wei Liu <[email protected]>

v3:
- New in v3

---
 docs/designs/xenstore-migration.md | 122 +++++++++++++++++++++++++++++
 1 file changed, 122 insertions(+)
 create mode 100644 docs/designs/xenstore-migration.md
docs/designs/xenstore-migration.md new file +122 -0
new file mode 100644
index 0000000000..9020b6ff9a
@@ -0,0 +1,122 @@
+# Xenstore Migration
+
+## Background
+
+The design for *Non-Cooperative Migration of Guests*[1] explains that extra
+save records are required in the migrations stream to allow a guest running
+PV drivers to be migrated without its co-operation. Moreover the save
+records must include details of registered xenstore watches as well as
+content; information that cannot currently be recovered from `xenstored`,
+and hence some extension to the xenstore protocol[2] will also be required.
+
+The *libxenlight Domain Image Format* specification[3] already defines a
+record type `EMULATOR_XENSTORE_DATA` but this is not suitable for
+transferring xenstore data pertaining to the domain directly as it is
+specified such that keys are relative to the path
+`/local/domain/$dm_domid/device-model/$domid`. Thus it is necessary to
+define at least one new save record type.
+
+## Proposal
+
+### New Save Record
+
+A new mandatory record type should be defined within the libxenlight Domain
+Image Format:
+
+`0x00000007: DOMAIN_XENSTORE_DATA`
+
+The format of each of these new records should be as follows:
+
+
+```
+0     1     2     3     4     5     6     7 octet
++------------------------+------------------------+
+| type                   | record specific data   |
++------------------------+                        |
+...
++-------------------------------------------------+
+```
+
+
+| Field | Description |
+|---|---|
+| `type` | 0x00000000: invalid |
+|        | 0x00000001: node data |
+|        | 0x00000002: watch data |
+|        | 0x00000003 - 0xFFFFFFFF: reserved for future use |
+
+
+where data is always in the form of a NUL separated and terminated tuple
+as follows
+
+
+**node data**
+
+
+`<path>|<value>|<perm-as-string>|`
+
+
+`<path>` is considered relative to the domain path `/local/domain/$domid`
+and hence must not begin with `/`.
+`<path>` and `<value>` should be suitable to formulate a `WRITE` operation
+to the receiving xenstore and `<perm-as-string>` should be similarly suitable
+to formulate a subsequent `SET_PERMS` operation.
+
+**watch data**
+
+
+`<path>|<token>|`
+
+`<path>` again is considered relative and, together with `<token>`, should
+be suitable to formulate an `ADD_DOMAIN_WATCHES` operation (see below).
+Note that `<path>` must not be a *special* value (beginning with `@`).
+
+
+### Protocol Extension
+
+The `WATCH` operation does not allow specification of a `<domid>`; it is
+assumed that the watch pertains to the domain that owns the shared ring
+over which the operation is passed. Hence, for the tool-stack to be able
+to register a watch on behalf of a domain a new operation is needed:
+
+```
+ADD_DOMAIN_WATCHES      <domid>|<watch>|+
+
+Adds watches on behalf of the specified domain.
+
+<watch> is a NUL separated tuple of <path>|<token>. <path> must not be
+@<wspecial>, otherwise the semantics of this operation are identical to
+the domain issuing WATCH <path>|<token>|.
+```
+
+The watch information for a domain also needs to be extracted from the
+sending xenstored so the following operation is also needed:
+
+```
+GET_DOMAIN_WATCHES      <domid>|<index>   <gencnt>|<watch>|* 
+
+Gets the list of watches that are currently registered for the domain.
+
+<watch> is a NUL separated tuple of <path>|<token>. The sub-list returned
+will start at <index> into the the overall list of watches and may be
+truncated such that the returned data fits within XENSTORE_PAYLOAD_MAX.
+If <index> is beyond the end of the overall list then the returned sub-
+list will be empty. If the value of <gencnt> changes then it indicates
+that the overall watch list has changed and thus it may be necessary
+to re-issue the operation for previous values of <index>.
+```
+
+It may also be desirable to state in the protocol specification that
+the `INTRODUCE` operation should not clear the `<mfn>` specified such that
+a `RELEASE` operation followed by an `INTRODUCE` operation form an
+idempotent pair. The current implementation of *C xentored* does this
+(in the `domain_conn_reset()` function) but this could be dropped as this
+behaviour is not currently specified and the page will always be zeroed
+for a newly created domain.
+
+
+* * *
+
+[1] See https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=docs/designs/non-cooperative-migration.md
+[2] See https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=docs/misc/xenstore.txt
+[3] See https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=docs/specs/libxl-migration-stream.pandoc
Signature · 7 lines
2.20.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#6 lore raw

Re: [Xen-devel] [PATCH v3 2/2] docs/designs: Add a design document for migration of xenstore data

Quoted 27 lines · Paul Durrant

This patch details proposes extra migration data and xenstore protocol extensions to support non-cooperative live migration of guests.

---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Wei Liu <[email protected]>

v3:
- New in v3

---
  docs/designs/xenstore-migration.md | 122 +++++++++++++++++++++++++++++
  1 file changed, 122 insertions(+)

create mode 100644 docs/designs/xenstore-migration.md

docs/designs/xenstore-migration.md new file +0 -0
new file mode 100644
index 0000000000..9020b6ff9a

docs/designs/xenstore-migration.md line 8

Quoted 8 lines
docs/designs/xenstore-migration.md new file +8 -0
@@ -0,0 +1,122 @@
+**watch data**
+
+
+`<path>|<token>|`
+
+`<path>` again is considered relative and, together with `<token>`, should
+be suitable to formulate an `ADD_DOMAIN_WATCHES` operation (see below).
+Note that `<path>` must not be a *special* value (beginning with `@`).

Why not? This is possible for a guest, so it should be possible to migrate such a watch.

Today it might not make any sense, but we should not block any future special values which might make sense for a guest to use.

Quoted 7 lines
docs/designs/xenstore-migration.md new file +7 -0
+
+
+### Protocol Extension
+
+The `WATCH` operation does not allow specification of a `<domid>`; it is
+assumed that the watch pertains to the domain that owns the shared ring
+over which the operation is passed. Hence, for the tool-stack to be able

docs/designs/xenstore-migration.md line 89

Quoted 10 lines
docs/designs/xenstore-migration.md new file +10 -0
+to register a watch on behalf of a domain a new operation is needed:
+
+```
+ADD_DOMAIN_WATCHES      <domid>|<watch>|+
+
+Adds watches on behalf of the specified domain.
+
+<watch> is a NUL separated tuple of <path>|<token>. <path> must not be
+@<wspecial>, otherwise the semantics of this operation are identical to
+the domain issuing WATCH <path>|<token>|.

I wouldn't exclude @<wspecial>.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#7 lore raw

Re: [Xen-devel] [PATCH v3 2/2] docs/designs: Add a design document for migration of xenstore data

Quoted 48 lines

-----Original Message-----
From: Jürgen Groß <[email protected]>
Sent: 28 January 2020 13:36
To: Durrant, Paul <[email protected]>; [email protected]
Cc: Stefano Stabellini <[email protected]>; Julien Grall <[email protected]>; Wei Liu <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; George Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Ian Jackson <[email protected]>
Subject: Re: [Xen-devel] [PATCH v3 2/2] docs/designs: Add a design document for migration of xenstore data

docs/designs/xenstore-

Quoted 22 lines · Paul Durrant

This patch details proposes extra migration data and xenstore protocol extensions to support non-cooperative live migration of guests.

---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Wei Liu <[email protected]>

v3:
- New in v3

---
  docs/designs/xenstore-migration.md | 122 +++++++++++++++++++++++++++++
  1 file changed, 122 insertions(+)

create mode 100644 docs/designs/xenstore-migration.md

docs/designs/xenstore- renamed from docs/designs/xenstore-migration.md +0 -0

migration.md

docs/designs/xenstore-migration.md line 6

Quoted 11 lines

new file mode 100644
index 0000000000..9020b6ff9a

docs/designs/xenstore-migration.md new file +6 -0
@@ -0,0 +1,122 @@
+**watch data**
+
+
+`<path>|<token>|`
+
+`<path>` again is considered relative and, together with `<token>`,

should

Quoted 9 lines

docs/designs/xenstore-migration.md line 72

Quoted 2 lines
docs/designs/xenstore-migration.md new file +2 -0
+be suitable to formulate an `ADD_DOMAIN_WATCHES` operation (see below).
+Note that `<path>` must not be a *special* value (beginning with `@`).

Why not? This is possible for a guest, so it should be possible to migrate such a watch.

Today it might not make any sense, but we should not block any future special values which might make sense for a guest to use.

Ok. I was just limiting things to what is actually needed. If you think there is merit in allowing them then I have no objection. I'll remove the exclusions.

Paul
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#8 lore raw

Re: [Xen-devel] [PATCH v3 2/2] docs/designs: Add a design document for migration of xenstore data

In reply to Paul Durrant
Quoted 11 lines · Paul Durrant

+```
+0 1 2 3 4 5 6 7 octet
++------------------------+------------------------+
+| type | record specific data |
++------------------------+ |
+...
++-------------------------------------------------+
+```

docs/designs/xenstore-migration.md new file +3 -0
+
+
+| Field | Description |

docs/designs/xenstore-migration.md line 51

Quoted 10 lines
docs/designs/xenstore-migration.md new file +10 -0
+|---|---|
+| `type` | 0x00000000: invalid |
+|        | 0x00000001: node data |
+|        | 0x00000002: watch data |
+|        | 0x00000003 - 0xFFFFFFFF: reserved for future use |
+
+
+where data is always in the form of a NUL separated and terminated tuple
+as follows
+

Is there any padding requirement for a record? I take it there isn't?

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#9 lore raw

Re: [Xen-devel] [PATCH v3 2/2] docs/designs: Add a design document for migration of xenstore data

Quoted 34 lines

-----Original Message-----
From: Xen-devel <[email protected]> On Behalf Of Wei Liu
Sent: 28 January 2020 13:46
To: Durrant, Paul <[email protected]>
Cc: Stefano Stabellini <[email protected]>; Julien Grall <[email protected]>; Wei Liu <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; George Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Ian Jackson <[email protected]>; [email protected]
Subject: Re: [Xen-devel] [PATCH v3 2/2] docs/designs: Add a design document for migration of xenstore data

Quoted 9 lines · Paul Durrant

+```
+0 1 2 3 4 5 6 7 octet
++------------------------+------------------------+
+| type | record specific data |
++------------------------+ |
+...
++-------------------------------------------------+
+```

docs/designs/xenstore-migration.md new file +1 -0
+

docs/designs/xenstore-migration.md

Quoted 10 lines
docs/designs/xenstore-migration.md new file +10 -0
+
+| Field | Description |
+|---|---|
+| `type` | 0x00000000: invalid |
+|        | 0x00000001: node data |
+|        | 0x00000002: watch data |
+|        | 0x00000003 - 0xFFFFFFFF: reserved for future use |
+
+
+where data is always in the form of a NUL separated and terminated

tuple

Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+as follows
+

Is there any padding requirement for a record? I take it there isn't?

No, the padding is at the generic record level (already part of the spec).

Paul

Quoted 6 lines

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel