daemon: consider /etc/mdadm/mdadm.conf while inspecting mountpoints.

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.
This commit is contained in:
Nikolay Ivanets
2018-09-11 12:18:07 +03:00
committed by Richard W.M. Jones
parent e6895bd9d2
commit eaa9c8cbc6
2 changed files with 10 additions and 6 deletions

View File

@@ -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 ->

View File

@@ -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