correct drives bug with uefi mode
This commit is contained in:
parent
177b5cec3e
commit
f4177bdbd4
1 changed files with 41 additions and 28 deletions
69
vm-start.sh
69
vm-start.sh
|
@ -12,29 +12,30 @@ Script to manage virtual machine easily.
|
||||||
NAME is the name of the virtual machine to use.
|
NAME is the name of the virtual machine to use.
|
||||||
|
|
||||||
COMMAND available
|
COMMAND available
|
||||||
init Create the conf file in conf/NAME_var.sh
|
init Create the conf file in conf/NAME_var.sh
|
||||||
start Start the virtual machine using the variabes in conf/NAME_var.sh
|
start Start the virtual machine using the variabes in conf/NAME_var.sh
|
||||||
start-backup Start the virtual machine using the backup volume if it exists.
|
start-backup Start the virtual machine using the backup volume if it exists.
|
||||||
create Create the virtual machine using the conf in conf/NAME_var.sh
|
create Create the virtual machine using the conf in conf/NAME_var.sh
|
||||||
backup Create a backup file for the vm
|
backup Create a backup file for the vm
|
||||||
restore Restore the virtual machine using to backup file
|
restore Restore the virtual machine using to backup file
|
||||||
suppr Suppr all data related to the virtual machine other than the conf file.
|
suppr Suppr all data related to the virtual machine other than the conf file.
|
||||||
|
|
||||||
COMMAND TODO
|
COMMAND TODO
|
||||||
suppr-all Suppr all data related to the vm even the conf file #TODO
|
suppr-all Suppr all data related to the vm even the conf file #TODO
|
||||||
|
|
||||||
PARAMETTER available
|
PARAMETTER available
|
||||||
-h, --help Print this help and exit
|
-h, --help Print this help and exit
|
||||||
-v, --version Print the version of this program and quit
|
-v, --version Print the version of this program and quit
|
||||||
|
|
||||||
OPTION available
|
OPTION available
|
||||||
nproc=<nb proc> Def the number of proc of the vm
|
nproc=<nb proc> Def the number of proc of the vm
|
||||||
memory=<mem> Def the qty of memory allocated to the vm
|
memory=<mem> Def the qty of memory allocated to the vm
|
||||||
size=<size> Def the size that should be allocated by create
|
size=<size> Def the size that should be allocated by create
|
||||||
uefi Select if there will be an UEFI by default.
|
uefi Select if there will be an UEFI by default.
|
||||||
can be either set or unset. By default is unset.
|
can be either set or unset. By default is unset.
|
||||||
options=<option> additinal options to give to qemu. By default is
|
options=<option> additinal options to give to qemu. By default is
|
||||||
-display gtk -vga qxl
|
-display gtk -vga qxl
|
||||||
|
create_disk=<loc_disk> Def a create disk to boot on. Is necessary for using create, or need the variable INSTALLATION_DISK_LOCATION to be set.
|
||||||
"
|
"
|
||||||
MAIN_LOCATION="$HOME/virtual_machine"
|
MAIN_LOCATION="$HOME/virtual_machine"
|
||||||
OPTION="-display gtk \
|
OPTION="-display gtk \
|
||||||
|
@ -89,7 +90,7 @@ start_the_vm() {
|
||||||
-net nic \
|
-net nic \
|
||||||
-net user"$FORWARD",hostname="$VMHOSTNAME" \
|
-net user"$FORWARD",hostname="$VMHOSTNAME" \
|
||||||
-m "$MEMORY" \
|
-m "$MEMORY" \
|
||||||
-drive file="${MAIN_LOCATION}/${LOCATION}/${VMDRIVE}" \
|
-drive file="${MAIN_LOCATION}/${LOCATION}/${VMDRIVE}",index=2,id=maindrive,media=disk \
|
||||||
$OPTION
|
$OPTION
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -132,7 +133,8 @@ CREATE() {
|
||||||
|
|
||||||
OPTION="$OPTION \
|
OPTION="$OPTION \
|
||||||
-boot d \
|
-boot d \
|
||||||
-drive file=$1,media=cdrom"
|
-drive file=$1,if=none,media=cdrom,id=drive-cd1 \
|
||||||
|
-device ide-cd,drive=drive-cd1,id=cd1,bootindex=1"
|
||||||
|
|
||||||
start_the_vm
|
start_the_vm
|
||||||
|
|
||||||
|
@ -208,13 +210,16 @@ cd "$( dirname "$( readlink -f "$0" )" )" || exit
|
||||||
# Véréfie qu'il y ait bien un fichier de config pour la vm que l'on tente de démarer dans la cas contraire en génére un.
|
# Véréfie qu'il y ait bien un fichier de config pour la vm que l'on tente de démarer dans la cas contraire en génére un.
|
||||||
# possibilitée de générer à nouveau le fichier de config avec vm-start nom-vm init
|
# possibilitée de générer à nouveau le fichier de config avec vm-start nom-vm init
|
||||||
|
|
||||||
if [ "$2" == "init" ]
|
if [ ! -f "conf/$1-vm_var.sh" ]
|
||||||
then
|
|
||||||
INIT "$1"
|
|
||||||
elif [ ! -f "conf/$1-vm_var.sh" ]
|
|
||||||
then
|
then
|
||||||
echo "no config file found. creating one in conf/${1}-vm_var.sh"
|
echo "no config file found. creating one in conf/${1}-vm_var.sh"
|
||||||
INIT "$1"
|
INIT "$1"
|
||||||
|
|
||||||
|
if [ "$2" == "init" ]
|
||||||
|
then
|
||||||
|
# Exit, it is the end of the program.
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Vérifie si l'option UEFI est set dans le fichier de config. Si oui l'ajoutte aux options.
|
#Vérifie si l'option UEFI est set dans le fichier de config. Si oui l'ajoutte aux options.
|
||||||
|
@ -232,6 +237,11 @@ for (( i=3; i<=$#; i++)); do
|
||||||
"uefi")
|
"uefi")
|
||||||
set_uefi
|
set_uefi
|
||||||
;;
|
;;
|
||||||
|
"create_disk")
|
||||||
|
INSTALLATION_DISK_LOCATION="${!i#*=}"
|
||||||
|
echo "${!i#*=}"
|
||||||
|
echo "${INSTALLATION_DISK_LOCATION}"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -261,12 +271,11 @@ case "$2" in
|
||||||
;;
|
;;
|
||||||
"create")
|
"create")
|
||||||
echo "creating VM"
|
echo "creating VM"
|
||||||
if [ $# -ge 3 ]
|
if [ ! "${INSTALLATION_DISK_LOCATION}" == "" ]
|
||||||
then
|
then
|
||||||
echo "using image disk $3"
|
echo "using image disk ${INSTALLATION_DISK_LOCATION}"
|
||||||
CREATE "$3"
|
CREATE "${INSTALLATION_DISK_LOCATION}"
|
||||||
else
|
else
|
||||||
echo "$#"
|
|
||||||
echo "Error, no image defined." >&2
|
echo "Error, no image defined." >&2
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -274,7 +283,11 @@ case "$2" in
|
||||||
echo "suppressing all data of the vm $1"
|
echo "suppressing all data of the vm $1"
|
||||||
SUPPRESS "$1"
|
SUPPRESS "$1"
|
||||||
;;
|
;;
|
||||||
"*")
|
"init")
|
||||||
|
echo "Init volume $1"
|
||||||
|
INIT "$1"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
echo "commande $2 inconnue" >&2
|
echo "commande $2 inconnue" >&2
|
||||||
HELP
|
HELP
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in a new issue