Skip to content

Commit b172bca

Browse files
authored
Merge pull request #196 from mtelvers/pin-on-windows
Fix pin on Windows
2 parents 29cde86 + 791ecf4 commit b172bca

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

lib/qemu_sandbox.ml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ let run ~cancelled ?stdin ~log t config result_tmp =
102102
Os.exec (ssh @ ["doas"; "fsck"; "-y"; dev]) >>= fun () ->
103103
Os.exec (ssh @ ["doas"; "mount"; dev; dst])
104104
| Windows ->
105-
Os.exec (ssh @ ["cmd"; "/c"; "rmdir /s /q '" ^ dst ^ "'"]) >>= fun () ->
105+
Os.exec (ssh @ ["cmd"; "/c"; "if exist '" ^ dst ^ "' rmdir /s /q '" ^ dst ^ "'"]) >>= fun () ->
106106
let drive_letter = String.init 1 (fun _ -> Char.chr (Char.code 'd' + i)) in
107107
Os.exec (ssh @ ["cmd"; "/c"; "mklink /j '" ^ dst ^ "' '" ^ drive_letter ^ ":\\'"])
108108
) config.Config.mounts >>= fun () ->
@@ -126,6 +126,16 @@ let run ~cancelled ?stdin ~log t config result_tmp =
126126
Os.process_result ~pp proc2 >>= fun res ->
127127
copy_log >>= fun () ->
128128

129+
Lwt_list.iter_s (fun { Config.Mount.dst; _ } ->
130+
match t.qemu_guest_os with
131+
| Linux
132+
| OpenBSD -> Lwt.return_unit
133+
| Windows ->
134+
(* if the junction isn't removed and the target drive is missing, then `mkdir -p <dst>/foo` fails *)
135+
(* also note that `fsutil reparsepoint delete <dst>` only works if the target exists *)
136+
Os.exec (ssh @ ["cmd"; "/c"; "rmdir '" ^ dst ^ "'"])
137+
) config.Config.mounts >>= fun () ->
138+
129139
(match t.qemu_guest_arch with
130140
| Amd64 ->
131141
Log.info (fun f -> f "Sending QEMU an ACPI shutdown event");

qemu/autounattend.xml.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@
248248
</SynchronousCommand>
249249
<SynchronousCommand wcm:action="add">
250250
<Order>20</Order>
251-
<CommandLine>netsh advfirewall firewall set rule group="OpenSSH SSH Server Preview (sshd)" new profile=any enable=yes</CommandLine>
251+
<CommandLine>netsh advfirewall firewall set rule name="OpenSSH SSH Server Preview (sshd)" new profile=any enable=yes</CommandLine>
252252
<Description>Configure OpenSSH</Description>
253253
</SynchronousCommand>
254254
<SynchronousCommand wcm:action="add">

0 commit comments

Comments
 (0)