The output format (eg. C<qcow2>).
+=item C<$guest_arch>
+
+The guest architecture (eg. "x86_64"). This is the output of the
+C<guest-arch> probe. If the template doesn't provide that, it
+defaults to the cluster node's host architecture.
+
=item C<$name>
The hostname.
The template MAY print the disk type supported by this guest. Possible
values include C<ide>, C<virtio>, C<virtio-scsi>.
+=item guest-arch
+
+The template MAY print the guest architecture.
+
+If supplied, this acts as a hint when generating the XML in the C<mclu
+boot> subcommand. The default is to assume the guest architecture is
+the same as the cluster host on which the guest runs.
+
=item minimum-memory
The template MAY print the minimum memory (RAM) required by this
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 remote_arch with
+ match guest_arch with
| "aarch64" ->
Some ("/usr/share/edk2.git/aarch64/QEMU_EFI-pflash.raw",
"/usr/share/edk2.git/aarch64/vars-template-pflash.raw",
<boot dev='hd'/>
" in
let xml =
- match remote_arch with
+ match guest_arch with
+ | "arm" | "armv7" | "armv7l" | "armv7hl" ->
+ xml ^ "\
+ <type arch='armv7l' machine='virt'>hvm</type>
+"
| "aarch64" ->
- xml ^ sprintf "\
+ xml ^ "\
<type machine='virt'>hvm</type>
"
| _ ->
</console>
" in
let xml =
- if remote_arch = "x86_64" then (
- 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'/>
<model type='cirrus' vram='9216' heads='1'/>
</video>
"
- ) else
- xml in
+ | _ -> xml in
let xml = xml ^ "\
</devices>
</domain>" in
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
type template_info = {
base_image : string;
+ guest_arch : string option;
minimum_memory : int64 option;
recommended_memory : int64 option;
minimum_size : int64 option;
| _ ->
eprintf "mclu: cannot parse '%s base-image'\n" filename;
exit 1 in
+ let guest_arch =
+ match run_template ~verbose filename "guest-arch" [] with
+ | Some [arch] -> Some arch
+ | _ -> None in
let minimum_memory =
match run_template ~verbose filename "minimum-memory" [] with
| Some [memory] ->
| Some _ -> false in
{ base_image = base_image;
+ guest_arch = guest_arch;
minimum_memory = minimum_memory;
recommended_memory = recommended_memory;
minimum_size = minimum_size;
type template_info = {
base_image : string;
+ guest_arch : string option;
minimum_memory : int64 option;
recommended_memory : int64 option;
minimum_size : int64 option;