For domain teardown, things work roughly like this:
- Domain stops execution for whatever reason (shutdown, crash, etc.)
- Xen raises VIRQ_DOM_EXC which is a notification to xenstored.
- xenstored refreshes it's global idea of which domains are alive, sees that dom$X has transitioned to the Shutdown state, and fires the @releaseDomain watch
- Anyone who cares (blk/net-back, userspace daemons inc toolstack) starts cleaning up. Most importantly, unmapping various mappings.
- Toolstack evaluates the on_$FOO actions, and by default will clean up the domain
- Toolstack issues domain_kill() which is a long running hypercall (potentially minutes) which causes various cleanup actions in Xen.
- domain_kill() triggers VIRQ_DOM_EXC a second time, which fires @releaseDomain a second tim