Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(spaces): boot local Windows VMs from AHCI like the image build (#4851)

ddupont7d0354fdfbe4
diff --git a/libs/cua/crates/cua-vmm/src/qemu/args.rs b/libs/cua/crates/cua-vmm/src/qemu/args.rs
index 12e9dbb7a4..526bdfa2f0 100644
--- a/libs/cua/crates/cua-vmm/src/qemu/args.rs
+++ b/libs/cua/crates/cua-vmm/src/qemu/args.rs
@@ -134,7 +134,20 @@ pub fn build(cfg: &LaunchConfig) -> Vec<String> {
cfg.disk_format
),
]);
- push(&["-device", "virtio-blk-pci,drive=disk0,bootindex=1"]);
+ // Windows boots from AHCI, as its image is built and validated: its
+ // virtio storage driver is not a boot driver there, so over virtio-blk
+ // it cannot find its system volume and lands in WinRE. Everything else
+ // boots virtio.
+ if cfg.os == GuestOs::Windows {
+ push(&[
+ "-device",
+ "ahci,id=ahci",
+ "-device",
+ "ide-hd,drive=disk0,bus=ahci.0,bootindex=1",
+ ]);
+ } else {
+ push(&["-device", "virtio-blk-pci,drive=disk0,bootindex=1"]);
+ }
if let Some(seed) = &cfg.seed_iso {
push(&[
"-drive",
@@ -396,6 +409,32 @@ mod tests {
assert!(has(&a, ["-device", "scsi-cd,drive=cd0,bootindex=0"]));
}
+ /// The Windows image is built and validated (libs/images/windows-2022/
+ /// build-image.sh, scripts/images/image-doctor-windows.sh) on AHCI: over
+ /// virtio-blk it cannot find its system volume and lands in WinRE
+ /// (#4777).
+ #[test]
+ fn windows_guest_boots_from_ahci_like_the_image_build() {
+ let mut c = cfg(Arch::X86_64, "kvm");
+ c.os = GuestOs::Windows;
+ c.seed_iso = None;
+ let a = build(&c);
+ assert!(has(&a, ["-device", "ahci,id=ahci"]), "{a:?}");
+ assert!(
+ has(&a, ["-device", "ide-hd,drive=disk0,bus=ahci.0,bootindex=1"]),
+ "{a:?}"
+ );
+ assert!(!a.iter().any(|x| x.starts_with("virtio-blk-pci")), "{a:?}");
+
+ // Linux guests keep virtio.
+ let a = build(&cfg(Arch::X86_64, "kvm"));
+ assert!(has(
+ &a,
+ ["-device", "virtio-blk-pci,drive=disk0,bootindex=1"]
+ ));
+ assert!(!a.iter().any(|x| x.starts_with("ahci")));
+ }
+
#[test]
fn disk_format_from_extension() {
assert_eq!(disk_format_for("a/b.QCOW2".as_ref()), "qcow2");