• D
    Support reboots with the QEMU driver · 42f43592
    Daniel P. Berrange 提交于
    For controlled shutdown we issue a 'system_powerdown' command
    to the QEMU monitor. This triggers an ACPI event which (most)
    guest OS wire up to a controlled shutdown. There is no equiv
    ACPI event to trigger a controlled reboot. This patch attempts
    to fake a reboot.
    
     - In qemuDomainObjPrivatePtr we have a bool fakeReboot
       flag.
     - The virDomainReboot method sets this flag and then
       triggers a normal 'system_powerdown'.
     - The QEMU process is started with '-no-shutdown'
       so that the guest CPUs pause when it powers off the
       guest
     - When we receive the 'POWEROFF' event from QEMU JSON
       monitor if fakeReboot is not set we invoke the
       qemuProcessKill command and shutdown continues
       normally
     - If fakeReboot was set, we spawn a background thread
       which issues 'system_reset' to perform a warm reboot
       of the guest hardware. Then it issues 'cont' to
       start the CPUs again
    
    * src/qemu/qemu_command.c: Add -no-shutdown flag if
      we have JSON support
    * src/qemu/qemu_domain.h: Add 'fakeReboot' flag to
      qemuDomainObjPrivate struct
    * src/qemu/qemu_driver.c: Fake reboot using the
      system_powerdown command if JSON support is available
    * src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
      src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h,
      src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h: Add
      binding for system_reset command
    * src/qemu/qemu_process.c: Reset the guest & start CPUs if
      fakeReboot is set
    42f43592
qemu_process.c 90.9 KB