[Libguestfs] [PATCH 2/2] firstboot: schedule firstboot as delayed task

Tomáš Golembiovský tgolembi at redhat.com
Thu Nov 21 11:04:18 UTC 2019


Instead of running firstboot scripts during early boot schedule a task
delayed for 1-2 minute.

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

Hopefully delaying the installtion to some later time can also fix
problem we sometimes saw on Windows 2012R2 when installing RHEV-APT,
where the installer terminated immediately with the error:

  Failed to connect to server. Error: 0x8007045B

Signed-off-by: Tomáš Golembiovský <tgolembi at redhat.com>
---
 mlcustomize/firstboot.ml | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/mlcustomize/firstboot.ml b/mlcustomize/firstboot.ml
index c3ebfd9..b4ca181 100644
--- a/mlcustomize/firstboot.ml
+++ b/mlcustomize/firstboot.ml
@@ -286,10 +286,18 @@ set log=%%firstboot%%\\log.txt
 set scripts=%%firstboot%%\\scripts
 set scripts_done=%%firstboot%%\\scripts-done
 
-call :main >> \"%%log%%\" 2>&1
+call :main %%1 >> \"%%log%%\" 2>&1
 exit /b
 
 :main
+
+if not '%%1' == 'real' (
+    REM schedule delayed task
+    schtasks.exe /Delete /TN Firstboot /F
+    powershell.exe -command \"$d = (get-date).AddSeconds(119); schtasks.exe /Create /SC ONCE /ST $d.ToString('HH:mm') /SD $d.ToString('MM/dd/yyyy') /RU SYSTEM /TN Firstboot /TR \\\"%%~dpnx0 real\\\"\"
+    exit /b
+)
+
 echo starting firstboot service
 
 if not exist \"%%scripts_done%%\" (
-- 
2.24.0





More information about the Libguestfs mailing list