mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

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

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