From: Richard W.M. Jones Date: Sat, 27 Feb 2016 13:09:09 +0000 (+0000) Subject: Fixes to allow (32 bit) arm guests to run on aarch64 hosts. X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=5f5bfbd6da3c0994be68d163bc3d0bc5205d8609;p=mclu.git Fixes to allow (32 bit) arm guests to run on aarch64 hosts. --- diff --git a/mclu.pod b/mclu.pod index 54bc6f0..e82f14c 100644 --- a/mclu.pod +++ b/mclu.pod @@ -274,6 +274,12 @@ probe. The output format (eg. C). +=item C<$guest_arch> + +The guest architecture (eg. "x86_64"). This is the output of the +C probe. If the template doesn't provide that, it +defaults to the cluster node's host architecture. + =item C<$name> The hostname. @@ -298,6 +304,14 @@ template can choose a default size. The template MAY print the disk type supported by this guest. Possible values include C, C, C. +=item guest-arch + +The template MAY print the guest architecture. + +If supplied, this acts as a hint when generating the XML in the C 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 diff --git a/mclu_boot.ml b/mclu_boot.ml index 6da1bc5..c1054e5 100644 --- a/mclu_boot.ml +++ b/mclu_boot.ml @@ -170,9 +170,17 @@ Try: `mclu on %s'\n" hostname hostname; 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", @@ -204,9 +212,13 @@ Try: `mclu on %s'\n" hostname hostname; " in let xml = - match remote_arch with + match guest_arch with + | "arm" | "armv7" | "armv7l" | "armv7hl" -> + xml ^ "\ + hvm +" | "aarch64" -> - xml ^ sprintf "\ + xml ^ "\ hvm " | _ -> @@ -297,8 +309,10 @@ Try: `mclu on %s'\n" hostname hostname; " in let xml = - if remote_arch = "x86_64" then ( - xml ^ "\ + match guest_arch with + | "i386" | "i486" | "i586" | "i686" + | "x86_64" -> + xml ^ "\ @@ -307,8 +321,7 @@ Try: `mclu on %s'\n" hostname hostname; " - ) else - xml in + | _ -> xml in let xml = xml ^ "\ " in @@ -387,6 +400,7 @@ Try: `mclu on %s'\n" hostname hostname; 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 diff --git a/template.ml b/template.ml index 4db0b66..20a5cc7 100644 --- a/template.ml +++ b/template.ml @@ -73,6 +73,7 @@ let run_template ~verbose filename subcmd args = type template_info = { base_image : string; + guest_arch : string option; minimum_memory : int64 option; recommended_memory : int64 option; minimum_size : int64 option; @@ -98,6 +99,10 @@ let probe ?(verbose = false) filename = | _ -> 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] -> @@ -146,6 +151,7 @@ let probe ?(verbose = false) filename = | Some _ -> false in { base_image = base_image; + guest_arch = guest_arch; minimum_memory = minimum_memory; recommended_memory = recommended_memory; minimum_size = minimum_size; diff --git a/template.mli b/template.mli index bb1d7f2..2cec7b7 100644 --- a/template.mli +++ b/template.mli @@ -26,6 +26,7 @@ val template_names : unit -> string list type template_info = { base_image : string; + guest_arch : string option; minimum_memory : int64 option; recommended_memory : int64 option; minimum_size : int64 option;