> Signed-off-by: Jeremy White <jwhite@xxxxxxxxxxxxxxx> > --- > scripts/Xspice | 59 > +++++++++++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 58 insertions(+), 1 deletion(-) > > diff --git a/scripts/Xspice b/scripts/Xspice > index 1686f9e..32219b4 100755 > --- a/scripts/Xspice > +++ b/scripts/Xspice > @@ -19,6 +19,7 @@ which can be overridden as well. > import argparse > import os > import sys > +import tempfile > > def which(x): > for p in os.environ['PATH'].split(':'): > @@ -44,6 +45,7 @@ parser = argparse.ArgumentParser("Xspice", > usage="Xspice [Xspice and Xorg options intermixed]", > epilog="Any options not parsed by Xspice get passed to Xorg as > is.") > parser.add_argument('--xorg', default=which('Xorg')) > +parser.add_argument('--auto', action='store_true', > help='Automatically create a temporary xorg.conf and start the X > server') > parser.add_argument('--config', default='spiceqxl.xorg.conf') > # Don't use any options that are already used by Xorg (unless we > must) > # specifically, don't use -p and -s. > @@ -119,6 +121,52 @@ def error(msg, exit_code=1): > if not args.xorg: > error("Xorg missing") > > +if args.auto: > + cf = tempfile.NamedTemporaryFile(prefix="Xspice-", delete=True) > + args.config = cf.name > + xorg_args = [ '-logfile', cf.name + ".log" ] + xorg_args > + cf.write(""" > +Section "Device" > + Identifier "XSPICE" > + Driver "spiceqxl" > +EndSection > + > +Section "InputDevice" > + Identifier "XSPICE POINTER" > + Driver "xspice pointer" > +EndSection > + > +Section "InputDevice" > + Identifier "XSPICE KEYBOARD" > + Driver "xspice keyboard" > +EndSection > + > +Section "Monitor" > + Identifier "Configured Monitor" > +EndSection > + > +Section "Screen" > + Identifier "XSPICE Screen" > + Monitor "Configured Monitor" > + Device "XSPICE" > +EndSection > + > +Section "ServerLayout" > + Identifier "XSPICE Example" > + Screen "XSPICE Screen" > + InputDevice "XSPICE KEYBOARD" > + InputDevice "XSPICE POINTER" > +EndSection > + > +# Prevent udev from loading vmmouse in a vm and crashing. > +Section "ServerFlags" > + Option "AutoAddDevices" "False" > +EndSection > + > + > + """) > + cf.flush() > + > var_args = ['port', 'tls_port', 'disable_ticketing', > 'x509_dir', 'sasl', 'cacert_file', 'x509_cert_file', > 'x509_key_file', 'x509_key_password', > @@ -134,4 +182,13 @@ if cgdb and args.cgdb: > exec_args = [cgdb, '--args'] + exec_args > args.xorg = cgdb > > -os.execv(args.xorg, exec_args + xorg_args) > +xpid = os.spawnv(os.P_NOWAIT, args.xorg, exec_args + xorg_args) > +try: > + os.waitpid(xpid, 0) > +except KeyboardInterrupt: > +# Catch Ctrl-C so we clean up the log file in that case > + print "Keyboard Interrupt" > + Probably better to use atexit to allow for possible python exceptions on the way (i.e. bugs) import atexit def cleanup(): if os.path.isfile(cf.name + ".log"): os.remove(cf.name + ".log") atexit.register(cleanup) > +if args.auto: > + if os.path.isfile(cf.name + ".log"): > + os.remove(cf.name + ".log") > -- > 1.7.10.4 > > > > _______________________________________________ > Spice-devel mailing list > Spice-devel@xxxxxxxxxxxxxxxxxxxxx > http://lists.freedesktop.org/mailman/listinfo/spice-devel > _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel