Andrey Drobyshev
2023-Mar-08 18:05 UTC
[Libguestfs] [V2V PATCH 0/1] convert_windows: add firstboot script to install drivers with pnputil
I've been experiencing problem with the drivers not always being installed.
This patch merely implements the solution offered by Richard in the
commit 73e009c04 ("v2v: windows: Document use of pnputil to install
drivers."). The solution wasn't implemented back then, but rather
added
merely as a comment. Thus I wonder is there some issues which it may
cause?
The most obvious issue I can think of is that this way we would install
all the drivers put into the driver store, rather than letting Windows
pick them one by one for the unknown devices only. But since each of
these drivers we put there for a good reason (discovering present
devices during conversion phase), this shouldn't really be a problem.
Andrey Drobyshev (1):
convert_windows: add firstboot script to install drivers with pnputil
convert/convert_windows.ml | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
--
2.31.1
Andrey Drobyshev
2023-Mar-08 18:05 UTC
[Libguestfs] [V2V PATCH 1/1] convert_windows: add firstboot script to install drivers with pnputil
During conversion we copy the necessary drivers to the directory
"%systemroot%\Drivers\Virtio", adding it to the DevicePath registry
value. As documented in [1], this should be enough for Windows to find
device drivers and successfully install them.
However, it doesn't always happen. Commit 73e009c04 ("v2v: windows:
Document use of pnputil to install drivers.") describes such issues with
Win2k12R2. I'm seeing the same problem with Win2k16 and netkvm.sys
driver not being installed.
That same commit 73e009c04 suggests adding a firstboot script invoking
pnputil at an early stage to install all the drivers we put into the
drivers store. So let's add such a script to make sure all the
necessary drivers are installed.
[1]
https://learn.microsoft.com/en-us/windows-hardware/drivers/install/how-windows-selects-a-driver-for-a-device
Signed-off-by: Andrey Drobyshev <andrey.drobyshev at virtuozzo.com>
---
convert/convert_windows.ml | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/convert/convert_windows.ml b/convert/convert_windows.ml
index 6bc2343b..e15a5e62 100644
--- a/convert/convert_windows.ml
+++ b/convert/convert_windows.ml
@@ -295,9 +295,11 @@ let convert (g : G.guestfs) _ inspect i_firmware
block_driver _ static_ips | Virt -> Virt
and configure_firstboot () - (* Note that pnp_wait.exe must be the first
firstboot script as it
- * suppresses PnP for all following scripts.
+ (* Run the firstboot script with pnputil.exe before the one with
+ * pnp_wait.exe as the latter suppresses PnP for all following scripts.
*)
+ configure_pnputil_install ();
+
let tool_path = virt_tools_data_dir () // "pnp_wait.exe" in
if Sys.file_exists tool_path then
configure_wait_pnp tool_path
@@ -345,6 +347,16 @@ let convert (g : G.guestfs) _ inspect i_firmware
block_driver _ static_ips strkey name value
| None -> sprintf "reg delete \"%s\" /v %s /f"
strkey name
+ and configure_pnputil_install () + let fb_script = "@echo off\n\
+ \n\
+ echo Wait for VirtIO drivers to be installed\n\
+ %systemroot%\\Sysnative\\PnPutil -i -a \
+ %systemroot%\\Drivers\\Virtio\\*.inf
>\"%~dpn0.log\" 2>&1\
+ " in
+ Firstboot.add_firstboot_script g inspect.i_root
+ "pnputil install drivers" fb_script;
+
and configure_wait_pnp tool_path (* Prevent destructive interactions of
firstboot with PnP. *)
--
2.31.1
Possibly Parallel Threads
- [V2V PATCH v2 1/1] convert_windows: add firstboot script to install drivers with pnputil
- [V2V PATCH 1/1] convert_windows: add firstboot script to install drivers with pnputil
- [V2V PATCH 1/1] convert_windows: add firstboot script to install drivers with pnputil
- [V2V PATCH 1/1] convert_windows: add firstboot script to install drivers with pnputil
- [V2V PATCH 1/1] convert_windows: add firstboot script to install drivers with pnputil