diff --git a/lib/qemu_sandbox.ml b/lib/qemu_sandbox.ml index 23d3f716..02beb4f5 100644 --- a/lib/qemu_sandbox.ml +++ b/lib/qemu_sandbox.ml @@ -102,7 +102,7 @@ let run ~cancelled ?stdin ~log t config result_tmp = Os.exec (ssh @ ["doas"; "fsck"; "-y"; dev]) >>= fun () -> Os.exec (ssh @ ["doas"; "mount"; dev; dst]) | Windows -> - Os.exec (ssh @ ["cmd"; "/c"; "rmdir /s /q '" ^ dst ^ "'"]) >>= fun () -> + Os.exec (ssh @ ["cmd"; "/c"; "if exist '" ^ dst ^ "' rmdir /s /q '" ^ dst ^ "'"]) >>= fun () -> let drive_letter = String.init 1 (fun _ -> Char.chr (Char.code 'd' + i)) in Os.exec (ssh @ ["cmd"; "/c"; "mklink /j '" ^ dst ^ "' '" ^ drive_letter ^ ":\\'"]) ) config.Config.mounts >>= fun () -> @@ -126,6 +126,16 @@ let run ~cancelled ?stdin ~log t config result_tmp = Os.process_result ~pp proc2 >>= fun res -> copy_log >>= fun () -> + Lwt_list.iter_s (fun { Config.Mount.dst; _ } -> + match t.qemu_guest_os with + | Linux + | OpenBSD -> Lwt.return_unit + | Windows -> + (* if the junction isn't removed and the target drive is missing, then `mkdir -p /foo` fails *) + (* also note that `fsutil reparsepoint delete ` only works if the target exists *) + Os.exec (ssh @ ["cmd"; "/c"; "rmdir '" ^ dst ^ "'"]) + ) config.Config.mounts >>= fun () -> + (match t.qemu_guest_arch with | Amd64 -> Log.info (fun f -> f "Sending QEMU an ACPI shutdown event"); diff --git a/qemu/autounattend.xml.m4 b/qemu/autounattend.xml.m4 index 54ed74dc..72284dea 100644 --- a/qemu/autounattend.xml.m4 +++ b/qemu/autounattend.xml.m4 @@ -248,7 +248,7 @@ 20 - netsh advfirewall firewall set rule group="OpenSSH SSH Server Preview (sshd)" new profile=any enable=yes + netsh advfirewall firewall set rule name="OpenSSH SSH Server Preview (sshd)" new profile=any enable=yes Configure OpenSSH