From a8bfe17b128cfebbc67b9ee417baf321f2b766e6 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Tue, 19 Jul 2011 19:14:14 +0300 Subject: fixes. handle spaces in image/cdrom name --- spice2 | 94 ++++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/spice2 b/spice2 index a7a2d5a..f6d3761 100755 --- a/spice2 +++ b/spice2 @@ -21,6 +21,7 @@ except: guestfs = None def which(x): + path = os.environ['PATH'] for f in path.split(':'): full_path = os.path.join(f, x) if os.path.exists(full_path): @@ -32,6 +33,7 @@ lddpath = which('ldd') spicedump_exe = which('spicedump.py') python_exe = which('python') #python_exe = which('pypy') +vncviewer = which('vncviewer') HOME = os.environ['HOME'] ################################################################################ @@ -102,7 +104,7 @@ with open(config_path, 'r') as fd: for name, default_location in [ ('res_change_exe', 'res_change.exe'), - ('suspend_exe', ('suspend.exe')]: + ('suspend_exe', 'suspend.exe')]: if not os.path.exists(globals()[name]) and os.path.exists(default_location): print "config file points to non existant %r (%r), changing to local copy" % ( name, globals()[name]) @@ -191,7 +193,6 @@ tests = [x[5:] for x in g if x.startswith('test_')] ################################################################################ red = "\x1b[101m%s\x1b[0m" -path = os.environ['PATH'] ################################################################################ @@ -224,8 +225,6 @@ def get_lib(fname, rexp): return 'library not found' return ref[0] -vncviewer = which('vncviewer') - def make_iso(iso_name, root, title): cmd = 'mkisofs -J -R -V %s_%s -o %s %s' % (title, datetime.datetime.now().strtime('%Y%m%d_%H%M'), iso_name, root) print cmd @@ -315,64 +314,69 @@ def build_cmdline(args): print "recording cmd ring to %r" % args.record_cmd os.environ['SPICE_WORKER_RECORD_FILENAME'] = args.record_cmd os.system('echo $LD_LIBRARY_PATH') - cmdline = ["%(qemuexe)s -chardev stdio,id=muxstdio,mux=on -spice disable-ticketing,port=%(spice_port)s -vga %(vga)s %(guest_debug_option)s %(qxl_debug_option)s %(cmdlog_option)s -drive file=%(image_fullpath)s,cache=%(cache)s -snapshot -mon chardev=muxstdio -enable-kvm -net nic,model=virtio -L %(bios_dir)s -m %(memory)d %(smp_option)s -cpu %(cpu)s %(no_shutdown)s" % dict( - qemuexe = qemuexe, - vga = args.vga, - spice_port = args.spice_port, - cache = args.cache, - image_fullpath = image_fullpath, - bios_dir = bios_dir, - guest_debug_option = '' if args.guestdebug == 0 else '-global qxl-vga.guestdebug=%d' % args.guestdebug, - qxl_debug_option = '' if args.qxldebug == 0 else '-global qxl-vga.debug=%d' % args.qxldebug, - cmdlog_option = '' if args.cmdlog == 0 else '-global qxl-vga.cmdlog=%d' % args.cmdlog, - memory = args.memory, - smp_option = '' if args.cpus == 1 else '-smp %d' % args.cpus, - no_shutdown = '-no-shutdown' if args.no_shutdown else '', - cpu = args.cpu, - )] + cmdline = [qemuexe, + "-chardev", "stdio,id=muxstdio,mux=on", + "-spice", "disable-ticketing,port=%s" % args.spice_port, + "-vga", args.vga, + "-drive", "file=%s,cache=%s" % (args.image_fullpath, args.cache), + "-snapshot", "-mon", "chardev=muxstdio", "-enable-kvm", + "-net", "nic,model=virtio", + "-L", bios_dir, "-m", + str(args.memory), + "-cpu", str(args.cpu), + '-no-shutdown' if args.no_shutdown else ''] + if args.cpus > 1: + cmdline.extend(['-smp', str(args.cpus)]) + if args.guestdebug > 0: + cmdline.extend(['-global', 'qxl-vga.guestdebug=%d' % args.guestdebug]) + if args.qxldebug > 0: + cmdline.extend(['-global', 'qxl-vga.debug=%d' % args.qxldebug]) + if args.cmdlog > 0: + cmdline.extend(['-global', 'qxl-vga.cmdlog=%d' % args.cmdlog]) if args.qxl > 1: - cmdline.append((' -device qxl,guestdebug=%d,cmdlog=%d,debug=%d' % (args.guestdebug, - args.cmdlog, args.qxldebug)) * (args.qxl - 1)) + cmdline.extend((['-device', 'qxl,guestdebug=%d,cmdlog=%d,debug=%d' % (args.guestdebug, + args.cmdlog, args.qxldebug)]) * (args.qxl - 1)) if args.revision: - cmdline.append(' -global qxl-vga.revision=%d' % args.revision) + cmdline.extend(['-global', 'qxl-vga.revision=%d' % args.revision]) if args.tablet: - cmdline.append(' -usb -device usb-tablet') + cmdline.extend(['-usb', '-device', 'usb-tablet']) else: - cmdline.append(' -device virtio-serial -chardev spicevmc,name=vdagent,id=vdagent -device virtserialport,chardev=vdagent,name=com.redhat.spice.0') + cmdline.extend(['-device', 'virtio-serial', '-chardev', 'spicevmc,name=vdagent,id=vdagent', + '-device', 'virtserialport,chardev=vdagent,name=com.redhat.spice.0']) # user networking if args.smb: - cmdline.append(' -net user,smb=%s,smbserver=10.0.2.2' % args.smb) + cmdline.extend(['-net', 'user,smb=%s,smbserver=10.0.2.2' % args.smb]) else: - cmdline.append(' -net user') + cmdline.extend('-net user'.split()) # windbg (TODO - better then serial) if args.windbg_server: - cmdline.append(' -serial tcp::%d,server,nowait' % args.windbg_server) + cmdline.extend(('-serial tcp::%d,server,nowait' % args.windbg_server).split()) if args.windbg_client: if port_is_available(args.windbg_client): - cmdline.append(' -serial tcp:localhost:%d' % args.windbg_client) + cmdline.extend(('-serial tcp:localhost:%d' % args.windbg_client).split()) else: print "nothing listening on %d, do you want to start something there? (p.s. maybe systemd service?)" % args.windbg_client # smartcard if args.smartcard != 'off': ccid_debug = 1 passthru_debug = 1 - cmdline.extend([' -chardev spicevmc,id=smartcard,debug=3,name=smartcard', - " -device usb-ccid,debug=%s,id=ccid" % ccid_debug, - " -device ccid-card-passthru,debug=%s,chardev=smartcard" % (passthru_debug), + cmdline.extend(['-chardev spicevmc,id=smartcard,debug=3,name=smartcard', + "-device", "usb-ccid,debug=%s,id=ccid" % ccid_debug, + "-device", "ccid-card-passthru,debug=%s,chardev=smartcard" % (passthru_debug), ]) # bios debugging if args.debugbios: - cmdline.append(' -device isa-debugcon,iobase=0x402,chardev=muxstdio') + cmdline.extend('-device isa-debugcon,iobase=0x402,chardev=muxstdio'.split()) # incoming migration if args.incoming: - cmdline.append(' -incoming tcp:localhost:%d' % args.incoming) + cmdline.extend(('-incoming tcp:localhost:%d' % args.incoming).split()) if args.freeze: - cmdline.append(' -S') + cmdline.extend(['-S']) # vnc server if args.vnc_port: if (args.vnc_port < 5900): print "vnc_port must be >= 5900" - cmdline.append(' -vnc %s:%s' % (args.spice_host, args.vnc_port - 5900)) + cmdline.extend(('-vnc %s:%s' % (args.spice_host, args.vnc_port - 5900)).split()) # cdrom if args.winqxl_cdrom: @@ -389,26 +393,22 @@ def build_cmdline(args): if not os.path.exists(args.cdrom): print "missing cdrom image %r" % args.cdrom sys.exit(1) - cmdline.append(' -cdrom %s' % args.cdrom) + cmdline.extend(['-cdrom', args.cdrom]) ###### - cmdline = ''.join(cmdline) print_qemu_and_spice_versions(qemuexe=qemuexe, which=qemu, bios_dir=bios_dir) # wrap in various tools if args.cgdb: cgdb = which('cgdb') - cmdline = '%s --args %s' % (cgdb, cmdline) + cmdline = [cgdb, '--args'] + cmdline if args.memcheck: print "wrapping with valgrind memcheck" - cmdline = 'valgrind --error-limit=no --leak-check=full --suppressions=%(HOME)s/bin/kvm.supp --log-file=/tmp/kvm_%(time_str)s.valgrind %(cmdline)s' % { - 'cmdline':cmdline, - 'time_str': time.strftime('%Y%m%d_%H%M%S',time.gmtime()), - 'HOME': HOME - } + cmdline = ['valgrind', '--error-limit=no', '--leak-check=full', '--suppressions=%s/bin/kvm.supp' % HOME, + '--log-file=/tmp/kvm_%s.valgrind' % time.strftime('%Y%m%d_%H%M%S',time.gmtime())] + cmdline if args.time: print "wrapping in time" - cmdline = '/usr/bin/time --verbose %s' % cmdline + cmdline = ['/usr/bin/time', '--verbose'] + cmdline return cmdline def run_xephyr(display, size=(1024,768+40), show_output=False): @@ -565,6 +565,8 @@ def parseargs(): parser.add_argument('--test-func', dest='test_func', choices=tests) parser.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] if len(parts) == 1 and not args.test_prog and not args.image: if image not in defaults: print "symlink %r not in %r" % (image, defaults.keys()) @@ -768,12 +770,12 @@ def main(): 'I ' if args.incoming else '', args.title if args.title else os.path.basename(sys.argv[0]) )) - print cmdline + print repr(cmdline) if args.showcmdline: return ignore_ctrlc() exit_on_hup() - test_process = start_process(args=cmdline.split(), show_output=True) + test_process = start_process(args=cmdline, show_output=True) if args.xephyr: display = xephyr_get_display() else: -- cgit v1.2.3