Skip to content
Permalink
Browse files

Add support for qemu machine type to emulate (option --qemu-machine-t…

…ype).
  • Loading branch information
isaoshimizu committed Jul 20, 2012
1 parent 5fb3b2d commit 29187d3f70cf5e72aed7aaff9e56a467086fe44f
Showing with 37 additions and 16 deletions.
  1. +26 −15 koan/app.py
  2. +11 −1 koan/virtinstall.py
@@ -209,6 +209,9 @@ def main():
p.add_option("", "--qemu-net-type",
dest="qemu_net_type",
help="when used with --virt_type=qemu, select type of network device to use: e1000, ne2k_pci, pcnet, rtl8139, virtio")
p.add_option("", "--qemu-machine-type",
dest="qemu_machine_type",
help="when used with --virt_type=qemu, select type of machine type to emulate: pc, pc-1.0, pc-0.15")

(options, args) = p.parse_args()

@@ -242,6 +245,7 @@ def main():
k.virt_auto_boot = options.virt_auto_boot
k.qemu_disk_type = options.qemu_disk_type
k.qemu_net_type = options.qemu_net_type
k.qemu_machine_type = options.qemu_machine_type

if options.virt_name is not None:
k.virt_name = options.virt_name
@@ -300,6 +304,7 @@ def __init__(self):
self.force_path = None
self.qemu_disk_type = None
self.qemu_net_type = None
self.qemu_machine_type = None
self.virt_auto_boot = None

# This option adds the --copy-default argument to /sbin/grubby
@@ -379,6 +384,11 @@ def run(self):
if self.virt_type not in [ "qemu", "auto", "kvm" ]:
raise InfoException, "--qemu-net-type must use with --virt-type=qemu"

# if --qemu-machine-type was called without --virt-type=qemu, then fail
if (self.qemu_machine_type is not None):
self.qemu_machine_type = self.qemu_machine_type.lower()
if self.virt_type not in [ "qemu", "auto", "kvm" ]:
raise InfoException, "--qemu-machine-type must use with --virt-type=qemu"


# if --static-interface and --profile was called together, then fail
@@ -1350,21 +1360,22 @@ def virt_net_install(self,profile_data):
virt_auto_boot = self.calc_virt_autoboot(pd, self.virt_auto_boot)

results = create_func(
name = virtname,
ram = ram,
disks = disks,
uuid = uuid,
extra = kextra,
vcpus = vcpus,
profile_data = profile_data,
arch = arch,
no_gfx = self.no_gfx,
fullvirt = fullvirt,
bridge = self.virt_bridge,
virt_type = self.virt_type,
virt_auto_boot = virt_auto_boot,
qemu_driver_type = self.qemu_disk_type,
qemu_net_type = self.qemu_net_type
name = virtname,
ram = ram,
disks = disks,
uuid = uuid,
extra = kextra,
vcpus = vcpus,
profile_data = profile_data,
arch = arch,
no_gfx = self.no_gfx,
fullvirt = fullvirt,
bridge = self.virt_bridge,
virt_type = self.virt_type,
virt_auto_boot = virt_auto_boot,
qemu_driver_type = self.qemu_disk_type,
qemu_net_type = self.qemu_net_type,
qemu_machine_type = self.qemu_machine_type
)

#print results
@@ -118,7 +118,8 @@ def build_commandline(uri,
virt_type=None,
virt_auto_boot=False,
qemu_driver_type=None,
qemu_net_type=None):
qemu_net_type=None,
qemu_machine_type=None):

# Set flags for CLI arguments based on the virtinst_version
# tuple above. Older versions of python-virtinst don't have
@@ -225,9 +226,15 @@ def build_commandline(uri,

net_model = None
disk_bus = None
machine_type = None

if is_qemu:
net_model = qemu_net_type
disk_bus = qemu_driver_type
machine_type = qemu_machine_type

if machine_type is None:
machine_type = "pc"

cmd = "virt-install "
if uri:
@@ -252,6 +259,9 @@ def build_commandline(uri,
if not disable_virt_type:
cmd += "--virt-type %s " % virt_type

if is_qemu and machine_type:
cmd += "--machine %s " % machine_type

if fullvirt or is_qemu or is_import:
if fullvirt is not None:
cmd += "--hvm "

0 comments on commit 29187d3

Please sign in to comment.
You can’t perform that action at this time.