修好 WHP 收攤卡死、補實機 smoke 腳本,並修單 crate 建置 - #135
Merged
Merged
Conversation
CreateJobObjectW 的第一個參數是 SECURITY_ATTRIBUTES,windows-sys 因此把它額外 gate 在 Win32_Security 上。vmm-backend 只宣告了 Win32_System_JobObjects,所以 cargo build -p vmm-backend 會 E0432;workspace 建置時被其他 crate 的 feature 聯集 補上,才一直沒被發現(CI 全綠)。 逐包掃過工作區其餘 9 個 crate,單獨建置皆正常,只有這個少宣告。
workspace 建置會把同一個 crate 的 feature 做聯集,某個 crate 少宣告的 feature 會 被別人補上,直到有人單獨 cargo build -p <crate> 才爆(vmm-backend 的 Win32_Security 就是這樣漏掉的,CI 一路全綠)。AGENTS.md 明寫單 crate 建置是支援 用法,在三個 OS 的 build & test job 各補一輪逐包建置把它鎖住。
上一版的 THRE 中斷雖然讓 guest 的 stdout 出得來,卻讓 app 再也無法正常收攤: VM 跑完服務後停在 HLT,CHEFER_GUEST_EXIT 印不出來,helper 撐到逾時才結束 (實機 A/B 確認:關掉 IRQ 拉線就恢復正常,開著就一定卡)。 兩個真因,都由實機 trace 定位: 1. THRE 被我做成邊緣觸發(讀 IIR 就清)。真硬體是準位——THRI 開著且 THR 空著 就一直拉線。Linux 讀到一次 IIR 卻沒接著寫 THR/IER 時,driver 的 ier 快取仍 認為 THRI 開著、不會重寫 IER,於是再也沒有 IO exit 能重新拉線。 2. PIC 餓死。take_pending_vector 每次只送一條、由小到大挑,而 HLT 分支每一輪 都無條件補 timer IRQ 0 → IRQ 0 永遠贏。trace 抓到 irr=0x11 isr=0x00 imr=0x0A:序列埠一直在等,永遠排不到。改成只有 pending_unmasked() == 0 才補 timer tick。 另補 scripts/whp-smoke.ps1:實體 Windows 上一鍵驗 whp 後端(exit code 傳播、 guest userspace stdout 到 host、TCP 埠轉發、helper 防孤兒)。CI 兩邊都覆蓋不到 這條路徑——windows runner 沒有巢狀虛擬化,QEMU E2E 走的是 virtio-console。 實機驗證:四項檢查全過(exit 7 傳播、[web] 前綴輸出出現在 host、TCP 轉發回 200、單殺 runtime 後 helper 無殘留)。
python 在 Windows 上 stdout 是文字模式,\n 會寫成 \r\n,crate 名字尾巴黏了 CR, cargo 回 invalid character in package name。ubuntu/macOS 不受影響,所以只有 windows-latest 那個 job 紅。
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.
What
收掉
AGENTS.md剩下的兩項 follow-up,並修掉一個上一個 PR 引入的回歸:WHP 上 app 跑完後無法正常收攤。Why / How
1. WHP 收攤卡死(回歸,最重要)
上一個 PR 的 THRE 中斷讓 guest 的 stdout 出得來了,但 app 從此無法正常結束:VM 跑完服務後停在 HLT,
CHEFER_GUEST_EXIT印不出來,helper 撐到逾時。實機 A/B 確認是那個改動造成的(關掉 IRQ 拉線就恢復,開著就一定卡)。兩個真因都由實機 trace 定位:ier快取仍認為 THRI 開著、不會重寫 IER,於是再也沒有 IO exit 能重新拉線。take_pending_vector每次只送一條、由小到大挑,而 HLT 分支每輪無條件補 timer IRQ 0 → IRQ 0 永遠贏。trace 抓到irr=0x11 isr=0x00 imr=0x0A:序列埠一直在等,永遠排不到。改成只有pending_unmasked() == 0才補 timer tick。2.
scripts/whp-smoke.ps1(新增)實體 Windows 上一鍵驗 whp 後端:exit code 傳播、guest userspace stdout 到 host、TCP 埠轉發、helper 防孤兒。CI 兩邊都覆蓋不到這條路徑——windows runner 沒有巢狀虛擬化,QEMU E2E 走的是 virtio-console/hvc0。
3.
cargo build -p vmm-backend單獨建不過CreateJobObjectW的第一個參數是SECURITY_ATTRIBUTES,windows-sys 因此把它額外 gate 在Win32_Security上,而 vmm-backend 只宣告了Win32_System_JobObjects。workspace 建置時被其他 crate 的 feature 聯集補上,所以 CI 一路全綠。順手在三個 OS 的 build & test job 補一輪逐包建置,把這類漏宣告鎖住。Testing
cargo test --workspace全過;cargo fmt --check、cargo clippy --workspace --all-targets無告警serial.rs的「讀 IIR 不得掉線」、pic.rs的「每輪補 timer 會餓死編號較大的 IRQ」scripts/whp-smoke.ps1四項檢查全過Notes
實機過程中另外發現一個既有問題並記進 follow-ups:helper 的 300 秒逾時是整段執行的上限、不是只管開機,等於 WHP 上的 app 五分鐘就會被砍(
CHEFER_WHP_TIMEOUT可蓋過)。smoke 腳本目前自行拉高到 900 秒繞開。這個沒有在本 PR 修——它會改到產品行為,想先讓你決定。