|
24 | 24 | - [Snapshot security and uniqueness](#snapshot-security-and-uniqueness) |
25 | 25 | - [Secure and insecure usage examples](#usage-examples) |
26 | 26 | - [Reusing snapshotted states securely](#reusing-snapshotted-states-securely) |
| 27 | + - [Userspace notifications of loading Virtual Machine snapshots](#userspace-notifications-of-loading-virtual-machine-snapshots) |
27 | 28 | - [Vsock device limitation](#vsock-device-limitation) |
28 | 29 | - [VMGenID device limitation](#vmgenid-device-limitation) |
29 | 30 | - [Where can I resume my snapshots?](#where-can-i-resume-my-snapshots) |
@@ -590,6 +591,38 @@ identifiers, cached random numbers, cryptographic tokens, etc **will** still be |
590 | 591 | replicated across multiple microVMs resumed from the same snapshot. Users need |
591 | 592 | to implement mechanisms for ensuring de-duplication of such state, where needed. |
592 | 593 |
|
| 594 | +## Userspace notifications of loading Virtual Machine snapshots |
| 595 | +
|
| 596 | +VMClock device ([specification](https://uapi-group.org/specifications/specs/vmclock/)) |
| 597 | +is a device that enables efficient application clock synchronization against |
| 598 | +real wallclock time, for applications running inside Virtual Machines. VMCLock |
| 599 | +also takes care situations where there is some sort disruption happens to the |
| 600 | +clock. It handles these through fields in the |
| 601 | +[`vmlcock_abi`](https://uapi-group.org/specifications/specs/vmclock/#the-vmclock_abi-structure). |
| 602 | +Currently, it handles two cases: |
| 603 | +1. Live migration through the `disruption_marker` field. |
| 604 | +1. Virtual machine snapshots through the `vm_generation_counter`. |
| 605 | +
|
| 606 | +Whenever a VM starts from a snapshot VMClock will present a new (different that |
| 607 | +what was previously stored) value in the `vm_generation_counter`. This happens |
| 608 | +in an atomic way, i.e. `vm_generation_counter` will include the new value as |
| 609 | +soon as vCPUs are resumed post snapshot loading. |
| 610 | +
|
| 611 | +User space libraries, e.g. userspace PRNGs can mmap() `vmclock_abi` and monitor |
| 612 | +changes in `vm_generation_counter` to observe when they need to adapt and/or |
| 613 | +recreate state. |
| 614 | +
|
| 615 | +Moreover, VMClock allows processes to call poll() on the VMClock device and get |
| 616 | +notified about changes through an event loop. |
| 617 | +
|
| 618 | +> [!IMPORTANT] |
| 619 | +> Support for `vm_generation_counter` and `poll()` is implemented in Linux through |
| 620 | +> the patches [here](https://lore.kernel.org/lkml/[email protected]/). |
| 621 | +> We have backported these patches for AL kernels [here](../../resources/patches/vmclock) |
| 622 | +> 5.10 and 6.1 kernels. Using the kernels suggested from the [Getting Started Guide](../getting-started.md) |
| 623 | +> includes these patches. When using mainline kernels users need to make sure that |
| 624 | +> they apply the linked patches, until these get merged upstream. |
| 625 | +
|
593 | 626 | ## Vsock device reset |
594 | 627 |
|
595 | 628 | The vsock device is reset across snapshot/restore to avoid inconsistent state |
|
0 commit comments