Previously the kernel_info field called 'ki_supports_virtio' really
meant that the kernel supports virtio-net. That was used as a proxy
to mean the kernel supports virtio in general.
This change splits the field so we explicitly test for both virtio-blk
and virtio-net drivers, and store the results as separate fields.
The patch is straightforward, except for the change to the
'rebuild_initrd' function. Instead of making the module list
conditional on whether virtio-net is available and using the old
(probably wrong) fallback if it happens to be unavailable, this now
tries to enable the common virtio kernel modules (just the ones needed
for virtio-blk and virtio-net to work). The fallback is only used if
none of the common virtio modules can be found.
---
v2v/convert_linux.ml | 23 +++++++++++++----------
v2v/linux_kernels.ml | 16 +++++++++++-----
v2v/linux_kernels.mli | 3 ++-
3 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml
index c768902cc..77270a629 100644
--- a/v2v/convert_linux.ml
+++ b/v2v/convert_linux.ml
@@ -403,11 +403,12 @@ let rec convert (g : G.guestfs) inspect source output rcaps =
error (f_"only Xen kernels are installed in this guest.\n\nRead the %s(1)
manual, section \"XEN PARAVIRTUALIZED GUESTS\", to see what to do.") prog;
(* Enable the best non-Xen kernel, where "best" means the one with
- * the highest version which supports virtio.
+ * the highest version, preferring non-debug kernels which support
+ * virtio.
*)
let best_kernel =
let compare_best_kernels k1 k2 =
- let i = compare k1.ki_supports_virtio k2.ki_supports_virtio in
+ let i = compare k1.ki_supports_virtio_net k2.ki_supports_virtio_net in
if i <> 0 then i
else (
let i = compare_app2_versions k1.ki_app k2.ki_app in
@@ -446,9 +447,9 @@ let rec convert (g : G.guestfs) inspect source output rcaps =
match kernel.ki_initrd with
| None -> ()
| Some initrd ->
- let virtio = kernel.ki_supports_virtio in
+ (* Enable the basic virtio modules in the kernel. *)
let modules =
- if virtio then
+ let modules =
(* The order of modules here is deliberately the same as the
* order specified in the postinstall script of kmod-virtio in
* RHEL3. The reason is that the probing order determines the
@@ -457,9 +458,12 @@ let rec convert (g : G.guestfs) inspect source output rcaps =
*)
List.filter (fun m -> List.mem m kernel.ki_modules)
[ "virtio"; "virtio_ring";
"virtio_blk";
- "virtio_scsi"; "virtio_net";
"virtio_pci" ]
- else
- [ "sym53c8xx" (* XXX why not "ide"? *) ] in
+ "virtio_scsi"; "virtio_net";
"virtio_pci" ] in
+ match modules with
+ | _::_ -> modules
+ | [] ->
+ (* Fallback copied from old virt-v2v. XXX Why not "ide"? *)
+ [ "sym53c8xx" ] in
(* Move the old initrd file out of the way. Note that dracut/mkinitrd
* will refuse to overwrite an old file so we have to do this.
@@ -1002,7 +1006,6 @@ let rec convert (g : G.guestfs) inspect source output rcaps =
unconfigure_prltools ();
let kernel = configure_kernel () in
- let virtio = kernel.ki_supports_virtio in
if output#keep_serial_console then (
configure_console ();
@@ -1021,12 +1024,12 @@ let rec convert (g : G.guestfs) inspect source output rcaps =
let block_type =
match rcaps.rcaps_block_bus with
- | None -> if virtio then Virtio_blk else IDE
+ | None -> if kernel.ki_supports_virtio_blk then Virtio_blk else IDE
| Some block_type -> block_type in
let net_type =
match rcaps.rcaps_net_bus with
- | None -> if virtio then Virtio_net else E1000
+ | None -> if kernel.ki_supports_virtio_net then Virtio_net else E1000
| Some net_type -> net_type in
configure_display_driver video;
diff --git a/v2v/linux_kernels.ml b/v2v/linux_kernels.ml
index 9fbc43b60..7a253fa04 100644
--- a/v2v/linux_kernels.ml
+++ b/v2v/linux_kernels.ml
@@ -38,18 +38,20 @@ type kernel_info = {
ki_initrd : string option;
ki_modpath : string;
ki_modules : string list;
- ki_supports_virtio : bool;
+ ki_supports_virtio_blk : bool;
+ ki_supports_virtio_net : bool;
ki_is_xen_kernel : bool;
ki_is_debug : bool;
ki_config_file : string option;
}
let string_of_kernel_info ki =
- sprintf "(%s, %s, %s, %s, %s, %s, virtio=%b, xen=%b, debug=%b)"
+ sprintf "(%s, %s, %s, %s, %s, %s, virtio-blk=%b, virtio-net=%b, xen=%b,
debug=%b)"
ki.ki_name ki.ki_version ki.ki_arch ki.ki_vmlinuz
(match ki.ki_initrd with None -> "None" | Some f -> f)
(match ki.ki_config_file with None -> "None" | Some f -> f)
- ki.ki_supports_virtio ki.ki_is_xen_kernel ki.ki_is_debug
+ ki.ki_supports_virtio_blk ki.ki_supports_virtio_net
+ ki.ki_is_xen_kernel ki.ki_is_debug
let detect_kernels (g : G.guestfs) inspect family bootloader =
(* What kernel/kernel-like packages are installed on the current guest? *)
@@ -181,7 +183,10 @@ let detect_kernels (g : G.guestfs) inspect family bootloader =
let kernel_supports what kconf =
List.mem what modules || check_config kconf config_file in
- let supports_virtio = kernel_supports "virtio_net"
"VIRTIO_NET" in
+ let supports_virtio_blk
+ = kernel_supports "virtio_blk" "VIRTIO_BLK" in
+ let supports_virtio_net
+ = kernel_supports "virtio_net" "VIRTIO_NET" in
let is_xen_kernel =
kernel_supports "xennet" "XEN_NETDEV_FRONTEND" in
@@ -202,7 +207,8 @@ let detect_kernels (g : G.guestfs) inspect family bootloader =
ki_initrd = initrd;
ki_modpath = modpath;
ki_modules = modules;
- ki_supports_virtio = supports_virtio;
+ ki_supports_virtio_blk = supports_virtio_blk;
+ ki_supports_virtio_net = supports_virtio_net;
ki_is_xen_kernel = is_xen_kernel;
ki_is_debug = is_debug;
ki_config_file = config_file;
diff --git a/v2v/linux_kernels.mli b/v2v/linux_kernels.mli
index 8d5b9f736..85ef0ee95 100644
--- a/v2v/linux_kernels.mli
+++ b/v2v/linux_kernels.mli
@@ -28,7 +28,8 @@ type kernel_info = {
ki_initrd : string option; (** Path of initramfs, if found. *)
ki_modpath : string; (** The module path. *)
ki_modules : string list; (** The list of module names. *)
- ki_supports_virtio : bool; (** Kernel has virtio drivers? *)
+ ki_supports_virtio_blk : bool; (** Kernel supports virtio-blk? *)
+ ki_supports_virtio_net : bool; (** Kernel supports virtio-net? *)
ki_is_xen_kernel : bool; (** Is a Xen paravirt kernel? *)
ki_is_debug : bool; (** Is debug kernel? *)
ki_config_file : string option; (** Path of config file, if found. *)
--
2.12.0