19
19
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
20
# MA 02110-1301 USA.
23
import DistroInstaller
25
22
from Guest import Guest
26
from VirtualDevice import VirtualDevice
27
from VirtualDisk import VirtualDisk
28
from VirtualInputDevice import VirtualInputDevice
29
from VirtualCharDevice import VirtualCharDevice
31
24
class FullVirtGuest(Guest):
26
_default_os_type = "hvm"
33
28
def __init__(self, type=None, arch=None, connection=None,
34
hypervisorURI=None, emulator=None, installer=None):
36
installer = DistroInstaller.DistroInstaller(type = type,
39
Guest.__init__(self, type, connection, hypervisorURI, installer)
44
self.features = { "acpi": None, "pae":
45
_util.is_pae_capable(self.conn), "apic": None }
29
hypervisorURI=None, emulator=None, installer=None,
31
Guest.__init__(self, type, connection, hypervisorURI, installer,
47
34
self.emulator = emulator
52
guest = self._caps.guestForOSType(type=self.installer.os_type,
54
if (not self.emulator) and guest:
55
for dom in guest.domains:
56
if dom.hypervisor_type == self.installer.type:
57
self.emulator = dom.emulator
58
self.loader = dom.loader
60
# Fall back to default hardcoding
61
if self.emulator is None:
62
if self.type == "xen":
63
if self._caps.host.arch in ("x86_64"):
64
self.emulator = "/usr/lib64/xen/bin/qemu-dm"
66
self.emulator = "/usr/lib/xen/bin/qemu-dm"
68
if (not self.loader) and self.type == "xen":
69
self.loader = "/usr/lib/xen-default/boot/hvmloader"
71
# Add a default console device
72
dev = VirtualCharDevice.get_dev_instance(self.conn,
73
VirtualCharDevice.DEV_CONSOLE,
74
VirtualCharDevice.CHAR_PTY)
76
self._default_console_assigned = True
78
self._set_default_input_dev()
81
def _get_input_device(self):
82
inputtype = VirtualDevice.VIRTUAL_DEV_INPUT
84
typ = self._lookup_device_param(inputtype, "type")
85
bus = self._lookup_device_param(inputtype, "bus")
86
dev = VirtualInputDevice(self.conn)
91
def _get_device_xml(self, install=True):
93
if self.emulator is not None:
94
emu_xml = " <emulator>%s</emulator>\n" % self.emulator
96
return (emu_xml + Guest._get_device_xml(self, install))
98
def _set_defaults(self, devlist_func):
99
disktype = VirtualDevice.VIRTUAL_DEV_DISK
100
nettype = VirtualDevice.VIRTUAL_DEV_NET
101
disk_bus = self._lookup_device_param(disktype, "bus")
102
net_model = self._lookup_device_param(nettype, "model")
104
# Only overwrite params if they weren't already specified
105
for net in devlist_func(nettype):
106
if net_model and not net.model:
107
net.model = net_model
109
for disk in devlist_func(disktype):
110
if (disk_bus and not disk.bus and
111
disk.device == VirtualDisk.DEVICE_DISK):
114
if self.clock.offset == None:
115
self.clock.offset = self._lookup_osdict_key("clock")
117
# Run this last, so we get first crack at disk attributes
118
Guest._set_defaults(self, devlist_func)
39
def _get_loader(self):
40
if not self.installer:
42
return self.installer.loader
43
def _set_loader(self, val):
45
if not self.installer:
47
self.installer.loader = val
48
loader = property(_get_loader, _set_loader)