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.git/aarch64/QEMU_EFI-pflash.raw",
+ "/usr/share/edk2.git/aarch64/vars-template-pflash.raw",
+ remote_image ^ ".nvram")
+ | _ -> None in
(* Get ready to generate the guest XML. *)
let vcpus = !vcpus in
let xml = xml ^ "\
<os>
- <type>hvm</type>
<boot dev='hd'/>
" in
+ let xml =
+ match guest_arch with
+ | "arm" | "armv7" | "armv7l" | "armv7hl" ->
+ xml ^ "\
+ <type arch='armv7l' machine='virt'>hvm</type>
+"
+ | "aarch64" ->
+ xml ^ "\
+ <type machine='virt'>hvm</type>
+"
+ | _ ->
+ xml ^ "\
+ <type>hvm</type>
+" in
+
+ let xml =
+ match nvram with
+ | Some (loader, nvram_template, nvram) ->
+ xml ^ sprintf "\
+ <loader readonly='yes' type='pflash'>%s</loader>
+ <nvram template='%s'>%s</nvram>
+" loader nvram_template nvram
+ | None -> xml in
let xml = xml ^
if template_info.Template.needs_external_kernel then
<apic/>
<pae/>
</features>
- <cpu mode='host-model' fallback='allow' />
+ <cpu mode='host-passthrough'/> <!-- -cpu host, also allows nested -->
<clock offset='utc'>
<timer name='rtc' tickpolicy='catchup'/>
<timer name='pit' tickpolicy='delay'/>
<console type='pty'>
<target type='serial' port='0'/>
</console>
+" in
+ let xml =
+ match guest_arch with
+ | "i386" | "i486" | "i586" | "i686"
+ | "x86_64" ->
+ xml ^ "\
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<video>
<model type='cirrus' vram='9216' heads='1'/>
</video>
+"
+ | _ -> xml in
+ let xml = xml ^ "\
</devices>
</domain>" in
xml
fpf "export LIBGUESTFS_BACKEND_SETTINGS=network_bridge=br0\n";
fpf "export base_image=%s\n" (quote template_info.Template.base_image);
fpf "export format=%s\n" (quote format);
+ fpf "export guest_arch=%s\n" (quote guest_arch);
fpf "export name=%s\n" (quote name);
fpf "export output=%s\n" (quote remote_image);
(match size with
| "" -> ()
| tz -> fpf "export timezone=%s\n" (quote (sprintf "--timezone %s" tz))
);
+ (match nvram with
+ | Some (_, nvram_template, nvram) ->
+ fpf "cp %s %s\n" (quote nvram_template) (quote nvram)
+ | None -> ()
+ );
fpf "%s build\n" remote_template;
if template_info.Template.needs_external_kernel then (
fpf "rm -rf %s\n" (quote remote_external_kernel_dir);