fix qemu run in subnet
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
7c4e3a8e47
commit
ce8bc452da
1 changed files with 8 additions and 7 deletions
15
lib/qemu.sh
15
lib/qemu.sh
|
|
@ -4,12 +4,13 @@
|
|||
. ./lib/colors.sh
|
||||
|
||||
function create_tap {
|
||||
tap_id="${1}"
|
||||
bridge_name="${2}"
|
||||
local tap_id="${1}"
|
||||
local bridge_name="${2}"
|
||||
local vpc_name="${3}"
|
||||
|
||||
ip tuntap add dev "tap${tap_id}" mode tap
|
||||
brctl addif "${bridge_name}" "tap${tap_id}"
|
||||
ip link set up dev "tap${tap_id}"
|
||||
ip -n "${vpc_name}" tuntap add dev "tap${tap_id}" mode tap
|
||||
ip netns exec "${vpc_name}" brctl addif "${bridge_name}" "tap${tap_id}"
|
||||
ip -n "${vpc_name}" link set up dev "tap${tap_id}"
|
||||
}
|
||||
|
||||
function qemu_start_vm {
|
||||
|
|
@ -23,10 +24,10 @@ function qemu_start_vm {
|
|||
local mac="$(find_mac "${vpc_name}_br-${subnet_id}" "${ip}")"
|
||||
|
||||
print_in_color "${COLOR_GREEN}" "Create tap tap${tap_id}"
|
||||
create_tap "${tap_id}" "br-${subnet_id}"
|
||||
create_tap "${tap_id}" "br-${subnet_id}" "${vpc_name}"
|
||||
|
||||
print_in_color "${COLOR_GREEN}" "Start vm ${vm_name}"
|
||||
qemu-system-x86_64 \
|
||||
ip netns exec "${vpc_name}" qemu-system-x86_64 \
|
||||
-enable-kvm \
|
||||
-cpu host \
|
||||
-m 512 \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue