When injecting virtio-win drivers, allow the list of block drivers that we search to be modified. --- 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 4e977b3..2a7c742 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 | 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&SUBSYS_00021AF4&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 0ced02e..7bd9b9f 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.39.2 _______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://listman.redhat.com/mailman/listinfo/libguestfs