+ let remote_external_kernel_dir = sprintf "/var/tmp/%s.boot" name in
+ let remote_external_kernel = sprintf "/var/tmp/%s.boot/kernel" name in
+ let remote_external_initrd = sprintf "/var/tmp/%s.boot/initrd" name in
+ let remote_arch = node.MS.node_status.node_info.model in
+
+ (* Guest arch defaults to the node host arch, but can be overridden
+ * in the template.
+ *)
+ let guest_arch =
+ match template_info.Template.guest_arch with
+ | Some arch -> arch
+ | None -> remote_arch in
+
+ (* UEFI firmware and NVRAM on remote, if required. *)
+ let nvram =
+ match guest_arch with
+ | "aarch64" ->
+ Some ("/usr/share/edk2/aarch64/QEMU_EFI-pflash.raw",
+ "/usr/share/edk2/aarch64/vars-template-pflash.raw",
+ remote_image ^ ".nvram")
+ | _ -> None in
+
+ (* Get the name of the remote bridge. *)
+ let bridge =
+ let cmd =
+ sprintf "ssh root@%s brctl show | sort" (quote hostname) in
+ if verbose then printf "%s\n%!" cmd;
+ let chan = Unix.open_process_in cmd in
+ let lines = ref [] in
+ (try while true do lines := input_line chan :: !lines done
+ with End_of_file -> ());
+ let stat = Unix.close_process_in chan in
+ (match stat with
+ | Unix.WEXITED 0 -> ()
+ | Unix.WEXITED i ->
+ eprintf "mclu: 'brctl show' exited with error %d\n" i;
+ exit 1
+ | Unix.WSIGNALED i ->
+ eprintf "mclu: 'brctl show' killed by signal %d\n" i;
+ exit 1
+ | Unix.WSTOPPED i ->
+ eprintf "mclu: 'brctl show' stopped by signal %d\n" i;
+ exit 1
+ );
+ let lines = List.rev !lines in
+ (* A heuristic: Use brX, but if none exist, try virbrX. *)
+ let brname = ref None in
+ let virbrname = ref None in
+ List.iter (
+ fun line ->
+ match Pcre.split ~rex:ws_rex line with
+ | str :: _ when Pcre.pmatch ~rex:br_rex str ->
+ if !brname = None then
+ brname := Some str
+ | str :: _ when Pcre.pmatch ~rex:virbr_rex str ->
+ if !virbrname = None then
+ virbrname := Some str
+ | _ -> ()
+ ) lines;
+
+ match !brname with
+ | Some br -> br
+ | None ->
+ match !virbrname with
+ | Some br -> br
+ | None ->
+ eprintf "mclu: Could not get remote bridge name\n";
+ exit 1 in