From 91e7f10dddef67a2e8d7e8d2e52564d544cfe8d5 Mon Sep 17 00:00:00 2001 From: Nicolas MORIN Date: Fri, 5 Jan 2024 15:50:54 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20du=20code=20g=C3=A9rant=20l'option=20di?= =?UTF-8?q?sque?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qemu-adm | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/qemu-adm b/qemu-adm index 60bee3e..ebfa5d7 100755 --- a/qemu-adm +++ b/qemu-adm @@ -39,6 +39,17 @@ nouvMV() ;; esac ;; + "disque") + echo "${2}" + if [[ ! -z ${2} ]]; then + if [[ ! -f ${bin_qemu_img} ]]; then + die "Le paquet qemu-utils n'est pas installé." 6 + fi + echo "Création du disque..." # Debogage + qemu-img create -f ${2} ${1} ${3} + fi + echo "-drive file=${1},if=virtio \\" >> ${chemin_mv} + ;; esac } @@ -154,6 +165,33 @@ creeMV() presenceParametre "$#" "$1" echo "disque parametre=${parametre}" # Debogage shift + + # |(|):(raw|qcow2):) + + disque_nom=$( echo ${1} | awk -F: '{print $1}' ) + echo "disque_nom=${disque_nom}" # Debogage + if [[ -z "${disque_nom}" ]]; then + die "Le disque n'est pas renseigné.\nSyntaxe attendue : |(|):(raw|qcow2):)." 5 + fi + if [[ "$(dirname ${1})" == "." ]];then + disque_nom="${base_chemin_mv}/${nom_mv}/${disque_nom}" + fi + + + disque_format=$( echo ${1} | awk -F: '{print $2}' ) + echo "disque_format=${disque_format}" # Debogage + if [[ -z "${disque_format}" && "$(dirname ${1})" == "." ]]; then + die "Le format du disque n'est pas renseigné.\nSyntaxe attendue : |(|):(raw|qcow2):)." 5 + fi + + disque_capacite=$( echo ${1} | awk -F: '{print $3}' ) + echo "disque_capacite=${disque_capacite}" # Debogage + if [[ -z "${disque_capacite}" && "$(dirname ${1})" == "." ]]; then + die "La capacité du disque n'est pas renseigné.\nSyntaxe attendue : |(|):(raw|qcow2):)." 5 + fi + + + commandes_a_executer+=( "nouvMV disque ${disque_nom} ${disque_format} ${disque_capacite}") ;; "-i") # Iso echo "iso" # Debogage @@ -218,6 +256,8 @@ usage() case ${1} in cree) echo "usage_cree" # Debogage + # qemu-img: Invalid image size specified. You may use k, M, G, T, P or E suffixes for + # qemu-img: kilobytes, megabytes, gigabytes, terabytes, petabytes and exabytes. die "" 0 ;; demarre)