Blame SOURCES/0064-windows-delay-installation-of-qemu-ga-MSI.patch

da373f
From 898b0654a0c4ef55af147a5ca081d2399ce05855 Mon Sep 17 00:00:00 2001
3efd08
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= <tgolembi@redhat.com>
3efd08
Date: Thu, 5 Mar 2020 15:37:13 +0100
3efd08
Subject: [PATCH] windows: delay installation of qemu-ga MSI
3efd08
MIME-Version: 1.0
3efd08
Content-Type: text/plain; charset=UTF-8
3efd08
Content-Transfer-Encoding: 8bit
3efd08
3efd08
Instead of running firstboot script during early boot schedule a task
3efd08
delayed for 2 minutes.
3efd08
3efd08
During the first boot, after virt-v2v conversion, Windows installs the
3efd08
drivers injected by virt-v2v. When this installation is finished
3efd08
Windows enforces some kind of internal reboot. This unfortunately
3efd08
terminates any running firstboot scripts thus killing the installation
3efd08
of qemu-ga MSI.
3efd08
3efd08
This is just a best-effort mitigation. It can still happen (e.g. with
3efd08
slow disk drives) that the drivers are not yet installed when the
3efd08
delayed installation starts. On the other hand we cannot delay it too
3efd08
much otherwise we risk that the users logs in and will be doing some
3efd08
work when the MSI installation starts. After MSI installation finishes
3efd08
the VM needs to be rebooted which would be annoying if that would happen
3efd08
under users hands. Although this is not a best fix (that may come later
3efd08
as it is more complex, e.g. introducing waiting mechanism), the delay as
3efd08
it is defined works in most cases. And it dramaticaly improves the
3efd08
situations -- originaly I experienced more than 90% failure rate.
3efd08
3efd08
Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
3efd08
3efd08
(cherry picked from commit dc66e78fa37db33e3c7358b7f7c7fa809cf62f9d
3efd08
in virt-v2v)
3efd08
---
3efd08
 v2v/convert_windows.ml | 17 +++++++----------
3efd08
 1 file changed, 7 insertions(+), 10 deletions(-)
3efd08
3efd08
diff --git a/v2v/convert_windows.ml b/v2v/convert_windows.ml
3efd08
index 43c1f85de..088cd33d9 100644
3efd08
--- a/v2v/convert_windows.ml
3efd08
+++ b/v2v/convert_windows.ml
3efd08
@@ -428,16 +428,13 @@ popd
3efd08
  and configure_qemu_ga files =
3efd08
    List.iter (
3efd08
      fun msi_path ->
3efd08
-       let fb_script = "\
3efd08
-echo Installing qemu-ga from " ^ msi_path ^ "
3efd08
-\"\\" ^ msi_path ^ "\" /norestart /qn /l+*vx \"%~dpn0.log\"
3efd08
-set elvl=!errorlevel!
3efd08
-echo Done installing qemu-ga error_level=!elvl!
3efd08
-if !elvl! == 0 (
3efd08
-  echo Restarting Windows...
3efd08
-  shutdown /r /f /c \"rebooted by firstboot script\"
3efd08
-)
3efd08
-" in
3efd08
+       let fb_script = sprintf "\
3efd08
+echo Removing any previously scheduled qemu-ga installation
3efd08
+schtasks.exe /Delete /TN Firstboot-qemu-ga /F
3efd08
+echo Scheduling delayed installation of qemu-ga from %s
3efd08
+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:\\%s /forcerestart /qn /l+*vx C:\\%s.log\\\"\"
3efd08
+      "
3efd08
+      msi_path msi_path msi_path in
3efd08
       Firstboot.add_firstboot_script g inspect.i_root
3efd08
         ("install " ^ msi_path) fb_script;
3efd08
     ) files
3efd08
-- 
da373f
2.18.4
3efd08