Repository navigation
openvmm: pin the gdb stub's detach when a debugger session ends - #2121
Merged
Merged
Conversation
OpenVMM's gdb stub never told the partition that the debugger had gone (#2094). After GDB detached, its connection dropped, or the debug worker stopped, the partition went on treating the debugger as attached: the session's hardware breakpoints and single-stepping stayed set on the VPs, the halts that followed, a power-off, reset, or triple fault included, went to the gone debugger instead of the VM's client, and a paused VM that a debugger's break held stayed held until a new session or a clear-halt. nvx never starts the gdb stub, so only a host debugging session reaches this. Pin 1633b3797af878bc9a7c42e4b9c57a2925799d5d, the head of microsoft/openvmm#5280, three commits on 043083f40, the head of microsoft/openvmm#5279, which NVX pins below this commit: - vmm_core: forget a debugger's halt reports when it detaches. A detach clears the partition's record that it told the debugger of the recorded halt, which the next session's first resume took for the debugger continuing from a halt recorded after the detach, such as a power-off, and so ran the VM again. It reports the recorded halt to the client only when the halt went to the debugger instead, no longer a second time when the client heard of it before the debugger attached. - vmm_core: clear VP debug state on detach only if the debugger set it, since the ARM64 backends of KVM and OpenHCL, which implement no guest debugging, panic when asked to clear it, which aborts the VMM. - debug_worker: detach the debugger when its session ends. The stub attaches through a guard that sends DebugRequest::Detach when it is dropped, however the session ends: GDB's D or k packet, a target exit, an error such as a dropped connection, or the worker dropping the session as it stops or restarts. The guard also forgets the session's hardware breakpoints, which the next session's first resume set on the VPs again. The Guide's gdbstub page says what a detach does. No saved state, protocol, ABI, or format, and no version of any of them, changes. NVX needs no coordinated change: the protocol vectors, the source excerpts, the contract versions, the activation bound, and the CPU profiles that nvx copies from OpenVMM match the revision's. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…enVMM roadmap Map positions 386-388, the commits of microsoft/openvmm#5280, which NVX now pins at 1633b3797, 262 commits past the mapped tip, on 043083f40, the head of microsoft/openvmm#5279, whose position 385 follows position 384, 44747bf1c, the head of microsoft/openvmm#5278, whose position follows position 383, fa239c823, the head of feature/microvm/dev since microsoft/openvmm#5277 landed it: - 386, vmm_core: forget a debugger's halt reports when it detaches. A detach clears halt_reported, which the next session's first resume took for the debugger continuing from a halt recorded after the detach, and reports the recorded halt to the client only when the halt went to the debugger instead, which position 150's record_halt now records through DebuggerState::route_halt. - 387, vmm_core: clear VP debug state on detach only if the debugger set it, since the ARM64 backends of KVM and OpenHCL panic on any request to set it. - 388, debug_worker: detach the debugger when its session ends. The stub attaches through a guard that sends DebugRequest::Detach when it is dropped, however the session ends, and forgets the session's hardware breakpoints; the Guide's gdbstub page says what a detach does. They are not fixups and stay unassigned to a PR: the missing detach and the defects of its handling are upstream's, and positions 150 and 372, whose record_halt line and debugger tests they change or extend, are not assigned to PRs. In partition_unit/debug.rs, they change upstream's handling of Detach and SetDebugState, beside position 372's hold, not the halt reasons that position 054 maps. No chain commit changes the debug worker, and none of the 43 that change Cargo.lock changes the entry of debug_worker. Of positions 373-385, only 378 and 384 change one of their files, other packages' entries of Cargo.lock. Replaying them on upstream main, 8d4e03132, conflicts in partition_unit.rs, partition_unit/debug.rs, and debug_rpc.rs, which lack the code of positions 150 and 372, so they cannot go upstream on their own. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the roadmap update pinning the debugger-session cleanup fix.
No open issues 🎉
What changed in this PR
This PR pins OpenVMM’s debugger-session cleanup fix for #2094 and records it in NVX’s upstream roadmap. The fix detaches ended debugger sessions so their hardware breakpoints, stepping state, and halt routing do not persist.
Changes:
- Updates the roadmap’s pinned revision to
1633b3797, at position 388. - Maps commits 386–388 and updates chain counts and ranges.
- Documents the fixes, regression coverage, and dependencies affecting upstream submission.
| File | Description |
|---|---|
doc/openvmm-upstream-roadmap.md |
Records the new pin and maps the three debugger-detach commits, including their rationale and upstream dependencies. |
Review effort: Balanced
Base automatically changed from
agents/issue-2093-virtiofs-hidden-entries
to
dev
November 25, 2026 06:11
Pedro Henrique Penna (ppenna)
deleted the
agents/issue-2094-gdb-detach
branch
November 25, 2026 06:33
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.
Fixes #2094
Stacked on #2120 (
agents/issue-2093-virtiofs-hidden-entries), itself stacked on #2119 and the pull requests below it; only the top two commits belong to this pull request (see OpenVMM pin for the landing order).What does this pull request change?
With OpenVMM's gdb stub (
--gdb), the end of a debugger session now detaches the debugger from the VM, whether GDB detaches, its connection drops, or the debug worker stops or restarts. The partition then clears the session's hardware breakpoints and single-stepping, reports the VM's halts, such as a guest power-off, reset, or triple fault, to its client again rather than to the gone debugger, and ends the hold that a debugger's break into a paused VM takes (#1374). Before, the stub never sentDebugRequest::Detach, so all three outlived the session, and the next session's first resume set the previous session's hardware breakpoints on the VPs again. A VM that the debugger stopped stays halted after the detach, as the partition's handling ofDetachalready intended: its client hears of that halt, andclear-haltresumes it. nvx never starts the gdb stub, so only host debugging sessions reach this.The fix is in OpenVMM, microsoft/openvmm#5280, which this pull request pins:
vmm_core: forget a debugger's halt reports when it detaches. A detach clearshalt_reported, which the next session's first resume took for the debugger continuing from a halt recorded after the detach, and reports the recorded halt to the client only when the halt went to the debugger instead, whichrecord_haltnow records throughDebuggerState::route_halt. Two tests in the partition unit's debugger tests.vmm_core: clear VP debug state on detach only if the debugger set it, since the ARM64 backends of KVM and OpenHCL panic on any request to set it, which aborts the VMM. One test.debug_worker: detach the debugger when its session ends.run_state_machineattaches through aSessionguard of the worker's VM proxy (VmProxy::attach), which sendsDetachwhen it is dropped, however the session ends, and forgets the proxy's hardware breakpoints, stepping, and stop channel.DebugRequest::Detach's documentation and the Guide's gdbstub page say what a detach does. Four tests, which run the stub on a loopback TCP connection, send GDB's packets, and serve the stub's requests as the partition does.The NVX commits are the gitlink-only pin and the mapping of the commits, positions 386-388, in the OpenVMM roadmap. Start with the OpenVMM diff:
git diff --submodule=diff origin/agents/issue-2093-virtiofs-hidden-entries...HEAD, at theSessionguard inworkers/debug_worker/src/gdb/mod.rsandrun_state_machineinworkers/debug_worker/src/lib.rs, thenhandle_gdb'sDetachinvmm_core/src/partition_unit/debug.rs, then the tests at the ends ofworkers/debug_worker/src/lib.rsandvmm_core/src/partition_unit.rs.Left out and limitations:
Detach.Why is this change needed?
Root cause: upstream's
run_state_machine(workers/debug_worker/src/lib.rs) sendsAttach,Resume, andBreakas a session starts, and returned without aDetachfrom every way the session ends: GDB'sDorkpacket and a target exit, which reachGdbStubStateMachine::Disconnected; an error, such as the read or packet error with which a dropped connection ends the session, which never reachesDisconnected, unlike what the issue assumed; and the worker dropping the session's future as it stops or restarts. The partition's handling ofDetach(PartitionUnitRunner::handle_gdb), which therefore never ran, had three defects that sending it would expose, which the first two OpenVMM commits fix:halt_reportedset, so the next session's first resume cleared a halt recorded after the detach, such as a power-off, and ran the VM again;unimplemented!()), and so would have aborted the VMM at every detach; the code review of this change found it.Alternatives rejected:
Detachonly when the state machine reachesDisconnected, as the issue suggests: a dropped connection ends the session with an error instead, and the worker drops the session when it stops or restarts, so neither would detach. A guard that sends it when the session is dropped covers every end.Detachkeeps such a VM halted and hands the halt to the client, whoseclear-haltresumes it, so that a debugger that goes away mid-session does not let the guest run on unobserved; this change keeps that.set_debug_state(None): it would change backends for a stub that does not otherwise set debug state on them; clearing only what the session set leaves them alone.How was this change validated?
Checks and results. "Before" is OpenVMM
d44a113be, the head offeature/microvm/devwhen this work started, with the new tests only; "after" is the fix, asb3f686464,66f661610, and41fb8512fond44a113beand, after the rebase onto microsoft/openvmm#5279, as the pinnedf06060dfe,320e09cf5, and1633b3797, whose patchesgit range-diffreports equal.cargo nextest run --profile agent -p vmm_core --features gdb -E 'test(/debugger/)', Windows 11 x64detach_hands_the_halt_that_the_debugger_took_to_the_clientfails: the second debugger is told of a break, and the power-off is cleared;detach_leaves_the_client_a_halt_that_it_already_hasfails: the client hears of the halt twicedetach_clears_no_debug_state_that_the_debugger_did_not_set, Windows 11 x64cargo nextest run --profile agent -p debug_worker, Windows 11 x64Detachends a session--stress-count 50)cargo check,cargo clippy --all-targets -- -D warnings, andcargo doc --no-depsofvmm_core(with and withoutgdb),vmm_core_defs, anddebug_worker, Windows 11 x64d44a113beand at1633b3797cargo nextest run --profile agentofvmm_core(with and withoutgdb),debug_worker, andvmm_core_defs, Windows 11 x64d44a113beand at1633b3797; each of the three commits builds and passes the tests ofvmm_coreanddebug_workercargo nextest run --profile agent -p vmm_core -p debug_worker --features vmm_core/gdb, then-p vmm_core, andcargo clippy --all-targets -- -D warningsof both, on nvx-kvm-test (Azure Linux 3, kernel 6.18, x86_64, Rust 1.97.1)d44a113be)cargo xtask fmtd44a113beand at1633b3797cargo test --locked --manifest-path nvx/Cargo.toml --no-default-features --test openvmm_vectors -- --ignored, and the same with--test openvmm_cpu_profilesnvxcopies are unchangedpython scripts/openvmm_pin.py check-branch --topic --target origin/agents/issue-2093-virtiofs-hidden-entries,python scripts/openvmm_pin.py check-roadmap --worktree,python scripts/check_markdown_links.py,git diff --check,python scripts/nvx.py verifypython scripts/local_gates.py --base origin/agents/issue-2093-virtiofs-hidden-entries --run --keep-goingtest-changes,markdown-links,test-layout,openvmm-vectors, andopenvmm-cpu-profilespass.nvx-cli, whose Python tests this change does not reach, since it changes no Python or script, ran 1,961 tests, throughtest_openvmm_pin, in 90 minutes on this loaded workstation before I stopped it, with one error: thetcp-missedsubtest oftest_private_network_ingress_script_checks_policy_and_traffic, whose shell script exceeded its 10 s timeout under Git'ssh, also when run alone. NVX CI'sNVX CLI / LinuxandNVX CLI / Windowspass the whole gate on this head (below).openvmm-ciis the next row's checkpython scripts/nvx.py check-openvmm-ci --revision 1633b3797af878bc9a7c42e4b9c57a2925799d5dunit tests [x64-linux]andunit tests [x64-windows]ran the seven new testsCI: this head's run 45551161300 passed, with the microVM scenarios on KVM, MSHV, and WHP, the NVX CLI jobs on Linux and Windows, and the check of OpenVMM's CI of the pin. Copilot reviewed this head and raised no issue.
A code review of the whole OpenVMM diff found the ARM64 panic above, which
vmm_core: clear VP debug state on detach only if the debugger set itfixes, and that the Guide's new paragraph promised to clear GDB's software breakpoints, which it now says a lost connection leaves in guest memory.Backend, host OS, host type, and guest: unit tests only, on Windows 11 x64 and on nvx-kvm-test, a virtual machine; the change is platform-independent and has no effect without an attached gdb stub, which nvx does not start, so no microVM scenario reaches it. nvx-kvm-test stopped responding after the rebase, so the Linux runs at the rebased
1633b3797are OpenVMM CI's.Left to CI: NVX's microVM jobs on KVM, MSHV, and WHP; OpenVMM's VMM tests, which passed for this pin in the run above, and none of which uses the gdb stub.
run vmm-tests [x64-windows-amd-snp]failed in that run; NVX does not require it, and it fails at microsoft/openvmm#5277 and #5278 too.Checklist
python3 scripts/check_test_layout.pychecks.python3 scripts/check_test_changes.py --base origin/devlists no changeto an existing test, or a Changes to existing tests section below
explains each one.
.github/copilot-instructions.mdand the skills when a convention orworkflow changes.
nvxupdatesnvx/public-api/withpython3 scripts/public_api.py --update.description says how the change versions or migrates them.
Changes to existing tests
None:
python scripts/check_test_changes.py --base origin/agents/issue-2093-virtiofs-hidden-entrieslists no change to an existing test, and the OpenVMM pull request adds seven tests and changes none.OpenVMM pin
1633b3797af878bc9a7c42e4b9c57a2925799d5d, three commits on043083f40, the head of [DO NOT REVIEW] virtiofs: count only shown entries toward a microVM listing's bound openvmm#5279, which the base branch pins.44747bf1c, position 384) and [DO NOT REVIEW] virtiofs: count only shown entries toward a microVM listing's bound openvmm#5279 (043083f40, position 385), both open, which sandbox: report why OpenVMM fails during startup, such as an io-uring set-up error #2119 and openvmm: pin microVM listing bounds that count only shown entries #2120 pin. They followfa239c823, position 383, the head offeature/microvm/devsince [DO NOT REVIEW] virt_whp: write no internal activity state with the user-mode APIC openvmm#5277 landed it.b3f686464,66f661610, and41fb8512fond44a113be, on which the before-and-after and Linux evidence above was collected, asgit range-diffreports; the rebase onto [DO NOT REVIEW] virtiofs: count only shown entries toward a microVM listing's bound openvmm#5279 applied without conflicts, and positions 376-385 change none of their files apart from other packages' entries ofCargo.lock.record_haltline and debugger tests they change or extend, are not assigned to PRs. They cannot go upstream on their own: replaying them on upstream main,8d4e03132, conflicts inpartition_unit.rs,partition_unit/debug.rs, anddebug_rpc.rs.DebugRequestkeeps its variants, and the protocol vectors and CPU profiles thatnvxcopies are unchanged.feature/microvm/devexactly to1633b3797af878bc9a7c42e4b9c57a2925799d5d(not with the merge button, which squashes) before this pull request merges;python scripts/openvmm_pin.py land 1633b3797af878bc9a7c42e4b9c57a2925799d5d --remote originfinds that fast-forward.