diff --git a/virtinst/VirtualGraphics.py b/virtinst/VirtualGraphics.py index 93de7d2c..835d21d1 100644 --- a/virtinst/VirtualGraphics.py +++ b/virtinst/VirtualGraphics.py @@ -127,6 +127,9 @@ class VirtualGraphics(VirtualDevice): if channels: self.channels = channels + def _cache(self): + # Make sure we've cached the _local_keymap value before copy() + self._default_keymap() def _default_keymap(self, force_local=False): if (not force_local and self.conn and diff --git a/virtinst/XMLBuilderDomain.py b/virtinst/XMLBuilderDomain.py index 74e0eed9..195c0623 100644 --- a/virtinst/XMLBuilderDomain.py +++ b/virtinst/XMLBuilderDomain.py @@ -434,10 +434,20 @@ class XMLBuilderDomain(object): except: pass + def _cache(self): + """ + This is a hook for classes to cache any state that is expensive + to lookup before we copy the object as part of Guest.get_xml_config. + Saves us from possibly doing the lookup over and over + """ + pass + + def copy(self): # Otherwise we can double free XML info if self._is_parse(): return self + self._cache() return copy.copy(self) def get_conn(self):