Analysis of Virtual Client Shutdown Process
Shutdown Process
The shutdown process of a Converge Cloud Windows instance is as follows:
- The libvirt on the host transmits the shutdown command to the qemu component through the qmp protocol.
- The qemu component transmits the shutdown command to the instance by injecting the ACPI interrupt (For details, see the vmcs technical documentation).
- After receiving a shutdown signal, the Windows instance notifies applications and service processes to exit.
- Close the core service processes.
- Turn off the power.
In Step 3 and Step 4, the shutdown order of various applications and services may vary depending on the system settings.
Windows is a closed-source system that provides some APIs to allow kernel-mode and user-mode programs to intervene in the shutdown process. At the same time, some services of Windows itself will affect the shutdown process during operation, resulting in failure to shut down the computer. Therefore, in some cases, the Windows shutdown process can be quite lengthy.
Hard Shutdown
In virtual scenes, in addition to notifying Windows of its own shutdown through messages, there is also another way to stop instances. This method is similar to turning off the power on a physical machine. We call this shutdown method hard shutdown. The shutdown operation initiated by system signals is relatively referred to as soft shutdown.
Hard shutdown has an impact on both Windows itself and user experience, mainly in the following two aspects:
- Hard shutdown interrupts certain services and applications, which may cause them to malfunction, such as unsaved documents or uncompleted Windows Update process.
- As the Windows NTFS system (or earlier systems such as FAT32) will write some critical data during the shutdown process, hard shutdown may cause these critical data not to be written to the disk, causing Windows to believe that the NTFS file system is damaged.
Based on the above reasons, we recommend that users of Converge Cloud prioritize soft shutdown to shut down Windows instances.
Several Scenes of Shutdown Failure
There may be some problems in the Windows system that affect the shutdown process and result in shutdown failure. Shutdown failures include but are not limited to the following scenes:
- The Windows update process may extend the shutdown time. When Windows performs certain patch operations, it will display prompt messages when shutting down the system. At this time, prompt messages such as "Please do not turn off the computer power or unplug the power cord" will generally appear on the screen.
- If the Shutdown Event Tracking mechanism is enabled in the Windows system, when errors occur in the system's services and drivers and lead to shutdown of the system, the system will, based on the configuration, prompt the user with a dialog box or allow the user to fill in an error description, and will wait for the user to complete these operations before shutdown. Windows will not shut down until the user completes the specified operation.
- Windows can be set to not allow shutdown when the user is not logged in to the system. In this case, the soft shutdown command sent by the virtual host will be discarded by Windows, making it impossible to shut down.
- Before Windows shuts down, it will broadcast a shutdown message to every service and application. If these programs do not return a shutdown response after receiving this message, the shutdown process will not be proceeded. In this scene, Windows can be set to ignore this process.
- In the Windows power management settings, if the Windows Processing Method When the Power Button Is Pressed is set to Ignore or No Operation, Windows will ignore the shutdown event of the virtualization host.
- When Windows enters hibernation due to power management settings, it will not process the shutdown event.
- If some malicious software is installed in the Windows system, or if a Trojan or virus is infected, the Windows system environment itself is damaged, which may cause Windows shutdown to be blocked.
When Converge Cloud releases the Windows public image, most of the above scenes are optimized so that soft shutdown can be completed smoothly. However, these optimization measures cannot guarantee smooth shutdown in scenes where Windows is infected with viruses or Trojans and the system is damaged. Furthermore, if these settings in the user's Windows instance are adjusted again, a smooth soft shutdown still cannot be guaranteed.
Forced shutdown may cause risks. It is recommended to perform hard shutdown only when it is absolutely necessary.