Revision 4246a133

b/image_creator/os_type/windows.py
37 37
Windows OSs."""
38 38

  
39 39
from image_creator.os_type import OSBase, sysprep, add_sysprep_param
40
from image_creator.util import FatalError, check_guestfs_version
40
from image_creator.util import FatalError, check_guestfs_version, \
41
    get_kvm_binary
41 42
from image_creator.winexe import WinEXE, WinexeTimeout
42 43

  
43 44
import hivex
......
762 763
        # Use ganeti's VNC port range for a random vnc port
763 764
        self.display = random.randint(11000, 14999) - 5900
764 765

  
766
        kvm = get_kvm_binary()
767

  
768
        if kvm is None:
769
            FatalError("Can't find the kvm binary")
770

  
765 771
        args = [
766
            'kvm', '-smp', '1', '-m', '1024', '-drive',
772
            kvm, '-smp', '1', '-m', '1024', '-drive',
767 773
            'file=%s,format=raw,cache=unsafe,if=virtio' % self.disk,
768 774
            '-netdev', 'type=user,hostfwd=tcp::445-:445,id=netdev0',
769 775
            '-device', 'virtio-net-pci,mac=%s,netdev=netdev0' % random_mac(),
b/image_creator/util.py
41 41
import hashlib
42 42
import time
43 43
import os
44
import re
44 45

  
45 46

  
46 47
class FatalError(Exception):
......
63 64
        return find_sbin_command(command, e)
64 65

  
65 66

  
67
def get_kvm_binary():
68
    """Returns the path to the kvm binary"""
69

  
70
    uname = get_command('uname')
71
    which = get_command('which')
72

  
73
    machine = str(uname('-m'))
74
    if re.match('i[3-6]86', machine):
75
        machine = 'i386'
76

  
77
    binary = which('qemu-system-%s' % machine)
78

  
79
    if binary is None:
80
        return which('kvm')
81

  
82
    return binary
83

  
84

  
66 85
def try_fail_repeat(command, *args):
67 86
    """Execute a command multiple times until it succeeds"""
68 87
    times = (0.1, 0.5, 1, 2)

Also available in: Unified diff