add cdrom option
This commit is contained in:
parent
bd5eb053a6
commit
654e156170
1 changed files with 45 additions and 3 deletions
48
vm-start.sh
48
vm-start.sh
|
@ -18,6 +18,7 @@ PARAMETTER available
|
||||||
|
|
||||||
COMMAND available
|
COMMAND available
|
||||||
init Create the conf file in conf/NAME_var.sh
|
init Create the conf file in conf/NAME_var.sh
|
||||||
|
init_cdrom init a RO image/cdrom. The network will have to be set later in the conf file. NO EUFI
|
||||||
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
|
||||||
|
@ -105,6 +106,24 @@ EOF
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INIT_cdrom() {
|
||||||
|
echo "Init for a cdrom."
|
||||||
|
echo "Init was already called."
|
||||||
|
|
||||||
|
# necessite au moins l'addresse de l'image en tant que $1
|
||||||
|
|
||||||
|
VMROM="$(basename $1)"
|
||||||
|
|
||||||
|
if [ ! -f "${MAIN_LOCATION}/${LOCATION}/${VMROM}" ]
|
||||||
|
then
|
||||||
|
echo "create directory ${MAIN_LOCATION}/${LOCATION}/"
|
||||||
|
mkdir -p "${MAIN_LOCATION}/${LOCATION}/"
|
||||||
|
cp $1 "${MAIN_LOCATION}/${LOCATION}/${VMROM}"
|
||||||
|
fi
|
||||||
|
echo "CDROM_DISK=\"${VMROM}\"" >> "conf/$NAME-vm_var.sh"
|
||||||
|
echo "Done"
|
||||||
|
}
|
||||||
|
|
||||||
start_the_vm() {
|
start_the_vm() {
|
||||||
|
|
||||||
if [ "${network}" == "" ]
|
if [ "${network}" == "" ]
|
||||||
|
@ -113,13 +132,20 @@ start_the_vm() {
|
||||||
-net user${FORWARD},hostname=${VMHOSTNAME}"
|
-net user${FORWARD},hostname=${VMHOSTNAME}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "${CDROM_DISK}" != "" ]
|
||||||
|
then
|
||||||
|
DRIVE="-drive file=${MAIN_LOCATION}/${LOCATION}/${CDROM_DISK},index=2,id=maindrive,media=cdrom"
|
||||||
|
else
|
||||||
|
DRIVE="-drive file=${MAIN_LOCATION}/${LOCATION}/${VMDRIVE},index=2,id=maindrive,media=disk"
|
||||||
|
fi
|
||||||
|
|
||||||
qemu-system-x86_64 \
|
qemu-system-x86_64 \
|
||||||
-enable-kvm \
|
-enable-kvm \
|
||||||
-cpu host \
|
-cpu host \
|
||||||
-smp "$NPROC" \
|
-smp "$NPROC" \
|
||||||
$network \
|
$network \
|
||||||
-m "$MEMORY" \
|
-m "$MEMORY" \
|
||||||
-drive file="${MAIN_LOCATION}/${LOCATION}/${VMDRIVE}",index=2,id=maindrive,media=disk \
|
$DRIVE \
|
||||||
$OPTION
|
$OPTION
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -228,9 +254,13 @@ set_net() {
|
||||||
echo "error, no mac set"
|
echo "error, no mac set"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
if [ "${driver}" == "" ]
|
||||||
|
then
|
||||||
|
driver="virtio-net"
|
||||||
|
fi
|
||||||
network="${network} \
|
network="${network} \
|
||||||
-netdev bridge,id=${1#*:},br=${1#*:} \
|
-netdev bridge,id=${1#*:},br=${1#*:} \
|
||||||
-device virtio-net,netdev=${1#*:},mac=${mac}"
|
-device ${driver},netdev=${1#*:},mac=${mac}"
|
||||||
;;
|
;;
|
||||||
"none")
|
"none")
|
||||||
echo "no interface will be connected."
|
echo "no interface will be connected."
|
||||||
|
@ -370,7 +400,19 @@ case "$2" in
|
||||||
;;
|
;;
|
||||||
"init")
|
"init")
|
||||||
echo "Init volume $1"
|
echo "Init volume $1"
|
||||||
INIT "$1"
|
#INIT "$1"
|
||||||
|
echo "Error, Normally, already called before."
|
||||||
|
;;
|
||||||
|
"init_cdrom")
|
||||||
|
echo "Init cdrom $1"
|
||||||
|
if [ ! "${INSTALLATION_DISK_LOCATION}" == "" ]
|
||||||
|
then
|
||||||
|
echo "using image disk ${INSTALLATION_DISK_LOCATION}"
|
||||||
|
INIT_cdrom "${INSTALLATION_DISK_LOCATION}"
|
||||||
|
else
|
||||||
|
echo "Error, no image defined." >&2
|
||||||
|
echo "use --create_disk=<loc_disk>" >&2
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "commande $2 inconnue" >&2
|
echo "commande $2 inconnue" >&2
|
||||||
|
|
Loading…
Reference in a new issue