Skip to content

feat(axvisor): Implement inter-VM communication (IVC) demo and protocol enhancements - #1834

Open
Josen-B wants to merge 22 commits into
devfrom
ivc
Open

feat(axvisor): Implement inter-VM communication (IVC) demo and protocol enhancements#1834
Josen-B wants to merge 22 commits into
devfrom
ivc

Conversation

@Josen-B

@Josen-B Josen-B commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Josen-B and others added 21 commits August 3, 2026 02:46
- Switch IVCChannel backing store from single frame to contiguous
  frames via PagingHandler::alloc_frames(); raise max size to 1 MiB.
- Zero-sized requests now fail with InvalidInput; Drop deallocates
  all frames via dealloc_frames().
- Subscribe path still uses single map_linear() (base + size suffice).
- Add mock PagingHandler regression tests: multi-page, single-page,
  truncation, zero-size rejection.
- Extend ArceOS demo channel to 64 KiB; verify e2e with axvisor QEMU
  smoke test (ArceOS publisher, Linux subscriber, 16-page).
Change the publisher/subscriber demo from alternating send/recv in a
single loop to two concurrent threads that run send and recv
independently, making the channel full-duplex.

Fix two bugs in the process:
- the publisher miscounted subscriber data messages as acks and could
  complete before all requests were acknowledged; only Ack messages
  now count toward completion;
- the subscriber's single-slot pending-ack handshake could be
  overwritten and drop acks; it now tracks the highest received
  sequence and sends every outstanding ack in order.

Give each thread its own IvcPeerEventWaiter so IRQ event observations
are not consumed by the sibling thread.

Add the axvisor qemu case ivc-arceos2arceos covering the ArceOS
publisher/subscriber pairing.
Replace the shared IvcRegion send/receive API with non-cloneable
producer and consumer endpoints whose operations require mutable access.
Keep role attachment unsafe so callers must create each endpoint pair
exactly once for a shared region.

Move the ArceOS publisher and subscriber endpoints into their respective
sender and receiver tasks, and remove the obsolete single-thread
request/ack helpers.

Publish the region header only after both rings are initialized. Add
compile-fail ownership checks and a threaded stress regression that
verifies FIFO delivery without message loss or corruption.
Replace the subscriber map with an optional binding so the host cannot
represent multiple active subscribers on a SPSC channel.

Reject a second subscriber during both subscription preparation and final
registration under the channel-table lock. Preserve re-subscription after
the active subscriber detaches.

Add regression coverage and document the current one-publisher,
one-subscriber contract. Leave versioned multi-peer support to #1238.
@Josen-B
Josen-B requested review from ZCShou and ZR233 August 3, 2026 02:56

@mai-team-app mai-team-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本 PR 新增 AxVisor IVC 共享内存协议、ArceOS/Linux 演示、AArch64 FDT/IRQ 接入以及对应 QEMU 测试发现路径;属于新增共享虚拟化能力,已按功能开发准则审查。改动会影响 AxVisor hypercall 结果语义、VM 间共享内存启动顺序与通知可靠性,不能视为隔离改动。

本地验证:cargo fmt --checkcargo test -p axivccargo test -p axhvc 通过;cargo xtask axvisor test qemu --arch aarch64 --test-group normal --test-case ivc --list 能发现 normal/ivc。未发现 [patch.crates-io],base 分支没有等价 IVC 实现;开放 PR 搜索未发现重复项。历史 review/issue 评论为空。

组织 CI:格式检查通过,但当前 head 的 Test axvisor qemu ivc / run_container 为 skipped,CI workflow 总结为 failure;因此没有 IVC QEMU 实际运行证据。该 CI 状态与本 PR 新增的 IVC 覆盖直接相关,修复后请确保该用例在当前 head 上执行并验证成功/失败标记。

仍有以下阻塞问题:IRQ 注入失败被伪造为成功,以及发布和协议头初始化之间存在订阅启动竞态。请修复后补充能覆盖这两条错误/时序路径的回归测试,并重新运行 IVC QEMU 用例。

审核清单已完成:基线准则、共享内存/并发/IRQ/FDT/测试发现、重复分析及本地验证均已检查;未完成的 IVC QEMU 运行证据已作为本次阻塞项列出。

Powered by gpt-5.6-terra

.map_err(|error| self.operation_error("get IVC notify target devices", error))?
.ivc_notify_irq();
if let Some(irq) = notify_irq
&& let Err(err) = target_vm.pulse_interrupt(irq)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

阻塞(正确性):这里把 pulse_interrupt 的失败仅记为 warning 后仍向发送方返回 0。目标 VM 的 IVC IRQ 路由不可用时,发送方会误以为对端已被通知,而实际没有中断投递;新 demo 又依赖该 IRQ 推进接收。请将注入失败转换为 hypercall 错误(或重新定义为明确的 best-effort ABI 并调整调用方),不要伪造成功。

println!("ivc publish failed: map shared page base={shm_base_gpa:#x}");
return;
};
region.initialize(demo_config::PUBLISHER_VM_ID, demo_config::CHANNEL_KEY);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

阻塞(并发/启动时序):publish_channel 成功后通道已经可被订阅,但协议头直到这里才初始化。订阅端对一次成功的 subscribe_channel 立即检查 header,未初始化便直接退出,且它的重试并不覆盖这一情况;两个 VM 并行启动时会稳定暴露这个竞态。请把协议初始化纳入发布原子步骤,或让订阅端对 header 的 Acquire 观察进行有界等待/重试并在超时后明确失败。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants