Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 157987 | Differences between
and this patch

Collapse All | Expand All

(-)kvm.orig (-44 / +1 lines)
Lines 5-17 Link Here
5
5
6
optparser = optparse.OptionParser()
6
optparser = optparse.OptionParser()
7
7
8
optparser.add_option('--no-reload-module',
9
                     help = 'do not reload kvm module',
10
                     action = 'store_false',
11
                     dest = 'reload',
12
                     default = True,
13
                     )
14
15
optparser.add_option('--install',
8
optparser.add_option('--install',
16
                     help = 'start up guest in installer boot cd',
9
                     help = 'start up guest in installer boot cd',
17
                     action = 'store_true',
10
                     action = 'store_true',
Lines 100-136 Link Here
100
if len(args) > 1:
93
if len(args) > 1:
101
    options.cdrom = args[1]
94
    options.cdrom = args[1]
102
95
103
def remove_module(module):
96
if options.kvm:
104
    module = module.replace('-', '_')
105
    lines = commands.getoutput('/sbin/lsmod').split('\n')
106
    for x in lines:
107
        if x.startswith(module + ' '):
108
            if os.spawnl(os.P_WAIT, '/sbin/rmmod', 'rmmod', module) != 0:
109
                raise Exception('failed to remove %s module' % (module,))
110
111
def insert_module(module):
112
    if os.spawnl(os.P_WAIT, '/sbin/insmod', 'insmod',
113
                 'kernel/%s.ko' % (module,)) != 0:
114
        if os.spawnl(os.P_WAIT, '/sbin/modprobe', 'modprobe', module) != 0:
115
            raise Exception('failed to load kvm module')
116
117
def vendor():
118
    for x in file('/proc/cpuinfo').readlines():
119
        m = re.match(r'vendor_id[ \t]*: *([a-zA-Z]+),*', x)
120
        if m:
121
            return m.group(1)
122
    return unknown
123
124
vendor_module = {
125
    'GenuineIntel': 'kvm-intel',
126
    'AuthenticAMD': 'kvm-amd',
127
    }[vendor()]
128
129
if options.kvm and options.reload:
130
    for module in [vendor_module, 'kvm']:
131
        remove_module(module)
132
    for module in ['kvm', vendor_module]:
133
        insert_module(module)
134
    commands.getstatusoutput('/sbin/udevsettle')
97
    commands.getstatusoutput('/sbin/udevsettle')
135
    if not os.access('/dev/kvm', os.F_OK):
98
    if not os.access('/dev/kvm', os.F_OK):
136
        print '/dev/kvm not present'
99
        print '/dev/kvm not present'
Lines 157-168 Link Here
157
else:
120
else:
158
    cmd = 'qemu'
121
    cmd = 'qemu'
159
122
160
local_cmd = 'qemu/' + arch + '-softmmu/' + cmd
161
if os.access(local_cmd, os.F_OK):
162
    cmd = local_cmd
163
else:
164
    cmd = '/usr/bin/kvm'
165
166
qemu_args = (cmd, '-boot', bootdisk,
123
qemu_args = (cmd, '-boot', bootdisk,
167
             '-hda', disk, '-m', str(options.memory),
124
             '-hda', disk, '-m', str(options.memory),
168
             '-serial', 'file:/tmp/serial.log',
125
             '-serial', 'file:/tmp/serial.log',

Return to bug 157987