diff options
author | Avi Kivity <avi@qumranet.com> | 2006-08-21 09:19:57 +0000 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2006-08-21 09:19:57 +0000 |
commit | 4e0c5f5db49da2007d08bff750d6dab67f567dff (patch) | |
tree | e1179c3deebc7dd6c6e688ac73790ded03a1cc06 /kvm | |
parent | a592d05de7e6468035abbff2f4b39e5ee21bdcc7 (diff) |
kvm: move run script into main directory
Diffstat (limited to 'kvm')
-rwxr-xr-x | kvm | 64 |
1 files changed, 64 insertions, 0 deletions
@@ -0,0 +1,64 @@ +#!/usr/bin/python + +import sys, os +import optparse + +optparser = optparse.OptionParser() + +optparser.add_option('--no-reload-module', + help = 'do not reload kvm module', + action = 'store_false', + dest = 'reload', + default = True, + ) + +optparser.add_option('--install', + help = 'start up guest in installer boot cd', + action = 'store_true', + default = False, + ) + +optparser.add_option('--no-kvm', + help = 'use standard qemu, without kvm', + action = 'store_false', + dest = 'kvm', + default = True, + ) +optparser.add_option('--image', + help = 'select disk image', + dest = 'image', + default = '/tmp/disk', + ) + +(options, args) = optparser.parse_args(sys.argv) + +if options.kvm and options.reload: + for x in os.popen4('/sbin/lsmod')[1].readlines(): + if x.startswith('kvm '): + if os.spawnl(os.P_WAIT, '/sbin/rmmod', 'rmmod', 'kvm') != 0: + raise Exception('failed to remove kvm module') + if os.spawnl(os.P_WAIT, '/sbin/insmod', 'insmod', 'kernel/kvm.ko') != 0: + raise Exception('failed to load kvm module') + +disk = options.image +if options.install: + fd = file(disk, 'w') + fd.truncate() + fd.seek(10*1024*1024*1024-1) + fd.write('\0') + fd.close() + +bootdisk = 'c' +if options.install: + bootdisk = 'd' + +cdrom = '/data/mirror/fedora/core/5/x86_64/os/images/boot.iso' + +cmd = 'qemu-system-x86_64' +if options.kvm: + cmd = 'qemu/x86_64-softmmu/' + cmd + +os.execlp(cmd, cmd, + '-cdrom', cdrom, '-boot', bootdisk, '-L', '/usr/share/qemu', + '-hda', disk, '-m', '384', '-serial', 'file:/tmp/serial.log', + ) |