]> gitweb.fluxo.info Git - kvmx.git/commitdiff
Check for requirements and use spicy as default spice_client
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 23 Jun 2018 12:53:54 +0000 (09:53 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 23 Jun 2018 12:53:54 +0000 (09:53 -0300)
kvmx
kvmx-create
kvmxfile
lib/kvmx/functions

diff --git a/kvmx b/kvmx
index 1718ac551b60a6e523de40b01cf01b86f1f512df..c6c9137d3bc5c4c60de6235038392512b804b3d1 100755 (executable)
--- a/kvmx
+++ b/kvmx
@@ -88,6 +88,9 @@ function __kvmx_initialize {
   export APP_BASE="`$DIRNAME/kvmx app_base`"
   source $APP_BASE/lib/kvmx/functions || exit 1
 
+  # Check dependencies
+  __kvmx_check_dependencies
+
   # Alias to be used in config files
   KVMX_BASE="$APP_BASE"
 
@@ -215,6 +218,10 @@ function __kvmx_initialize {
         echo "$BASENAME: WARNING: Intel VT or AMD-V not present at /proc/cpuinfo, expect slow performance"
       fi
 
+      if ! lsmod | grep -q '^kvm '; then
+        echo "$BASENAME: WARNING: kvm kernel module not loaded, expect slow performance"
+      fi
+
       if ! groups `whoami` | grep -q 'kvm'; then
         echo "$BASENAME: WARNING: user `whoami` not in kvm group, expect slow performance"
       fi
@@ -247,11 +254,14 @@ function kvmx_spice {
     spicy -h localhost -p $PORT &
   elif [ "$spice_client" == "virt-viewer" ] && which virt-viewer &> /dev/null; then
     remote-viewer spice://localhost:$PORT &
-  else
+  elif [ "$spice_client" == "spicec" ]; then
     if which spicec &> /dev/null; then
       # https://lists.freedesktop.org/archives/spice-devel/2013-September/014643.html
       SPICE_NOGRAB=1 spicec --host localhost --port $PORT &> $SPICELOG &
     fi
+  else
+    echo "$BASENAME: spice_client $spice_client not currently supported"
+    exit 1
   fi
 
   SPICEPID="$!"
index 9d956ab2c93ce464e23e2c857336ca24a2603beb..64a66ecaf5edd78bb4856962448baf8cdd4c9964 100755 (executable)
@@ -197,6 +197,16 @@ function kvmx_create_vmdebootstrap {
 # Custom version
 #
 function kvmx_create_custom {
+  # Check dependencies
+  DEPENDENCIES="sudo apt qemu-img sed awk tr head debootstrap chroot"
+  __kvmx_check_dependencies
+
+  # Check for package requirements
+  #for req in debootstrap parted apt-transport-https; do
+  for req in debootstrap parted; do
+    kvmx_install_package $req
+  done
+
   if [ -z "$TMP" ]; then
     TMP="/tmp"
   fi
@@ -231,12 +241,6 @@ function kvmx_create_custom {
     fi
   fi
 
-  # Check for requirements.
-  #for req in debootstrap parted apt-transport-https; do
-  for req in debootstrap parted; do
-    kvmx_install_package $req
-  done
-
   if [ -z "$image_type" ] || [ "$image_type" == "file" ]; then
     echo "Creating image file..."
     #kvmx_sudo_run dd if=/dev/zero of=$image bs=$size count=1
index 660132d00e1c8ac65ca486af4f9303f5502907d6..a8979e72c2cd113c85d3d93c85758b6c1100b2e5 100644 (file)
--- a/kvmxfile
+++ b/kvmxfile
@@ -85,7 +85,9 @@ spice="1"
 run_spice_client="1"
 
 # SPICE client
-spice_client="spicec"
+#spice_client="spicec"
+#spice_client="virt-viewer"
+spice_client="spicy"
 
 # Set this if you want to start an xpra session when the machine boots.
 run_xpra="0"
index 134f4be190d5eab67428d70dd4d86a29da4c545d..d1a1015913f86061d134e9489fc579b45af6766e 100755 (executable)
@@ -19,3 +19,17 @@ function __kvmx_ssh_keygen {
     ssh-keygen -t rsa -b 4096 -f $1 -N '' -C $2
   fi
 }
+
+# Check dependencies
+function __kvmx_check_dependencies {
+  if [ -z "$DEPENDENCIES" ]; then
+    DEPENDENCIES="ssh sudo apt kvm virt-viewer spicy socat screen sed awk"
+  fi
+
+  for dependency in $DEPENDENCIES; do
+    if ! which $dependency &> /dev/null; then
+      echo "$BASENAME: cannot find dependency program $dependency"
+      exit 1
+    fi
+  done
+}