mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-14 19:24:31 +03:00
domcapabilities: Get arch from caps XML
This commit is contained in:
parent
a5b3e2adab
commit
4ee9fdf944
@ -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)
|
||||
|
@ -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):
|
||||
|
@ -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")
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user