On Tue, Sep 11, 2018 at 12:18:07PM +0300, Mykola Ivanets wrote:
From: Nikolay Ivanets <stenavin(a)gmail.com>
Inspection code checks /etc/mdadm.conf to map MD device paths listed in
mdadm.conf to MD device paths in the guestfs appliance. However on some
operating systems (e.g. Ubuntu) mdadm.conf has alternative location:
/etc/mdadm/mdadm.conf.
This patch consider an alternative location of mdadm.conf as well.
---
daemon/inspect_fs_unix_fstab.ml | 13 ++++++++-----
daemon/inspect_fs_unix_fstab.mli | 3 ++-
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/daemon/inspect_fs_unix_fstab.ml b/daemon/inspect_fs_unix_fstab.ml
index 170440d2c..9d54dadda 100644
--- a/daemon/inspect_fs_unix_fstab.ml
+++ b/daemon/inspect_fs_unix_fstab.ml
@@ -38,14 +38,15 @@ let re_xdev = PCRE.compile
"^/dev/(h|s|v|xv)d([a-z]+)(\\d*)$"
let rec check_fstab ?(mdadm_conf = false) (root_mountable : Mountable.t)
os_type =
- let configfiles =
- "/etc/fstab" :: if mdadm_conf then ["/etc/mdadm.conf"] else []
in
+ let mdadmfiles =
+ if mdadm_conf then ["/etc/mdadm.conf"; "/etc/mdadm/mdadm.conf"]
else [] in
+ let configfiles = "/etc/fstab" :: mdadmfiles in
with_augeas ~name:"check_fstab_aug"
configfiles (check_fstab_aug mdadm_conf root_mountable os_type)
and check_fstab_aug mdadm_conf root_mountable os_type aug =
- (* Generate a map of MD device paths listed in /etc/mdadm.conf
+ (* Generate a map of MD device paths listed in mdadm.conf
* to MD device paths in the guestfs appliance.
*)
let md_map = if mdadm_conf then map_md_devices aug else StringMap.empty in
@@ -224,11 +225,13 @@ and map_md_devices aug =
if StringMap.is_empty uuid_map then StringMap.empty
else (
(* Get all arrays listed in mdadm.conf. *)
- let entries = aug_matches_noerrors aug "/files/etc/mdadm.conf/array" in
+ let entries1 = aug_matches_noerrors aug "/files/etc/mdadm.conf/array" in
+ let entries2 = aug_matches_noerrors aug
"/files/etc/mdadm/mdadm.conf/array" in
+ let entries = List.append entries1 entries2 in
(* Log a debug entry if we've got md devices but nothing in mdadm.conf. *)
if verbose () && entries = [] then
- eprintf "warning: appliance has MD devices, but augeas returned no array
matches in /etc/mdadm.conf\n%!";
+ eprintf "warning: appliance has MD devices, but augeas returned no array
matches in mdadm.conf\n%!";
List.fold_left (
fun md_map entry ->
diff --git a/daemon/inspect_fs_unix_fstab.mli b/daemon/inspect_fs_unix_fstab.mli
index 4778fd962..2ca06debc 100644
--- a/daemon/inspect_fs_unix_fstab.mli
+++ b/daemon/inspect_fs_unix_fstab.mli
@@ -24,7 +24,8 @@ val check_fstab : ?mdadm_conf:bool -> Mountable.t ->
Inspect_types.os_type ->
this function also knows how to map (eg) BSD device names into
Linux/libguestfs device names.
- [mdadm_conf] is true if you want to check [/etc/mdadm.conf] as well.
+ [mdadm_conf] is true if you want to check [/etc/mdadm.conf] or
+ [/etc/mdadm/mdadm.conf] as well.
[root_mountable] is the [Mountable.t] of the root filesystem. (Note
that the root filesystem must be mounted on sysroot before this
Looks fine to me, I'll push it soon, thanks.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html