Thanks to visit codestin.com
Credit goes to github.com

Skip to content

vmm: keep VMM running on guest shutdown with --no-shutdown - #8025

Merged
rbradford merged 3 commits into
cloud-hypervisor:mainfrom
Coffeeri:upstream/add-no-shutdown
Apr 15, 2026
Merged

rbradford merged 3 commits into
cloud-hypervisor:mainfrom
Coffeeri:upstream/add-no-shutdown

Conversation

@Coffeeri

@Coffeeri Coffeeri commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

This PR introduces a --no-shutdown flag to the CLI, allowing higher-level management layers such as libvirt to handle guest-triggered shutdowns without losing VM state tracking. This behavior is analogous to QEMU's -no-shutdown. When the flag is set and the guest triggers a shutdown, the CH process remains running, allowing the management layer to gracefully clean up and track the shutdown VM state.

We do the following:

  1. Split guest-induced shutdown handling from EpollDispatch::Exit into a new EpollDispatch::GuestExit.
  2. Add the --no-shutdown CLI flag.
  3. When the flag is set, a guest-triggered shutdown invokes vm_shutdown() instead of vmm_shutdown(), allowing the VMM to remain active and preserving VM state for external management.

This PR upstreams most of cyberus-technology#104 from our fork, with the exception of cyberus-technology@6416bbf, as the full migration implementation is not upstreamed yet.

It also closes #8005.

@Coffeeri
Coffeeri requested a review from a team as a code owner April 15, 2026 07:13
@Coffeeri
Coffeeri force-pushed the upstream/add-no-shutdown branch from c15ddc0 to 5b6f396 Compare April 15, 2026 07:21

@phip1611 phip1611 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very good to have that upstream soon!

nit: the commit messages should speak about management software in general (e.g. libvirt) and that this streamlines the behavior with QEMU.

Introduce a dedicated guest_exit_evt and a matching epoll dispatch
path for guest-triggered shutdowns.

This series is needed because managment software such as libvirt may
still need the Cloud Hypervisor process to stay alive after the guest
has shut down.
Today a guest-triggered shutdown can make the VMM disappear immediately,
which means the managment software can lose track of the VM run-state.

This must only apply to guest-triggered shutdowns. Fatal error paths
and other internal exit paths must keep using the existing VMM exit
handling.

For now GuestExit still calls vmm_shutdown(), so this commit only adds
the separate plumbing and keeps the current behavior unchanged.

On-behalf-of: SAP [email protected]
Signed-off-by: Leander Kohler <[email protected]>
Plumb ACPI S5 shutdown through guest_exit_evt instead of the shared
exit path.

This keeps guest-triggered shutdown separate from fatal VMM exit
handling. Management software, for example libvirt, expects that
distinction, and making it explicit aligns Cloud Hypervisor more
closely with QEMU.

Only the guest shutdown path is moved here. Reboot handling stays on
reset_evt and non-guest exit paths are left unchanged.

On-behalf-of: SAP [email protected]
Signed-off-by: Leander Kohler <[email protected]>
Add a CLI-only --no-shutdown flag that keeps the VMM process alive
after a guest-triggered shutdown.

Management software may still need the Cloud Hypervisor process
after the guest has powered off. Exposing this separately lets
management software, for example libvirt, keep the VMM around in a
way that is closer to QEMU.

The flag only affects the GuestExit path. Fatal exits and other
existing VMM shutdown paths remain unchanged.

On-behalf-of: SAP [email protected]
Signed-off-by: Leander Kohler <[email protected]>
@rbradford

Copy link
Copy Markdown
Member

I feel like this a good solution to #8005 ?

@Coffeeri

Coffeeri commented Apr 15, 2026

Copy link
Copy Markdown
Contributor Author

I feel like this a good solution to #8005 ?

Great, I didn't even see the open issue.
This change addresses most of the problem by separating guest-triggered shutdown from the VMM exit path.
I think it makes sense to keep the current behavior as the default and make the new behavior opt-in, similar to how QEMU handles it. The --no-shutdown flag seems like a reasonable approach for that.

@EpicStep do you have any remarks?

@rbradford

Copy link
Copy Markdown
Member

Can you comment on that issue (or here) using the same style table with your option as additional variable

@EpicStep

Copy link
Copy Markdown
Contributor

@Coffeeri Thanks for this! The solution looks good to me - it should fix the issue I was experiencing 👍

@rbradford
rbradford added this pull request to the merge queue Apr 15, 2026
Merged via the queue into cloud-hypervisor:main with commit 005ce38 Apr 15, 2026
38 checks passed
@Coffeeri
Coffeeri deleted the upstream/add-no-shutdown branch April 15, 2026 19:42
@rbradford rbradford moved this to ✅ Done in Cloud Hypervisor Roadmap Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Daemon process exits on guest-initiated shutdown, but not on API vm.shutdown

4 participants