Commit Graph

10901 Commits

Author SHA1 Message Date
Philipp Schuster
2e62081bec docs: update SEV-SNP backend support
Remove the stale MSHV-only wording now that the docs and CVM test path
cover KVM SEV-SNP with IGVM stage0 and fw_cfg [0, 1].

[0]: https://github.com/cloud-hypervisor/cloud-hypervisor/pull/7942
[1]: https://github.com/cloud-hypervisor/cloud-hypervisor/pull/8347

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-06-30 17:03:30 +00:00
Philipp Schuster
013981b649 vm-migration: improve debuggability on receiver for failed migrations
We cannot reliably send Request::abandon() on every kind of failure on
the sender side, as we might be in the middle of a memory transmission.
The receiver would not reliably know what to do with that. So instead,
when the receiver cannot read from the socket, we log that the migration
sender failed, which is the only likely cause of that failure.

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-06-30 16:59:20 +00:00
Philipp Schuster
81022ab087 vm-migration: improve logging to make clear if receiver caused failure
This improves the observability whether a migration failed because of
the sender or because of some error on the receiving side.

Using a simple log message is simpler than introducing a new error enum
to differentiate between SendError and RemoteError.

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-06-30 16:59:20 +00:00
Sebastian Eydam
969d2f855d vm-migration: stop sending abandon after error response
When the receiver of a live migration encounters an error, it sends an
error response. The sender of the migration would then send an abandon
request and wait for a response. This abandon request is not necessary,
because the receiver already abandoned the migration due to the error it
encountered.

From now on this function will not send an abandon request to the
receiver anymore, thus it was renamed to "ok_or_error".

Also, this case was always broken, because after sending the error
response, the receiver just exits without waiting for the additional
abandon request.

On-behalf-of: SAP sebastian.eydam@sap.com
Signed-off-by: Sebastian Eydam <sebastian.eydam@cyberus-technology.de>
2026-06-30 16:59:20 +00:00
Philipp Schuster
f35c9842be docs: update new prefault behavior in memory.md
On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-06-30 16:56:42 +00:00
Sebastian Eydam
22cf10b6ab vmm: return error if prefaulting fails
Prefaulting pages was done on a best-effort basis before, meaning that
errors were ignored. This could lead to errors during runtime,
especially when used with hugepages, because there was no guarantee that
enough pages are available. With this change errors during prefaulting
will be reported.

Co-authored-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP sebastian.eydam@sap.com
Signed-off-by: Sebastian Eydam <sebastian.eydam@cyberus-technology.de>
2026-06-30 16:56:42 +00:00
Daniel Verkamp
494c30be19 block: Avoid unsafe Vec construction in detect_image_type()
The `read_aligned_block_size()` function used `Vec::from_raw_parts()`
incorrectly, causing undefined behavior when deallocating the `Vec<u8>`.

One of the safety invariants of `Vec::from_raw_parts()` is that the
provided pointer must be allocated with the exact same alignment as `T`
(`u8` in this case), but this is clearly not true: `align_of::<u8>()` is
1, but the pointer was allocated with aligment of `blocksize` (typically
512 or greater).

Fix this by using the existing `AlignedFile` helper to read the header
block when probing the image type. This is slightly less efficient than
using `AlignedBuffer` directly, but since this is only called once per
disk image at startup, the difference is probably not worth the extra
verbosity.

Signed-off-by: Daniel Verkamp <drv@meta.com>
2026-06-29 23:26:17 +00:00
Anatol Belski
ab593accb3 virtio-devices: Test device config capability presence
Add unit tests for add_pci_capabilities covering the configless
device path. The device config capability is present when the
config region is sized and absent when the size is zero.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-06-29 23:09:52 +00:00
Anatol Belski
3c90f91491 virtio-devices: Report no config space for configless devices
The watchdog, rng, and rtc devices expose no device specific
configuration fields. Each now reports a config size of zero so the
transport omits the device configuration capability instead of
advertising an unbacked region that the device cannot service.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-06-29 23:09:52 +00:00
Anatol Belski
d1dd6b13d5 virtio-devices: Size the device config capability per device
Add a config_size method to VirtioDevice and use it when building the
PCI device configuration capability. The transport advertises the size
reported by the device and omits the capability entirely when the size
is zero, because the virtio driver rejects a zero length capability.

