Windows OSs."""
from image_creator.os_type import OSBase, sysprep, add_sysprep_param
-from image_creator.util import FatalError, check_guestfs_version
+from image_creator.util import FatalError, check_guestfs_version, \
+ get_kvm_binary
from image_creator.winexe import WinEXE, WinexeTimeout
import hivex
# Use ganeti's VNC port range for a random vnc port
self.display = random.randint(11000, 14999) - 5900
+ kvm = get_kvm_binary()
+
+ if kvm is None:
+ FatalError("Can't find the kvm binary")
+
args = [
- 'kvm', '-smp', '1', '-m', '1024', '-drive',
+ kvm, '-smp', '1', '-m', '1024', '-drive',
'file=%s,format=raw,cache=unsafe,if=virtio' % self.disk,
'-netdev', 'type=user,hostfwd=tcp::445-:445,id=netdev0',
'-device', 'virtio-net-pci,mac=%s,netdev=netdev0' % random_mac(),
import hashlib
import time
import os
+import re
class FatalError(Exception):
return find_sbin_command(command, e)
+def get_kvm_binary():
+ """Returns the path to the kvm binary"""
+
+ uname = get_command('uname')
+ which = get_command('which')
+
+ machine = str(uname('-m'))
+ if re.match('i[3-6]86', machine):
+ machine = 'i386'
+
+ binary = which('qemu-system-%s' % machine)
+
+ if binary is None:
+ return which('kvm')
+
+ return binary
+
+
def try_fail_repeat(command, *args):
"""Execute a command multiple times until it succeeds"""
times = (0.1, 0.5, 1, 2)