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`:
* 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).
PORT="$(($RANDOM + 1024))"
SSH="$(($PORT + 22))"
GUEST_DISPLAY="$(((RANDOM % 10) + 1))"
+ XDMCP_PORT="$(($RANDOM + 10000))"
# Initalize
mkdir -p $GLOBAL_USER_CONFIG_FOLDER
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"
$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"
-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="$!"
echo $PORT > $PORTFILE
echo $SSH > $SSHFILE
echo $GUEST_DISPLAY > $DISPLAYFILE
+ echo $XDMCP_PORT > $XDMCPPORTFILE
if [ "$run_spice_client" == "1" ]; then
kvmx_spice
$DIRNAME/$BASENAME xpra $VM
fi
+ if [ "$run_xephyr" == "1" ]; then
+ $DIRNAME/$BASENAME xephyr $VM
+ fi
+
kvmx_status
}
exit 1
fi
+ GUEST_DISPLAY="`cat $DISPLAYFILE`"
+
if [ -z "$vnc_client" ]; then
vnc_client="virt-viewer"
fi
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
#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"