The method defaults to None, so every device keeps its current
capability size.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-06-29 23:09:52 +00:00
Anatol Belski
9c085e11bb block: Add unit tests for qcow raw file positional access
Cover read_pointer_table round trip and masking, and the
write_cluster then zero_cluster round trip, exercising the positional
read_exact_at, write_all_at, and write_all_zeroes_at paths on the
AlignedFile.

Assisted-by: Claude:Opus-4.8
Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-06-29 21:55:08 +00:00
Anatol Belski
833b360e18 block: Convert qcow raw file table and cluster writes to positional
Replace the seek then read/write metadata access in QcowRawFile with
positional read_exact_at, write_all_at, and write_all_zeroes_at on the
AlignedFile. read_pointer_table, write_pointer_table,
write_pointer_table_direct, zero_cluster, and write_cluster no longer
move the file cursor.

These calls still route through AlignedFile, which implements FileExt
and WriteZeroesAt with the O_DIRECT alignment bounce, so the unaligned
behavior is preserved. Each access already issued an absolute seek
before touching the file, so the cursor never carried state between
calls and dropping it is unobservable.

Decoding the pointer table now uses native from_be_bytes over the read
buffer, matching the to_be_bytes path on the write side.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-06-29 21:55:08 +00:00
Henry Hrvoje Tonkovac
fe8bd6e62c block: fix VHDX region table overlap detection
The region table overlap check in RegionInfo::new only rejected a new
region that strictly engulfed an existing one. Identical, fully
contained, and partially overlapping regions passed undetected, so a
malformed VHDX with overlapping region entries was wrongly accepted.

Per [MS-VHDX] all region objects MUST be non-overlapping, so such an
image should be rejected. Replace the faulty predicate with a correct
half-open interval overlap test, extracted into a small pure helper
(ranges_overlap).

Add a unit test for the predicate and an integration test that feeds a
crafted region table with two overlapping entries through the real
RegionInfo::new, confirming it is now rejected with RegionOverlap.

Related to #8009 (broader VHDX overlap validation).

Signed-off-by: Henry Hrvoje Tonkovac <htonkovac@gmail.com>
Assisted-by: Claude:Opus-4.8
2026-06-29 21:51:12 +00:00
Philipp Schuster
19e67a2c7e vmm: streamline migration related API error variants
Receiving a migration happens inside the VMM thread, which blocks the
API until a migration was received. On the other hand, sending a
migration is actually just a dispatch operation. We adjust the wording
to improve clarity of the error messages.

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-06-29 18:07:51 +00:00
CMGS
f8d0186a26 arch: x86_64: recommend Hyper-V paravirt TLB flush and cluster IPI
Adds three recommendation bits to CPUID 0x40000004.EAX so Windows /
Hyper-V-aware guests use the corresponding paravirtualized hypercalls
instead of falling back to architectural primitives. The hypercalls
themselves are emulated unconditionally by KVM and surfaced via the
corresponding KVM_CAP_HYPERV_* info caps; no userspace cap negotiation
is needed because KVM advertises support to the guest at hypercall
issue time:

  KVM_CAP_HYPERV_TLBFLUSH advertises HvFlush{VirtualAddressSpace,Ex,
                          List,ListEx} (api.rst 8.18, info-only cap).
  KVM_CAP_HYPERV_SEND_IPI advertises HvCallSendSyntheticClusterIpi{,Ex}
                          (api.rst 8.20, also info-only).

Leaf 0x40000004.EAX (HV_CPUID_ENLIGHTMENT_INFO):
  bit 1  LocalTlbFlushRecommended
  bit 2  RemoteTlbFlushRecommended
         Recommend HvFlushVirtualAddressSpace / List in place of
         architectural INVPCID / INVLPG broadcasts. Remote shoot-down
         via hypercall lets the host skip vCPUs that are not currently
         scheduled, instead of waiting for an IPI ack.
  bit 10 ClusterIpiRecommended
         Recommend HvCallSendSyntheticClusterIpi over per-target APIC
         ICR writes. A single hypercall can target up to 64 vCPUs (or
         all of them via the Ex variant) versus one VM exit per APIC
         access on the architectural path.

