Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit dbc5821

Browse files
committed
Pull emulator and loader values from capabilities.
1 parent f00ee91 commit dbc5821

2 files changed

Lines changed: 26 additions & 8 deletions

File tree

virtinst/FullVirtGuest.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import DistroManager
2727
import logging
2828
import time
29+
import platform
30+
2931
from VirtualDisk import VirtualDisk
3032
from DistroManager import PXEInstaller
3133
from virtinst import _virtinst as _
@@ -168,18 +170,31 @@ def __init__(self, type=None, arch=None, connection=None, hypervisorURI=None, em
168170
Guest.Guest.__init__(self, type, connection, hypervisorURI, installer)
169171
self.disknode = "hd"
170172
self.features = { "acpi": None, "pae": util.is_pae_capable(), "apic": None }
173+
if arch is None:
174+
arch = platform.machine
171175
self.arch = arch
172-
if emulator is None:
176+
177+
self.emulator = emulator
178+
self.loader = None
179+
guest = self._caps.guestForOSType(type=self.installer.os_type,
180+
arch=self.arch)
181+
if (not self.emulator) and guest:
182+
for dom in guest.domains:
183+
if dom.hypervisor_type == self.installer.type:
184+
self.emulator = dom.emulator
185+
self.loader = dom.loader
186+
187+
# Fall back to default hardcoding
188+
if self.emulator is None:
173189
if self.type == "xen":
174190
if os.uname()[4] in ("x86_64"):
175-
emulator = "/usr/lib64/xen/bin/qemu-dm"
191+
self.emulator = "/usr/lib64/xen/bin/qemu-dm"
176192
else:
177-
emulator = "/usr/lib/xen/bin/qemu-dm"
178-
self.emulator = emulator
179-
if self.type == "xen":
193+
self.emulator = "/usr/lib/xen/bin/qemu-dm"
194+
195+
if (not self.loader) and self.type == "xen":
180196
self.loader = "/usr/lib/xen/boot/hvmloader"
181-
else:
182-
self.loader = None
197+
183198
self._os_type = None
184199
self._os_variant = None
185200

virtinst/Guest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import util
2929
import libvirt
3030
import __builtin__
31+
import CapabilitiesParser
3132
from VirtualDisk import VirtualDisk
3233
from virtinst import _virtinst as _
3334

@@ -395,7 +396,9 @@ def __init__(self, type=None, connection=None, hypervisorURI=None, installer=Non
395396
hypervisorURI)
396397
self.conn = libvirt.open(hypervisorURI)
397398
if self.conn == None:
398-
raise RuntimeError, _("Unable to connect to hypervisor, aborting installation!")
399+
raise RuntimeError, _("Unable to connect to hypervisor, aborting "
400+
"installation!")
401+
self._caps = CapabilitiesParser.parse(self.conn.getCapabilities())
399402

400403
self.disknode = None # this needs to be set in the subclass
401404

0 commit comments

Comments
 (0)