Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pin on Windows #196

Merged
merged 1 commit into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/qemu_sandbox.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 () ->
Expand All @@ -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 <dst>/foo` fails *)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does "junction" mean in this context?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A "junction", or more fully, an NTFS junction point, is a specific type of file system symbolic link available on NTFS.

(* also note that `fsutil reparsepoint delete <dst>` 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");
Expand Down
2 changes: 1 addition & 1 deletion qemu/autounattend.xml.m4
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<Order>20</Order>
<CommandLine>netsh advfirewall firewall set rule group="OpenSSH SSH Server Preview (sshd)" new profile=any enable=yes</CommandLine>
<CommandLine>netsh advfirewall firewall set rule name="OpenSSH SSH Server Preview (sshd)" new profile=any enable=yes</CommandLine>
<Description>Configure OpenSSH</Description>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
Expand Down
Loading