Andrey Drobyshev
2023-Mar-07 19:40 UTC
[Libguestfs] [V2V PATCH v2 0/5] Bring support for virtio-scsi back to Windows
Discussion on v1: https://listman.redhat.com/archives/libguestfs/2023-February/030849.html https://listman.redhat.com/archives/libguestfs/2023-March/030917.html v1 -> v2: * Adapt the patch suggested by Richard, splitting it up into 3: https://listman.redhat.com/archives/libguestfs/2023-March/030975.html Now we have "--block-driver" command line option which regulates the order in which block drivers are being searched for (and, as a consequence, the default driver). Andrey Drobyshev (2): Revert "Remove guestcaps_block_type Virtio_SCSI" convert_windows: add Inject_virtio_win.Virtio_SCSI as a possible block type Richard W.M. Jones (3): convert: introduce "block_driver" convert option convert_windows: set block driver priority according to block_driver option v2v, in-place: introduce --block-driver command line option convert/convert.ml | 11 +++++++---- convert/convert.mli | 1 + convert/convert_linux.ml | 11 ++++++++--- convert/convert_linux.mli | 3 ++- convert/convert_windows.ml | 11 ++++++++++- convert/convert_windows.mli | 3 ++- convert/target_bus_assignment.ml | 1 + docs/virt-v2v-in-place.pod | 10 ++++++++++ docs/virt-v2v.pod | 10 ++++++++++ in-place/in_place.ml | 12 +++++++++++- inspector/inspector.ml | 3 ++- lib/create_ovf.ml | 1 + lib/types.ml | 3 ++- lib/types.mli | 2 +- output/openstack_image_properties.ml | 7 +++++++ v2v/v2v.ml | 12 +++++++++++- 16 files changed, 86 insertions(+), 15 deletions(-) -- 2.31.1
Andrey Drobyshev
2023-Mar-07 19:40 UTC
[Libguestfs] [V2V PATCH v2 1/5] Revert "Remove guestcaps_block_type Virtio_SCSI"
This code is needed to check whether virtio-scsi driver was installed. This reverts commit f0afc439524853508938b2bfc758896f053462e3. --- convert/convert.ml | 2 +- convert/convert_linux.ml | 9 +++++++-- convert/target_bus_assignment.ml | 1 + lib/create_ovf.ml | 1 + lib/types.ml | 3 ++- lib/types.mli | 2 +- output/openstack_image_properties.ml | 7 +++++++ 7 files changed, 20 insertions(+), 5 deletions(-) diff --git a/convert/convert.ml b/convert/convert.ml index 0aa0e5cd..084619c8 100644 --- a/convert/convert.ml +++ b/convert/convert.ml @@ -252,7 +252,7 @@ and do_convert g source inspect i_firmware keep_serial_console interfaces (* Did we manage to install virtio drivers? *) if not (quiet ()) then ( match guestcaps.gcaps_block_bus with - | Virtio_blk -> + | Virtio_blk | Virtio_SCSI -> info (f_"This guest has virtio drivers installed.") | IDE -> info (f_"This guest does not have virtio drivers installed.") diff --git a/convert/convert_linux.ml b/convert/convert_linux.ml index d5c0f24d..dab4f36d 100644 --- a/convert/convert_linux.ml +++ b/convert/convert_linux.ml @@ -1068,8 +1068,12 @@ let convert (g : G.guestfs) source inspect i_firmware keep_serial_console _ (* Update 'alias scsi_hostadapter ...' *) let paths = augeas_modprobe ". =~ regexp('scsi_hostadapter.*')" in (match block_type with - | Virtio_blk -> - let block_module = "virtio_blk" in + | Virtio_blk | Virtio_SCSI -> + let block_module + match block_type with + | Virtio_blk -> "virtio_blk" + | Virtio_SCSI -> "virtio_scsi" + | IDE -> assert false in if paths <> [] then ( (* There's only 1 scsi controller in the converted guest. @@ -1142,6 +1146,7 @@ let convert (g : G.guestfs) source inspect i_firmware keep_serial_console _ let block_prefix_after_conversion match block_type with | Virtio_blk -> "vd" + | Virtio_SCSI -> "sd" | IDE -> ide_block_prefix in let map diff --git a/convert/target_bus_assignment.ml b/convert/target_bus_assignment.ml index 54c9516b..d13340c7 100644 --- a/convert/target_bus_assignment.ml +++ b/convert/target_bus_assignment.ml @@ -35,6 +35,7 @@ let rec target_bus_assignment source_disks source_removables guestcaps let bus match guestcaps.gcaps_block_bus with | Virtio_blk -> virtio_blk_bus + | Virtio_SCSI -> scsi_bus | IDE -> ide_bus in List.iteri ( fun i d -> diff --git a/lib/create_ovf.ml b/lib/create_ovf.ml index 5e444868..f0b32e01 100644 --- a/lib/create_ovf.ml +++ b/lib/create_ovf.ml @@ -920,6 +920,7 @@ and add_disks sizes guestcaps output_alloc output_format "ovf:disk-interface", (match guestcaps.gcaps_block_bus with | Virtio_blk -> "VirtIO" + | Virtio_SCSI -> "VirtIO_SCSI" | IDE -> "IDE"); "ovf:disk-type", "System"; (* RHBZ#744538 *) "ovf:boot", if is_bootable_drive then "True" else "False"; diff --git a/lib/types.ml b/lib/types.ml index e16da007..75c14fd4 100644 --- a/lib/types.ml +++ b/lib/types.ml @@ -400,12 +400,13 @@ type guestcaps = { gcaps_arch_min_version : int; gcaps_virtio_1_0 : bool; } -and guestcaps_block_type = Virtio_blk | IDE +and guestcaps_block_type = Virtio_blk | Virtio_SCSI | IDE and guestcaps_net_type = Virtio_net | E1000 | RTL8139 and guestcaps_machine = I440FX | Q35 | Virt let string_of_block_type = function | Virtio_blk -> "virtio-blk" + | Virtio_SCSI -> "virtio-scsi" | IDE -> "ide" let string_of_net_type = function | Virtio_net -> "virtio-net" diff --git a/lib/types.mli b/lib/types.mli index 4a183dd3..65ef2e35 100644 --- a/lib/types.mli +++ b/lib/types.mli @@ -280,7 +280,7 @@ type guestcaps = { } (** Guest capabilities after conversion. eg. Was virtio found or installed? *) -and guestcaps_block_type = Virtio_blk | IDE +and guestcaps_block_type = Virtio_blk | Virtio_SCSI | IDE and guestcaps_net_type = Virtio_net | E1000 | RTL8139 and guestcaps_machine = I440FX | Q35 | Virt diff --git a/output/openstack_image_properties.ml b/output/openstack_image_properties.ml index c75d72fe..c76ad913 100644 --- a/output/openstack_image_properties.ml +++ b/output/openstack_image_properties.ml @@ -35,6 +35,7 @@ let create source inspect { target_buses; guestcaps; target_firmware } "hw_disk_bus", (match guestcaps.gcaps_block_bus with | Virtio_blk -> "virtio" + | Virtio_SCSI -> "scsi" | IDE -> "ide"); "hw_vif_model", (match guestcaps.gcaps_net_bus with @@ -69,6 +70,12 @@ let create source inspect { target_buses; guestcaps; target_firmware } List.push_back properties ("hw_cpu_threads", string_of_int threads); ); + (match guestcaps.gcaps_block_bus with + | Virtio_SCSI -> + List.push_back properties ("hw_scsi_model", "virtio-scsi") + | Virtio_blk | IDE -> () + ); + (match inspect.i_major_version, inspect.i_minor_version with | 0, 0 -> () | x, 0 -> List.push_back properties ("os_version", string_of_int x) -- 2.31.1
Andrey Drobyshev
2023-Mar-07 19:40 UTC
[Libguestfs] [V2V PATCH v2 2/5] convert_windows: add Inject_virtio_win.Virtio_SCSI as a possible block type
Signed-off-by: Andrey Drobyshev <andrey.drobyshev at virtuozzo.com> --- convert/convert_windows.ml | 1 + 1 files changed, 1 insertions(+) diff --git a/convert/convert_windows.ml b/convert/convert_windows.ml index 9d8d271d..4f672487 100644 --- a/convert/convert_windows.ml +++ b/convert/convert_windows.ml @@ -273,6 +273,7 @@ let convert (g : G.guestfs) _ inspect i_firmware _ static_ips and of_virtio_win_block_type = function | Inject_virtio_win.Virtio_blk -> Virtio_blk + | Inject_virtio_win.Virtio_SCSI -> Virtio_SCSI | IDE -> IDE and of_virtio_win_net_type = function -- 2.31.1
Andrey Drobyshev
2023-Mar-07 19:40 UTC
[Libguestfs] [V2V PATCH v2 3/5] convert: introduce "block_driver" convert option
From: "Richard W.M. Jones" <rjones at redhat.com> When injecting a block VirtIO driver during conversion, we rely on the predefined list of names of such drivers. Order in this list denotes the priority (see common/mlcustomize/inject_virtio_win.ml). This commit introduces the "block_driver" convert option, setting its value to the default Virtio_blk and making sure it's being properly passed to the conversion functions. Along with the means of altering the drivers list (introduced in a separate commit in the common submodule), this option will be brought to command line, giving us the opportunity to choose the block driver to be used on conversion. Originally-by: Richard W.M. Jones <rjones at redhat.com> Signed-off-by: Andrey Drobyshev <andrey.drobyshev at virtuozzo.com> --- convert/convert.ml | 9 ++++++--- convert/convert.mli | 1 + convert/convert_linux.ml | 2 +- convert/convert_linux.mli | 3 ++- convert/convert_windows.ml | 2 +- convert/convert_windows.mli | 3 ++- in-place/in_place.ml | 3 ++- inspector/inspector.ml | 3 ++- v2v/v2v.ml | 3 ++- 9 files changed, 19 insertions(+), 10 deletions(-) diff --git a/convert/convert.ml b/convert/convert.ml index 084619c8..9c76f76d 100644 --- a/convert/convert.ml +++ b/convert/convert.ml @@ -31,6 +31,7 @@ open Utils module G = Guestfs type options = { + block_driver : guestcaps_block_type; keep_serial_console : bool; ks : key_store; network_map : Networks.t; @@ -88,7 +89,7 @@ let rec convert dir options source (* Conversion. *) let guestcaps do_convert g source inspect i_firmware - options.keep_serial_console options.static_ips in + options.block_driver options.keep_serial_console options.static_ips in g#umount_all (); @@ -221,7 +222,8 @@ and do_fstrim g inspect ) fses (* Conversion. *) -and do_convert g source inspect i_firmware keep_serial_console interfaces +and do_convert g source inspect i_firmware + block_driver keep_serial_console interfaces (match inspect.i_product_name with | "unknown" -> message (f_"Converting the guest to run on KVM") @@ -246,7 +248,8 @@ and do_convert g source inspect i_firmware keep_serial_console interfaces inspect.i_type inspect.i_distro in debug "picked conversion module %s" conversion_name; let guestcaps - convert g source inspect i_firmware keep_serial_console interfaces in + convert g source inspect i_firmware + block_driver keep_serial_console interfaces in debug "%s" (string_of_guestcaps guestcaps); (* Did we manage to install virtio drivers? *) diff --git a/convert/convert.mli b/convert/convert.mli index 3bd39e2d..c63bf6f0 100644 --- a/convert/convert.mli +++ b/convert/convert.mli @@ -17,6 +17,7 @@ *) type options = { + block_driver : Types.guestcaps_block_type; (** [--block-driver] option *) keep_serial_console : bool; ks : Tools_utils.key_store; (** [--key] option *) network_map : Networks.t; (** [-b] and [-n] options *) diff --git a/convert/convert_linux.ml b/convert/convert_linux.ml index dab4f36d..8d702084 100644 --- a/convert/convert_linux.ml +++ b/convert/convert_linux.ml @@ -34,7 +34,7 @@ open Linux_kernels module G = Guestfs (* The conversion function. *) -let convert (g : G.guestfs) source inspect i_firmware keep_serial_console _ +let convert (g : G.guestfs) source inspect i_firmware _ keep_serial_console _ (*----------------------------------------------------------------------*) (* Inspect the guest first. We already did some basic inspection in * the common v2v.ml code, but that has to deal with generic guests diff --git a/convert/convert_linux.mli b/convert/convert_linux.mli index 6eb272e9..dc6968fe 100644 --- a/convert/convert_linux.mli +++ b/convert/convert_linux.mli @@ -23,5 +23,6 @@ Mint and Kali are supported by this module. *) val convert : Guestfs.guestfs -> Types.source -> Types.inspect -> - Firmware.i_firmware -> bool -> Types.static_ip list -> + Firmware.i_firmware -> Types.guestcaps_block_type -> + bool -> Types.static_ip list -> Types.guestcaps diff --git a/convert/convert_windows.ml b/convert/convert_windows.ml index 4f672487..1ace2948 100644 --- a/convert/convert_windows.ml +++ b/convert/convert_windows.ml @@ -38,7 +38,7 @@ module G = Guestfs * time the Windows VM is booted on KVM. *) -let convert (g : G.guestfs) _ inspect i_firmware _ static_ips +let convert (g : G.guestfs) _ inspect i_firmware block_driver _ static_ips (*----------------------------------------------------------------------*) (* Inspect the Windows guest. *) diff --git a/convert/convert_windows.mli b/convert/convert_windows.mli index 42dac9f5..33a14f65 100644 --- a/convert/convert_windows.mli +++ b/convert/convert_windows.mli @@ -21,5 +21,6 @@ This module converts a Windows guest to run on KVM. *) val convert : Guestfs.guestfs -> Types.source -> Types.inspect -> - Firmware.i_firmware -> bool -> Types.static_ip list -> + Firmware.i_firmware -> Types.guestcaps_block_type -> + bool -> Types.static_ip list -> Types.guestcaps diff --git a/in-place/in_place.ml b/in-place/in_place.ml index 68ef9965..2049db16 100644 --- a/in-place/in_place.ml +++ b/in-place/in_place.ml @@ -294,7 +294,8 @@ read the man page virt-v2v-in-place(1). (* Get the conversion options. *) let conv_options = { - Convert.keep_serial_console = true; + Convert.block_driver = Virtio_blk; + keep_serial_console = true; ks = opthandle.ks; network_map; root_choice; diff --git a/inspector/inspector.ml b/inspector/inspector.ml index a6428946..02d1a0e7 100644 --- a/inspector/inspector.ml +++ b/inspector/inspector.ml @@ -324,7 +324,8 @@ read the man page virt-v2v-inspector(1). (* Get the conversion options. *) let conv_options = { - Convert.keep_serial_console = true; + Convert.block_driver = Virtio_blk; + keep_serial_console = true; ks = opthandle.ks; network_map; root_choice; diff --git a/v2v/v2v.ml b/v2v/v2v.ml index 13fe477a..22f7c631 100644 --- a/v2v/v2v.ml +++ b/v2v/v2v.ml @@ -524,7 +524,8 @@ read the man page virt-v2v(1). (* Get the conversion options. *) let conv_options = { - Convert.keep_serial_console = not remove_serial_console; + Convert.block_driver = Virtio_blk; + keep_serial_console = not remove_serial_console; ks = opthandle.ks; network_map; root_choice; -- 2.31.1
Andrey Drobyshev
2023-Mar-07 19:40 UTC
[Libguestfs] [V2V PATCH v2 4/5] convert_windows: set block driver priority according to block_driver option
From: "Richard W.M. Jones" <rjones at redhat.com> If "block_driver" option is set to Virtio_SCSI, prepend the block drivers priority list with "vioscsi" so that we first search for "vioscsi.sys" during the drivers injection phase. Originally-by: Richard W.M. Jones <rjones at redhat.com> Signed-off-by: Andrey Drobyshev <andrey.drobyshev at virtuozzo.com> --- convert/convert_windows.ml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/convert/convert_windows.ml b/convert/convert_windows.ml index 1ace2948..6bc2343b 100644 --- a/convert/convert_windows.ml +++ b/convert/convert_windows.ml @@ -47,6 +47,14 @@ let convert (g : G.guestfs) _ inspect i_firmware block_driver _ static_ips *) let virtio_win Inject_virtio_win.from_environment g inspect.i_root Config.datadir in + (match block_driver with + | Virtio_blk -> () (* the default, no need to do anything *) + | Virtio_SCSI -> + let drivers = Inject_virtio_win.get_block_driver_priority virtio_win in + let drivers = "vioscsi" :: drivers in + Inject_virtio_win.set_block_driver_priority virtio_win drivers + | IDE -> assert false (* not possible - but maybe ...? *) + ); (* If the Windows guest appears to be using group policy. * -- 2.31.1
Andrey Drobyshev
2023-Mar-07 19:40 UTC
[Libguestfs] [V2V PATCH v2 5/5] v2v, in-place: introduce --block-driver command line option
From: "Richard W.M. Jones" <rjones at redhat.com> The option takes values of "virtio-scsi", "virtio-blk" (with the latter being the default). It maps on the convert option with the same name introduced in the previous commits, thus allowing us to alter the order in which the VirtIO block drivers are going to be searched for. This is useful if we want the virtio-scsi driver to be installed during conversion instead of the default virtio-blk. Also update the docs accordingly. Originally-by: Richard W.M. Jones <rjones at redhat.com> Signed-off-by: Andrey Drobyshev <andrey.drobyshev at virtuozzo.com> --- docs/virt-v2v-in-place.pod | 10 ++++++++++ docs/virt-v2v.pod | 10 ++++++++++ in-place/in_place.ml | 11 ++++++++++- v2v/v2v.ml | 11 ++++++++++- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/docs/virt-v2v-in-place.pod b/docs/virt-v2v-in-place.pod index 6e1c5363..1e993e8c 100644 --- a/docs/virt-v2v-in-place.pod +++ b/docs/virt-v2v-in-place.pod @@ -47,6 +47,16 @@ Display help. See I<--network> below. +=item B<--block-driver virtio-blk> + +=item B<--block-driver virtio-scsi> + +When choosing a block driver for Windows guests, prefer C<virtio-blk> or +C<virtio-scsi>. The default is C<virtio-blk>. + +Note this has no effect for Linux guests at the moment. That may be +added in future. + =item B<--colors> =item B<--colours> diff --git a/docs/virt-v2v.pod b/docs/virt-v2v.pod index b458607d..e096418b 100644 --- a/docs/virt-v2v.pod +++ b/docs/virt-v2v.pod @@ -207,6 +207,16 @@ The options are silently ignored for other input methods. See I<--network> below. +=item B<--block-driver virtio-blk> + +=item B<--block-driver virtio-scsi> + +When choosing a block driver for Windows guests, prefer C<virtio-blk> or +C<virtio-scsi>. The default is C<virtio-blk>. + +Note this has no effect for Linux guests at the moment. That may be +added in future. + =item B<--colors> =item B<--colours> diff --git a/in-place/in_place.ml b/in-place/in_place.ml index 2049db16..e8c260c2 100644 --- a/in-place/in_place.ml +++ b/in-place/in_place.ml @@ -43,6 +43,7 @@ let rec main () let bandwidth = ref None in let bandwidth_file = ref None in + let block_driver = ref None in let input_conn = ref None in let input_format = ref None in let input_password = ref None in @@ -156,6 +157,8 @@ let rec main () let argspec = [ [ S 'b'; L"bridge" ], Getopt.String ("in:out", add_bridge), s_"Map bridge ?in? to ?out?"; + [ L"block-driver" ], Getopt.String ("driver", set_string_option_once "--block-driver" block_driver), + s_"Prefer 'virtio-blk' or 'virtio-scsi'"; [ S 'i' ], Getopt.String ("disk|libvirt|libvirtxml|ova|vmx", set_input_mode), s_"Set input mode (default: libvirt)"; [ M"ic" ], Getopt.String ("uri", set_string_option_once "-ic" input_conn), @@ -211,6 +214,12 @@ read the man page virt-v2v-in-place(1). (* Dereference the arguments. *) let args = List.rev !args in + let block_driver + match !block_driver with + | None | Some "virtio-blk" -> Virtio_blk + | Some "virtio-scsi" -> Virtio_SCSI + | Some driver -> + error (f_"unknown block driver ?--block-driver %s?") driver in let input_conn = !input_conn in let input_mode = !input_mode in let print_source = !print_source in @@ -294,7 +303,7 @@ read the man page virt-v2v-in-place(1). (* Get the conversion options. *) let conv_options = { - Convert.block_driver = Virtio_blk; + Convert.block_driver = block_driver; keep_serial_console = true; ks = opthandle.ks; network_map; diff --git a/v2v/v2v.ml b/v2v/v2v.ml index 22f7c631..3b2eafbd 100644 --- a/v2v/v2v.ml +++ b/v2v/v2v.ml @@ -48,6 +48,7 @@ let rec main () let bandwidth = ref None in let bandwidth_file = ref None in + let block_driver = ref None in let input_conn = ref None in let input_format = ref None in let input_password = ref None in @@ -230,6 +231,8 @@ let rec main () s_"Set bandwidth dynamically from file"; [ S 'b'; L"bridge" ], Getopt.String ("in:out", add_bridge), s_"Map bridge ?in? to ?out?"; + [ L"block-driver" ], Getopt.String ("driver", set_string_option_once "--block-driver" block_driver), + s_"Prefer 'virtio-blk' or 'virtio-scsi'"; [ L"compressed" ], Getopt.Unit (fun () -> set_output_option_compat "compressed" ""), s_"Compress output file (-of qcow2 only)"; [ S 'i' ], Getopt.String ("disk|libvirt|libvirtxml|ova|vmx", set_input_mode), @@ -351,6 +354,12 @@ read the man page virt-v2v(1). (* Dereference the arguments. *) let args = List.rev !args in + let block_driver + match !block_driver with + | None | Some "virtio-blk" -> Virtio_blk + | Some "virtio-scsi" -> Virtio_SCSI + | Some driver -> + error (f_"unknown block driver ?--block-driver %s?") driver in let input_conn = !input_conn in let input_mode = !input_mode in let input_transport @@ -524,7 +533,7 @@ read the man page virt-v2v(1). (* Get the conversion options. *) let conv_options = { - Convert.block_driver = Virtio_blk; + Convert.block_driver = block_driver; keep_serial_console = not remove_serial_console; ks = opthandle.ks; network_map; -- 2.31.1
Richard W.M. Jones
2023-Mar-08 20:46 UTC
[Libguestfs] [V2V PATCH v2 0/5] Bring support for virtio-scsi back to Windows
The patch series looks generally fine, but it really needs a test ... We find that having tests prevents unnoticed regressions from happening later. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html
Reasonably Related Threads
- [V2V PATCH v2 0/5] Bring support for virtio-scsi back to Windows
- [V2V PATCH v2 0/5] Bring support for virtio-scsi back to Windows
- [V2V PATCH v3 0/6] Bring support for virtio-scsi back to Windows
- [V2V PATCH 0/5] Bring support for virtio-scsi back to Windows
- [V2V PATCH v2 0/5] Bring support for virtio-scsi back to Windows