diff options
author | Alon Levy <alevy@redhat.com> | 2011-08-14 11:34:34 -0700 |
---|---|---|
committer | Alon Levy <alevy@redhat.com> | 2011-08-14 11:34:34 -0700 |
commit | e4e99b2f445cafa57892017e520e9c9d330f72c1 (patch) | |
tree | fdca4054f98c6ff818904725d0631bc5ed3ae1aa /spice2 | |
parent | e767c7a3a1e16aeec07d2fb63025463e21b6c7a0 (diff) |
multiple, no strength to split
--help better with argument groups
--bandwidthmon added, for both vnc and spice, easy to compare.
Diffstat (limited to 'spice2')
-rwxr-xr-x | spice2 | 200 |
1 files changed, 117 insertions, 83 deletions
@@ -39,6 +39,7 @@ spicedump_exe = which('spicedump.py') python_exe = which('python') #python_exe = which('pypy') vncviewer = which('vncviewer') +bandwidthmon_exe = which('bandwidthmon') HOME = os.environ['HOME'] ################################################################################ @@ -316,14 +317,14 @@ test_progs = { 'sockets': 'test_just_sockets_no_ssl', 'replay': 'replay', } -def build_test_cmdline(args): +def build_test_cmdline_and_env(args): parts = (['/usr/bin/libtool', '--mode=execute', 'cgdb', '--args'] if args.cgdb else []) + [os.path.join(spice_src_path, 'server/tests', test_progs[args.test_prog])] if args.test_prog == 'replay' and args.replay_file: parts.append(args.replay_file) # tests have this port hardcoded args.port = 5912 - return ' '.join(parts) + return ' '.join(parts), [] def build_spice_option(args): ret = ["disable-ticketing"] @@ -424,7 +425,7 @@ def fatal_error(msg): print red % msg sys.exit(1) -def build_qemu_cmdline(args): +def build_qemu_cmdline_and_env(args): """ Build qemu command line. Most of it is straight forward translation of the arguments from command @@ -441,8 +442,9 @@ def build_qemu_cmdline(args): --qemu exists? require --dest-dir, and make sure --qemu is in qemus dict (set in the config file, .spice_launcher). """ + environment = [] if args.test_prog: - return build_test_cmdline(args) + return build_test_cmdline_and_env(args) bios_dir = get_bios_dir(args) qemu_exec = get_qemu_exec(args) args.image_fullpath = image_fullpath = get_image(args) @@ -477,6 +479,12 @@ def build_qemu_cmdline(args): if args.qxl > 1: cmdline.extend((['-device', 'qxl,guestdebug=%d,cmdlog=%d,debug=%d,multifunction=%s' % ( args.guestdebug, args.cmdlog, args.qxldebug, 'on' if args.multifunction else 'off')]) * (args.qxl - 1)) + if args.sound == 'intel-hda': + # -soundhw hda not in RHEL? + #cmdline.extend(['-soundhw', 'hda']) + cmdline.extend(['-device', 'intel-hda,id=sound0', '-device', 'hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0']) + if args.sound: + environment.append(('QEMU_AUDIO_DRV', 'spice')) if args.revision: cmdline.extend(['-global', 'qxl-vga.revision=%d' % args.revision]) if args.tablet: @@ -581,7 +589,7 @@ def build_qemu_cmdline(args): if args.time: print "wrapping in time" cmdline = ['/usr/bin/time', '--verbose'] + cmdline - return cmdline + return cmdline, environment def run_xephyr(display, size=(1024,768+40), show_output=False, debug=False): if not display: @@ -710,86 +718,95 @@ def parseargs(): sys.exit(1) image = images[base_part] parser = argparse.ArgumentParser(description='SPICE Launcher script, mark 2. Run spice, qemu, spice tests, automated tests on pre prepared images. Still missing: automated driver installation.') - parser.add_argument('--record-cmd', dest='record_cmd', help='record qxl command ring') - parser.add_argument('--network-device', choices=['virtio-net-pci', 'rtl8139'], default='virtio-net-pci') - parser.add_argument('--copy-in', dest='copy_in', action='append') - parser.add_argument('--no-backing-file', default=True, action='store_false', dest='backing_file', help='use the image as a backing file for the actual image') - parser.add_argument('--startup', dest='startup') - parser.add_argument('--wintest', dest='wintest', choices=win_tests.keys()) - parser.add_argument('--cache', dest='cache', choices=['unsafe','off','writeback','writethrough'], default='unsafe') - parser.add_argument('--shutdown', dest='no_shutdown', action='store_false', default=True) - parser.add_argument('--time', dest='time', action='store_true', default=False) - parser.add_argument('--runonce', dest='runonce') - parser.add_argument('--clear-runonce', dest='clear_runonce', default=False, action='store_true') - parser.add_argument('--showcmdline', dest='showcmdline', default=False, action='store_true') - parser.add_argument('--vga', dest='vga', choices=['qxl', 'cirrus'], default='qxl') - parser.add_argument('--memcheck', dest='memcheck', default=False, action='store_true') - parser.add_argument('--client', choices=['spicec', 'spicy'], default='spicec') - parser.add_argument('--clients', dest='clients', default=0, type=int) - parser.add_argument('--port', dest='spice_port', type=int, action='store') - parser.add_argument('--host', dest='spice_host', default='127.0.0.1') - parser.add_argument('--qxl', dest='qxl', type=int, default=1) - parser.add_argument('--qmp-port', dest='qmp_port', type=int, default=0) - parser.add_argument('--tablet', dest='tablet', action='store_true', default=False) - parser.add_argument('--vdagent', dest='vdagent', action='store_true', default=False) - parser.add_argument('--no-vdagent', dest='vdagent', action='store_false') - parser.add_argument('--no-tablet', dest='tablet', action='store_false') - parser.add_argument('--xephyr', dest='xephyr', action='store_true', default=False) - parser.add_argument('--xdm', '--xephyr-dbg-mode', dest='xephyr', action='store_const', const='debug') - parser.add_argument('--tls-port', type=int) - parser.add_argument('--x509-dir') - parser.add_argument('--ca-cert') - parser.add_argument('--server-cert') - parser.add_argument('--server-key') - parser.add_argument('--server-key-password') - parser.add_argument('--host-subject') - parser.add_argument('--sasl', dest='sasl', action='store_true', default=False) - parser.add_argument('--smb', dest='smb', default=None) - parser.add_argument('--cgdb', dest='cgdb', default=False, action='store_true') - parser.add_argument('--guestdebug', dest='guestdebug', type=int, default=0) - parser.add_argument('--qxldebug', dest='qxldebug', type=int, default=0) - parser.add_argument('--cmdlog', dest='cmdlog', type=int, default=0) - parser.add_argument('--windbg-server', dest='windbg_server', type=int, default=None) - parser.add_argument('--windbg-client', dest='windbg_client', type=int, default=None) - parser.add_argument('--memory', dest='memory', type=int, default=512) - parser.add_argument('--cpus', dest='cpus', type=int, default=2) - parser.add_argument('--smartcard', dest='smartcard', choices=['off','hw','sw'], default='off') - parser.add_argument('--smartcard-dbdir', dest='dbdir') - parser.add_argument('--smartcard-certs', dest='certs', action='append') - parser.add_argument('--debugbios', dest='debugbios', action='store_true', default=False) - parser.add_argument('--image', dest='image', default=image) - parser.add_argument('--snapshot', action='store_true', default=True) - parser.add_argument('--no-snapshot', dest='snapshot', action='store_false') - parser.add_argument('--cdrom', dest='cdrom', default=None) - parser.add_argument('--winqxl-cdrom', dest='winqxl_cdrom', default=False, action='store_true') - parser.add_argument('--qemu-exec', dest='qemu_exec') - parser.add_argument('--root', default=root, choices=roots.keys() + [None]) - parser.add_argument('--root-dir', default=os.path.join(HOME, 'spice')) - parser.add_argument('--bios-dir', default=None) - parser.add_argument('--incoming', dest='incoming', type=int, default=None) - parser.add_argument('--title', dest='title', default=None) - parser.add_argument('--second', dest='second', default=False, action='store_true') - parser.add_argument('--revision', dest='revision', default=None, type=int) - parser.add_argument('--freeze', dest='freeze', default=False, action='store_true') - parser.add_argument('--vncport', dest='vnc_port', type=int) - parser.add_argument('--vncclients', dest='vnc_clients', type=int, default=1) - parser.add_argument('--cpu', dest='cpu', choices=['host'], default='host', help='qemu cpu flag') - parser.add_argument('--keep-temp-backing-file', dest='erase_temp_backing_file', default=True, action='store_false') - parser.add_argument('--spicedump', dest='spicedump', default=False, action='store_true') - parser.add_argument('--spicedump-filter', dest='spicedump_filter') - parser.add_argument('--network', choices=['user', 'bridge', None], default='user') - parser.add_argument('--mac') - parser.add_argument('--bridge', default='virbr0') - parser.add_argument('--tun', default='tap0') - parser.add_argument('--uid', type=int, default=int(os.environ.get('SUDO_UID', os.getuid()))) - parser.add_argument('--gid', type=int, default=int(os.environ.get('SUDO_GID', os.getgid()))) + network_group = parser.add_argument_group('network') + devices_group = parser.add_argument_group('devices') + misc_group = parser.add_argument_group('misc') + disk_group = parser.add_argument_group('disk') + tests_group = parser.add_argument_group('tests') + client_group = parser.add_argument_group('clients') + qemu_group = parser.add_argument_group('qemu') + qemu_group.add_argument('--qemu-exec') + qemu_group.add_argument('--root', default=root, choices=roots.keys() + [None]) + qemu_group.add_argument('--root-dir', default=os.path.join(HOME, 'spice')) + qemu_group.add_argument('--bios-dir', default=None) + disk_group.add_argument('--image', default=image) + disk_group.add_argument('--snapshot', action='store_true', default=True) + disk_group.add_argument('--no-snapshot', dest='snapshot', action='store_false') + disk_group.add_argument('--cdrom', default=None) + disk_group.add_argument('--winqxl-cdrom', default=False, action='store_true') + disk_group.add_argument('--second', default=False, action='store_true') + disk_group.add_argument('--keep-temp-backing-file', dest='erase_temp_backing_file', default=True, action='store_false') + disk_group.add_argument('--copy-in', action='append') + disk_group.add_argument('--no-backing-file', default=True, action='store_false', dest='backing_file', help='use the image as a backing file for the actual image') + disk_group.add_argument('--startup') + disk_group.add_argument('--cache', choices=['unsafe','off','writeback','writethrough'], default='unsafe') + disk_group.add_argument('--runonce') + disk_group.add_argument('--clear-runonce', default=False, action='store_true') + client_group.add_argument('--client', choices=['spicec', 'spicy'], default='spicec') + client_group.add_argument('--clients', default=0, type=int) + client_group.add_argument('--port', dest='spice_port', type=int, action='store') + client_group.add_argument('--host', dest='spice_host', default='127.0.0.1') + client_group.add_argument('--tls-port', type=int) + client_group.add_argument('--x509-dir') + client_group.add_argument('--ca-cert') + client_group.add_argument('--server-cert') + client_group.add_argument('--server-key') + client_group.add_argument('--server-key-password') + client_group.add_argument('--host-subject') + client_group.add_argument('--sasl', action='store_true', default=False) + client_group.add_argument('--vncport', dest='vnc_port', type=int) + client_group.add_argument('--vncclients', dest='vnc_clients', type=int, default=1) + devices_group.add_argument('--vga', choices=['qxl', 'cirrus'], default='qxl') + devices_group.add_argument('--qxl', type=int, default=1) + devices_group.add_argument('--tablet', action='store_true', default=False) + devices_group.add_argument('--vdagent', dest='vdagent', action='store_true', default=False) + devices_group.add_argument('--no-vdagent', dest='vdagent', action='store_false') + devices_group.add_argument('--no-tablet', action='store_false') + devices_group.add_argument('--guestdebug', type=int, default=0) + devices_group.add_argument('--qxldebug', type=int, default=0) + devices_group.add_argument('--cmdlog', type=int, default=0) + devices_group.add_argument('--memory', type=int, default=512) + devices_group.add_argument('--cpus', type=int, default=2) + devices_group.add_argument('--smartcard', choices=['off','hw','sw'], default='off') + devices_group.add_argument('--smartcard-dbdir', dest='dbdir') + devices_group.add_argument('--smartcard-certs', dest='certs', action='append') + devices_group.add_argument('--debugbios', action='store_true', default=False) + devices_group.add_argument('--network-device', choices=['virtio-net-pci', 'rtl8139'], default='virtio-net-pci') + devices_group.add_argument('--sound', choices=['intel-hda', 'ac97', None], default=None) + network_group.add_argument('--smb', default=None) + network_group.add_argument('--network', choices=['user', 'bridge', None], default='user') + network_group.add_argument('--mac') + network_group.add_argument('--bridge', default='virbr0') + network_group.add_argument('--tun', default='tap0') + devices_group.add_argument('--revision', default=None, type=int) + devices_group.add_argument('--cpu', choices=['host'], default='host', help='qemu cpu flag') + devices_group.add_argument('--multifunction', action='store_true', default=False, help='libvirt uses multifunction exclusively') + misc_group.add_argument('--shutdown', dest='no_shutdown', action='store_false', default=True) + misc_group.add_argument('--time', action='store_true', default=False) + misc_group.add_argument('--cgdb', default=False, action='store_true') + misc_group.add_argument('--windbg-server', type=int, default=None) + misc_group.add_argument('--windbg-client', type=int, default=None) + misc_group.add_argument('--incoming', type=int, default=None) + misc_group.add_argument('--title', default=None) + misc_group.add_argument('--freeze', default=False, action='store_true') + misc_group.add_argument('--uid', type=int, default=int(os.environ.get('SUDO_UID', os.getuid()))) + misc_group.add_argument('--gid', type=int, default=int(os.environ.get('SUDO_GID', os.getgid()))) + misc_group.add_argument('--showcmdline', default=False, action='store_true') + misc_group.add_argument('--memcheck', default=False, action='store_true') + misc_group.add_argument('--qmp-port', type=int, default=0) + tests_group.add_argument('--wintest', choices=win_tests.keys()) + tests_group.add_argument('--record-cmd', help='record qxl command ring') + tests_group.add_argument('--xephyr', action='store_true', default=False) + tests_group.add_argument('--xdm', '--xephyr-dbg-mode', dest='xephyr', action='store_const', const='debug') + tests_group.add_argument('--spicedump', default=False, action='store_true') + tests_group.add_argument('--spicedump-filter') + tests_group.add_argument('--bandwidthmon', action='store_true') # convenient to run tests via the same framework, though this is not using # any of of the qemu flags, just the client running parts. - parser.add_argument('--test-prog', dest='test_prog', + tests_group.add_argument('--test-prog', dest='test_prog', choices=test_progs.keys()) - parser.add_argument('--test-func', dest='test_func', choices=tests) - parser.add_argument('--replay-file', dest='replay_file') - parser.add_argument('--multifunction', action='store_true', default=False, help='libvirt uses multifunction exclusively') + tests_group.add_argument('--test-func', dest='test_func', choices=tests) + tests_group.add_argument('--replay-file', dest='replay_file') args = parser.parse_args(default_args + sys.argv[1:]) if args.image in images.keys(): args.image = images[args.image] @@ -975,7 +992,10 @@ def xephyr_get_display(): def main(): args = parseargs() update_certs(args) - cmdline = build_qemu_cmdline(args) + cmdline, env = build_qemu_cmdline_and_env(args) + for k, v in env: + print "setting environment variable %s = %r" % (k, v) + os.environ[k] = v atexit.register(cleanup) if args.runonce: set_runonce(args.image_fullpath, args.runonce) @@ -1018,6 +1038,7 @@ def main(): else: display = default_get_display() if args.spicedump: + print "running spicedump" real_spice_port = args.spice_port args.spice_port = proxy_port = real_spice_port + 1000 # run a spicedump proxy in the middle @@ -1025,6 +1046,19 @@ def main(): (python_exe, spicedump_exe, proxy_port, real_spice_port, ' -f %s' % args.spicedump_filter if args.spicedump_filter else '' )).split()) + if args.bandwidthmon: + print "running bandwidthmon" + real_spice_port = args.spice_port + args.spice_port = proxy_port = real_spice_port + 1000 + proxy_args = [bandwidthmon_exe, '--listen-port', str(proxy_port), + '--remote-port', str(real_spice_port), '--remote-host', 'localhost'] + # TODO - go over the ports once, to avoid errors later + if args.vnc_port: + real_vnc_port = args.vnc_port + args.vnc_port = proxy_port = real_vnc_port + 1000 + proxy_args.extend(['--listen-port', str(proxy_port), + '--remote-port', str(real_vnc_port)]) + start_process(args=proxy_args) if args.qmp_port: #start_process( print "TODO" |