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):
|
def get_uri(self):
|
||||||
return self.uri
|
return self.uri
|
||||||
|
|
||||||
def _invalidate_caps(self):
|
def invalidate_caps(self):
|
||||||
self._caps_xml = None
|
self._caps_xml = None
|
||||||
self._caps = None
|
self._caps = None
|
||||||
|
|
||||||
def _check_caps(self):
|
def _check_caps(self):
|
||||||
self._caps_xml = self.vmm.getCapabilities()
|
if not (self._caps_xml or self._caps):
|
||||||
self._caps = virtinst.CapabilitiesParser.parse(self._caps_xml)
|
self._caps_xml = self.vmm.getCapabilities()
|
||||||
|
self._caps = virtinst.CapabilitiesParser.parse(self._caps_xml)
|
||||||
|
|
||||||
def get_capabilities_xml(self):
|
def get_capabilities_xml(self):
|
||||||
xml = None
|
if not self._caps_xml:
|
||||||
while xml == None:
|
|
||||||
self._check_caps()
|
self._check_caps()
|
||||||
xml = self._caps_xml
|
return self._caps_xml
|
||||||
|
|
||||||
return xml
|
|
||||||
|
|
||||||
def get_capabilities(self):
|
def get_capabilities(self):
|
||||||
# Make sure we aren't returning None
|
if not self._caps:
|
||||||
caps = None
|
|
||||||
while caps == None:
|
|
||||||
self._check_caps()
|
self._check_caps()
|
||||||
caps = self._caps
|
return self._caps
|
||||||
|
|
||||||
return caps
|
|
||||||
|
|
||||||
def get_max_vcpus(self, _type=None):
|
def get_max_vcpus(self, _type=None):
|
||||||
return virtinst.util.get_max_vcpus(self.vmm, _type)
|
return virtinst.util.get_max_vcpus(self.vmm, _type)
|
||||||
@ -1453,7 +1447,6 @@ class vmmConnection(gobject.GObject):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.hostinfo = self.vmm.getInfo()
|
self.hostinfo = self.vmm.getInfo()
|
||||||
self._invalidate_caps()
|
|
||||||
|
|
||||||
# Poll for new virtual network objects
|
# Poll for new virtual network objects
|
||||||
(startNets, stopNets, newNets,
|
(startNets, stopNets, newNets,
|
||||||
|
@ -399,6 +399,7 @@ class vmmCreate(gobject.GObject):
|
|||||||
|
|
||||||
# A bit out of order, but populate arch + hv lists so we can
|
# A bit out of order, but populate arch + hv lists so we can
|
||||||
# determine a default
|
# determine a default
|
||||||
|
self.conn.invalidate_caps()
|
||||||
self.caps = self.conn.get_capabilities()
|
self.caps = self.conn.get_capabilities()
|
||||||
self.change_caps()
|
self.change_caps()
|
||||||
self.populate_hv()
|
self.populate_hv()
|
||||||
|
@ -1112,7 +1112,9 @@ class vmmDomain(vmmDomainBase):
|
|||||||
return self._guest
|
return self._guest
|
||||||
|
|
||||||
def _build_guest(self, xml):
|
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):
|
def _reparse_xml(self, ignore=None):
|
||||||
self._guest = self._build_guest(self._get_domain_xml())
|
self._guest = self._build_guest(self._get_domain_xml())
|
||||||
|
Loading…
Reference in New Issue
Block a user