mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
mllib: Add a function to test if a guest is "unix-like".
This is not a precise replacement, since we now allow SSH key injection into Minix, but that is probably correct anyway.
This commit is contained in:
@@ -346,12 +346,11 @@ exec >>%s 2>&1
|
||||
do_run ~display:cmd ~warn_failed_no_network:true cmd
|
||||
|
||||
| `SSHInject (user, selector) ->
|
||||
(match g#inspect_get_type root with
|
||||
| "linux" | "freebsd" | "netbsd" | "openbsd" | "hurd" ->
|
||||
if unix_like (g#inspect_get_type root) then (
|
||||
message (f_"SSH key inject: %s") user;
|
||||
Ssh_key.do_ssh_inject_unix g user selector
|
||||
| _ ->
|
||||
warning (f_"SSH key could be injected for this type of guest"))
|
||||
) else
|
||||
warning (f_"SSH key could be injected for this type of guest")
|
||||
|
||||
| `Truncate path ->
|
||||
message (f_"Truncating: %s") path;
|
||||
|
||||
@@ -1079,6 +1079,14 @@ let guest_arch_compatible guest_arch =
|
||||
| "x86_64", "i386" -> true
|
||||
| _ -> false
|
||||
|
||||
(* Is the guest OS "Unix-like"? *)
|
||||
let unix_like = function
|
||||
| "hurd"
|
||||
| "linux"
|
||||
| "minix" -> true
|
||||
| typ when String.is_suffix typ "bsd" -> true
|
||||
| _ -> false
|
||||
|
||||
(** Return the last part of a string, after the specified separator. *)
|
||||
let last_part_of str sep =
|
||||
try
|
||||
|
||||
@@ -426,6 +426,10 @@ val guest_arch_compatible : string -> bool
|
||||
(** Are guest arch and host_cpu compatible, in terms of being able
|
||||
to run commands in the libguestfs appliance? *)
|
||||
|
||||
val unix_like : string -> bool
|
||||
(** Is the guest OS "Unix-like"? Call this with the result of
|
||||
{!Guestfs.inspect_get_type}. *)
|
||||
|
||||
val last_part_of : string -> char -> string option
|
||||
(** Return the last part of a string, after the specified separator. *)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user