[Libguestfs] [PATCH v2v] convert: Allow preferred block driver to be specified on the command line

Laszlo Ersek lersek at redhat.com
Tue Mar 7 07:48:56 UTC 2023


On 3/6/23 17:52, Richard W.M. Jones wrote:

> diff --git a/convert/convert_windows.ml b/convert/convert_windows.ml
> index 9d8d271d05..f36b486359 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. *)
>  
> @@ -47,6 +47,16 @@ let convert (g : G.guestfs) _ inspect i_firmware _ 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.
>     *

So ["virtio_blk"; "vrtioblk"; "viostor"] in
"common/mlcustomize/inject_virtio_win.ml" would be replaced with a
reference cell, and get_block_driver_priority /
set_block_driver_priority would manipulate that.

This looks OK to me.

That said, I'd prefer that this patch be split up a bit (by Andrey).
Patch#1 could introduce the new field and make sure it is passed around
(incl. setting the default virtio-blk value); that's purely boilerplate,
so the patch would be well-focused. Patch #2 could glue the new field to
the new Inject_virtio_win APIs, in "convert_windows.ml". Patch#3 could
implement the command line changes and update the documentation.

Laszlo


More information about the Libguestfs mailing list