(OK)(OK) install_android-x86_64_in_QEMU-KVM.txt

[root@localhost ~]#

virt-manager

virsh list --all

virsh start kvm_android-x86_64-6.0-rc1-0

virt-viewer kvm_android-x86_64-6.0-rc1-0 &

virsh reboot kvm_android-x86_64-6.0-rc1-0
virsh shutdown kvm_android-x86_64-6.0-rc1-0
virsh destroy kvm_android-x86_64-6.0-rc1-0

virsh domiflist kvm_android-x86_64-6.0-rc1-0
virsh domif-getlink kvm_android-x86_64-6.0-rc1-0 vnet0

virsh attach-interface --domain kvm_android-x86_64-6.0-rc1-0 --type bridge --source virbr0 --mac 00:16:3e:1b:f7:47 --live

virsh detach-interface --domain kvm_android-x86_64-6.0-rc1-0 --type bridge --mac 00:16:3e:1b:f7:47 --live

virsh edit kvm_android-x86_64-6.0-rc1-0


++++++++++++++++++++++++++++++++++++++++++++++++++++++
OK HOST AND GUEST can ping each other
++++++++++++++++++++++++++++++++++++++++++++++++++++++
HOST
---------
bridge=br0
brctl addbr ${bridge}
ifconfig ${bridge} 192.168.0.1 promisc up

ifconfig ${bridge} down
brctl delbr ${bridge}

---------
GUEST
---------
virt-manager

网络源:指定共享设备名称
网络名称:br0
设备型号:virtio  or  rtl8139  or  e1000

ifconfig eth0 192.168.0.2 up

---------
then, can ping each other
---------

++++++++++++++++++++++++++++++++++++++++++++++++++++++
tunctl -b -u $USER -t tap0
ifconfig tap0 192.168.10.1 promisc up

ifconfig tap0 down
tunctl -d tap0


qemu-system-x86_64 -enable-kvm -m 1024 -smp 1 -hda kvm_android-x86_64-6.0-rc1-0 -net nic,vlan=0 -net tap,vlan=0,ifname=tap0,script=no,downscript=no


++++++++++++++++++++++++++++++++++++++++++++++++++++++

virsh attach-interface --domain kvm_android-x86_64-6.0-rc1-0 --type bridge --source virbr0 --mac 00:16:3e:1b:f7:47 --live


qemu-kvm -soundhw es1370 -net nic -net user,hostfwd=tcp::4444-:5555 --domain kvm_android-x86_64-6.0-rc1-0

++++++++++++++++++++++++++++++++++++++++++++++++++++++

adb kill-server
adb start-server

adb connect 192.168.0.2 && adb -s 192.168.0.2 root


ethtool -k br0
ethtool -K br0 tx off rx off
ethtool -K br0 tx on rx off

tcpdump -i br0 -vv -n

++++++++++++++++++++++++++++++++++++++++++++++++++++++
netcat transfer file to android from fedora23
++++++++++++++++++++++++++++++++++++++++++++++++++++++
iptables -I INPUT -p tcp --dport 12123 -j ACCEPT
iptables -D INPUT -p tcp --dport 12123 -j ACCEPT
nc -l 12123 < chrome51.apk

Client (Android)

nc 10.108.162.164 12123 > chrome51.apk

Client (fedora/linux)

nc -n 10.108.162.164 12123 > chrome51.apk
++++++++++++++++++++++++++++++++++++++++++++++++++++++


--------------------
ip link add link enp13s0 address 3c:97:0e:f0:b5:bb br0 type macvlan mode bridge
ip address add 192.168.1.100/24 dev br0
ip link set dev br0 up

ip route flush dev enp13s0
ip route add default via 192.168.1.1 dev br0 proto static
--------------------

ip link add link enp13s0 name macvtap0 type macvtap
ip link set macvtap0 address 1a:46:0b:ca:bc:7b up
ip link show macvtap0

ifconfig macvtap1 192.168.0.3 up

qemu -net nic,model=virtio,addr=1a:46:0b:ca:bc:7b -net tap,fd=3 3<>/dev/tap11

echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/conf/macvtap0/proxy_arp

--------------------
#!/bin/bash
bridge=br0
tap="tap1"
tunctl -t ${tap}
ip link set $tap up
sleep 1s
brctl addbr ${bridge}
brctl addif $bridge $tap
brctl addif $bridge enp13s0
ifconfig ${bridge} up

qemu-kvm -m 1024 -hda kvm_android-x86_64-6.0-rc1-0 \
-net nic,vlan=0,model=virtio,macaddr=00:16:35:AF:94:4B \
-net tap,vlan=0,ifname=$tap,script=no,downscript=no

brctl delif $bridge $tap
ip link set $tap down
tunctl -d $tap

ifconfig ${bridge} down
brctl delbr ${bridge}
--------------------
tap="tap1"
tunctl -t ${tap}

echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/conf/tap1/proxy_arp

ip link set tap1 up
route add -host 192.168.0.20 dev tap1   <-- to be changed by you.




+++++++++++++++++++++++++++++++++++++++++++++++++++++++
1. 列出虚拟机的所有网口:

virsh domiflist domain

结果如下:
Interface  Type       Source     Model       MAC
-------------------------------------------------------
vnet0      bridge     br0      virtio      52:54:10:e6:c9:02
vnet1      bridge     br1      virtio      52:54:10:f5:c5:6c

2. 新增一个网口

virsh attach-interface domain --type bridge --source br1 --model virtio --config                      // 下次启动生效
virsh attach-interface domain --type bridge --source br1 --model virtio --current                      // 立即生效
virsh detach-interface domain --type bridge --mac 52:54:10:f5:c5:6c --config                       // 下次启动生效
virsh detach-interface domain --type bridge --mac 52:54:10:f5:c5:6c --current                     // 立即生效

3.关闭或打开某个网口:

virsh domif-setlink domain vnet0 down
virsh domif-setlink domain vnet0 up

4.获取某个网口状态

virsh domif-getlink domain vnet1

5. 设置虚拟机自启动

virsh autostart domain

6. 启动,关闭和重启一个虚拟机

virsh start domain_name
virsh shutdown domain_name
virsh reboot domain_name

7.列出所有的块设备

virsh domblklist domain

+++++++++++++++++++++++++++++++++++++++++++++++++++++++
posted @ 2016-07-07 11:18  张同光  阅读(208)  评论(0编辑  收藏  举报