Blob Blame History Raw
From 54ee5f5734616f4ab9e40795f829884884275040 Mon Sep 17 00:00:00 2001
From: Cole Robinson <crobinso@redhat.com>
Date: Fri, 12 Sep 2014 10:15:09 -0400
Subject: [PATCH 05/12] domain: Cache autostart value

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1111986

(cherry picked from commit 50415298225518b98908fc9d240fc82466507439)
---
 virtManager/domain.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/virtManager/domain.py b/virtManager/domain.py
index 864c591..f28bad2 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -300,6 +300,7 @@ class vmmDomain(vmmLibvirtObject):
         self._uuid = None
         self._has_managed_save = None
         self._snapshot_list = None
+        self._autostart = None
 
         self.lastStatus = libvirt.VIR_DOMAIN_SHUTOFF
         self._lastStatusReason = getattr(libvirt, "VIR_DOMAIN_SHUTOFF_SHUTDOWN",
@@ -1012,12 +1013,16 @@ class vmmDomain(vmmLibvirtObject):
         return self._backend.XMLDesc(flags)
 
     def get_autostart(self):
-        return self._backend.autostart()
+        if self._autostart is None:
+            self._autostart = self._backend.autostart()
+        return self._autostart
     def set_autostart(self, val):
-        if self.get_autostart() == val:
-            return
         self._backend.setAutostart(val)
 
+        # Recache value
+        self._autostart = None
+        self.get_autostart()
+
     def job_info(self):
         return self._backend.jobInfo()
     def abort_job(self):
-- 
1.9.3