diff --git a/virtinst/domain/pm.py b/virtinst/domain/pm.py index 513442072..e6dae9d67 100644 --- a/virtinst/domain/pm.py +++ b/virtinst/domain/pm.py @@ -13,3 +13,23 @@ class DomainPm(XMLBuilder): suspend_to_mem = XMLProperty("./suspend-to-mem/@enabled", is_yesno=True) suspend_to_disk = XMLProperty("./suspend-to-disk/@enabled", is_yesno=True) + + + ################## + # Default config # + ################## + + def set_defaults(self, guest): + # When the suspend feature is exposed to VMs, an ACPI shutdown + # event triggers a suspend in the guest, which causes a lot of + # user confusion (especially compounded with the face that suspend + # is often buggy so VMs can get hung, etc). + # + # We've been disabling this in virt-manager for a while, but lets + # do it here too for consistency. + if (guest.os.is_x86() and + self.conn.check_support(self.conn.SUPPORT_CONN_PM_DISABLE)): + if self.suspend_to_mem is None: + self.suspend_to_mem = False + if self.suspend_to_disk is None: + self.suspend_to_disk = False diff --git a/virtinst/guest.py b/virtinst/guest.py index 11e0a0b01..ec56f32f8 100644 --- a/virtinst/guest.py +++ b/virtinst/guest.py @@ -757,7 +757,7 @@ class Guest(XMLBuilder): self.features.set_defaults(self) for seclabel in self.seclabels: seclabel.set_defaults(self) - self._set_pm_defaults() + self.pm.set_defaults(self) for dev in self.devices.get_all(): dev.set_defaults(self) @@ -918,21 +918,6 @@ class Guest(XMLBuilder): if i.name == "hypervclock": self.clock.remove_timer(i) - def _set_pm_defaults(self): - # When the suspend feature is exposed to VMs, an ACPI shutdown - # event triggers a suspend in the guest, which causes a lot of - # user confusion (especially compounded with the face that suspend - # is often buggy so VMs can get hung, etc). - # - # We've been disabling this in virt-manager for a while, but lets - # do it here too for consistency. - if (self.os.is_x86() and - self.conn.check_support(self.conn.SUPPORT_CONN_PM_DISABLE)): - if self.pm.suspend_to_mem is None: - self.pm.suspend_to_mem = False - if self.pm.suspend_to_disk is None: - self.pm.suspend_to_disk = False - def _add_implied_controllers(self): has_spapr_scsi = False has_virtio_scsi = False