hypervisor: ivshmem support compatible with arm - #1307
Draft
lisongqian wants to merge 3 commits into
Draft
Conversation
lisongqian
force-pushed
the
sync-ivshmem
branch
4 times, most recently
from
August 7, 2026 08:26
fa62ca8 to
78be756
Compare
Collaborator
|
@lisongqian Pls add some e2e tests for tests/e2e/sdk_compat so that we can verify this feature on both x86 and arm. |
lisongqian
marked this pull request as draft
August 10, 2026 08:20
Collaborator
Author
|
Reopen after #1302 has been merged. |
Collaborator
Author
There are integration tests for the hypervisor, and they're enough since this PR only modifies BTW, we will add e2e tests for ivshmem on metric/log features in the future. @lkml-likexu |
lisongqian
force-pushed
the
sync-ivshmem
branch
2 times, most recently
from
August 11, 2026 14:02
a1be3e8 to
201d6a2
Compare
Cherry-pick the upstream cloud-hypervisor ivshmem series, adapt it to cube-sandbox APIs, and make ivshmem work on both x86_64 and aarch64 by default. * hypervisor: remove pre-existing legacy ivshmem implementation Drop the locally-forked ivshmem device plus all of its vmm/config/CLI/main wiring so that we can cleanly cherry-pick the upstream cloud-hypervisor ivshmem series on top. * devices: introduce ivshmem device Introduce the inter-vm shared memory (ivshmem) device to share a memory region between multiple processes running different guests and the host. Supports the basic ivshmem functions like ivshmem-plain in QEMU (https://www.qemu.org/docs/master/specs/ivshmem-spec.html). * vmm: ivshmem device support. * docs: add ivshmem device introduction. * fuzz: add ivshmem device config. * tests: add ivshmem integration test case. * hypervisor: adapt upstream ivshmem to cube-sandbox APIs The freshly cherry-picked upstream ivshmem series targets newer pci/vm-migration/vm-device APIs than cube-sandbox currently exposes. Adjust the ported sources so that they compile against cube-sandbox's existing trait surface: - devices/ivshmem.rs: drop the upstream-only PCI_CONFIGURATION_ID / UserspaceMapping / EventFd dependencies; use the 10-arg PciConfiguration::new; switch allocate_bars/free_bars to the local 4-/3-arg signatures (BAR0 via the SystemAllocator mmio hole, BAR2 via the AddressAllocator); split write_config_register and detect_bar_reprogramming to match the local PciDevice trait; rename as_any_mut to as_any; align Snapshot/Snapshottable usage with the local API. - vmm/config.rs: feature-gate the std::fs import so the default build no longer warns, and add fmt::Display arms for the new ValidationError::InvalidIvshmem* variants. * hypervisor: enable ivshmem unconditionally Drop the ivshmem cargo feature so that ivshmem support is built and shipped as part of the default cube-hypervisor binary. - Remove the 'ivshmem' feature declaration from hypervisor/Cargo.toml (workspace), vmm/Cargo.toml, devices/Cargo.toml and fuzz/Cargo.toml. - Strip every '#[cfg(feature = "ivshmem")]' attribute (37 occurrences across 6 files) so the ivshmem types, CLI flag, ValidationError variants, VmConfig field, DeviceManager wiring, fuzz target wiring and src/main.rs hook-up are always compiled. - Update integration test scripts to drop '--features ivshmem' (the feature no longer exists). - Promote tests/integration.rs::snapshot_and_check_events to pub(crate) and call it via crate:: from the ivshmem live-migration test, since ivshmem-related integration tests are now always compiled. Signed-off-by: Songqian Li <sionli@tencent.com>
When the guest reprograms BAR2 of the ivshmem device to a new GPA, we must tear down the host-side userspace mapping at the old address and create a new mapping at the new address; otherwise guest accesses via the new BAR address would not hit the host backing memory. Introduce an IvshmemOps trait so the device can ask the VMM to (re)map and unmap RAM regions, plus an IvshmemUserspaceMapping struct kept inside the devices crate to avoid a cyclic dependency on virtio-devices. The vmm crate now provides an IvshmemHandler that implements IvshmemOps on top of MemoryManager. Adapted from upstream commit 5128ee9b. The path layout and a few API signatures (Snapshot::to_state, PciConfiguration::new, MemoryManager::create_ram_region) differ in this tree, so this is a manual port rather than a straight cherry-pick. Signed-off-by: Songqian Li <sionli@tencent.com>
Add test_live_migration_ivshmem and test_live_migration_ivshmem_local to exercise live-migration of a guest that has an ivshmem device attached. Both tests share the existing _test_ivshmem helper to validate host<->guest data exchange before and after the migration. To reuse the live_migration helpers (start_live_migration and print_and_panic) from the new ivshmem tests, those helpers are promoted to pub fn. Adapted from upstream commit 9011ff21; the binary path is changed from cloud-hypervisor to cube-hypervisor and Duration::new is replaced with std::time::Duration::new to match the local style. Signed-off-by: Songqian Li <sionli@tencent.com>
lisongqian
force-pushed
the
sync-ivshmem
branch
from
August 12, 2026 02:56
201d6a2 to
4fef959
Compare
Collaborator
|
@lisongqian Any status update for this PR ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick the upstream cloud-hypervisor ivshmem series, adapt it to
cube-sandbox APIs, and make ivshmem work on both x86_64 and aarch64 by
default.