]> gitweb.fluxo.info Git - kvmx.git/commitdiff
Fix: support for newer kvm and screen such as those from debian buster
authorSilvio Rhatto <rhatto@riseup.net>
Mon, 11 May 2020 21:42:13 +0000 (18:42 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Mon, 11 May 2020 21:42:13 +0000 (18:42 -0300)
kvmx

diff --git a/kvmx b/kvmx
index 730e0dfd74ea0fb0b0d4e217cc336fabd9784734..c0895a7a43278e57b744a872efa89d09fb1144de 100755 (executable)
--- a/kvmx
+++ b/kvmx
@@ -511,12 +511,27 @@ function kvmx_up {
   #usb_opts="$usb_opts -chardev spicevmc,name=usbredir,id=usbredirchardev3"
   #usb_opts="$usb_opts -device usb-redir,chardev=usbredirchardev3,id=usbredirdev3"
 
+  # Check screen version
+  if screen --help | grep -q -- "-Logfile"; then
+    local screen_log="-L -Logfile $LOGFILE"
+  else
+    local screen_log="-L $LOGFILE"
+  fi
+
+  # Check kvm version
+  if kvm --help | grep -q -- "^-balloon"; then
+    local balloon="-balloon virtio"
+  else
+    local balloon="-device virtio-balloon"
+  fi
+
   # Run virtual machine, nohup approach
   # See https://en.wikipedia.org/wiki/Nohup#Overcoming_hanging
   #nohup setsid kvm -m $memory -name $VM                                                             \
   #  -chardev "socket,id=monitor,path=$MONITORFILE,server,nowait" -mon chardev=monitor,mode=readline \
   #  -chardev "socket,id=serial0,path=$CONSOLEFILE,server,nowait" -device isa-serial,chardev=serial0 \
-  #  -smp $smp -cpu host -balloon virtio                                                             \
+  #  -smp $smp -cpu host                                                                             \
+  #  $balloon                                                                                        \
   #  $graphics $shared                                                                               \
   #  $image_opts                                                                                     \
   #  $spice_opts                                                                                     \
@@ -528,10 +543,11 @@ function kvmx_up {
 
   # Run virtual machine, screen approach
   # This is more immune to hangups
-  screen -L $LOGFILE -S kvmx-qemu-$VM -d -m kvm -m $memory -name $VM                                \
+  screen $screen_log -S kvmx-qemu-$VM -d -m kvm -m $memory -name $VM                                \
     -chardev "socket,id=monitor,path=$MONITORFILE,server,nowait" -mon chardev=monitor,mode=readline \
     -chardev "socket,id=serial0,path=$CONSOLEFILE,server,nowait" -device isa-serial,chardev=serial0 \
-    -smp $smp -cpu host -balloon virtio                                                             \
+    -smp $smp -cpu host                                                                             \
+    $balloon                                                                                        \
     $graphics $shared                                                                               \
     $image_opts                                                                                     \
     $spice_opts                                                                                     \