VM chooser menu and much faster direct kernel loading.
This commit is contained in:
parent
1622106e3c
commit
cfae3f22ed
2 changed files with 46 additions and 14 deletions
|
@ -4,27 +4,58 @@
|
||||||
#
|
#
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
|
menu=(standard "CLI Standard Debian GNU/Linux"
|
||||||
|
kde-desktop "KDE Plasma Desktop Debian GNU/Linux"
|
||||||
|
gnome-desktop "Gnome Desktop Debian GNU/Linux")
|
||||||
|
img=$(dialog --clear --backtitle "Virtual Machine Chooser" \
|
||||||
|
--title "Choose the Virtual Machine to Start" \
|
||||||
|
--menu "Start VM:" 12 60 6 \
|
||||||
|
"${menu[@]}" 2>&1 >/dev/tty)
|
||||||
|
|
||||||
|
if [[ -z $img ]] ; then
|
||||||
|
echo "Starting VM canceled."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
mac="$(ip link | grep -A1 "vm-macvtap" | \
|
mac="$(ip link | grep -A1 "vm-macvtap" | \
|
||||||
sed -nE "s%\s+link/ether ([[:xdigit:]:]{17}) .+%\1%p")"
|
sed -nE "s%\s+link/ether ([[:xdigit:]:]{17}) .+%\1%p")"
|
||||||
|
|
||||||
if [[ $# -eq 0 ]] ; then
|
if [[ $# -eq 0 ]] ; then
|
||||||
mem=$(sed -En "s/^MemTotal:\s+([0-9]+)\s+kB/\1/p" /proc/meminfo)
|
mem=$(sed -En "s/^MemTotal:\s+([0-9]+)\s+kB/\1/p" /proc/meminfo)
|
||||||
cpu=$(sed -En "0,/^cpu cores/s/^cpu cores\s+:\s+([0-9]+)/\1/p" /proc/cpuinfo)
|
cpu=$(sed -En "0,/^cpu cores/s/^cpu cores\s+:\s+([0-9]+)/\1/p" /proc/cpuinfo)
|
||||||
arg="--memory $((mem/2048)) --vcpu $((cpu/2))"
|
arg=("--memory=$((mem/2048))" "--vcpu=$((cpu/2))")
|
||||||
echo "Set options: $arg"
|
echo Set options: "${arg[@]}"
|
||||||
|
else
|
||||||
|
arg=("$@")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
loader='/usr/share/OVMF/OVMF_CODE_4M.fd,\
|
kernel="http://livebox/d-i/n-live/$img/live/vmlinuz"
|
||||||
loader.readonly=yes,loader.type=pflash,\
|
initrd="http://livebox/d-i/n-live/$img/live/initrd.img"
|
||||||
nvram.template=/usr/share/OVMF/OVMF_VARS_4M.fd'
|
kargs=(boot=live components splash locales=de_DE.UTF-8 keyboard-layouts=de \
|
||||||
|
swap=true live-config.timezone=Europe/Berlin netboot=nfs \
|
||||||
|
"nfsroot=10.190.1.2:/srv/nfs/debian-live/$img/")
|
||||||
|
|
||||||
type="ethernet,mac=${mac},target.dev=vm-macvtap,xpath1.set=./target/@managed=no"
|
type="ethernet,mac=${mac},target.dev=vm-macvtap,xpath1.set=./target/@managed=no"
|
||||||
|
|
||||||
XDG_CONFIG_HOME="/tmp/${UID}/.config" \
|
## FIXME: use passt, needs more settings for correct DNS/gateway
|
||||||
exec "virt-install \
|
# type=user,xpath1.create=./backend,xpath2.set=./backend/@type=passt,xpath3.create=./ip,xpath4.set=./ip/@family=ipv4,xpath5.set=./ip/@address=172.16.1.1,xpath6.set=./ip/@prefix=24,xpath7.create=./portForward,xpath8.set=./portForward/@proto=tcp,xpath9.set=./portForward/range/@start=2001,xpath10.set=./portForward/range/@end=2500,xpath11.set=./portForward/range/@to=1
|
||||||
--name bookworm \
|
|
||||||
--osinfo debiantesting \
|
case "$img" in
|
||||||
--nodisks --import \
|
standard)
|
||||||
--pxe --boot loader=$loader \
|
arg+=("--autoconsole=text")
|
||||||
--network type=$type \
|
kargs+=("console=ttyS0")
|
||||||
$* ${arg:-}"
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
http_proxy='' XDG_CONFIG_HOME="/tmp/${UID}/.config" \
|
||||||
|
exec virt-install \
|
||||||
|
--name "$img" \
|
||||||
|
--osinfo debiantesting \
|
||||||
|
--nodisks --import --noreboot --transient \
|
||||||
|
--install kernel="$kernel",initrd="$initrd",kernel_args="${kargs[*]}" \
|
||||||
|
--network "type=$type" "${arg[@]}"
|
||||||
|
|
||||||
|
# --filesystem "$HOME",share
|
||||||
|
# mount -t 9p share /mnt
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
- ctorrent
|
- ctorrent
|
||||||
- libvirt-daemon-system
|
- libvirt-daemon-system
|
||||||
- virt-manager
|
- virt-manager
|
||||||
|
- dialog # for vm-netboot menu
|
||||||
state: latest
|
state: latest
|
||||||
autoremove: true
|
autoremove: true
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue