Compare commits

...

6 commits

Author SHA1 Message Date
Hippolyte Chauvin
c115dbd144 Ajout : fonctions pour manipuler des images disque dans qemush 2023-10-15 12:08:45 +02:00
Hippolyte Chauvin
7db32e1bbf Correction : la fonction list affiche les VM disponibles. Ajout : la
fonction active remplace la fonction list
2023-10-15 11:59:15 +02:00
Hippolyte Chauvin
b4921b8686 Ajout : fonctions dans qemush. Remaniement : screen géré par qemush pour
les machines virtuelles
2023-10-15 11:57:01 +02:00
Hippolyte Chauvin
7f934cd200 Remaniement : nouveau nom pour startvm -> qemush 2023-10-15 11:33:46 +02:00
Hippolyte Chauvin
30b1b52a1b Suppression : lien symbolique windows10 2023-10-15 11:33:46 +02:00
Hippolyte Chauvin
2457abe3d1 Ajout : script startvm
startvm permet de contrôler l'exécution de machines virtuelles en tant
que l'utilisateur Unix qemu
2023-10-15 11:33:46 +02:00
4 changed files with 89 additions and 5 deletions

87
bin/qemush Executable file
View file

@ -0,0 +1,87 @@
#!/bin/bash
exec_as() {
local user="$1"
shift
if [ "$(whoami)" != "$user" ]; then
exec sudo -u "$user" "$0" "$@"
else
cd
fi
}
exec_as qemu "$@" || exit
PATH="./bin:${PATH}"
perror() {
>&2 printf '\033[1;31mERROR:\033[0m \033[1m%s\033[0m\n' "$*"
}
public_help() {
local name
name="$(basename "$0")"
cat << EOF
${name}: usage:
${name} start <VM name> - start a VM
${name} watch <VM name> - attach VM screen session
${name} active - (default behaviour) list active VMs
${name} list - list available VMs
${name} help - show this help
${name} diskls - list available disk images
${name} diskadd <disk name> <size> - create a disk image
${name} diskrm <disk name> - delete disk image
EOF
}
error_usage() {
perror "Invalid usage"
>&2 public_help
return 1
}
public_start() {
local vm_name="$1"
shift
screen -d -m -S "$vm_name" "$vm_name" "$@"
}
public_watch() {
screen -dr "$1"
}
public_active() {
screen -ls
}
public_list() {
echo "Available machines:"
ls --color=auto bin
}
diskpath() {
printf 'images/%s.qcow2' "$1"
}
public_diskadd() {
qemu-img create -f qcow2 "$(diskpath "$1")" "$2"
}
public_diskrm() {
rm -vi -- "$(diskpath "$1")"
}
public_diskls() {
echo "Available disks:"
ls --color=auto images
}
function="$1"
shift
if declare -F | cut -d \ -f 3- | grep '^public_' | sed 's/^public_//' | grep -q "^${function}$"; then
"public_${function}" "$@"
else
error_usage
fi

View file

@ -1 +0,0 @@
../share/qemu/scripts/windows10

View file

@ -1,7 +1,6 @@
#!/bin/sh -ex #!/bin/sh -ex
name="$(basename "$0")" name="$(basename "$0")"
cd "$(dirname "$(readlink -f "$0")")/.." qemu-system-x86_64 \
exec screen -S "QEMU : ${name}" -d -m qemu-system-x86_64 \
-monitor stdio -enable-kvm \ -monitor stdio -enable-kvm \
-cpu host -smp "$(nproc)" \ -cpu host -smp "$(nproc)" \
-m 4G \ -m 4G \

View file

@ -1,7 +1,6 @@
#!/bin/sh -ex #!/bin/sh -ex
name="$(basename "$0")" name="$(basename "$0")"
cd "$(dirname "$(readlink -f "$0")")/.." qemu-system-x86_64 \
exec screen -S "QEMU : ${name}" -d -m qemu-system-x86_64 \
-monitor stdio -enable-kvm \ -monitor stdio -enable-kvm \
-bios /usr/share/edk2/x64/OVMF_CODE.fd \ -bios /usr/share/edk2/x64/OVMF_CODE.fd \
-usb -device usb-ehci,id=ehci -device usb-host,bus=ehci.0,vendorid=1452 \ -usb -device usb-ehci,id=ehci -device usb-host,bus=ehci.0,vendorid=1452 \