aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-04-01 13:59:53 -0300
committerSilvio Rhatto <rhatto@riseup.net>2017-04-01 13:59:53 -0300
commita081dc7bf787ae58df3602f3b717922f76599979 (patch)
tree49b5b121455fabea333884325f64bcad09b75b41
parent7d4ab63dc0f6bddda7de991b79db7f9e9711096d (diff)
downloadkvmx-a081dc7bf787ae58df3602f3b717922f76599979.tar.gz
kvmx-a081dc7bf787ae58df3602f3b717922f76599979.tar.bz2
Adds VNC support
-rw-r--r--README.md1
-rwxr-xr-xkvmx35
-rw-r--r--kvmxfile10
3 files changed, 41 insertions, 5 deletions
diff --git a/README.md b/README.md
index 3d6a870..d93b154 100644
--- a/README.md
+++ b/README.md
@@ -46,7 +46,6 @@ If no folder is specified, the current folder is assumed as the project home.
## Further development
-* VNC support.
* Alternative folder sharing support (NFS or SMB).
* Remount 9p shared folders and reinitialize spice-vdagent upon resume from disk [see possible bug](https://bugzilla.redhat.com/show_bug.cgi?id=1333072).
* More params (memory, cpus, ssh, serial console, additional shared folders, etc).
diff --git a/kvmx b/kvmx
index 2b410f2..1b7c4cf 100755
--- a/kvmx
+++ b/kvmx
@@ -97,6 +97,7 @@ function __kvmx_initialize {
# Default parameters
PORT="$(($RANDOM + 1024))"
SSH="$(($PORT + 22))"
+ GUEST_DISPLAY="$(((RANDOM % 10) + 1))"
# Initalize
mkdir -p $GLOBAL_USER_CONFIG_FOLDER
@@ -138,6 +139,7 @@ function __kvmx_initialize {
PIDFILE="$STATE_DIR/pid"
PORTFILE="$STATE_DIR/port"
SSHFILE="$STATE_DIR/ssh"
+ DISPLAYFILE="$STATE_DIR/display"
SPICEFILE="$STATE_DIR/spice"
LOGFILE="$LOG_DIR/qemu"
SPICELOG="$LOG_DIR/spice"
@@ -258,9 +260,13 @@ function kvmx_up {
fi
fi
+ if [ -z "$graphics" ]; then
+ graphics="-vga qxl"
+ fi
+
# Run virtual machine
# See https://en.wikipedia.org/wiki/Nohup#Overcoming_hanging
- nohup kvm -m 2048 -name $VM -drive file=$image,if=virtio -vga qxl $shared \
+ nohup kvm -m 2048 -name $VM -drive file=$image,if=virtio $graphics $shared \
-spice port=$PORT,addr=127.0.0.1,disable-ticketing,streaming-video=off,jpeg-wan-compression=never,playback-compression=off,zlib-glz-wan-compression=never,image-compression=off \
-device virtio-serial-pci \
-device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 \
@@ -272,9 +278,10 @@ function kvmx_up {
PID="$!"
# Save state
- echo $PID > $PIDFILE
- echo $PORT > $PORTFILE
- echo $SSH > $SSHFILE
+ echo $PID > $PIDFILE
+ echo $PORT > $PORTFILE
+ echo $SSH > $SSHFILE
+ echo $GUEST_DISPLAY > $DISPLAYFILE
if [ "$run_spice_client" == "1" ]; then
kvmx_spice
@@ -764,6 +771,26 @@ function kvmx_start {
kvmx_up $*
}
+# Connect to the guest using VNC
+function kvmx_vnc {
+ if ! kvmx_running; then
+ echo "$BASENAME: guest $VM is not running"
+ exit 1
+ fi
+
+ if [ -z "$vnc_client" ]; then
+ vnc_client="xvncviewer"
+ fi
+
+ if which $vnc_client &> /dev/null; then
+ GUEST_DISPLAY="`cat $DISPLAYFILE`"
+ $vnc_client :$GUEST_DISPLAY
+ else
+ echo "$BASENAME: no vnc_client configured"
+ exit 1
+ fi
+}
+
# Dispatch
if type kvmx_$ACTION 2> /dev/null | grep -q 'function'; then
__kvmx_initialize
diff --git a/kvmxfile b/kvmxfile
index 7867049..20309f4 100644
--- a/kvmxfile
+++ b/kvmxfile
@@ -21,6 +21,16 @@ shared_folder_mountpoint="/home/$user/code/$VM"
# Absolute path for a provision script located inside the guest.
#provision_command="/usr/local/share/kvmx/provision/desktop-basic"
+# Graphics
+# See https://wiki.archlinux.org/index.php/QEMU#Graphics
+#graphics="-vga std -nographic -vnc :$GUEST_DISPLAY"
+graphics="-vga qxl"
+
+# VNC Client
+#vnc_client="xtightvncviewer"
+#vnc_client="xvnc4viewer"
+vnc_client="xvncviewer"
+
# Set this if you want to automatically attach an spice client when the machine
# boots.
run_spice_client="1"