VirtualGraphics: Don't lookup local keymap over and over

Triggered with virt-manager: new vm -> customize before install with a
non qemu. Guest.get_xml_config copies each device so it can set defaults
in a non persistent way. Unfortunately VirtualGraphics was copied before
a keymap lookup was ever done. End result was that we called
util.default_keymap over and over which is slow and floods the logs.
This commit is contained in:
Cole Robinson 2013-04-13 16:18:03 -04:00
parent 94cf9a204b
commit abbc828b70
2 changed files with 13 additions and 0 deletions

View File

@ -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

View File

@ -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):