Richard W.M. Jones
2017-Apr-06 10:04 UTC
[Libguestfs] [PATCH v4 0/9] v2v: Add drivers for virtio-rng, balloon, pvpanic.
v1: https://www.redhat.com/archives/libguestfs/2017-April/msg00031.html v2: https://www.redhat.com/archives/libguestfs/2017-April/msg00040.html v3: https://www.redhat.com/archives/libguestfs/2017-April/msg00051.html v3 -> v4: - Properly fix Xen PV-only kernel detection, and test it. Rich.
Richard W.M. Jones
2017-Apr-06 10:04 UTC
[Libguestfs] [PATCH v4 1/9] v2v: linux: Don't return virtio flag from configure_kernel function.
This is pure refactoring, no change to functionality. --- v2v/convert_linux.ml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml index 50e013a3a..c768902cc 100644 --- a/v2v/convert_linux.ml +++ b/v2v/convert_linux.ml @@ -424,9 +424,6 @@ let rec convert (g : G.guestfs) inspect source output rcaps if best_kernel <> List.hd bootloader_kernels then bootloader#set_default_kernel best_kernel.ki_vmlinuz; - (* Does the best/bootable kernel support virtio? *) - let virtio = best_kernel.ki_supports_virtio in - (* Update /etc/sysconfig/kernel DEFAULTKERNEL (RHBZ#1176801). *) if g#is_file ~followsymlinks:true "/etc/sysconfig/kernel" then ( let entries @@ -438,7 +435,7 @@ let rec convert (g : G.guestfs) inspect source output rcaps ) ); - best_kernel, virtio + best_kernel (* Even though the kernel was already installed (this version of * virt-v2v does not install new kernels), it could have an @@ -1004,7 +1001,8 @@ let rec convert (g : G.guestfs) inspect source output rcaps unconfigure_kudzu (); unconfigure_prltools (); - let kernel, virtio = configure_kernel () in + let kernel = configure_kernel () in + let virtio = kernel.ki_supports_virtio in if output#keep_serial_console then ( configure_console (); -- 2.12.0
Richard W.M. Jones
2017-Apr-06 10:04 UTC
[Libguestfs] [PATCH v4 2/9] v2v: linux: Fix Xen PV-only detection.
We want to detect if a Linux kernel is Xen PV only ("PV-only"). Such a kernel will not boot on KVM, and if a guest has only PV-only kernels, it will not be able to boot at all on the target. Our previous test was wrong. It tested whether the xennet.ko module exists. This module was renamed in more recent kernels (to xen-netfront.ko), so it happened to not detect modern kernels as PV-only, but this was by chance. Modern kernel images can be compiled with Xen PV guest support. The same image can boot on baremetal, KVM, Xen PV or Xen HVM. Testing if the xennet (or xen-netfront) module exists is irrelevant to this. This test, which is based on ideas from Laszlo Ersek and https://wiki.xen.org/wiki/Xen_Project_Software_Overview#Guest_Types uses the kernel config test CONFIG_X86_XEN || CONFIG_X86_64_XEN to determine PV-only kernels. Note that these CONFIG flags were never upstream, and existed only in Linux kernels forked by Xen ("XenLinux"). By the time Xen guest support was added upstream, it was implemented using pvops support, so a single image could boot on Xen and non-Xen as described above, and these flags were no longer used. Updates commit 7eb219d1938968c4d6bffda038aaace936f7efbf. Thanks: Laszlo Ersek. --- v2v/convert_linux.ml | 4 ++-- v2v/linux_kernels.ml | 10 ++++++---- v2v/linux_kernels.mli | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml index c768902cc..5a83be625 100644 --- a/v2v/convert_linux.ml +++ b/v2v/convert_linux.ml @@ -397,7 +397,7 @@ let rec convert (g : G.guestfs) inspect source output rcaps (* Check a non-Xen kernel exists. *) let only_xen_kernels = List.for_all ( - fun { ki_is_xen_kernel = is_xen_kernel } -> is_xen_kernel + fun { ki_is_xen_pv_only_kernel = is_xen_pv_only_kernel } -> is_xen_pv_only_kernel ) bootloader_kernels in if only_xen_kernels then 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; @@ -417,7 +417,7 @@ let rec convert (g : G.guestfs) inspect source output rcaps ) in let kernels = bootloader_kernels in - let kernels = List.filter (fun { ki_is_xen_kernel = is_xen_kernel } -> not is_xen_kernel) kernels in + let kernels = List.filter (fun { ki_is_xen_pv_only_kernel = is_xen_pv_only_kernel } -> not is_xen_pv_only_kernel) kernels in let kernels = List.sort compare_best_kernels kernels in let kernels = List.rev kernels (* so best is first *) in List.hd kernels in diff --git a/v2v/linux_kernels.ml b/v2v/linux_kernels.ml index 2efd070a6..312d6d1c0 100644 --- a/v2v/linux_kernels.ml +++ b/v2v/linux_kernels.ml @@ -39,7 +39,7 @@ type kernel_info = { ki_modpath : string; ki_modules : string list; ki_supports_virtio : bool; - ki_is_xen_kernel : bool; + ki_is_xen_pv_only_kernel : bool; ki_is_debug : bool; ki_config_file : string option; } @@ -49,7 +49,7 @@ let string_of_kernel_info ki 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 ki.ki_is_xen_pv_only_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? *) @@ -182,7 +182,9 @@ let detect_kernels (g : G.guestfs) inspect family bootloader List.mem what modules || check_config kconf config_file in let supports_virtio = kernel_supports "virtio_net" "VIRTIO_NET" in - let is_xen_kernel = List.mem "xennet" modules in + let is_xen_pv_only_kernel + check_config "X86_XEN" config_file || + check_config "X86_64_XEN" config_file in (* If the package name is like "kernel-debug", then it's * a debug kernel. @@ -202,7 +204,7 @@ let detect_kernels (g : G.guestfs) inspect family bootloader ki_modpath = modpath; ki_modules = modules; ki_supports_virtio = supports_virtio; - ki_is_xen_kernel = is_xen_kernel; + ki_is_xen_pv_only_kernel = is_xen_pv_only_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..a56516233 100644 --- a/v2v/linux_kernels.mli +++ b/v2v/linux_kernels.mli @@ -29,7 +29,7 @@ type kernel_info = { ki_modpath : string; (** The module path. *) ki_modules : string list; (** The list of module names. *) ki_supports_virtio : bool; (** Kernel has virtio drivers? *) - ki_is_xen_kernel : bool; (** Is a Xen paravirt kernel? *) + ki_is_xen_pv_only_kernel : bool; (** Is a Xen paravirt-only kernel? *) ki_is_debug : bool; (** Is debug kernel? *) ki_config_file : string option; (** Path of config file, if found. *) } -- 2.12.0
Richard W.M. Jones
2017-Apr-06 10:04 UTC
[Libguestfs] [PATCH v4 3/9] v2v: linux: Replace 'ki_supports_virtio' field.
Previously the kernel_info field '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 | 20 +++++++++++--------- v2v/linux_kernels.ml | 38 ++++++++++++++++++++++---------------- v2v/linux_kernels.mli | 3 ++- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml index 5a83be625..46b989d5d 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,11 @@ 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" ] + "virtio_scsi"; "virtio_net"; "virtio_pci" ] in + if modules <> [] then modules else - [ "sym53c8xx" (* XXX why not "ide"? *) ] in + (* 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 +1005,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 +1023,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 312d6d1c0..725bd03c2 100644 --- a/v2v/linux_kernels.ml +++ b/v2v/linux_kernels.ml @@ -38,18 +38,25 @@ 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_pv_only_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)" - 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_pv_only_kernel ki.ki_is_debug +let print_kernel_info chan prefix ki + let fpf fs = output_string chan prefix; fprintf chan fs in + fprintf chan "* %s %s (%s)\n" ki.ki_name ki.ki_version ki.ki_arch; + fpf "%s\n" ki.ki_vmlinuz; + fpf "%s\n" (match ki.ki_initrd with None -> "no initrd" | Some s -> s); + fpf "%s\n" (match ki.ki_config_file with None -> "no config" | Some s -> s); + fpf "%s\n" ki.ki_modpath; + fpf "%d modules found\n" (List.length ki.ki_modules); + fpf "virtio: blk=%b net=%b\n" + ki.ki_supports_virtio_blk ki.ki_supports_virtio_net; + fpf "xen=%b debug=%b\n" + ki.ki_is_xen_pv_only_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 +188,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_pv_only_kernel check_config "X86_XEN" config_file || check_config "X86_64_XEN" config_file in @@ -203,7 +213,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_pv_only_kernel = is_xen_pv_only_kernel; ki_is_debug = is_debug; ki_config_file = config_file; @@ -218,9 +229,7 @@ let detect_kernels (g : G.guestfs) inspect family bootloader if verbose () then ( eprintf "installed kernel packages in this guest:\n"; - List.iter ( - fun kernel -> eprintf "\t%s\n" (string_of_kernel_info kernel) - ) installed_kernels; + List.iter (print_kernel_info stderr "\t") installed_kernels; flush stderr ); @@ -257,10 +266,7 @@ let detect_kernels (g : G.guestfs) inspect family bootloader if verbose () then ( eprintf "kernels offered by the bootloader in this guest (first in list is default):\n"; - List.iter ( - fun kernel -> - eprintf "\t%s\n" (string_of_kernel_info kernel) - ) bootloader_kernels; + List.iter (print_kernel_info stderr "\t") bootloader_kernels; flush stderr ); diff --git a/v2v/linux_kernels.mli b/v2v/linux_kernels.mli index a56516233..f536583ca 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_pv_only_kernel : bool; (** Is a Xen paravirt-only kernel? *) ki_is_debug : bool; (** Is debug kernel? *) ki_config_file : string option; (** Path of config file, if found. *) -- 2.12.0
Richard W.M. Jones
2017-Apr-06 10:04 UTC
[Libguestfs] [PATCH v4 4/9] v2v: Extend guestcaps to record drivers for virtio-rng, balloon and pvpanic.
Extend the guestcaps structure so it records whether a guest supports (or drivers were added) for virtio-rng, the virtio memory balloon, and the ISA pvpanic device. --- v2v/convert_linux.ml | 3 +++ v2v/convert_windows.ml | 6 +++++- v2v/linux_kernels.ml | 21 +++++++++++++++++---- v2v/linux_kernels.mli | 3 +++ v2v/types.ml | 3 +++ v2v/types.mli | 4 ++++ v2v/windows_virtio.ml | 10 ++++++++-- v2v/windows_virtio.mli | 5 +++-- 8 files changed, 46 insertions(+), 9 deletions(-) diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml index 46b989d5d..a65ce99b9 100644 --- a/v2v/convert_linux.ml +++ b/v2v/convert_linux.ml @@ -1042,6 +1042,9 @@ let rec convert (g : G.guestfs) inspect source output rcaps gcaps_block_bus = block_type; gcaps_net_bus = net_type; gcaps_video = video; + gcaps_virtio_rng = kernel.ki_supports_virtio_rng; + gcaps_virtio_balloon = kernel.ki_supports_virtio_balloon; + gcaps_isa_pvpanic = kernel.ki_supports_isa_pvpanic; gcaps_arch = Utils.kvm_arch inspect.i_arch; gcaps_acpi = acpi; } in diff --git a/v2v/convert_windows.ml b/v2v/convert_windows.ml index 4fe671fab..dfb90d079 100644 --- a/v2v/convert_windows.ml +++ b/v2v/convert_windows.ml @@ -600,7 +600,8 @@ if errorlevel 3010 exit /b 0 configure_firstboot (); (* Open the system hive for writes and update it. *) - let block_driver, net_driver, video_driver + let block_driver, net_driver, video_driver, + virtio_rng_supported, virtio_ballon_supported, isa_pvpanic_supported Registry.with_hive_write g inspect.i_windows_system_hive update_system_hive in @@ -628,6 +629,9 @@ if errorlevel 3010 exit /b 0 gcaps_block_bus = block_driver; gcaps_net_bus = net_driver; gcaps_video = video_driver; + gcaps_virtio_rng = virtio_rng_supported; + gcaps_virtio_balloon = virtio_ballon_supported; + gcaps_isa_pvpanic = isa_pvpanic_supported; gcaps_arch = Utils.kvm_arch inspect.i_arch; gcaps_acpi = true; } in diff --git a/v2v/linux_kernels.ml b/v2v/linux_kernels.ml index 725bd03c2..e8c3a93c6 100644 --- a/v2v/linux_kernels.ml +++ b/v2v/linux_kernels.ml @@ -40,6 +40,9 @@ type kernel_info = { ki_modules : string list; ki_supports_virtio_blk : bool; ki_supports_virtio_net : bool; + ki_supports_virtio_rng : bool; + ki_supports_virtio_balloon : bool; + ki_supports_isa_pvpanic : bool; ki_is_xen_pv_only_kernel : bool; ki_is_debug : bool; ki_config_file : string option; @@ -53,10 +56,11 @@ let print_kernel_info chan prefix ki fpf "%s\n" (match ki.ki_config_file with None -> "no config" | Some s -> s); fpf "%s\n" ki.ki_modpath; fpf "%d modules found\n" (List.length ki.ki_modules); - fpf "virtio: blk=%b net=%b\n" - ki.ki_supports_virtio_blk ki.ki_supports_virtio_net; - fpf "xen=%b debug=%b\n" - ki.ki_is_xen_pv_only_kernel ki.ki_is_debug + fpf "virtio: blk=%b net=%b rng=%b balloon=%b\n" + ki.ki_supports_virtio_blk ki.ki_supports_virtio_net + ki.ki_supports_virtio_rng ki.ki_supports_virtio_balloon; + fpf "pvpanic=%b xen=%b debug=%b\n" + ki.ki_supports_isa_pvpanic ki.ki_is_xen_pv_only_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? *) @@ -192,6 +196,12 @@ let detect_kernels (g : G.guestfs) inspect family bootloader kernel_supports "virtio_blk" "VIRTIO_BLK" in let supports_virtio_net kernel_supports "virtio_net" "VIRTIO_NET" in + let supports_virtio_rng + kernel_supports "virtio-rng" "HW_RANDOM_VIRTIO" in + let supports_virtio_balloon + kernel_supports "virtio_balloon" "VIRTIO_BALLOON" in + let supports_isa_pvpanic + kernel_supports "pvpanic" "PVPANIC" in let is_xen_pv_only_kernel check_config "X86_XEN" config_file || check_config "X86_64_XEN" config_file in @@ -215,6 +225,9 @@ let detect_kernels (g : G.guestfs) inspect family bootloader ki_modules = modules; ki_supports_virtio_blk = supports_virtio_blk; ki_supports_virtio_net = supports_virtio_net; + ki_supports_virtio_rng = supports_virtio_rng; + ki_supports_virtio_balloon = supports_virtio_balloon; + ki_supports_isa_pvpanic = supports_isa_pvpanic; ki_is_xen_pv_only_kernel = is_xen_pv_only_kernel; ki_is_debug = is_debug; ki_config_file = config_file; diff --git a/v2v/linux_kernels.mli b/v2v/linux_kernels.mli index f536583ca..3702063d7 100644 --- a/v2v/linux_kernels.mli +++ b/v2v/linux_kernels.mli @@ -30,6 +30,9 @@ type kernel_info = { ki_modules : string list; (** The list of module names. *) ki_supports_virtio_blk : bool; (** Kernel supports virtio-blk? *) ki_supports_virtio_net : bool; (** Kernel supports virtio-net? *) + ki_supports_virtio_rng : bool; (** Kernel supports virtio-rng? *) + ki_supports_virtio_balloon : bool; (** Kernel supports memory balloon? *) + ki_supports_isa_pvpanic : bool; (** Kernel supports ISA pvpanic device? *) ki_is_xen_pv_only_kernel : bool; (** Is a Xen paravirt-only kernel? *) ki_is_debug : bool; (** Is debug kernel? *) ki_config_file : string option; (** Path of config file, if found. *) diff --git a/v2v/types.ml b/v2v/types.ml index 31cbbd2a8..a46c90439 100644 --- a/v2v/types.ml +++ b/v2v/types.ml @@ -396,6 +396,9 @@ type guestcaps = { gcaps_block_bus : guestcaps_block_type; gcaps_net_bus : guestcaps_net_type; gcaps_video : guestcaps_video_type; + gcaps_virtio_rng : bool; + gcaps_virtio_balloon : bool; + gcaps_isa_pvpanic : bool; gcaps_arch : string; gcaps_acpi : bool; } diff --git a/v2v/types.mli b/v2v/types.mli index c902b7abf..ca3697694 100644 --- a/v2v/types.mli +++ b/v2v/types.mli @@ -264,6 +264,10 @@ type guestcaps = { installing drivers). Thus this is not known until after conversion. *) + gcaps_virtio_rng : bool; (** Guest supports virtio-rng. *) + gcaps_virtio_balloon : bool; (** Guest supports virtio balloon. *) + gcaps_isa_pvpanic : bool; (** Guest supports ISA pvpanic device. *) + gcaps_arch : string; (** Architecture that KVM must emulate. *) gcaps_acpi : bool; (** True if guest supports acpi. *) } diff --git a/v2v/windows_virtio.ml b/v2v/windows_virtio.ml index 965d6ac8b..84a16e34e 100644 --- a/v2v/windows_virtio.ml +++ b/v2v/windows_virtio.ml @@ -61,7 +61,7 @@ let rec install_drivers ((g, _) as reg) inspect rcaps match net_type with | Some model -> model | None -> RTL8139 in - (IDE, net_type, Cirrus) + (IDE, net_type, Cirrus, false, false, false) ) else ( (* Can we install the block driver? *) @@ -165,7 +165,13 @@ let rec install_drivers ((g, _) as reg) inspect rcaps | Some Cirrus, _ -> Cirrus in - (block, net, video) + (* Did we install the miscellaneous drivers? *) + let virtio_rng_supported = g#exists (driverdir // "viorng.inf") in + let virtio_ballon_supported = g#exists (driverdir // "balloon.inf") in + let isa_pvpanic_supported = g#exists (driverdir // "pvpanic.inf") in + + (block, net, video, + virtio_rng_supported, virtio_ballon_supported, isa_pvpanic_supported) ) and add_guestor_to_registry ((g, root) as reg) inspect drv_name drv_pciid diff --git a/v2v/windows_virtio.mli b/v2v/windows_virtio.mli index 0bc6faaa2..166e9ecfa 100644 --- a/v2v/windows_virtio.mli +++ b/v2v/windows_virtio.mli @@ -20,7 +20,7 @@ val install_drivers : Registry.t -> Types.inspect -> Types.requested_guestcaps -> - Types.guestcaps_block_type * Types.guestcaps_net_type * Types.guestcaps_video_type + Types.guestcaps_block_type * Types.guestcaps_net_type * Types.guestcaps_video_type * bool * bool * bool (** [install_drivers reg inspect rcaps] installs virtio drivers from the driver directory or driver ISO into the guest driver directory and updates the registry @@ -34,7 +34,8 @@ val install_drivers install_drivers will adjust its choices based on that information, and abort if the requested driver wasn't found. - This returns the tuple [(block_driver, net_driver, video_driver)] + This returns the tuple [(block_driver, net_driver, video_driver, + virtio_rng_supported, virtio_ballon_supported, isa_pvpanic_supported)] reflecting what devices are now required by the guest, either virtio devices if we managed to install those, or legacy devices if we didn't. *) -- 2.12.0
Richard W.M. Jones
2017-Apr-06 10:04 UTC
[Libguestfs] [PATCH v4 5/9] v2v: -o libvirt: Add virtio-rng, balloon and pvpanic to output XML (RHBZ#1438794).
When outputting libvirt XML, create virtio-rng, a memory balloon device, and a pvpanic device, if the guest supports it. Thanks: Daniel Berrangé for advice on memballoon --- v2v/create_libvirt_xml.ml | 26 ++++++++++++++++++++++++++ v2v/test-v2v-i-ova.xml | 4 ++++ 2 files changed, 30 insertions(+) diff --git a/v2v/create_libvirt_xml.ml b/v2v/create_libvirt_xml.ml index fc7196595..246cacd21 100644 --- a/v2v/create_libvirt_xml.ml +++ b/v2v/create_libvirt_xml.ml @@ -338,6 +338,32 @@ let create_libvirt_xml ?pool source target_buses guestcaps [] in append devices sound; + (* Miscellaneous KVM devices. *) + if guestcaps.gcaps_virtio_rng then + push_back devices ( + e "rng" ["model", "virtio"] [ + (* XXX Using /dev/urandom requires libvirt >= 1.3.4. Libvirt + * was broken before that. + *) + e "backend" ["model", "random"] [PCData "/dev/urandom"] + ] + ); + (* For the balloon device, libvirt adds an implicit device + * unless we use model='none', hence this: + *) + push_back devices ( + e "memballoon" + ["model", + if guestcaps.gcaps_virtio_balloon then "virtio" else "none"] + [] + ); + if guestcaps.gcaps_isa_pvpanic then + push_back devices ( + e "panic" ["model", "isa"] [ + e "address" ["type", "isa"; "iobase", "0x505"] [] + ] + ); + (* Standard devices added to every guest. *) append devices [ e "input" ["type", "tablet"; "bus", "usb"] []; diff --git a/v2v/test-v2v-i-ova.xml b/v2v/test-v2v-i-ova.xml index 1a31c44d5..4b5f615c9 100644 --- a/v2v/test-v2v-i-ova.xml +++ b/v2v/test-v2v-i-ova.xml @@ -37,6 +37,10 @@ <model type='qxl' ram='65536' heads='1'/> </video> <graphics type='vnc' autoport='yes' port='-1'/> + <rng model='virtio'> + <backend model='random'>/dev/urandom</backend> + </rng> + <memballoon model='virtio'/> <input type='tablet' bus='usb'/> <input type='mouse' bus='ps2'/> <console type='pty'/> -- 2.12.0
Richard W.M. Jones
2017-Apr-06 10:04 UTC
[Libguestfs] [PATCH v4 6/9] v2v: -o glance: Add virtio-rng to output properties (RHBZ#1438794).
Only virtio-rng is supported at the time. --- v2v/output_glance.ml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/v2v/output_glance.ml b/v2v/output_glance.ml index 04a284337..b712d6801 100644 --- a/v2v/output_glance.ml +++ b/v2v/output_glance.ml @@ -138,6 +138,11 @@ object | x, 0 -> push_back properties ("os_version", string_of_int x) | x, y -> push_back properties ("os_version", sprintf "%d.%d" x y) ); + if guestcaps.gcaps_virtio_rng then + push_back properties ("hw_rng_model", "virtio"); + (* XXX Neither memory balloon nor pvpanic are supported by + * Glance at this time. + *) let properties List.flatten ( -- 2.12.0
Richard W.M. Jones
2017-Apr-06 10:04 UTC
[Libguestfs] [PATCH v4 7/9] v2v: -o qemu: Add virtio-rng, balloon and pvpanic to output (RHBZ#1438794).
--- v2v/output_qemu.ml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/v2v/output_qemu.ml b/v2v/output_qemu.ml index a6feeaab4..7246511dc 100644 --- a/v2v/output_qemu.ml +++ b/v2v/output_qemu.ml @@ -211,6 +211,18 @@ object ) ); + (* Add the miscellaneous KVM devices. *) + if guestcaps.gcaps_virtio_rng then ( + arg "-object" "rng-random,filename=/dev/urandom,id=rng0"; + arg "-device" "virtio-rng-pci,rng=rng0" + ); + if guestcaps.gcaps_virtio_balloon then + arg "-balloon" "virtio" + else + arg "-balloon" "none"; + if guestcaps.gcaps_isa_pvpanic then + arg "-device" "pvpanic,ioport=0x505"; + (* Add a serial console to Linux guests. *) if inspect.i_type = "linux" then arg "-serial" "stdio"; -- 2.12.0
Richard W.M. Jones
2017-Apr-06 10:04 UTC
[Libguestfs] [PATCH v4 8/9] v2v: windows: Prefer virtio-win ISO over directory (RHBZ#1438794).
The exploded tree has many missing drivers (eg. virtio-rng). The ISO contains the complete set, so prefer it. --- v2v/virt-v2v.pod | 34 +++++++++++++++++++++++++--------- v2v/windows_virtio.ml | 4 +++- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod index 5d6628d65..ff6e020a6 100644 --- a/v2v/virt-v2v.pod +++ b/v2v/virt-v2v.pod @@ -607,10 +607,10 @@ the named root device does not exist or was not detected as a root device, then virt-v2v will fail. Note that there is a bug in grub which prevents it from successfully -booting a multiboot system if VirtIO is enabled. Grub is only able to -boot an operating system from the first VirtIO disk. Specifically, -F</boot> must be on the first VirtIO disk, and it cannot chainload an -OS which is not in the first VirtIO disk. +booting a multiboot system if virtio is enabled. Grub is only able to +boot an operating system from the first virtio disk. Specifically, +F</boot> must be on the first virtio disk, and it cannot chainload an +OS which is not in the first virtio disk. =item B<--vdsm-compat=0.10> @@ -766,9 +766,8 @@ below. Ubuntu 10.04+ All versions support virtio - Windows Drivers are installed from the directory pointed to by - "VIRTIO_WIN" environment variable - (/usr/share/virtio-win by default) if present + Windows Drivers are installed from the ISO or directory pointed + to by "VIRTIO_WIN" environment variable if present =head1 RHEL 4 @@ -2014,8 +2013,25 @@ distributed with virt-v2v. =item C<VIRTIO_WIN> -This is where VirtIO drivers for Windows are searched for -(F</usr/share/virtio-win> if unset). It can be a directory I<or> +This is where virtio drivers for Windows are searched for. + +If unset, then we look for drivers in whichever of these paths +is found first: + +=over 4 + +=item F</usr/share/virtio-win/virtio-win.iso> + +The ISO containing virtio drivers for Windows. + +=item F</usr/share/virtio-win> + +The exploded tree of virtio drivers for Windows. This is +usually incomplete, hence the ISO is preferred. + +=back + +(F<> if unset). It can be a directory I<or> point to F<virtio-win.iso> (CD ROM image containing drivers). See L<ENABLING VIRTIO>. diff --git a/v2v/windows_virtio.ml b/v2v/windows_virtio.ml index 84a16e34e..6c9708c03 100644 --- a/v2v/windows_virtio.ml +++ b/v2v/windows_virtio.ml @@ -31,7 +31,9 @@ let virtio_win with Not_found -> try Sys.getenv "VIRTIO_WIN_DIR" (* old name for VIRTIO_WIN *) with Not_found -> - Guestfs_config.datadir // "virtio-win" + let iso = Guestfs_config.datadir // "virtio-win" // "virtio-win.iso" in + if Sys.file_exists iso then iso + else Guestfs_config.datadir // "virtio-win" let scsi_class_guid = "{4D36E97B-E325-11CE-BFC1-08002BE10318}" let viostor_pciid = "VEN_1AF4&DEV_1001&SUBSYS_00021AF4&REV_00" -- 2.12.0
Richard W.M. Jones
2017-Apr-06 10:04 UTC
[Libguestfs] [PATCH v4 9/9] v2v: linux: Print best kernel in debug output.
After sorting kernels to find the best one, print the best kernel if verbose is enabled. --- v2v/convert_linux.ml | 10 ++++++++-- v2v/linux_kernels.mli | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml index a65ce99b9..aaa06584f 100644 --- a/v2v/convert_linux.ml +++ b/v2v/convert_linux.ml @@ -422,8 +422,14 @@ let rec convert (g : G.guestfs) inspect source output rcaps let kernels = List.sort compare_best_kernels kernels in let kernels = List.rev kernels (* so best is first *) in List.hd kernels in - if best_kernel <> List.hd bootloader_kernels then - bootloader#set_default_kernel best_kernel.ki_vmlinuz; + if verbose () then ( + eprintf "best kernel for this guest:\n"; + print_kernel_info stderr "\t" best_kernel + ); + if best_kernel <> List.hd bootloader_kernels then ( + debug "best kernel is not the bootloader default, setting bootloader default ..."; + bootloader#set_default_kernel best_kernel.ki_vmlinuz + ); (* Update /etc/sysconfig/kernel DEFAULTKERNEL (RHBZ#1176801). *) if g#is_file ~followsymlinks:true "/etc/sysconfig/kernel" then ( diff --git a/v2v/linux_kernels.mli b/v2v/linux_kernels.mli index 3702063d7..394dfd89d 100644 --- a/v2v/linux_kernels.mli +++ b/v2v/linux_kernels.mli @@ -49,3 +49,7 @@ val detect_kernels : Guestfs.guestfs -> Types.inspect -> installed and kernels that the bootloader knows about. The first kernel in the returned list is the default boot option, ie. what the guest would boot without interaction or overrides. *) + +val print_kernel_info : out_channel -> string -> kernel_info -> unit +(** Print a kernel_info struct to the given output channel. The + second parameter is a prefix for indentation etc. *) -- 2.12.0
Pino Toscano
2017-Apr-06 15:06 UTC
Re: [Libguestfs] [PATCH v4 3/9] v2v: linux: Replace 'ki_supports_virtio' field.
On Thursday, 6 April 2017 12:04:21 CEST Richard W.M. Jones wrote:> Previously the kernel_info field '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. > --- > [...] > 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 inShould this consider both virtio-net+virtio-blk to determine that a kernel "supports virtio"?> -let string_of_kernel_info ki > - sprintf "(%s, %s, %s, %s, %s, %s, virtio=%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_pv_only_kernel ki.ki_is_debug > +let print_kernel_info chan prefix kiCan you please expose this function (as interface in linux_kernels.mli) in this patch already (instead of patch #9)? Thanks, -- Pino Toscano
Pino Toscano
2017-Apr-06 15:08 UTC
Re: [Libguestfs] [PATCH v4 0/9] v2v: Add drivers for virtio-rng, balloon, pvpanic.
On Thursday, 6 April 2017 12:04:18 CEST Richard W.M. Jones wrote:> v1: https://www.redhat.com/archives/libguestfs/2017-April/msg00031.html > v2: https://www.redhat.com/archives/libguestfs/2017-April/msg00040.html > v3: https://www.redhat.com/archives/libguestfs/2017-April/msg00051.html > > v3 -> v4: > > - Properly fix Xen PV-only kernel detection, and test it.Just a couple of notes in patch #3, but seems okay otherwise. Thanks, -- Pino Toscano
Pino Toscano
2017-Apr-07 08:59 UTC
Re: [Libguestfs] [PATCH v4 2/9] v2v: linux: Fix Xen PV-only detection.
On Thursday, 6 April 2017 12:04:20 CEST Richard W.M. Jones wrote:> Our previous test was wrong. It tested whether the xennet.ko module > exists. This module was renamed in more recent kernels (to > xen-netfront.ko), so it happened to not detect modern kernels as > PV-only, but this was by chance.Just stumbled upon this bit in v2v/convert_linux.ml: if family = `SUSE_family then ( (* Remove xen modules from INITRD_MODULES and DOMU_INITRD_MODULES. *) let variables = ["INITRD_MODULES"; "DOMU_INITRD_MODULES"] in let xen_modules = ["xennet"; "xen-vnif"; "xenblk"; "xen-vbd"] in should the list above be updated with the newer names of the Xen modules? -- Pino Toscano
Maybe Matching Threads
- [PATCH v3 0/8] v2v: Add drivers for virtio-rng, balloon, pvpanic.
- [PATCH 0/6] v2v: Add drivers for virtio-rng, balloon, pvpanic.
- [PATCH v2 0/8] v2v: Add drivers for virtio-rng, balloon, pvpanic.
- Re: [PATCH v4 3/9] v2v: linux: Replace 'ki_supports_virtio' field.
- [v2v PATCH 1/3] linux: remove warning for packages with no files