On 3/7/23 20:40, Andrey Drobyshev wrote: > From: "Richard W.M. Jones" <rjo...@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 <rjo...@redhat.com> > Signed-off-by: Andrey Drobyshev <andrey.drobys...@virtuozzo.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 cf078c0..345fe32 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" > @@ -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
Changes in this patch on top of Rich's: - the commit message has been extended with the sentence "This functionality will be used when we introduce an option for changing the default block driver in virt-v2v." - context difference in "type block_type" (Virtio_SCSI) - context difference in "viostor_legacy_pciid" (VEN_1AF4&DEV_1001) So I'm repeating my R-b from under Rich's patch. Reviewed-by: Laszlo Ersek <ler...@redhat.com> _______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://listman.redhat.com/mailman/listinfo/libguestfs