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.
This commit is contained in:
Richard W.M. Jones
2017-04-05 13:38:37 +01:00
parent f5ce03c4da
commit 3e0ff263a5
8 changed files with 46 additions and 9 deletions

View File

@@ -1050,6 +1050,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

View File

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

View File

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

View File

@@ -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. *)

View File

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

View File

@@ -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. *)
}

View File

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

View File

@@ -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. *)