[Libguestfs] [PATCH v2] windows: delay installation of qemu-ga MSI

Tomáš Golembiovský tgolembi at redhat.com
Tue Mar 3 13:28:44 UTC 2020


Instead of running firstboot script during early boot schedule a task
delayed for 2 minutes.

During the first boot, after virt-v2v conversion, Windows installs the
drivers injected by virt-v2v. When this installation is finished
Windows enforces some kind of internal reboot. This unfortunately
terminates any running firstboot scripts thus killing the installation
of qemu-ga MSI.

Signed-off-by: Tomáš Golembiovský <tgolembi at redhat.com>
---
 common                 |  2 +-
 v2v/convert_windows.ml | 12 ++++--------
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/common b/common
index ea10827b..5371257c 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit ea10827b4cfb3cfe5f782421c01d2902e5f73f90
+Subproject commit 5371257c3cf27fb09d5f2e31ba378b0e6ccf5df6
diff --git a/v2v/convert_windows.ml b/v2v/convert_windows.ml
index 0fda1d4e..bed5989a 100644
--- a/v2v/convert_windows.ml
+++ b/v2v/convert_windows.ml
@@ -429,14 +429,10 @@ popd
    List.iter (
      fun msi_path ->
        let fb_script = "\
-echo Installing qemu-ga from " ^ msi_path ^ "
-\"\\" ^ msi_path ^ "\" /norestart /qn /l+*vx \"%~dpn0.log\"
-set elvl=!errorlevel!
-echo Done installing qemu-ga error_level=!elvl!
-if !elvl! == 0 (
-  echo Restarting Windows...
-  shutdown /r /f /c \"rebooted by firstboot script\"
-)
+echo Removing any previously scheduled qemu-ga installation
+schtasks.exe /Delete /TN Firstboot-qemu-ga /F
+echo Scheduling delayed installation of qemu-ga from " ^ msi_path ^ "
+powershell.exe -command \"$d = (get-date).AddSeconds(120); schtasks.exe /Create /SC ONCE /ST $d.ToString('HH:mm') /SD $d.ToString('MM/dd/yyyy') /RU SYSTEM /TN Firstboot-qemu-ga /TR \\\"C:\\" ^ msi_path ^ " /forcerestart /qn /l+*vx C:\\" ^ msi_path ^ ".log\\\"\"
 " in
       Firstboot.add_firstboot_script g inspect.i_root
         ("install " ^ msi_path) fb_script;
-- 
2.25.0





More information about the Libguestfs mailing list