mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
Domain: Pass pre-parsed capabilities to virtinst objects
Saves us from continually refetching caps and parsing. Also, only refresh connection caps when we launch the create wizard: changing caps shouldn't be common, and are really only important when creating guests.
This commit is contained in:
parent
5320431d85
commit
8b371b6e22
@ -261,30 +261,24 @@ class vmmConnection(gobject.GObject):
|
||||
def get_uri(self):
|
||||
return self.uri
|
||||
|
||||
def _invalidate_caps(self):
|
||||
def invalidate_caps(self):
|
||||
self._caps_xml = None
|
||||
self._caps = None
|
||||
|
||||
def _check_caps(self):
|
||||
self._caps_xml = self.vmm.getCapabilities()
|
||||
self._caps = virtinst.CapabilitiesParser.parse(self._caps_xml)
|
||||
if not (self._caps_xml or self._caps):
|
||||
self._caps_xml = self.vmm.getCapabilities()
|
||||
self._caps = virtinst.CapabilitiesParser.parse(self._caps_xml)
|
||||
|
||||
def get_capabilities_xml(self):
|
||||
xml = None
|
||||
while xml == None:
|
||||
if not self._caps_xml:
|
||||
self._check_caps()
|
||||
xml = self._caps_xml
|
||||
|
||||
return xml
|
||||
return self._caps_xml
|
||||
|
||||
def get_capabilities(self):
|
||||
# Make sure we aren't returning None
|
||||
caps = None
|
||||
while caps == None:
|
||||
if not self._caps:
|
||||
self._check_caps()
|
||||
caps = self._caps
|
||||
|
||||
return caps
|
||||
return self._caps
|
||||
|
||||
def get_max_vcpus(self, _type=None):
|
||||
return virtinst.util.get_max_vcpus(self.vmm, _type)
|
||||
@ -1453,7 +1447,6 @@ class vmmConnection(gobject.GObject):
|
||||
return
|
||||
|
||||
self.hostinfo = self.vmm.getInfo()
|
||||
self._invalidate_caps()
|
||||
|
||||
# Poll for new virtual network objects
|
||||
(startNets, stopNets, newNets,
|
||||
|
@ -399,6 +399,7 @@ class vmmCreate(gobject.GObject):
|
||||
|
||||
# A bit out of order, but populate arch + hv lists so we can
|
||||
# determine a default
|
||||
self.conn.invalidate_caps()
|
||||
self.caps = self.conn.get_capabilities()
|
||||
self.change_caps()
|
||||
self.populate_hv()
|
||||
|
@ -1112,7 +1112,9 @@ class vmmDomain(vmmDomainBase):
|
||||
return self._guest
|
||||
|
||||
def _build_guest(self, xml):
|
||||
return virtinst.Guest(connection=self.connection.vmm, parsexml=xml)
|
||||
return virtinst.Guest(connection=self.connection.vmm,
|
||||
parsexml=xml,
|
||||
caps=self.connection.get_capabilities())
|
||||
|
||||
def _reparse_xml(self, ignore=None):
|
||||
self._guest = self._build_guest(self._get_domain_xml())
|
||||
|
Loading…
Reference in New Issue
Block a user