~ubuntu-branches/ubuntu/quantal/virtinst/quantal-proposed

« back to all changes in this revision

Viewing changes to virtinst/FullVirtGuest.py

  • Committer: Bazaar Package Importer
  • Author(s): Laurent Léonard
  • Date: 2011-01-29 21:41:21 UTC
  • mto: (1.6.3 sid)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: james.westby@ubuntu.com-20110129214121-pjuxf2xz08l5zqew
Tags: upstream-0.500.5
Import upstream version 0.500.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
20
# MA 02110-1301 USA.
21
21
 
22
 
import _util
23
 
import DistroInstaller
24
 
 
25
22
from Guest import Guest
26
 
from VirtualDevice import VirtualDevice
27
 
from VirtualDisk import VirtualDisk
28
 
from VirtualCharDevice import VirtualCharDevice
29
23
 
30
24
class FullVirtGuest(Guest):
31
25
 
 
26
    _default_os_type = "hvm"
 
27
 
32
28
    def __init__(self, type=None, arch=None, connection=None,
33
 
                 hypervisorURI=None, emulator=None, installer=None):
34
 
        if not installer:
35
 
            installer = DistroInstaller.DistroInstaller(type = type,
36
 
                                                        os_type = "hvm",
37
 
                                                        conn=connection)
38
 
        Guest.__init__(self, type, connection, hypervisorURI, installer)
39
 
 
40
 
        self.disknode = "hd"
41
 
        self._diskbus = "ide"
42
 
 
43
 
        self.features = { "acpi": None, "pae":
44
 
            _util.is_pae_capable(self.conn), "apic": None }
 
29
                 hypervisorURI=None, emulator=None, installer=None,
 
30
                 caps=None):
 
31
        Guest.__init__(self, type, connection, hypervisorURI, installer,
 
32
                       caps=caps)
45
33
 
46
34
        self.emulator = emulator
47
35
        if arch:
48
36
            self.arch = arch
49
37
 
50
 
        self.loader = None
51
 
        guest = self._caps.guestForOSType(type=self.installer.os_type,
52
 
                                          arch=self.arch)
53
 
        if (not self.emulator) and guest:
54
 
            for dom in guest.domains:
55
 
                if dom.hypervisor_type == self.installer.type:
56
 
                    self.emulator = dom.emulator
57
 
                    self.loader = dom.loader
58
 
 
59
 
        # Fall back to default hardcoding
60
 
        if self.emulator is None:
61
 
            if self.type == "xen":
62
 
                if self._caps.host.arch in ("x86_64"):
63
 
                    self.emulator = "/usr/lib64/xen/bin/qemu-dm"
64
 
                else:
65
 
                    self.emulator = "/usr/lib/xen/bin/qemu-dm"
66
 
 
67
 
        if (not self.loader) and self.type == "xen":
68
 
            self.loader = "/usr/lib/xen/boot/hvmloader"
69
 
 
70
 
    def _get_default_console_device(self):
71
 
        dev = VirtualCharDevice.get_dev_instance(self.conn,
72
 
                                                 VirtualCharDevice.DEV_CONSOLE,
73
 
                                                 VirtualCharDevice.CHAR_PTY)
74
 
        return dev
75
 
 
76
 
    def _get_emulator_xml(self):
77
 
        emu_xml = ""
78
 
        if self.emulator is not None:
79
 
            emu_xml = "    <emulator>%s</emulator>" % self.emulator
80
 
 
81
 
        return emu_xml
82
 
 
83
 
    def _set_defaults(self, devlist_func):
84
 
        disktype = VirtualDevice.VIRTUAL_DEV_DISK
85
 
        nettype = VirtualDevice.VIRTUAL_DEV_NET
86
 
        disk_bus  = self._lookup_device_param(disktype, "bus")
87
 
        net_model = self._lookup_device_param(nettype, "model")
88
 
 
89
 
        # Only overwrite params if they weren't already specified
90
 
        for net in devlist_func(nettype):
91
 
            if net_model and not net.model:
92
 
                net.model = net_model
93
 
 
94
 
        for disk in devlist_func(disktype):
95
 
            if (disk_bus and not disk.bus and
96
 
                disk.device == VirtualDisk.DEVICE_DISK):
97
 
                disk.bus = disk_bus
98
 
 
99
 
        if self.clock.offset == None:
100
 
            self.clock.offset = self._lookup_osdict_key("clock")
101
 
 
102
 
        # Run this last, so we get first crack at disk attributes
103
 
        Guest._set_defaults(self, devlist_func)
 
38
    # Back compat
 
39
    def _get_loader(self):
 
40
        if not self.installer:
 
41
            return None
 
42
        return self.installer.loader
 
43
    def _set_loader(self, val):
 
44
        print val
 
45
        if not self.installer:
 
46
            return
 
47
        self.installer.loader = val
 
48
    loader = property(_get_loader, _set_loader)