kvm創建虛擬機,以網橋方式連接網絡
ifconfig eth0 down # 先關閉eth0接口
brctl addbr br0 # 增加一個虛擬網橋br0
brctl addif br0 eth0 # 在br0中添加一個接口eth0
brctl stp br0 off # 只有一個網橋,所以關閉生成樹協議
brctl setfd br0 1 # 設置br0的轉發延遲
brctl sethello br0 1 # 設置br0的hello時間
ifconfig br0 0.0.0.0 promisc up # 打開br0接口
ifconfig eth0 0.0.0.0 promisc up # 打開eth0接口
dhclient br0 # 從dhcp服務器獲得br0的IP地址
brctl show br0 # 查看虛擬網橋列表
brctl showstp br0 # 查看br0的各接口信息
在沒有dhcp服務器的網絡中也可以用ifconfig命令爲br0接口配置一個靜態IP地址:
ifconfig br0 192.168.0.22 netmask 255.255.255.0
route add -net 0.0.0.0 netmask 0.0.0.0 gw 192.168.0.254
配置TAP設備的操作:
tunctl -t tap0 -u root # 創建一個tap0接口,只允許root用戶訪問
brctl addif br0 tap0 # 在虛擬網橋中增加一個tap0接口
ifconfig tap0 0.0.0.0 promisc up # 打開tap0接口
brctl showstp br0 # 顯示br0的各個接口
qemu -kernel arch/x86/boot/bzImage -net nic -net tap,ifname=tap0,script=no,downscript=no
taskset 將任務綁定到具體CPU上執行
kernel啓動參數 isolcpus=2,3 使調度器不將任務調度到2,3CPU上執行。