private void __InstallThreadHandler() { if (WinVersion.IsWOW64()) { throw new Exception("WOW64: Do not do that."); } SetInstallStatus("Installing"); if (!Installer.GetFlag(Installer.States.NetworkSettingsSaved)) { Trace.WriteLine("NetSettings not saved.."); XenVif.NetworkSettingsSaveRestore(true); Installer.SetFlag(Installer.States.NetworkSettingsSaved); } while (!Installer.SystemCleaned()) // use 'while' to abuse the 'break' statement { if (VM.GetPVToolsVersionOnFirstRun() != VM.PVToolsVersion.LessThanEight) // System clean not needed; flip all relevant flags { Installer.SetFlag(Installer.States.RemovedFromFilters); Installer.SetFlag(Installer.States.BootStartDisabled); Installer.SetFlag(Installer.States.MSIsUninstalled); Installer.SetFlag(Installer.States.DrvsAndDevsUninstalled); Installer.SetFlag(Installer.States.CleanedUp); break; } Trace.WriteLine("PV Tools < 8.x detected; cleaning.."); if (!PVDriversWipe()) // Regardless of the 'rebootOption' value, the VM has to // reboot after the first 2 actions in PVDriversWipe(), // before the new drivers can be installed { Trace.WriteLine( "Prevented old drivers from being used after " + "the system reboots. Install Agent will " + "continue after the reboot" ); if (rebootOption == RebootType.AUTOREBOOT) { TryReboot(); } else // NOREBOOT { SetInstallStatus("NeedsReboot"); } return; } // Enumerate the PCI Bus after // cleaning the system Device.Enumerate(@"ACPI\PNP0A03", true); Trace.WriteLine("Old PV Tools removal complete!"); } if (!Installer.EverythingInstalled()) { InstallCertificates(); PVDriversInstall(); } if (PVDevice.PVDevice.AllFunctioning()) { Helpers.EnsureBootStartServicesStartAtBoot(); SetInstallStatus("Installed"); } else { Helpers.EnsureBootStartServicesStartAtBoot(); if (rebootOption == RebootType.AUTOREBOOT) { TryReboot(); } else { SetInstallStatus("NeedsReboot"); } } string installStatus = GetInstallStatus(); if (!installStatus.Equals("Installed") && !installStatus.Equals("Failed")) { return; } for (;;) { if (InformInstallerInitiator(installStatus)) { Helpers.ChangeServiceStartMode( this.ServiceName, Helpers.ExpandedServiceStartMode.Manual ); break; } Thread.Sleep(15000); // 15 seconds } }
private void __InstallThreadHandler() { if (WinVersion.IsWOW64()) { throw new Exception("WOW64: Do not do that."); } SetInstallStatus(InstallStatus.Installing); if (!Installer.GetFlag(Installer.States.DriversRequired)) { if (VM.DriversRequired()) { Installer.SetFlag(Installer.States.DriversRequired); } } if (!Installer.GetFlag(Installer.States.NetworkSettingsSaved)) { Trace.WriteLine("NetSettings not saved.."); XenVif.NetworkSettingsSaveRestore(true); Installer.SetFlag(Installer.States.NetworkSettingsSaved); } while (!Installer.SystemCleaned()) // use 'while' to abuse the 'break' statement { if (VM.GetPVToolsVersionOnFirstRun() != VM.PVToolsVersion.LessThanEight) // System clean not needed; flip all relevant flags { Installer.SetFlag(Installer.States.RemovedFromFilters); Installer.SetFlag(Installer.States.BootStartDisabled); Installer.SetFlag(Installer.States.MSIsUninstalled); Installer.SetFlag(Installer.States.DrvsAndDevsUninstalled); Installer.SetFlag(Installer.States.CleanedUp); break; } Trace.WriteLine("PV Tools < 8.x detected; cleaning.."); if (!PVDriversWipe()) // Regardless of the 'rebootOption' value, the VM has to // reboot after the first 2 actions in PVDriversWipe(), // before the new drivers can be installed { Trace.WriteLine( "Prevented old drivers from being used after " + "the system reboots. Install Agent will " + "continue after the reboot" ); goto ExitReboot; } // Enumerate the PCI Bus after // cleaning the system Device.Enumerate(@"ACPI\PNP0A03", true); Trace.WriteLine("Old PV Tools removal complete!"); } if (!Installer.GetFlag(Installer.States.DriversRequired)) { SetInstallStatus(InstallStatus.Installed); goto ExitDone; } if (!Installer.EverythingInstalled()) { bool needReboot; InstallCertificates(); PVDriversInstall(out needReboot); if (needReboot) { goto ExitReboot; } } if (PVDevice.PVDevice.AllFunctioning()) { if (!Helpers.BlockUntilNoDriversInstalling(0)) { Trace.WriteLine("A driver is still installing"); while (!(Helpers.BlockUntilNoDriversInstalling(5) || VM.GetOtherDriverInstallingOnFirstRun())) { Trace.WriteLine("Waiting to see if drivers request reboot"); if (!PVDevice.PVDevice.AllFunctioning()) { Trace.WriteLine("Reboot needed"); goto ExitReboot; } } Trace.WriteLine("No reboot needed"); } goto ExitDone; } else { goto ExitReboot; } ExitReboot: Helpers.EnsureBootStartServicesStartAtBoot(); this.InstallerReboot(); return; ExitDone: Helpers.EnsureBootStartServicesStartAtBoot(); SetInstallStatus(InstallStatus.Installed); this.InstallerDone(); }