summaryrefslogtreecommitdiffstats
path: root/os-plugins/plugins/qemukvm/files/run-virt.include
diff options
context:
space:
mode:
authorMichael Janczyk2010-03-22 19:06:22 +0100
committerMichael Janczyk2010-03-22 19:06:22 +0100
commit3f82922eef9a7b3e894d629d6cac59cadb66e2de (patch)
tree6a01c4c65bb88da9e268d1c3bddac520fa8811b2 /os-plugins/plugins/qemukvm/files/run-virt.include
parentqemukvm angepasst... geht noch nicht :( (diff)
downloadcore-3f82922eef9a7b3e894d629d6cac59cadb66e2de.tar.gz
core-3f82922eef9a7b3e894d629d6cac59cadb66e2de.tar.xz
core-3f82922eef9a7b3e894d629d6cac59cadb66e2de.zip
small bugfix regarding xmlfile and paths.
writelog now additional into rwshare. virtualbox rmdirs new. qemukvm plugin added new konfigurations and headless support, to be tested
Diffstat (limited to 'os-plugins/plugins/qemukvm/files/run-virt.include')
-rw-r--r--os-plugins/plugins/qemukvm/files/run-virt.include206
1 files changed, 189 insertions, 17 deletions
diff --git a/os-plugins/plugins/qemukvm/files/run-virt.include b/os-plugins/plugins/qemukvm/files/run-virt.include
index 8d6d442b..0cec83da 100644
--- a/os-plugins/plugins/qemukvm/files/run-virt.include
+++ b/os-plugins/plugins/qemukvm/files/run-virt.include
@@ -28,31 +28,108 @@ else
fi
################################################################################
-### Pepare and configure virtual machine and disk image
+### Declaration of default variables
################################################################################
-permem=50
-mem=$(expr ${totalmem} / 100 \* ${permem})
+PLUGINCONFVIRTUALBOX="${PLUGINCONFROOT}/${self}"
+# create TMPDIR for all users
+mkdir -m 1777 /tmp/${self} 2>/dev/null
+# TMPDIR
+QKTMPDIR="/tmp/${self}/${USER}/${VM_ID}"
+# define dirs and files which can be removed after exit, be carefull!
+RMDIRS="${QKTMPDIR}"
+rm -rf ${RMDIRS} 2>/dev/null
+mkdir -p ${QKTMPDIR} 2>/dev/null
+# vmpath is the path to the vm, here an image (img|qcow*|vmdk)
+diskfile=${vmpath}
+
+# check the file type
+if echo ${imgname} | grep -iE "img|qcow|vmdk" >/dev/null 2>&1; then
+ imgtype=$(echo ${imgname#*.} | tr [a-z] [A-Z])
+else
+ writelog "${imgname} is not a valid image type (img|qcow*|vmdk), exiting!"
+ exit 1
+fi
+
+# display name
+VIRTCMDOPTS="${VIRTCMDOPTS} -name ${displayname}"
+
+writelog "Directories:"
+writelog "\tTMPDIR:\t\t$QKTMPDIR"
+writelog "Diskimage:"
+writelog "\tDisk type:\t\t$imgtype"
+writelog "\tDisk file:\t\t$diskfile"
+
+################################################################################
+### Hardware checks
+################################################################################
+
+# memory part equal to vmware plugin
+# percentage of memory to use for virtualbox in standard case
+if [ -n "${forcemem}" ]; then
+ mem="${forcemem}"
+else
+# permem=30
+# if [ "${totalmem}" -ge "1600" ]; then
+# permem=40
+# fi
+# # check if /tmp is on harddisk
+# if grep -qe "/dev/.* /tmp " /proc/mounts ; then
+# permem=60
+# id44="1"
+# # Hack, if more than 2,5G RAM use 40% of Ram and write vmem into Ram as well
+# # (40% vmware | 40% confdir(vmem...) | 20% host
+# # VMplayer 2+ issue
+# # TODO: makes this sense for vbox?
+# #if [ "${totalmem}" -ge "2500" ]; then
+# #permem=40
+# #rmdir ${snapshotdir}
+# #snapshotdirold=${snapshotdir}
+# #snapshotdir=/dev/shm/${self}/${USER}/${VM_ID}
+# #mkdir -p ${snapshotdir}
+# #ln -sf ${snapshotdir} ${snapshotdirold}
+# #fi
+# fi
+# mem=$(expr ${totalmem} / 100 \* ${permem})
+# if [ "${id44}" = "1" ]; then
+# memhost=$(expr ${totalmem} - ${mem})
+# else
+# memhost=$(expr ${totalmem} - ${mem} - ${mem})
+# fi
+ # static first
+ permem=50
+ mem=$(expr ${totalmem} / 100 \* ${permem})
+ if [ "${mem}" -lt "256" ] || [ "${memhost}" -lt "256" ]; then
+ writelog "Memory out of range: ${mem} MB (guest) / ${memhost} MB (host)!"
+ writelog "Min. 256 MB for host and guest!"
+ exit 1
+ fi
+fi
+
VIRTCMDOPTS="${VIRTCMDOPTS} -m ${mem}"
# network adaptor alternatives: rtl8139, pcnet, e1000
-VIRTCMDOPTS="${VIRTCMDOPTS} -net nic,model=pcnet"
+network_card=${network_card:=pcnet}
+VIRTCMDOPTS="${VIRTCMDOPTS} -net nic,model=${network_card}"
case "${network_kind}" in
bridge*)
VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tap0"
;;
- nat|NAT)
- VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tap1"
- ;;
- hostonly)
+ hostonly|host-only)
VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tap2"
;;
+ *)
+ network_kind="NAT"
+ VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tap1"
+ ;;
esac
+# external GUI port
+vncport="590${VM_ID}"
+
+# TODO: most of the following does not make much sense yet ...
# virtual fd/cd/dvd and drive devices, floppy b: for configuration
-#VIRTCMDOPTS="${VIRTCMDOPTS} -fda /dev/fd0"
-VIRTCMDOPTS="${VIRTCMDOPTS} -fdb /var/lib/virt/vmchooser/loopimg/fd.img"
# if $floppy_0 from run-virt.include set then fdtest="TRUE"
fdtest=
fdtest=${floppy_0:+"TRUE"}
@@ -75,19 +152,114 @@ cdrom1=${cdtest:-"FALSE"}
ide="TRUE"
hddrv="ide"
+# TODO: nur bei vmchooser
+#VIRTCMDOPTS="${VIRTCMDOPTS} -fda /dev/fd0"
+#VIRTCMDOPTS="${VIRTCMDOPTS} -fdb ${floppy1name}"
+
# audio
VIRTCMDOPTS="${VIRTCMDOPTS} -soundhw all"
# serial
#VIRTCMDOPTS="${VIRTCMDOPTS} -serial /dev/ttyS0"
+writelog "Virtual Hardware:"
+writelog "\tGuest RAM:\t\t${mem} MB"
+# echo nur wenn memhost gesetzt
+[ -n "${memhost}" ] && writelog "\tHost RAM:\t\t${memhost} MB"
+writelog "\tMAC address:\t\t$macaddr"
+writelog "\tNetwork card:\t\t${network_card}"
+writelog "\tNetwork kind:\t\t${network_kind}"
+#writelog "\tCD-ROM1:\t${cdrom0}"
+#writelog "\tCD-ROM2:\t${cdrom1}"
+#writelog "\tFloppy_A:\t${floppy0}"
+#writelog "\tFloppy_B:\t${floppy1}"
+#writelog "\tShared Folders 'home':\t/home/${USER}"
+
+################################################################################
+### finally set env for run-virt.sh
+################################################################################
+
+#-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i]
+# [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off]
+# [,cache=writethrough|writeback|none][,format=f][,serial=s]
+# [,boot=on|off]
+#-snapshot write to temporary files instead of disk image files
+#-usb enable the USB driver (will be the default soon)
+#-usbdevice name add the host or guest USB device 'name'
+#-nographic disable graphical output and redirect serial I/Os to console
+#-vga [std|cirrus|vmware|none] select video card type
+#-vnc display start a VNC server on display
+#-tftp dir allow tftp access to files in dir [-net user]
+#-bootp file advertise file in BOOTP replies
+#-no-fd-bootchk disable boot signature checking for floppy disks
+#-no-acpi disable ACPI
+#-kernel bzImage use 'bzImage' as kernel image
+#-append cmdline use 'cmdline' as kernel command line
+#-initrd file use 'file' as initial ram disk
+#-serial dev redirect the serial port to char device 'dev'
+#-parallel dev redirect the parallel port to char device 'dev'
+#-monitor dev redirect the monitor to char device 'dev'
+#-pidfile file write PID to 'file'
+#-d item1,... output log to /tmp/qemu.log (use -d ? for a list of log items)
+#-L path set the directory for the BIOS, VGA BIOS and keymaps
+#-bios file set the filename for the BIOS
+#-no-kvm disable KVM hardware virtualization
+#-enable-nesting enable support for running a VM inside the VM (AMD only)
+#-no-reboot exit instead of rebooting
+#-no-shutdown stop before shutdown
+#-loadvm [tag|id]
+# start right away with a saved state (loadvm in monitor)
+#-daemonize daemonize QEMU after initializing
+#-kvm-shadow-memory megs set the amount of shadow pages to be allocated
+#-mem-path set the path to hugetlbfs/tmpfs mounted directory, also
+# enables allocation of guest memory with huge pages
+#-mem-prealloc toggles preallocation of -mem-path backed physical memory
+# at startup. Default is enabled.
+#-option-rom rom load a file, rom, into the option ROM space
+#-localtime set the real time clock to local time [default=utc]
+#-startdate select initial date of the clock
+#-icount [N|auto]
+# enable virtual instruction counter with 2^N clock ticks per instruction
+#-echr chr set terminal escape character instead of ctrl-a
+#-virtioconsole c
+# set virtio console
+#-show-cursor show cursor
+
+# check for kvm modules
+# TODO: check for /dev/kvm
+if [ -n "${kvm}" ]; then
+ if lsmod |Ęgrep ${kvm}; then
+ for tool in kvm qemu-kvm; do
+ VIRTCMD=$(which ${tool} 2>/dev/null)
+ [ -n "$VIRTCMD" ] && break
+ done
+ else
+ writelog "KVM available but no modules loaded, maybe compiled into kernel?"
+ VIRTCMD=$(which qemu 2>/dev/null)
+ fi
+fi
+
# set the variables appropriately
-for tool in kvm qemu-kvm qemu; do
- VIRTCMD=$(which ${tool} 2>/dev/null)
- [ "x$VIRTCMD" != "x" ] && break
-done
+#for tool in kvm qemu-kvm qemu; do
+# VIRTCMD=$(which ${tool} 2>/dev/null)
+# [ -n "$VIRTCMD" ] && break
+#done
+
+if [ -z "${VIRTCMD}" ]; then
+ writelog "No QEMU/KVM found."
+ rm -rf ${RMDIRS}
+ exit 1
+elif [ "${VIRTCMD}" = "qemu" ]; then
+ writelog "No KVM fouund. Starting slow QEMU emulation"
+ VIRTCMD="qemu"
+else
+ VIRTCMD="sudo $VIRTCMD"
+fi
-[ -z $VIRTCMD ] && { writelog "No qemu/kvm tool found."; exit 1; }
+# set headless mode
+VIRTCMDHL="$VIRTCMD"
+VIRTCMDOPTSHL="${VIRTCMDOPTS} -boot c -alt-grab -nographic"
-VIRTCMD="sudo $VIRTCMD"
-VIRTCMDOPTS="${VIRTCMDOPTS} -boot c -alt-grab ${diskfile}"
+# graphical start
+VIRTCMD="$VIRTCMD"
+VIRTCMDOPTS="${VIRTCMDOPTS} -boot c -alt-grab -full-screen ${diskfile}"