These bits depend on AccessVpIndex (0x40000003.EAX bit 6), which is
advertised by the partition-privileges change.

Sources:
  Microsoft Hypervisor Top-Level Functional Specification 7.4.5
  qemu/qemu docs/system/i386/hyperv.rst (hv-tlbflush, hv-ipi)
  Linux Documentation/virt/kvm/api.rst 8.18, 8.20

Signed-off-by: CMGS <ilskdw@gmail.com>
2026-06-29 18:03:44 +00:00
CMGS
ba11523760 arch: x86_64: advertise additional Hyper-V CPUID enlightenments
Extends the Hyper-V partition feature CPUID leaf 0x40000003 with bits
that KVM emulates unconditionally and that Windows / Hyper-V-aware
guests consult to skip slow fallback paths. No KVM capability
negotiation is required for any of these -- they are hints to the
guest about what is already legal to use.

Leaf 0x40000003.EAX (HV_CPUID_FEATURES):
  bit 0  AccessVpRuntimeReg     -- HV_X64_MSR_VP_RUNTIME (0x40000010)
  bit 4  AccessIntrCtrlRegs     -- HV_X64_MSR_{EOI,ICR,TPR,APIC_ASSIST}
  bit 11 AccessFrequencyMsrs    -- HV_X64_MSR_{TSC,APIC}_FREQUENCY (skips
                                   guest TSC/APIC calibration loops)

Leaf 0x40000003.EDX (HV_CPUID_FEATURES, TLFS rev 6.0c):
  bit 4  FastHypercall          -- HV_HYPERCALL_PARAMS_XMM_AVAILABLE
  bit 8  ExtendedGvaRangesForFlushVirtualAddressList -- pairs with the
                                   tlbflush-ext recommendation bit

AccessHypercallMsrs (bit 5) and AccessVpIndex (bit 6) are already
advertised by the partition-privileges change.

Sources:
  Microsoft Hypervisor Top-Level Functional Specification 7.4.{2,5}
  qemu/qemu docs/system/i386/hyperv.rst (hv-vapic, hv-frequencies,
                                          hv-vpruntime)

Signed-off-by: CMGS <ilskdw@gmail.com>
2026-06-29 18:03:44 +00:00
Sebastian Eydam
aa629a1485 vmm: make aborted migrations on receiver side return an error
On the receiver side, a live migration with status "aborted" does not
return an error. Thus, management software will think that the live
migration was successful (from just looking at the API response). This
is not expected behaviour.

On-behalf-of: SAP sebastian.eydam@sap.com
Signed-off-by: Sebastian Eydam <sebastian.eydam@cyberus-technology.de>
2026-06-29 17:19:28 +00:00
Philipp Schuster
1ae1cc787d vmm: migration seccomp: add for TCP workers (send and receive)
On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-06-29 17:15:14 +00:00
Philipp Schuster
fd88e23ecb vmm: migration seccomp: add for migration worker (coordinator thread)
On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-06-29 17:15:14 +00:00
Philipp Schuster
b5c028c286 vmm: migration seccomp: add plumbing for all migration-related threads
So far, we only have seccomp rules for the postcopy-send thread. This
commit introduces the basic plumbing to add seccomp rules also for the
migration worker (the migration coordinator) as well as the TCP workers
(both, send and receive) in the following.

