Tomáš Golembiovský
2020-Mar-05 14:37 UTC
[Libguestfs] [PATCH v4] windows: delay installation of qemu-ga MSI
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. This is just a best-effort mitigation. It can still happen (e.g. with slow disk drives) that the drivers are not yet installed when the delayed installation starts. On the other hand we cannot delay it too much otherwise we risk that the users logs in and will be doing some work when the MSI installation starts. After MSI installation finishes the VM needs to be rebooted which would be annoying if that would happen under users hands. Although this is not a best fix (that may come later as it is more complex, e.g. introducing waiting mechanism), the delay as it is defined works in most cases. And it dramaticaly improves the situations -- originaly I experienced more than 90% failure rate. Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com> --- common | 2 +- v2v/convert_windows.ml | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 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..9b90f611 100644 --- a/v2v/convert_windows.ml +++ b/v2v/convert_windows.ml @@ -428,16 +428,13 @@ popd and configure_qemu_ga files 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\" -) -" in + let fb_script = sprintf "\ +echo Removing any previously scheduled qemu-ga installation +schtasks.exe /Delete /TN Firstboot-qemu-ga /F +echo Scheduling delayed installation of qemu-ga from %s +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\\\"\" + " + msi_path msi_path msi_path in Firstboot.add_firstboot_script g inspect.i_root ("install " ^ msi_path) fb_script; ) files -- 2.25.0
Richard W.M. Jones
2020-Mar-10 12:24 UTC
Re: [Libguestfs] [PATCH v4] windows: delay installation of qemu-ga MSI
On Thu, Mar 05, 2020 at 03:37:13PM +0100, Tomáš Golembiovský wrote:> 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. > > This is just a best-effort mitigation. It can still happen (e.g. with > slow disk drives) that the drivers are not yet installed when the > delayed installation starts. On the other hand we cannot delay it too > much otherwise we risk that the users logs in and will be doing some > work when the MSI installation starts. After MSI installation finishes > the VM needs to be rebooted which would be annoying if that would happen > under users hands. Although this is not a best fix (that may come later > as it is more complex, e.g. introducing waiting mechanism), the delay as > it is defined works in most cases. And it dramaticaly improves the > situations -- originaly I experienced more than 90% failure rate. > > Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com> > --- > common | 2 +- > v2v/convert_windows.ml | 17 +++++++---------- > 2 files changed, 8 insertions(+), 11 deletions(-) > > diff --git a/common b/common > index ea10827b..5371257c 160000 > --- a/common > +++ b/common > @@ -1 +1 @@ > -Subproject commit ea10827b4cfb3cfe5f782421c01d2902e5f73f90 > +Subproject commit 5371257c3cf27fb09d5f2e31ba378b0e6ccf5df6I think(?) this hunk was not intended?> diff --git a/v2v/convert_windows.ml b/v2v/convert_windows.ml > index 0fda1d4e..9b90f611 100644 > --- a/v2v/convert_windows.ml > +++ b/v2v/convert_windows.ml > @@ -428,16 +428,13 @@ popd > and configure_qemu_ga files > 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\" > -) > -" in > + let fb_script = sprintf "\ > +echo Removing any previously scheduled qemu-ga installation > +schtasks.exe /Delete /TN Firstboot-qemu-ga /F > +echo Scheduling delayed installation of qemu-ga from %s > +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\\\"\" > + " > + msi_path msi_path msi_path in > Firstboot.add_firstboot_script g inspect.i_root > ("install " ^ msi_path) fb_script; > ) files > --This part looks fine, ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
Tomáš Golembiovský
2020-Mar-10 13:12 UTC
Re: [Libguestfs] [PATCH v4] windows: delay installation of qemu-ga MSI
> > diff --git a/common b/common > > index ea10827b..5371257c 160000 > > --- a/common > > +++ b/common > > @@ -1 +1 @@ > > -Subproject commit ea10827b4cfb3cfe5f782421c01d2902e5f73f90 > > +Subproject commit 5371257c3cf27fb09d5f2e31ba378b0e6ccf5df6 > > I think(?) this hunk was not intended? >Yes, that's a mistake. Sorry for that. Tomas -- Tomáš Golembiovský <tgolembi@redhat.com>
Reasonably Related Threads
- [PATCH v3] windows: delay installation of qemu-ga MSI
- Re: [PATCH v3] windows: delay installation of qemu-ga MSI
- Re: [PATCH 1/1] windows: delay installation of qemu-ga MSI
- Re: [PATCH v4] windows: delay installation of qemu-ga MSI
- Re: [PATCH v3] windows: delay installation of qemu-ga MSI