Andrey Drobyshev
2023-Mar-10 17:54 UTC
[Libguestfs] [COMMON PATCH v3 0/4] Bring support for virtio-scsi back to Windows
Discussion on v2: https://listman.redhat.com/archives/libguestfs/2023-March/030989.html v2 -> v3: * Patch 1/4 ("inject_virtio_win: match only vendor/device/revision"): do not omit PCI Revision ID. Adjust commit message accordingly; * Patch 2/4 ("inject_virtio_win: add Virtio_SCSI to block_type"): add non-empty commit message body. * Patch 4/4 ("inject_virtio_win: write the proper block controller PCI ID to Win registry"): use nested matching instead of string comparison. 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: * Drop the logic where default is switched to "vioscsi". Keep virtio-blk as default. * Adapt the patch suggested by Richard: https://listman.redhat.com/archives/libguestfs/2023-March/030974.html This introduces API for changing the order in which drivers are being searched for. This API is used by v2v. Andrey Drobyshev (2): inject_virtio_win: add Virtio_SCSI to block_type inject_virtio_win: write the proper block controller PCI ID to Win registry Richard W.M. Jones (1): mlcustomize: Add accessors for block driver priority list Roman Kagan (1): inject_virtio_win: match only vendor/device/revision mlcustomize/inject_virtio_win.ml | 33 ++++++++++++++++++++----------- mlcustomize/inject_virtio_win.mli | 12 ++++++++++- 2 files changed, 33 insertions(+), 12 deletions(-) -- 2.31.1
Andrey Drobyshev
2023-Mar-10 17:54 UTC
[Libguestfs] [COMMON PATCH v3 1/4] inject_virtio_win: match only vendor/device/revision
From: Roman Kagan <rkagan at virtuozzo.com> Since different hypervisor vendors are allowed to use their own vendor-id as PCI subsystem-vendor-id for virtio devices, during v2v conversion it makes sense to only match the vendor/device/revision and not the full device "path" in the Windows registry. This way the code will remain universal but will work for different hypervisor vendors. Signed-off-by: Andrey Drobyshev <andrey.drobyshev at virtuozzo.com> Originally-by: Roman Kagan <rkagan at virtuozzo.com> Acked-by: Laszlo Ersek <lersek at redhat.com> --- mlcustomize/inject_virtio_win.ml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mlcustomize/inject_virtio_win.ml b/mlcustomize/inject_virtio_win.ml index 4e977b3..ed63fa7 100644 --- a/mlcustomize/inject_virtio_win.ml +++ b/mlcustomize/inject_virtio_win.ml @@ -110,10 +110,10 @@ and get_inspection g root virtio_win = ""; was_set = false } let scsi_class_guid = "{4D36E97B-E325-11CE-BFC1-08002BE10318}" -let viostor_legacy_pciid = "VEN_1AF4&DEV_1001&SUBSYS_00021AF4&REV_00" -let viostor_modern_pciid = "VEN_1AF4&DEV_1042&SUBSYS_11001AF4&REV_01" -let vioscsi_legacy_pciid = "VEN_1AF4&DEV_1004&SUBSYS_00081AF4&REV_00" -let vioscsi_modern_pciid = "VEN_1AF4&DEV_1048&SUBSYS_11001AF4&REV_01" +let viostor_legacy_pciid = "VEN_1AF4&DEV_1001&REV_00" +let viostor_modern_pciid = "VEN_1AF4&DEV_1042&REV_01" +let vioscsi_legacy_pciid = "VEN_1AF4&DEV_1004&REV_00" +let vioscsi_modern_pciid = "VEN_1AF4&DEV_1048&REV_01" let rec inject_virtio_win_drivers ({ g } as t) reg (* Copy the virtio drivers to the guest. *) -- 2.31.1
Andrey Drobyshev
2023-Mar-10 17:54 UTC
[Libguestfs] [COMMON PATCH v3 2/4] inject_virtio_win: add Virtio_SCSI to block_type
This type is going to be used as a return value in case we're injecting virtio-scsi block driver during conversion. Signed-off-by: Andrey Drobyshev <andrey.drobyshev at virtuozzo.com> Acked-by: Laszlo Ersek <lersek at redhat.com> --- mlcustomize/inject_virtio_win.ml | 2 +- mlcustomize/inject_virtio_win.mli | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mlcustomize/inject_virtio_win.ml b/mlcustomize/inject_virtio_win.ml index ed63fa7..1f4a5c4 100644 --- a/mlcustomize/inject_virtio_win.ml +++ b/mlcustomize/inject_virtio_win.ml @@ -51,7 +51,7 @@ type t = { the user to select where they want to get drivers from. XXX *) } -type block_type = Virtio_blk | IDE +type block_type = Virtio_blk | Virtio_SCSI | IDE and net_type = Virtio_net | E1000 | RTL8139 and machine_type = I440FX | Q35 | Virt diff --git a/mlcustomize/inject_virtio_win.mli b/mlcustomize/inject_virtio_win.mli index 0ced02e..58169e1 100644 --- a/mlcustomize/inject_virtio_win.mli +++ b/mlcustomize/inject_virtio_win.mli @@ -20,7 +20,7 @@ type t (** Handle *) -type block_type = Virtio_blk | IDE +type block_type = Virtio_blk | Virtio_SCSI | IDE and net_type = Virtio_net | E1000 | RTL8139 and machine_type = I440FX | Q35 | Virt -- 2.31.1
Andrey Drobyshev
2023-Mar-10 17:54 UTC
[Libguestfs] [COMMON PATCH v3 3/4] mlcustomize: Add accessors for block driver priority list
From: "Richard W.M. Jones" <rjones at redhat.com> When injecting virtio-win drivers, allow the list of block drivers that we search to be modified. This functionality will be used when we introduce an option for changing the default block driver in virt-v2v. Originally-by: Richard W.M. Jones <rjones at redhat.com> Signed-off-by: Andrey Drobyshev <andrey.drobyshev at virtuozzo.com> Reviewed-by: Laszlo Ersek <lersek at redhat.com> --- mlcustomize/inject_virtio_win.ml | 12 +++++++++--- mlcustomize/inject_virtio_win.mli | 10 ++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/mlcustomize/inject_virtio_win.ml b/mlcustomize/inject_virtio_win.ml index 1f4a5c4..eca0ad7 100644 --- a/mlcustomize/inject_virtio_win.ml +++ b/mlcustomize/inject_virtio_win.ml @@ -49,6 +49,9 @@ type t = { of libosinfo. Although this behaviour is documented, IMHO it has always been a bad idea. We should change this in future to allow the user to select where they want to get drivers from. XXX *) + + mutable block_driver_priority : string list + (** List of block drivers *) } type block_type = Virtio_blk | Virtio_SCSI | IDE @@ -107,7 +110,11 @@ and get_inspection g root { g; root; i_arch; i_major_version; i_minor_version; i_osinfo; i_product_variant; i_windows_current_control_set; i_windows_systemroot; - virtio_win = ""; was_set = false } + virtio_win = ""; was_set = false; + block_driver_priority = ["virtio_blk"; "vrtioblk"; "viostor"] } + +let get_block_driver_priority t = t.block_driver_priority +let set_block_driver_priority t v = t.block_driver_priority <- v let scsi_class_guid = "{4D36E97B-E325-11CE-BFC1-08002BE10318}" let viostor_legacy_pciid = "VEN_1AF4&DEV_1001&REV_00" @@ -176,14 +183,13 @@ let rec inject_virtio_win_drivers ({ g } as t) reg else ( (* Can we install the block driver? *) let block : block_type - let filenames = ["virtio_blk"; "vrtioblk"; "viostor"] in let viostor_driver = try ( Some ( List.find ( fun driver_file -> let source = driverdir // driver_file ^ ".sys" in g#exists source - ) filenames + ) t.block_driver_priority ) ) with Not_found -> None in match viostor_driver with diff --git a/mlcustomize/inject_virtio_win.mli b/mlcustomize/inject_virtio_win.mli index 58169e1..d14f049 100644 --- a/mlcustomize/inject_virtio_win.mli +++ b/mlcustomize/inject_virtio_win.mli @@ -64,6 +64,16 @@ val from_environment : Guestfs.guestfs -> string -> string -> t This should only be used by [virt-v2v] and is considered a legacy method. *) +val get_block_driver_priority : t -> string list +val set_block_driver_priority : t -> string list -> unit +(** Get or set the current block driver priority list. This is + a list of virtio-win block driver names (eg. ["viostor"]) that + we search until we come to the first [name ^ ".sys"] that + we find, and that is the block driver which gets installed. + + This module contains a default priority list which should + be suitable for most use cases. *) + val inject_virtio_win_drivers : t -> Registry.t -> virtio_win_installed (** [inject_virtio_win_drivers t reg] installs virtio drivers from the driver directory or driver -- 2.31.1
Andrey Drobyshev
2023-Mar-10 17:54 UTC
[Libguestfs] [COMMON PATCH v3 4/4] inject_virtio_win: write the proper block controller PCI ID to Win registry
In case when we are injecting virtio-scsi device driver into the guest (rather than the default virtio-blk), make sure we write the right PCI ID value into the Windows guest registry. This is essential for the guest to be bootable afterwards. Originally-by: Roman Kagan <rkagan at virtuozzo.com> Signed-off-by: Andrey Drobyshev <andrey.drobyshev at virtuozzo.com> --- mlcustomize/inject_virtio_win.ml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mlcustomize/inject_virtio_win.ml b/mlcustomize/inject_virtio_win.ml index eca0ad7..2a30b20 100644 --- a/mlcustomize/inject_virtio_win.ml +++ b/mlcustomize/inject_virtio_win.ml @@ -207,10 +207,15 @@ let rec inject_virtio_win_drivers ({ g } as t) reg let target = sprintf "%s/system32/drivers/%s.sys" t.i_windows_systemroot driver_name in let target = g#case_sensitive_path target in + let installed_block_type, legacy_pciid, modern_pciid + match driver_name with + | "vioscsi" -> Virtio_SCSI, vioscsi_legacy_pciid, vioscsi_modern_pciid + | _ -> Virtio_blk, viostor_legacy_pciid, viostor_modern_pciid + in g#cp source target; - add_guestor_to_registry t reg driver_name viostor_legacy_pciid; - add_guestor_to_registry t reg driver_name viostor_modern_pciid; - Virtio_blk in + add_guestor_to_registry t reg driver_name legacy_pciid; + add_guestor_to_registry t reg driver_name modern_pciid; + installed_block_type in (* Can we install the virtio-net driver? *) let net : net_type -- 2.31.1
Possibly Parallel Threads
- [COMMON PATCH v2 0/4] Bring support for virtio-scsi back to Windows
- [COMMON PATCH v3 3/4] mlcustomize: Add accessors for block driver priority list
- [V2V PATCH 0/5] Bring support for virtio-scsi back to Windows
- [PATCH common] mlcustomize: Add accessors for block driver priority list
- [COMMON PATCH v3 1/4] inject_virtio_win: match only vendor/device/revision