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:
parent
94cf9a204b
commit
abbc828b70
|
@ -127,6 +127,9 @@ class VirtualGraphics(VirtualDevice):
|
||||||
if channels:
|
if channels:
|
||||||
self.channels = 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):
|
def _default_keymap(self, force_local=False):
|
||||||
if (not force_local and self.conn and
|
if (not force_local and self.conn and
|
||||||
|
|
|
@ -434,10 +434,20 @@ class XMLBuilderDomain(object):
|
||||||
except:
|
except:
|
||||||
pass
|
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):
|
def copy(self):
|
||||||
# Otherwise we can double free XML info
|
# Otherwise we can double free XML info
|
||||||
if self._is_parse():
|
if self._is_parse():
|
||||||
return self
|
return self
|
||||||
|
self._cache()
|
||||||
return copy.copy(self)
|
return copy.copy(self)
|
||||||
|
|
||||||
def get_conn(self):
|
def get_conn(self):
|
||||||
|
|
Loading…
Reference in New Issue