mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 17:06:09 +00:00
fix(instances): power off does not wait a minute for a guest agent that hangs
libvirt shuts a VM down through its guest agent when one is connected, and waits 60 s for an agent that hangs before it presses the ACPI power button. The Power Off request hung for that minute, holding the VM's lock. A running VM's connected agent is now pinged first; one that does not answer in 10 s is passed over and the power button is pressed.
This commit is contained in:
parent
3412c63417
commit
272a40f4e1
2 changed files with 41 additions and 1 deletions
|
|
@ -19,6 +19,7 @@ from libvirt import (
|
|||
VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP,
|
||||
VIR_DOMAIN_PAUSED,
|
||||
VIR_DOMAIN_RUNNING,
|
||||
VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN,
|
||||
VIR_DOMAIN_SHUTOFF,
|
||||
VIR_DOMAIN_START_PAUSED,
|
||||
VIR_DOMAIN_XML_SECURE,
|
||||
|
|
@ -694,7 +695,18 @@ class wvmInstance(wvmConnect):
|
|||
check_hostdevs(self, dom.name(), [etree.fromstring(xml)], restore)
|
||||
|
||||
def shutdown(self):
|
||||
self.instance.shutdown()
|
||||
"""libvirt asks a connected guest agent first and waits 60 s for one
|
||||
that hangs before it presses the ACPI power button: an agent that
|
||||
does not answer a ping in AGENT_TIMEOUT is passed over. One that
|
||||
answers with an error (guest-ping disabled) may still shut it down."""
|
||||
flags = 0
|
||||
if self.instance.state()[0] == VIR_DOMAIN_RUNNING and self.is_agent_ready():
|
||||
try:
|
||||
self.ping_agent()
|
||||
except libvirtError as err:
|
||||
if err.get_error_code() != VIR_ERR_AGENT_COMMAND_FAILED:
|
||||
flags = VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN
|
||||
self.instance.shutdownFlags(flags)
|
||||
|
||||
def force_shutdown(self):
|
||||
self.instance.destroy()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue