ADDED ask_shutdown Index: ask_shutdown ================================================================== --- ask_shutdown +++ ask_shutdown @@ -0,0 +1,17 @@ +#!/usr/bin/wish +if {![llength $argv]} { + puts stderr "Usage $argv0 machinename" + exit 1 +} +set name [lindex $argv 0] +label .top -text "Virtual machine [lindex $argv 0] is still running" -font {serif 20} +frame .buttons +button .buttons.shutdown -text "Shut down" -command "exec vws shutdown $name +destroy ." +button .buttons.suspend -text "Suspend" -command "exec vws save $name +destroy ." +button .buttons.bgd -text "Run in background" -command "destroy ." -default active +pack .buttons.shutdown .buttons.suspend .buttons.bgd -side left -expand n -padx 20 -pady 10 +#.top configure -wraplength [winfo reqwidth .buttons]p +pack .top -side top -expand y -fill x -padx 10 -pady 20 +pack .buttons -side top -expand n ADDED start.template Index: start.template ================================================================== --- start.template +++ start.template @@ -0,0 +1,15 @@ +#!/bin/sh +NAME=$(basename $(pwd)) +# if remote access is enabled, then there should be +# SPICE_PASSWORD=password +SPICE_PORT=$(find_free_port 5900) +. /etc/vws/vm.conf +{qemubinary} -name $NAME {accel} \ +{drive} \ +{cdrom} \ +{net} \ +{usb} \ +{sound} \ +$MONITOR_OPTIONS \ +$SPICE_OPTIONS \ +$PROCESS_OPTIONS ADDED vm.conf Index: vm.conf ================================================================== --- vm.conf +++ vm.conf @@ -0,0 +1,14 @@ +QEMU_AUDIO_DRV=spice +export QEMU_AUDIO_DRV +if [ -n "$SPICE_PASSWORD" = yes ]; then + SPICE_AUTH="password=$SPICE_PASSWORD" +else + SPICE_AUTH="disable-ticketing,addr=127.0.0.1 +fi +SPICE_OPTIONS="-vga qxl +-spice port=$SPICE_PORT,$SPICE_AUTH +-device virtio-serial -chardev spicevmc,id=vdagent,name=vdagent +-device virtserialport,chardev=vdagent,name=com.redhat.spice.0" +MONITOR_OPTIONS="-monitor socket,path=monitor" +PROCESS_OPTIONS="-daemonize -pidfile pid" + ADDED vws Index: vws ================================================================== --- vws +++ vws @@ -0,0 +1,35 @@ +#!/usr/bin/python +from ConfigParser import ConfigParser +import socket +config=ConfigParser({"SharedVMs":"/var/cache/vws/shared","AutostartVMs":"/var/cache/vws/auto"}) +def find_vm(name): + search_path=[os.environ['HOME']+"/VWs", + config.get("directories","SharedVMs"), + config.get("directories","AutostartVMs")] + for dirname in search_path: + if name in os.listdir(dirname): + return dirname+"/"+name + raise ValueError("Machine "+name+" not found.") + +def connect_vm(vm_dir): + sock=socket.socket(socket.AF_UNIX) + sock.connect(vm_dir+"/monitor") + +def get_spice_url(sock): + f=sock.makefile("r") + sock.send("info spice\n") + line="" + url=None + while not line.startswith("(qemu)"): + line=f.getline().strip("\n\r") + if url is not None: + continue + n=line.find("address:") + if n != -1: + url=line[n+9:] + if url.startswith('*:'): + url="localhost"+url[1:] + f.close() + return "spice://"+url + + ADDED vws.conf Index: vws.conf ================================================================== --- vws.conf +++ vws.conf @@ -0,0 +1,4 @@ +[directories] +SharedVMs=/home/virtual/vws/shared +AutostartVMs=/home/virtual/vws/autostart +[misc] ADDED vwsgui Index: vwsgui ================================================================== --- vwsgui +++ vwsgui @@ -0,0 +1,12 @@ +#!/bin/sh +if [ -z "$1" ]; then + echo "Usage: $0 vm-name" + exit 1 +fi + +uri=`vms spiceuri $1` +if [ $? -gt 0 ]; then + exit 1 +fi +spicy $uri