use check vm
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
7a52ee8af2
commit
a49a918a16
1 changed files with 24 additions and 17 deletions
41
lib/qemu.sh
41
lib/qemu.sh
|
|
@ -35,24 +35,31 @@ function qemu_start_vm {
|
||||||
local subnet_id="$(echo "${subnet_name}" | cut -d\- -f2)"
|
local subnet_id="$(echo "${subnet_name}" | cut -d\- -f2)"
|
||||||
local mac="$(find_mac "${vpc_name}_br-${subnet_id}" "${ip}")"
|
local mac="$(find_mac "${vpc_name}_br-${subnet_id}" "${ip}")"
|
||||||
|
|
||||||
print_in_color "${COLOR_GREEN}" "Create tap tap${tap_id}"
|
check_qemu_exist "${vm_name}"
|
||||||
add_in_db "vm" "${vm_name}" "${subnet_name}" "${tap_id}"
|
[ "$?" -eq "0" ] && \
|
||||||
create_tap "${tap_id}" "br-${subnet_id}" "${vpc_name}"
|
{
|
||||||
|
print_in_color "${COLOR_ORANGE}" "Would have create ${vm_name}"
|
||||||
|
} || \
|
||||||
|
{
|
||||||
|
print_in_color "${COLOR_GREEN}" "Create tap tap${tap_id}"
|
||||||
|
add_in_db "vm" "${vm_name}" "${subnet_name}" "${tap_id}"
|
||||||
|
create_tap "${tap_id}" "br-${subnet_id}" "${vpc_name}"
|
||||||
|
|
||||||
print_in_color "${COLOR_GREEN}" "Start vm ${vm_name}"
|
print_in_color "${COLOR_GREEN}" "Start vm ${vm_name}"
|
||||||
ip netns exec "${vpc_name}" qemu-system-x86_64 \
|
ip netns exec "${vpc_name}" qemu-system-x86_64 \
|
||||||
-enable-kvm \
|
-enable-kvm \
|
||||||
-cpu host \
|
-cpu host \
|
||||||
-m 512 \
|
-m 512 \
|
||||||
-smp 1 \
|
-smp 1 \
|
||||||
-serial "unix:/tmp/${vm_name}.sock,server,nowait" \
|
-serial "unix:/tmp/${vm_name}.sock,server,nowait" \
|
||||||
-monitor "unix:/tmp/${vm_name}.mon-sock,server,nowait" \
|
-monitor "unix:/tmp/${vm_name}.mon-sock,server,nowait" \
|
||||||
-qmp "unix:/tmp/${vm_name}.qmp-sock,server,nowait" \
|
-qmp "unix:/tmp/${vm_name}.qmp-sock,server,nowait" \
|
||||||
-display "none" \
|
-display "none" \
|
||||||
-drive "file=${volume_path},if=virtio" \
|
-drive "file=${volume_path},if=virtio" \
|
||||||
-netdev "tap,id=net0,ifname=tap${tap_id},script=no,downscript=no" \
|
-netdev "tap,id=net0,ifname=tap${tap_id},script=no,downscript=no" \
|
||||||
-device "virtio-net-pci,netdev=net0,mac=${mac}" \
|
-device "virtio-net-pci,netdev=net0,mac=${mac}" \
|
||||||
-daemonize
|
-daemonize
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function qemu_stop_vm {
|
function qemu_stop_vm {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue