Richard W.M. Jones
2016-Sep-09 15:45 UTC
[Libguestfs] [PATCH 1/2] v2v: linux: Avoid recursive functions.
Just code motion.
---
v2v/convert_linux.ml | 68 +++++++++++++++++++++++++++-------------------------
1 file changed, 36 insertions(+), 32 deletions(-)
diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml
index 7bc1dde..3fd58ce 100644
--- a/v2v/convert_linux.ml
+++ b/v2v/convert_linux.ml
@@ -78,7 +78,7 @@ let rec convert ~keep_serial_console (g : G.guestfs) inspect
source rcaps
(*----------------------------------------------------------------------*)
(* Conversion step. *)
- let rec augeas_grub_configuration () + let augeas_grub_configuration ()
if bootloader#set_augeas_configuration () then
Linux.augeas_reload g
@@ -675,6 +675,41 @@ let rec convert ~keep_serial_console (g : G.guestfs)
inspect source rcaps and configure_kernel_modules block_type net_type (*
This function modifies modules.conf (and its various aliases). *)
+ let augeas_modprobe query + (* Execute g#aug_match, but against every
known location of
+ modules.conf. *)
+ let paths = [
+ "/files/etc/conf.modules/alias";
+ "/files/etc/modules.conf/alias";
+ "/files/etc/modprobe.conf/alias";
+ "/files/etc/modprobe.d/*/alias";
+ ] in
+ let paths + List.map (
+ fun p ->
+ let p = sprintf "%s[%s]" p query in
+ Array.to_list (g#aug_match p)
+ ) paths in
+ List.flatten paths
+
+ and discover_modpath () + (* Find what /etc/modprobe.conf is called
today. *)
+ if g#is_dir ~followsymlinks:true "/etc/modprobe.d" then (
+ (* Create a new file /etc/modprobe.d/virt-v2v-added.conf. *)
+ "/etc/modprobe.d/virt-v2v-added.conf"
+ ) else (
+ (* List of methods, in order of preference. *)
+ let paths = [
+ "/etc/modprobe.conf";
+ "/etc/modules.conf";
+ "/etc/conf.modules"
+ ] in
+ try List.find (g#is_file ~followsymlinks:true) paths
+ with Not_found ->
+ error (f_"unable to find any valid modprobe configuration file
such as /etc/modprobe.conf");
+ )
+ in
+
(* Update 'alias eth0 ...'. *)
let paths = augeas_modprobe ". =~ regexp('eth[0-9]+')" in
let net_device @@ -744,37 +779,6 @@ let rec convert ~keep_serial_console (g
: G.guestfs) inspect source rcaps (* Update files. *)
g#aug_save ()
- and augeas_modprobe query - (* Execute g#aug_match, but against every
known location of modules.conf. *)
- let paths = [
- "/files/etc/conf.modules/alias";
- "/files/etc/modules.conf/alias";
- "/files/etc/modprobe.conf/alias";
- "/files/etc/modprobe.d/*/alias";
- ] in
- let paths - List.map (
- fun p ->
- let p = sprintf "%s[%s]" p query in
- Array.to_list (g#aug_match p)
- ) paths in
- List.flatten paths
-
- and discover_modpath () - (* Find what /etc/modprobe.conf is called today.
*)
- if g#is_dir ~followsymlinks:true "/etc/modprobe.d" then (
- (* Create a new file /etc/modprobe.d/virt-v2v-added.conf. *)
- "/etc/modprobe.d/virt-v2v-added.conf"
- ) else (
- (* List of methods, in order of preference. *)
- let paths = [ "/etc/modprobe.conf";
"/etc/modules.conf"; "/etc/conf.modules" ] in
-
- try
- List.find (g#is_file ~followsymlinks:true) paths
- with Not_found ->
- error (f_"unable to find any valid modprobe configuration file
such as /etc/modprobe.conf");
- )
-
and remap_block_devices block_type (* This function's job is to
iterate over boot configuration
* files, replacing "hda" with "vda" or whatever is
appropriate.
--
2.9.3
Richard W.M. Jones
2016-Sep-09 15:45 UTC
[Libguestfs] [PATCH 2/2] v2v: linux: Use /etc/modprobe.conf.local if it exists.
On SUSE (only) there is /etc/modprobe.conf which is generated from a
/usr/share file. Local changes are meant to be added to
/etc/modprobe.conf.local.
---
v2v/convert_linux.ml | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml
index 3fd58ce..08f4b2a 100644
--- a/v2v/convert_linux.ml
+++ b/v2v/convert_linux.ml
@@ -679,9 +679,10 @@ let rec convert ~keep_serial_console (g : G.guestfs)
inspect source rcaps (* Execute g#aug_match, but against every known
location of
modules.conf. *)
let paths = [
- "/files/etc/conf.modules/alias";
+ "/files/etc/conf.modules/alias"; (* modules_conf.aug
*)
"/files/etc/modules.conf/alias";
- "/files/etc/modprobe.conf/alias";
+ "/files/etc/modprobe.conf/alias"; (* modprobe.aug *)
+ "/files/etc/modprobe.conf.local/alias";
"/files/etc/modprobe.d/*/alias";
] in
let paths @@ -700,6 +701,7 @@ let rec convert ~keep_serial_console (g :
G.guestfs) inspect source rcaps ) else (
(* List of methods, in order of preference. *)
let paths = [
+ "/etc/modprobe.conf.local";
"/etc/modprobe.conf";
"/etc/modules.conf";
"/etc/conf.modules"
--
2.9.3
Apparently Analagous Threads
- [PATCH 0/2] v2v: fix setting custom modprobe options
- [PATCH v2] v2v: factor out bootloader handling
- [PATCH] v2v: factor out bootloader handling
- [V2V PATCH v3 1/6] Revert "Remove guestcaps_block_type Virtio_SCSI"
- [V2V PATCH v2 1/5] Revert "Remove guestcaps_block_type Virtio_SCSI"