diff options
author | Alon Levy <alevy@redhat.com> | 2014-04-30 18:35:30 +0300 |
---|---|---|
committer | Alon Levy <alevy@redhat.com> | 2014-04-30 18:35:30 +0300 |
commit | 4dc38f2e5abc23beed398331bee933f7f4e456da (patch) | |
tree | beeae5b7167dd0ebc6c24db9c14d9fe7062f2cd8 | |
parent | df4033b1ea8615dcfaf375c66b1e63be34c1b1de (diff) |
-rwxr-xr-x | spice2 | 81 |
1 files changed, 61 insertions, 20 deletions
@@ -313,8 +313,8 @@ def create_qcow_with_backing_file(target_base, backing_file, erase_at_exit, temp_files.append(filename) return filename -def get_image(args): - image_base_fullpath = args.image +def get_image(image, args): + image_base_fullpath = image if not os.path.exists(image_base_fullpath): print("missing image %s" % image_base_fullpath) return None @@ -324,7 +324,7 @@ def get_image(args): if args.backing_file and args.migrator: print "cannot have a migration source using a backing file" sys.exit(-1) - base_image_name = os.path.basename(args.image) + base_image_name = os.path.basename(image) if args.backing_file: image_fullpath = create_qcow_with_backing_file( target_base=os.path.join(os.path.dirname(base_image_name), base_image_name), @@ -332,7 +332,7 @@ def get_image(args): erase_at_exit=args.erase_temp_backing_file, use_temp=True) elif args.migrator: - image_fullpath = '/tmp/'+base_image_name+'.migrate' + os.path.splitext(args.image)[1] + image_fullpath = '/tmp/' + base_image_name + '.migrate' + os.path.splitext(image)[1] if not os.path.exists(image_fullpath): image_fullpath = create_qcow_with_backing_file( target_base=image_fullpath, @@ -348,6 +348,9 @@ def get_image(args): print("image %s" % image_fullpath) return image_fullpath +def get_images(args): + return [get_image(image=im, args=args) for im in args.images] + test_progs = { 'streaming': 'test_display_streaming', 'display': 'test_display_no_ssl', @@ -396,8 +399,12 @@ def build_spice_option(args): ret.append('jpeg-wan-compression=%s' % args.wan_jpeg_compression) if args.image_compression: ret.append('image-compression=%s' % args.image_compression) + if args.streaming_video: + ret.append('streaming-video=%s' % args.streaming_video) if args.secure_channels: ret.extend(['tls-channel=%s' % name for name in args.secure_channels.split(',')]) + if args.egl_path: + ret.append('egl-path=%s' % args.egl_path) return ['-spice', ','.join(ret)] class MissingFileException(Exception): @@ -501,18 +508,28 @@ def build_qemu_cmdline_and_env(args): if args.clients >= 0: print "no root dir - %s" % str(e) sys.exit(1) - args.image_fullpath = image_fullpath = get_image(args) + args.image_fullpaths = get_images(args) if args.record_cmd: print("recording cmd ring to %r" % args.record_cmd) os.environ['SPICE_WORKER_RECORD_FILENAME'] = args.record_cmd + if args.ld_library_path: + # This removes any existing one, so you have to add it yourself. + environment.append('LD_LIBRARY_PATH', ':'.join(args.ld_library_path)) + if len(args.ld_preload) > 0: + for lib in args.ld_preload: + if not os.path.exists(lib): + print("no such file or access problem: %r" % lib) + sys.exit(1) + environment.append(('LD_PRELOAD', ':'.join(args.ld_preload))) os.system('echo $LD_LIBRARY_PATH') cmdline = [qemu_exec, "-chardev", "stdio,id=muxstdio,mux=on", "-mon", "chardev=muxstdio,mode=readline", - "-drive", "file=%s,cache=%s,if=%s,readonly=%s" % (args.image_fullpath, - args.cache, args.block_if, args.read_only), "-enable-kvm", "-L", bios_dir, "-m", str(args.memory)] + for image in args.image_fullpaths: + cmdline.extend(["-drive", "file=%s,cache=%s,if=%s,readonly=%s" % (image, + args.cache, args.block_if, args.read_only)]) if args.vga != 'virtio': cmdline += ["-vga", args.vga] else: @@ -831,7 +848,7 @@ def spice_uri(host, port, tls_port): return ''.join(s) @run_with_display -def run_client(host, port, client, +def run_client(conf, host, port, client, smartcard, certs, dbdir, tls_port=None, ca_file=None, host_subject=None, display=None, auto_conf=False, client_debug=False): @@ -867,6 +884,10 @@ def run_client(host, port, client, if client_debug: environment['SPICE_DEBUG'] = '1' environment['G_DEBUG'] = 'all' + if conf.ld_library_path: + environment['LD_LIBRARY_PATH'] = ':'.join(conf.ld_library_path) + if conf.ld_preload: + environment['LD_PRELOAD'] = ':'.join(conf.ld_preload) return start_process(args=args, kill=True, env=environment) @run_with_display @@ -970,12 +991,16 @@ def parseargs(): tests_group = parser.add_argument_group('tests') client_group = parser.add_argument_group('clients') qemu_group = parser.add_argument_group('qemu') + threed_group = parser.add_argument_group('3d') + threed_group.add_argument('--egl-path') qemu_group.add_argument('--qemu-exec') + qemu_group.add_argument('--ld-preload', action='append', default=[]) + qemu_group.add_argument('--ld-library-path', action='append', default=[]) qemu_group.add_argument('--root', default=root, choices=list(roots.keys()) + [None]) qemu_group.add_argument('--root-dir', default=os.path.join(HOME, 'spice')) qemu_group.add_argument('--bios-dir', default=None) qemu_group.add_argument('--bios', default=None) - disk_group.add_argument('--image', default=image) + disk_group.add_argument('--image', dest='images', default=[image] if image else [], action='append') disk_group.add_argument('--block-if', default='virtio', choices=['ahci', 'ide', 'virtio']) disk_group.add_argument('--read-only', default='off', action='store_const', const='on') disk_group.add_argument('--snapshot', action='store_true', default=True) @@ -1021,6 +1046,8 @@ def parseargs(): choices=['always', 'auto', 'never']) devices_group.add_argument('--image-compression', choices=['off', 'auto', 'on', 'quic', 'auto_glz', 'auto_lz']) + devices_group.add_argument('--streaming-video', + choices=['off', 'all', 'filter']) devices_group.add_argument('--tablet', action='store_true', default=False) devices_group.add_argument('--vdagent', dest='vdagent', action='store_true', default=False) @@ -1122,16 +1149,15 @@ def parseargs(): default_rest = [] args, rest = parser.parse_known_args(default_args + sys.argv[1:]) rest = default_rest + rest - if args.image in images.keys(): - args.image = images[args.image] - if len(parts) == 1 and not args.test_prog and not args.image: + args.images = [images[im] if im in images.keys() else im for im in args.images] + if len(parts) == 1 and not args.test_prog and len(args.images) == 0: if image not in defaults: print("symlink %r not in %r" % (image, defaults.keys())) sys.exit(1) if not args.root: args.root = defaults[image]['root'] - elif not args.image: - args.image = '/dev/null' + elif len(args.images) == 0: + args.images = ['/dev/null'] # tls arguments if args.x509_dir: args.ca_cert = os.path.join(args.x509_dir, 'ca-cert.pem') @@ -1322,6 +1348,7 @@ def launch_clients(args, display, clients, num_clients): wait_for_port(args.tls_port) for i in xrange(num_clients): client_process = run_client( + conf=args, host=args.spice_host, port=args.spice_port, client=args.client, smartcard=args.smartcard, certs=args.certs, dbdir=args.dbdir, @@ -1362,27 +1389,41 @@ def main(): if args.print_commandline_only: print(repr(cmdline)) print(' '.join(cmdline)) + def iterswitches(cmdline): + ret = [] + for e in cmdline: + if e[0] == '-': + yield ' '.join(ret) + ret = [] + ret.append(e) + if len(ret): + yield ' '.join(ret) + maxlen = max(len(e) for e in iterswitches(cmdline)) + 9 + print('\\\n'.join((((' ' if i > 0 else '') + e).ljust(maxlen) for i, e in enumerate(iterswitches(cmdline))))) return for k, v in env: print("setting environment variable %s = %r" % (k, v)) os.environ[k] = v atexit.register(cleanup) + + # NOTE: implicit assumption that first image is the drive we want. This hasn't been used in a while. + first_image = args.image_fullpaths[0] if args.runonce: - set_runonce(args.image_fullpath, args.runonce) + set_runonce(first_image, args.runonce) elif args.clear_runonce: - set_runonce(args.image_fullpath, None) + set_runonce(first_image, None) g = None if args.startup: - g = set_startup_from_file(g, args.image_fullpath, args.startup) + g = set_startup_from_file(g, first_image, args.startup) if args.wintest: - g = set_startup_from_contents(g, image=args.image_fullpath, filename='startup.bat', + g = set_startup_from_contents(g, image=first_image, filename='startup.bat', contents=win_tests[args.wintest]['contents']) # NOTE: can just use autoplay and a suitable cdrom iso for these, faster then guestfs by far. for filename in win_tests[args.wintest].get('files', []): - g = copy_file_in(g, args.image_fullpath, filename, '/') + g = copy_file_in(g, first_image, filename, '/') if args.copy_in: for p in args.copy_in: - g = copy_dir_in(g, args.image_fullpath, p) + g = copy_dir_in(g, first_image, p) if g: g.sync() g.umount_all() |