core/hvm: fix error message when creating HVM while not supported by the hardware

libvirt reports such errors at domain definition, not startup (as was in
libxl).

QubesOS/qubes-issues#1198
This commit is contained in:
Marek Marczykowski-Górecki 2015-09-25 22:21:10 +02:00
parent 4a4d16feb9
commit b9e6b0a076
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -711,7 +711,15 @@ class QubesVm(object):
def _update_libvirt_domain(self):
domain_config = self.create_config_file()
self._libvirt_domain = vmm.libvirt_conn.defineXML(domain_config)
try:
self._libvirt_domain = vmm.libvirt_conn.defineXML(domain_config)
except libvirt.libvirtError as e:
# shouldn't this be in QubesHVm implementation?
if e.get_error_code() == libvirt.VIR_ERR_OS_TYPE and \
e.get_str2() == 'hvm':
raise QubesException("HVM domains not supported on this "
"machine. Check BIOS settings for "
"VT-x/AMD-V extensions.")
self.uuid = uuid.UUID(bytes=self._libvirt_domain.UUID())
@property