domcapabilities: Get arch from caps XML

This commit is contained in:
Cole Robinson 2015-02-22 11:02:55 -05:00
parent a5b3e2adab
commit 4ee9fdf944
4 changed files with 21 additions and 12 deletions

View File

@ -830,7 +830,7 @@ class vmmDetails(vmmGObjectUI):
self.widget("overview-firmware-label").set_visible(
not self.is_customize_dialog)
show_firmware = ((self.conn.is_qemu() or self.conn.is_test_conn()) and
domcaps.arch_can_uefi(arch) and
domcaps.arch_can_uefi() and
not self.vm.is_management_domain())
uiutil.set_grid_row_visible(
self.widget("overview-firmware-title"), show_firmware)

View File

@ -457,10 +457,17 @@ class VirtualConnection(object):
# if needed
if "domcaps" in opts:
domcapsxml = file(opts.pop("domcaps")).read()
def fake_domcaps(*args, **kwargs):
ignore = args
ignore = kwargs
return domcapsxml
def fake_domcaps(emulator, arch, machine, virttype, flags=0):
ignore = emulator
ignore = flags
ignore = machine
ignore = virttype
ret = domcapsxml
if arch:
ret = re.sub("arch>.+</arch", "arch>%s</arch" % arch, ret)
return ret
conn.getDomainCapabilities = fake_domcaps
if ("qemu" in opts) or ("xen" in opts) or ("lxc" in opts):

View File

@ -107,24 +107,24 @@ class DomainCapabilities(XMLBuilder):
],
}
def find_uefi_path_for_arch(self, arch):
def find_uefi_path_for_arch(self):
"""
Search the loader paths for one that matches the passed arch
"""
if not self.arch_can_uefi(arch):
if not self.arch_can_uefi():
return
patterns = self._uefi_arch_patterns.get(arch)
patterns = self._uefi_arch_patterns.get(self.arch)
for pattern in patterns:
for path in [v.value for v in self.os.loader.values]:
if re.match(pattern, path):
return path
def arch_can_uefi(self, arch):
def arch_can_uefi(self):
"""
Return True if we know how to setup UEFI for the passed arch
"""
return arch in self._uefi_arch_patterns.keys()
return self.arch in self._uefi_arch_patterns.keys()
def supports_uefi_xml(self):
"""
@ -137,3 +137,5 @@ class DomainCapabilities(XMLBuilder):
_XML_ROOT_NAME = "domainCapabilities"
os = XMLChildProperty(_OS, is_single=True)
devices = XMLChildProperty(_Devices, is_single=True)
arch = XMLProperty("./arch")

View File

@ -544,12 +544,12 @@ class Guest(XMLBuilder):
if not domcaps.supports_uefi_xml():
raise RuntimeError(_("Libvirt version does not support UEFI."))
if not domcaps.arch_can_uefi(self.os.arch):
if not domcaps.arch_can_uefi():
raise RuntimeError(
_("Don't know how to setup UEFI for arch '%s'") %
self.os.arch)
path = domcaps.find_uefi_path_for_arch(self.os.arch)
path = domcaps.find_uefi_path_for_arch()
if not path:
raise RuntimeError(_("Did not find any UEFI binary path for "
"arch '%s'") % self.os.arch)