To streamline code setup, all filters are created at a central place
early in the migration code. Although this means that some filters are
created without the need to do so (e.g., postcopy), this massively
simplifies code setup and error handling. This overhead is negligible.

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-06-29 17:15:14 +00:00
dependabot[bot]
e7371984b8 build(deps): bump the non-rust-vmm group across 2 directories with 12 updates
Bumps the non-rust-vmm group with 9 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [itertools](https://github.com/rust-itertools/itertools) | `0.14.0` | `0.15.0` |
| [jiff](https://github.com/BurntSushi/jiff) | `0.2.28` | `0.2.29` |
| [log](https://github.com/rust-lang/log) | `0.4.32` | `0.4.33` |
| [rustls](https://github.com/rustls/rustls) | `0.23.40` | `0.23.41` |
| [getrandom](https://github.com/rust-random/getrandom) | `0.4.2` | `0.4.3` |
| [cc](https://github.com/rust-lang/cc-rs) | `1.2.64` | `1.2.65` |
| [quote](https://github.com/dtolnay/quote) | `1.0.45` | `1.0.46` |
| [syn](https://github.com/dtolnay/syn) | `2.0.117` | `2.0.118` |
| [zeroize](https://github.com/RustCrypto/utils) | `1.8.2` | `1.9.0` |

Bumps the non-rust-vmm group with 6 updates in the /fuzz directory:

| Package | From | To |
| --- | --- | --- |
| [itertools](https://github.com/rust-itertools/itertools) | `0.14.0` | `0.15.0` |
| [log](https://github.com/rust-lang/log) | `0.4.32` | `0.4.33` |
| [rustls](https://github.com/rustls/rustls) | `0.23.40` | `0.23.41` |
| [cc](https://github.com/rust-lang/cc-rs) | `1.2.64` | `1.2.65` |
| [quote](https://github.com/dtolnay/quote) | `1.0.45` | `1.0.46` |
| [syn](https://github.com/dtolnay/syn) | `2.0.117` | `2.0.118` |



Updates `itertools` from 0.14.0 to 0.15.0
- [Changelog](https://github.com/rust-itertools/itertools/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-itertools/itertools/compare/v0.14.0...v0.15.0)

Updates `jiff` from 0.2.28 to 0.2.29
- [Release notes](https://github.com/BurntSushi/jiff/releases)
- [Changelog](https://github.com/BurntSushi/jiff/blob/master/CHANGELOG.md)
- [Commits](https://github.com/BurntSushi/jiff/compare/jiff-static-0.2.28...jiff-static-0.2.29)

Updates `log` from 0.4.32 to 0.4.33
- [Release notes](https://github.com/rust-lang/log/releases)
- [Changelog](https://github.com/rust-lang/log/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/log/compare/0.4.32...0.4.33)

Updates `rustls` from 0.23.40 to 0.23.41
- [Release notes](https://github.com/rustls/rustls/releases)
- [Changelog](https://github.com/rustls/rustls/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rustls/rustls/compare/v/0.23.40...v/0.23.41)

Updates `getrandom` from 0.4.2 to 0.4.3
- [Changelog](https://github.com/rust-random/getrandom/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-random/getrandom/compare/v0.4.2...v0.4.3)

Updates `cc` from 1.2.64 to 1.2.65
- [Release notes](https://github.com/rust-lang/cc-rs/releases)
- [Changelog](https://github.com/rust-lang/cc-rs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.64...cc-v1.2.65)

Updates `hashbrown` from 0.15.5 to 0.17.0
- [Release notes](https://github.com/rust-lang/hashbrown/releases)
- [Changelog](https://github.com/rust-lang/hashbrown/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/hashbrown/compare/v0.15.5...v0.17.0)

Updates `jiff-static` from 0.2.28 to 0.2.29
- [Release notes](https://github.com/BurntSushi/jiff/releases)
- [Changelog](https://github.com/BurntSushi/jiff/blob/master/CHANGELOG.md)
- [Commits](https://github.com/BurntSushi/jiff/compare/jiff-static-0.2.28...jiff-static-0.2.29)

Updates `quote` from 1.0.45 to 1.0.46
- [Release notes](https://github.com/dtolnay/quote/releases)
- [Commits](https://github.com/dtolnay/quote/compare/1.0.45...1.0.46)

Updates `syn` from 2.0.117 to 2.0.118
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/2.0.117...2.0.118)

Updates `wit-bindgen` from 0.51.0 to 0.57.1
- [Release notes](https://github.com/bytecodealliance/wit-bindgen/releases)
- [Commits](https://github.com/bytecodealliance/wit-bindgen/compare/v0.51.0...v0.57.1)

Updates `zeroize` from 1.8.2 to 1.9.0
- [Commits](https://github.com/RustCrypto/utils/compare/zeroize-v1.8.2...zeroize-v1.9.0)

Updates `itertools` from 0.14.0 to 0.15.0
- [Changelog](https://github.com/rust-itertools/itertools/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-itertools/itertools/compare/v0.14.0...v0.15.0)

Updates `log` from 0.4.32 to 0.4.33
- [Release notes](https://github.com/rust-lang/log/releases)
- [Changelog](https://github.com/rust-lang/log/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/log/compare/0.4.32...0.4.33)

Updates `rustls` from 0.23.40 to 0.23.41
- [Release notes](https://github.com/rustls/rustls/releases)
- [Changelog](https://github.com/rustls/rustls/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rustls/rustls/compare/v/0.23.40...v/0.23.41)

Updates `cc` from 1.2.64 to 1.2.65
- [Release notes](https://github.com/rust-lang/cc-rs/releases)
- [Changelog](https://github.com/rust-lang/cc-rs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.64...cc-v1.2.65)

Updates `quote` from 1.0.45 to 1.0.46
- [Release notes](https://github.com/dtolnay/quote/releases)
- [Commits](https://github.com/dtolnay/quote/compare/1.0.45...1.0.46)

Updates `syn` from 2.0.117 to 2.0.118
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/2.0.117...2.0.118)

---
updated-dependencies:
- dependency-name: itertools
  dependency-version: 0.15.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: non-rust-vmm
- dependency-name: jiff
  dependency-version: 0.2.29
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: log
  dependency-version: 0.4.33
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: rustls
  dependency-version: 0.23.41
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: getrandom
  dependency-version: 0.4.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: cc
  dependency-version: 1.2.65
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: hashbrown
  dependency-version: 0.17.0
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: non-rust-vmm
- dependency-name: jiff-static
  dependency-version: 0.2.29
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: quote
  dependency-version: 1.0.46
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: syn
  dependency-version: 2.0.118
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: wit-bindgen
  dependency-version: 0.57.1
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: non-rust-vmm
- dependency-name: zeroize
  dependency-version: 1.9.0
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: non-rust-vmm
- dependency-name: itertools
  dependency-version: 0.15.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: non-rust-vmm
- dependency-name: log
  dependency-version: 0.4.33
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: rustls
  dependency-version: 0.23.41
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: cc
  dependency-version: 1.2.65
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: quote
  dependency-version: 1.0.46
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: syn
  dependency-version: 2.0.118
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-26 16:47:02 +00:00
Philipp Schuster
ebc653d0c8 vmm: silence some info!() messages with little value-add
On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-06-26 16:46:30 +00:00
Philipp Schuster
48c9e9d86b vmm: split code in ReceiveAdditionalConnections into smaller chunks
This ensures the code stays maintainable.

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-06-26 16:46:30 +00:00
Philipp Schuster
6b441f0746 vmm: improve rustdoc for ReceiveAdditionalConnections
ReceiveAdditionalConnections got quite complicated, especially with the
many threads involved for precopy and the special-case of postcopy. We
therefore should add comprehensive documentation.

I tried to keep it short and concise - what remains provides high value
and improves the mental model of the code.

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-06-26 16:46:30 +00:00
Philipp Schuster
4d727c4899 vmm: keep virtio activation alive in migration
Live migration can deadlock if the guest triggers a virtio device
activation while the migration worker owns the VM.

The failure shows up when starting live migrations during boot and
firmware startup, where the guest can reset and reinitialize virtio
devices while precopy is running. In the failing case, the source log
shows a pending virtio activation that never completes:

    8.115833s _virtio-pci-net_0: Needs activation; returning barrier
    8.115854s vmm/src/vm.rs:464 -- Waiting for barrier
    24.875452s Entering downtime phase
    24.875481s stopping vcpu throttling thread
    ...
    vCPU thread did not respond in 10ms to signal - retrying
    vCPU thread did not respond in 20ms to signal - retrying
    ...
    thread 'throttle-vcpu' (1029) panicked
    ...
    Pause(Error signalling vCPUs: Timeout when waiting for signal
        to be acknowledged)

The vCPU blocks on the activation barrier and never reaches the normal
pause checkpoint. Later, migration enters downtime and stops the vCPU
throttle thread. In the failing case, that thread is still inside a
CpuManager::pause() call, which waits for every vCPU to acknowledge
the signal. The blocked vCPU never does, so the pause times out.

Fix this by storing the DeviceManager inside VmOwnership::Migration.
This keeps just enough state on the VMM thread to drain pending virtio
activations while the migration worker owns the Vm. The barrier logic
stays unchanged. The VMM now releases the same activation barrier during
migration that it already released before migration started.

This keeps the guest from getting stuck in the activation wait and
lets the later pause succeed.

Co-authored-by: Leander Kohler <leander.kohler@cyberus-technology.de>
On-behalf-of: SAP leander.kohler@sap.com
Signed-off-by: Leander Kohler <leander.kohler@cyberus-technology.de>

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-06-26 16:42:37 +00:00
Sebastian Eydam
08526a65b5 main: print seccomp syscall details
When seccomp traps a SIGSYS, print the syscall number that caused it,
the current thread id and thread name to make violations easier to
debug.

This change requires that all threads are allowed to execute the
`gettid` and the `prctl` syscalls, thus the seccomp filters have also
been adjusted.

On-behalf-of: SAP sebastian.eydam@sap.com
Signed-off-by: Sebastian Eydam <sebastian.eydam@cyberus-technology.de>
2026-06-26 16:40:45 +00:00
Sebastien Boeuf
693c236e06 vm-migration: Use zerocopy for safe serialization
Getting rid of the unsafe ByteValued implementation for MemoryRange,
Request and Response structures, by relying on zerocopy's safe
implementation instead.

Signed-off-by: Sebastien Boeuf <sboeuf@meta.com>
Assisted-by: Claude:claude-opus-4-8
2026-06-26 14:59:45 +00:00
Philipp Schuster
516caed5cc vmm: streamline rustdoc of tls_dir
On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-06-26 01:12:59 +00:00
Philipp Schuster
9dc970630b vmm: log successful TCP/TLS handshake
This helps operators and developers to easily verify if the TLS
handshake was successful.

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-06-26 01:12:59 +00:00
Philipp Schuster
90429c56c8 vmm: streamline error messages
In [0] we agreed on the current format.

[0] https://github.com/cloud-hypervisor/cloud-hypervisor/pull/7066

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-06-25 19:13:13 +00:00
Philipp Schuster
40d8f9ee51 pci: streamline error messages
In [0] we agreed on the current format.

[0] https://github.com/cloud-hypervisor/cloud-hypervisor/pull/7066

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-06-25 19:13:13 +00:00
Philipp Schuster
fdc076d22f net_util: streamline error messages
In [0] we agreed on the current format.

[0] https://github.com/cloud-hypervisor/cloud-hypervisor/pull/7066

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-06-25 19:13:13 +00:00
Philipp Schuster
786d40f549 block: streamline error messages
In [0] we agreed on the current format.

[0] https://github.com/cloud-hypervisor/cloud-hypervisor/pull/7066

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-06-25 19:13:13 +00:00
Philipp Schuster
9ba653dc16 misc: persist Error-message style in CONTRIBUTING.md and AGENTS.md
In [0] we agreed on the current format.

[0] https://github.com/cloud-hypervisor/cloud-hypervisor/pull/7066

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-06-25 19:13:13 +00:00
Philipp Schuster
252702049e vmm: migration: print whole error chain on error
In [0] we agreed on the current format. When ch-remote or
cloud-hypervisor exit with an error, they nicely print the whole chain.
This, however, doesn't work when simply doing `error!("error: {e}")`
- which is what we currently do for migration-related errors.

This commit walks the chain of errors and prints all components in a
single line. This massively improves the quality of error messages and
helps tracing down where an error is originating from. Using ` => ` as
separator is better than `\n` which doesn't work well in our current
log format.

# Example (Before - Bad)

```
cloud-hypervisor:   2.859287s: <vmm> ERROR:vmm/src/lib.rs:2021 -- Migration failed: Failed to send migratable component snapshot
```

# Example (New - Better)

```
cloud-hypervisor:   2.296160s: <vmm> ERROR:vmm/src/lib.rs:2038 -- Migration failed: Failed to send migratable component snapshot => Error connecting to TCP socket => Connection refused (os error 111)
```

[0] https://github.com/cloud-hypervisor/cloud-hypervisor/pull/7066

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-06-25 19:12:15 +00:00
Philipp Schuster
8c71a0d821 vmm: make migration errors more helpful
Keep the original error sources while adding operation context to the
straightforward migration send and receive paths. This keeps up a
chain of errors that can be printed nicely and in a helpful way.

This commit does that for all MigratableError-occurences where this
change is easily applicable.

Co-authored-by: Sebastian Eydam <sebastian.eydam@cyberus-technology.de>

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-06-25 19:12:15 +00:00
Henry Hrvoje Tonkovac
05f026440a devices: rtc_pl031: update outdated ARM TRM doc link
static.docs.arm.com no longer serves the PL031 RTC technical reference
manual; point the comment at the current developer.arm.com location.
Clears the lychee link check, as requested on the review.

Signed-off-by: Henry Hrvoje Tonkovac <htonkovac@gmail.com>
Assisted-by: Claude:Opus-4.8
2026-06-25 16:54:35 +00:00
Henry Hrvoje Tonkovac
f720e619c1 misc: use prelude size_of
size_of is part of std::prelude as of Rust 1.80 (with size_of_val,
align_of, align_of_val), and the workspace MSRV is 1.89, so qualifying
it (mem::size_of, std::mem::size_of, core::mem::size_of) is unnecessary.

Convert every qualified size_of call-site to the bare prelude form and
drop the now-redundant `use std::mem::size_of;` imports, keeping
`use std::mem;` where it still serves non-prelude items (transmute,
swap, replace, take, zeroed, MaybeUninit, offset_of). size_of is the
only one of the four currently used in the tree.

Pure refactor, no behavioural change. Follow-up to the
clippy::absolute_paths cleanup (#7670), as discussed in #8444.

Signed-off-by: Henry Hrvoje Tonkovac <htonkovac@gmail.com>
Assisted-by: Claude:Opus-4.8
2026-06-25 16:54:35 +00:00
Henry Hrvoje Tonkovac
f56fa3a865 tests: trim qualified paths in integration
Import the modules used in the integration tests instead of spelling
the full paths at every use site, and drop the file's now-unnecessary

Signed-off-by: Henry Hrvoje Tonkovac <htonkovac@gmail.com>
Assisted-by: Claude:Opus-4.8
2026-06-24 15:13:07 +00:00
Henry Hrvoje Tonkovac
025e782e50 vmm: trim qualified paths
Import the modules used in the crate instead of spelling the full paths
at every use site, and drop the now-unnecessary crate-level

Signed-off-by: Henry Hrvoje Tonkovac <htonkovac@gmail.com>
Assisted-by: Claude:Opus-4.8
2026-06-24 15:12:32 +00:00
Philipp Schuster
0caa3ee73f vmm: silence some info! messages
We have larger cloud deployments and analyzed the logs. Let's silence
some messages that generally provide little value on the `info!` level.

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-06-24 13:58:46 +00:00
Philipp Schuster
dcaccf21ea virtio-devices: silence some info! messages
We have larger cloud deployments and analyzed the logs. Let's silence
some messages that generally provide little value on the `info!` level.

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-06-24 13:58:46 +00:00
Sebastien Boeuf
cc98a232e6 vmm: Add seccomp filter for migrate-send-postcopy thread
Applying seccomp filtering to the migration postcopy thread running on
the source VM during migration.

Signed-off-by: Sebastien Boeuf <sboeuf@meta.com>
Assisted-by: Claude:claude-opus-4-8
2026-06-24 12:51:40 +00:00
Sebastien Boeuf
80958acdab vmm: Wire postcopy live migration from source VM
Wire up the source side of postcopy migration over TCP. When
`mode=postcopy` is requested on vm.send-migration, the source skips
the pre-copy dirty-tracking loop and lets the destination resume early,
then serves guest pages on demand over a dedicated connection.

Signed-off-by: Sebastien Boeuf <sboeuf@meta.com>
Assisted-by: Claude:claude-opus-4-7
2026-06-24 12:51:40 +00:00
Sebastien Boeuf
60398f11ff offload_daemon: Add --ondemand restore mode
Add an --ondemand flag to the offload daemon's restore subcommand to
support the post-copy mechanism from the live migration protocol.

In on-demand mode, the daemon creates empty memfds to back the guest
memory and sends them over to the VMM. This lets the VM start quickly,
right after the memfds are mapped into CH's address space.

At runtime, when the guest accesses a page (or the prefault handler
requests it), the daemon faults it in by copying the page content into
its shared memory mapping, then replies to the PageFault request so the
VMM can consider the page present.

Signed-off-by: Sebastien Boeuf <sboeuf@meta.com>
Assisted-by: Claude:claude-opus-4-7
2026-06-24 12:51:40 +00:00
Sebastien Boeuf
48ba1f1417 vmm: Add postcopy support to receive-migration
Plumb the SocketUffdMemorySource into the receiving side of live
migration. When memory_mode=postcopy is requested, the destination
brings up a dedicated fault connection, registers userfaultfd on the
restored memory regions, and serves guest pages on demand over that
connection while the VM resumes early.

Signed-off-by: Sebastien Boeuf <sboeuf@meta.com>
Assisted-by: Claude:claude-opus-4-7
2026-06-24 12:51:40 +00:00
Sebastien Boeuf
282d1c989d vmm: Add SocketUffdMemorySource implementation
Add the socket-backed UffdMemorySource that resolves each fault by
sending a Command::PageFault request to the peer over a dedicated fault
connection.

Signed-off-by: Sebastien Boeuf <sboeuf@meta.com>
Assisted-by: Claude:claude-opus-4-7
2026-06-24 12:51:40 +00:00
Sebastien Boeuf
0d82d16432 vmm: Introduce MigrationMode migration option
Introducing a migration mode to both sides of the migration (send and
receive), so that a user can desribe which way the memory should be
migrated between the source and destination VMs.

For now, we only introduce `precopy` and `postcopy` as viable options,
but we can expect other modes (more optimized) to be added in the
future.

Signed-off-by: Sebastien Boeuf <sboeuf@meta.com>
Assisted-by: Claude:claude-opus-4-8
2026-06-24 12:51:40 +00:00
Sebastien Boeuf
3807dc82de vmm: Refactor restore_by_uffd behind UffdMemorySource trait
Extract the page content provider out of the userfaultfd handler so it
can be plugged with different backends in followup commits.

No functional change intended.

Signed-off-by: Sebastien Boeuf <sboeuf@meta.com>
Assisted-by: Claude:claude-opus-4-7
2026-06-24 12:51:40 +00:00
Sebastien Boeuf
a887d87c2a vm-migration: Add PageFault command for postcopy and on demand restore
Introducing PageFault as the new wire command needed by both postcopy
live migration and on demand restore from the offload daemon. This new
command describes the need from the destination to fault the page
content in. This request describes the page through a MemoryRange
structure, and the response can be either 0 or the actual page size.

In case it is 0, that means the source had access to the guest memory
and was able to copy the page content directly. In case the response is
the actual page size, there is a payload associated which contains the
page content.

We can expect local live migration and offload restore to run locally
and therefore have access to the guest memory. The remote live migration
over the network is the case where we would expect the page content to
be sent over the wire.

This command is served through an additional connection happening on the
UNIX or TCP socket. The goal is to keep the same codepath between local
and remote migrations. This additional channel allows PageFault commands
to be issued asynchronously so they can be served without blocking the
main connection.

A connection role is introduced in order to identify an additional
connection related to pre-copy memory versus the newly introduced
channel for serving post-copy requests.

Signed-off-by: Sebastien Boeuf <sboeuf@meta.com>
Assisted-by: Claude:claude-opus-4-7
2026-06-24 12:51:40 +00:00