]> gitweb.fluxo.info Git - kvmx.git/commitdiff
Adds Xephyr support
authorSilvio Rhatto <rhatto@riseup.net>
Mon, 1 May 2017 17:07:53 +0000 (14:07 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Mon, 1 May 2017 17:07:53 +0000 (14:07 -0300)
README.md
kvmx
kvmxfile
share/provision/files/desktop-basic/etc/lightdm/lightdm.conf

index c81c2eee49f2f69f6fc1da729bad65c61b90944f..d51389b60b6cbeb10ef578f94a86b2e8f17c0169 100644 (file)
--- 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 91029a4729cc832252f389cd3a51f8e032ae7dc7..2814780b9282d397d90f2243855556944009eb97 100755 (executable)
--- 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
index 45b5e2a34f811338f108c8b8a21ea8501e05c364..d70a7428e53783689956ea64713b1b2fd51634d4 100644 (file)
--- 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"
 
index f9b137130a01a4e38257438890e9e01b82f63117..7614cc23ef277945c31b1fd8cdb2e15be389c2d4 100644 (file)
@@ -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=