On Friday 15 May 2015 10:08:09 Richard W.M. Jones wrote:
In cases where we are asked to run commands in the guest (eg.
options
such as --run-command or --install), give a clear error in the cases
where the guest arch is not compatible with the host arch.
---
customize/customize_run.ml | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/customize/customize_run.ml b/customize/customize_run.ml
index 08cff0b..0f1d72a 100644
--- a/customize/customize_run.ml
+++ b/customize/customize_run.ml
@@ -30,6 +30,19 @@ let run ~verbose ~quiet (g : Guestfs.guestfs) root (ops : ops) =
(* Timestamped messages in ordinary, non-debug non-quiet mode. *)
let msg fs = make_message_function ~quiet fs in
+ (* Is the host_cpu compatible with the guest arch? ie. Can we
+ * run commands in this guest?
+ *)
+ let guest_arch = g#inspect_get_arch root in
+ let guest_arch_compatible =
+ match Config.host_cpu, guest_arch with
+ | x, y when x = y -> true
+ | "x86_64",
("i386"|"i486"|"i586"|"i686") -> true
+ (* In theory aarch64 host could run armv7l commands, but it won't
+ * work without libvirt changes. XXX
+ *)
+ | _ -> false in
Isn't this close to what Architecture.arch_is_compatible in
builder/architecture.ml does? It seems so to me, it would just require
filter_arch to map ("i386"|"i486"|"i586"|"i686")
as "i386".
If so, I guess it might be better to adapt that and move Architecture
(with or without Uname) to mllib.
--
Pino Toscano