aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-05-01 14:07:53 -0300
committerSilvio Rhatto <rhatto@riseup.net>2017-05-01 14:07:53 -0300
commitb333a9022f1dc511e3196688c59f3db54bcfa697 (patch)
treecfa0caf0a130bbeb10ae1e6aef05ff2e96a4b09d
parent2676158c225668827639a7e74d8b24af68ec33d0 (diff)
downloadkvmx-b333a9022f1dc511e3196688c59f3db54bcfa697.tar.gz
kvmx-b333a9022f1dc511e3196688c59f3db54bcfa697.tar.bz2
Adds Xephyr support
-rw-r--r--README.md5
-rwxr-xr-xkvmx36
-rw-r--r--kvmxfile11
-rw-r--r--share/provision/files/desktop-basic/etc/lightdm/lightdm.conf6
4 files changed, 50 insertions, 8 deletions
diff --git a/README.md b/README.md
index c81c2ee..d51389b 100644
--- a/README.md
+++ b/README.md
@@ -23,6 +23,10 @@ If you plan to create guest images, you may also want the following packages:
sudo apt install debootstrap grub-pc parted vmdebootstrap mbr libguestfs-tools
+If you want Xpra and Xephyr support:
+
+ sudo apt install xpra xserver-xephyr
+
## Instalation
Simply clone it and add to your `$PATH`:
@@ -53,7 +57,6 @@ If no folder is specified, the current folder is assumed as the project home.
* https://bbs.archlinux.org/viewtopic.php?id=177299
* Alternative folder sharing support (NFS, SMB or even [via SSH](https://superuser.com/questions/831659/mount-a-local-directory-to-a-remote-ssh-server)).
* Remount 9p shared folders and reinitialize spice-vdagent upon resume from disk [see possible bug](https://bugzilla.redhat.com/show_bug.cgi?id=1333072).
-* [Xephyr support](http://jeffskinnerbox.me/posts/2014/Apr/29/howto-using-xephyr-to-create-a-new-display-in-a-window/).
* [Nested virtualization](http://www.rdoxenham.com/?p=275).
* More params (memory, cpus, ssh, serial console, additional shared folders, etc).
* Integration with [image-bootstrap](https://github.com/hartwork/image-bootstrap).
diff --git a/kvmx b/kvmx
index 91029a4..2814780 100755
--- a/kvmx
+++ b/kvmx
@@ -101,6 +101,7 @@ function __kvmx_initialize {
PORT="$(($RANDOM + 1024))"
SSH="$(($PORT + 22))"
GUEST_DISPLAY="$(((RANDOM % 10) + 1))"
+ XDMCP_PORT="$(($RANDOM + 10000))"
# Initalize
mkdir -p $GLOBAL_USER_CONFIG_FOLDER
@@ -156,12 +157,14 @@ function __kvmx_initialize {
LOG_DIR="$STORAGE/log"
PIDFILE="$STATE_DIR/pid"
PORTFILE="$STATE_DIR/port"
+ XDMCPPORTFILE="$STATE_DIR/xdmcp"
SSHFILE="$STATE_DIR/ssh"
DISPLAYFILE="$STATE_DIR/display"
SPICEFILE="$STATE_DIR/spice"
LOGFILE="$LOG_DIR/qemu"
SPICELOG="$LOG_DIR/spice"
XPRALOG="$LOG_DIR/xpra"
+ XDMCPLOG="$LOG_DIR/xdmcp"
if [ -e "$STORAGE/ssh/$VM.key" ]; then
mkdir -p "$STORAGE/ssh"
@@ -233,6 +236,10 @@ function kvmx_up {
$DIRNAME/$BASENAME xpra $VM
fi
+ if [ "$run_xephyr" == "1" ]; then
+ $DIRNAME/$BASENAME xephyr $VM
+ fi
+
exit
elif kvmx_running; then
echo "$BASENAME: guest $VM is already running"
@@ -308,7 +315,7 @@ function kvmx_up {
-chardev spicevmc,id=spicechannel0,name=vdagent \
-smp 2 -soundhw ac97 -cpu host -balloon virtio \
-net nic,model=virtio \
- -net user,hostfwd=tcp:127.0.0.1:$SSH-:22$hostfwd &> $LOGFILE < /dev/null &
+ -net user,hostfwd=tcp:127.0.0.1:$SSH-:22,hostfwd=udp:127.0.0.1:$XDMCP_PORT-:177$hostfwd &> $LOGFILE < /dev/null &
PID="$!"
@@ -317,6 +324,7 @@ function kvmx_up {
echo $PORT > $PORTFILE
echo $SSH > $SSHFILE
echo $GUEST_DISPLAY > $DISPLAYFILE
+ echo $XDMCP_PORT > $XDMCPPORTFILE
if [ "$run_spice_client" == "1" ]; then
kvmx_spice
@@ -361,6 +369,10 @@ function kvmx_up {
$DIRNAME/$BASENAME xpra $VM
fi
+ if [ "$run_xephyr" == "1" ]; then
+ $DIRNAME/$BASENAME xephyr $VM
+ fi
+
kvmx_status
}
@@ -907,6 +919,8 @@ function kvmx_vnc {
exit 1
fi
+ GUEST_DISPLAY="`cat $DISPLAYFILE`"
+
if [ -z "$vnc_client" ]; then
vnc_client="virt-viewer"
fi
@@ -924,6 +938,26 @@ function kvmx_vnc {
fi
}
+# Connect to the guest using XDMCP/Xephyr
+# See http://jeffskinnerbox.me/posts/2014/Apr/29/howto-using-xephyr-to-create-a-new-display-in-a-window/
+function kvmx_xephyr {
+ # Clipboard sharing
+ # https://ubuntuforums.org/showthread.php?t=1430363
+ GUEST_DISPLAY="`cat $DISPLAYFILE`"
+ XDMCP_PORT="`cat $XDMCPPORTFILE`"
+
+ if [ ! -z "$resolution" ]; then
+ resolution="-screen $resolution"
+ fi
+
+ if ! which Xephyr &> /dev/null; then
+ echo "$BASENAME: please install Xephyr"
+ exit 1
+ fi
+
+ Xephyr :$GUEST_DISPLAY -ac -port $XDMCP_PORT -query 127.0.0.1 $resolution &> $XDMCPLOG < /dev/null &
+}
+
# Dispatch
if type kvmx_$ACTION 2> /dev/null | grep -q 'function'; then
__kvmx_initialize
diff --git a/kvmxfile b/kvmxfile
index 45b5e2a..d70a742 100644
--- a/kvmxfile
+++ b/kvmxfile
@@ -35,13 +35,18 @@ graphics="-vga qxl"
#vnc_client="xvncviewer"
vnc_client="virt-viewer"
-# Set this if you want to automatically attach an spice client when the machine
-# boots.
+# Set this if you want to attach an spice client when the machine boots.
run_spice_client="1"
-# Set this if you want to automatically a xpra session when the machine boots.
+# Set this if you want to start an xpra session when the machine boots.
run_xpra="0"
+# Set this if you want to start an xephyr session when the machine boots.
+run_xephyr="0"
+
+# Set screen resolution
+#resolution="1280x785"
+
# Set additional hostfwd mappings
#port_mapping="hostfwd=tcp:127.0.0.1:8080-:80,hostfwd=tcp:127.0.0.1:8443-:443"
diff --git a/share/provision/files/desktop-basic/etc/lightdm/lightdm.conf b/share/provision/files/desktop-basic/etc/lightdm/lightdm.conf
index f9b1371..7614cc2 100644
--- a/share/provision/files/desktop-basic/etc/lightdm/lightdm.conf
+++ b/share/provision/files/desktop-basic/etc/lightdm/lightdm.conf
@@ -92,7 +92,7 @@
#xmir-command=Xmir
#xserver-config=
#xserver-layout=
-#xserver-allow-tcp=false
+xserver-allow-tcp=true
#xserver-share=true
#xserver-hostname=
#xserver-display-number=
@@ -138,8 +138,8 @@ autologin-user-timeout=0
# it can be a word and the first 7 characters are used as the key.
#
[XDMCPServer]
-#enabled=false
-#port=177
+enabled=true
+port=177
#listen-address=
#key=
#hostname=