66. Vhost User Live Migration Tests¶
This feature is to make sure vhost user live migration works based on testpmd.
66.1. Prerequisites¶
HW setup
- Connect three ports to one switch, these three ports are from Host, Backup host and tester. Ensure the tester can send packets out, then host/backup server ports can receive these packets.
- Better to have 2 similar machine with the same OS.
NFS configuration
Make sure host nfsd module updated to v4 version(v2 not support file > 4G)
Start nfs service and export nfs to backup host IP:
host# service rpcbind start host# service nfs-server start host# service nfs-mountd start host# systemctrl stop firewalld.service host# vim /etc/exports host# /home/vm-image backup-host-ip(rw,sync,no_root_squash)
Mount host nfs folder on backup host:
backup# mount -t nfs -o nolock,vers=4 host-ip:/home/vm-image /mnt/nfs
On host server side:
Create enough hugepages for vhost-switch and qemu backend memory:
host# echo 4096 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages host# mount -t hugetlbfs hugetlbfs /mnt/huge
Bind host port to igb_uio and start testpmd with vhost port:
#./tools/dpdk-devbind.py -b igb_uio 83:00.1 #./x86_64-native-linuxapp-gcc/app/testpmd -c 0xc0000 -n 4 --vdev 'eth_vhost0,iface=./vhost-net,queues=1' --socket-mem 1024,1024 -- -i testpmd>start
Start VM on host, here we set 5432 as the serial port, 3333 as the qemu monitor port, 5555 as the SSH port:
taskset -c 22-23 qemu-system-x86_64 -name vm1host \ -enable-kvm -m 2048 -object memory-backend-file,id=mem,size=2048M,mem-path=/mnt/huge,share=on \ -numa node,memdev=mem -mem-prealloc -smp 2 -cpu host -drive file=/home/qxu10/img/vm1.img \ -net nic,model=e1000,addr=1f -net user,hostfwd=tcp:127.0.0.1:5555-:22 \ -chardev socket,id=char0,path=./vhost-net \ -netdev type=vhost-user,id=netdev0,chardev=char0,vhostforce \ -device virtio-net-pci,netdev=netdev0,mac=52:54:00:00:00:01 \ -monitor telnet::3333,server,nowait \ -serial telnet:localhost:5432,server,nowait \ -daemonize
On the backup server, run the vhost testpmd on the host and launch VM:
Set huge page, bind one port to igb_uio and run testpmd on the backup server, the command is very similar to host:
backup server# echo 4096 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages backup server# mount -t hugetlbfs hugetlbfs /mnt/huge backup server#./tools/dpdk-devbind.py -b igb_uio 81:00.1 backup server#./x86_64-native-linuxapp-gcc/app/testpmd -c 0xc0000 -n 4 --vdev 'eth_vhost0,iface=./vhost-net,queues=1' --socket-mem 1024,1024 -- -i testpmd>start
Launch VM on the backup server, and the script is similar to host, but note the 2 differences:
need add ” -incoming tcp:0:4444 ” for live migration.
need make sure the VM image is the NFS mounted folder, VM image is the exact one on host server:
Backup server # qemu-system-x86_64 -name vm2 \ -enable-kvm -m 2048 -object memory-backend-file,id=mem,size=2048M,mem-path=/mnt/huge,share=on \ -numa node,memdev=mem -mem-prealloc -smp 4 -cpu host -drive file=/mnt/nfs/vm1.img \ -net nic,model=e1000,addr=1f -net user,hostfwd=tcp:127.0.0.1:5555-:22 \ -chardev socket,id=char0,path=./vhost-net \ -netdev type=vhost-user,id=netdev0,chardev=char0,vhostforce \ -device virtio-net-pci,netdev=netdev0,mac=52:54:00:00:00:01 \ -monitor telnet::3333,server,nowait \ -serial telnet:localhost:5432,server,nowait \ -incoming tcp:0:4444 \ -daemonize
66.1.1. Test Case 1: migrate with virtio-pmd¶
Make sure all Prerequisites has been done
SSH to VM and scp the DPDK folder from host to VM:
host # ssh -p 5555 localhost, then input password to log in. host # scp -P 5555 -r <dpdk_folder>/ localhost:/root, then input password to let the file transfer.
Telnet the serial port and run testpmd in VM:
host # telnet localhost 5432 Input Enter, then log in to VM If need leave the session, input "CTRL" + "]", then quit the telnet session. On the Host server VM, run below commands to launch testpmd host vm # cd /root/dpdk modprobe uio insmod ./x86_64-native-linuxapp-gcc/kmod/igb_uio.ko ./tools/dpdk_nic_bind.py --bind=igb_uio 00:03.0 echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x3 -n 4 -- -i > set fwd rxonly > set verbose 1 > start tx_first
Check host vhost pmd connect with VM’s virtio device:
testpmd> host testpmd message for connection
Send continuous packets with the physical port’s mac(e.g: 90:E2:BA:69:C9:C9) from tester port:
tester# scapy tester# p = Ether(dst="90:E2:BA:69:C9:C9")/IP()/UDP()/Raw('x'*20) tester# sendp(p, iface="p5p1", inter=1, loop=1) Then check the host VM can receive the packet: host VM# testpmd> port 0/queue 0: received 1 packets
Start Live migration, ensure the traffic is continuous at the HOST VM side:
host server # telnet localhost 3333 (qemu)migrate -d tcp:backup server:4444 e.g: migrate -d tcp:10.239.129.176:4444 (qemu)info migrate Check if the migrate is active and not failed.
Check host vm can receive packet before migration done
Query stats of migrate in monitor, check status of migration, when the status is completed, then the migration is done:
host# (qemu)info migrate host# (qemu) Migration status: completed
After live migration, go to the backup server and check if the virtio-pmd can continue to receive packets.:
Backup server # telnet localhost 5432
Log in then see the same screen from the host server, and check if the virtio-pmd can continue receive the packets.
66.1.2. Test Case 2: migrate with virtio-net¶
Make sure all Prerequisites has been done.
Telnet the serial port and run testpmd in VM:
host # telnet localhost 5432 Input Enter, then log in to VM
If need leave the session, input “CTRL” + “]”, then quit the telnet session.
Let the virtio-net link up:
host vm # ifconfig eth1 up
Send continuous packets with the physical port’s mac(e.g: 90:E2:BA:69:C9:C9) from tester port:
tester# scapy tester# p = Ether(dst="90:E2:BA:69:C9:C9")/IP()/UDP()/Raw('x'*20) tester# sendp(p, iface="p5p1", inter=1, loop=1)
Check the host VM can receive the packet:
host VM# tcpdump -i eth1
Start Live migration, ensure the traffic is continuous at the HOST VM side:
host server # telnet localhost 3333 (qemu)migrate -d tcp:backup server:4444 e.g: migrate -d tcp:10.239.129.176:4444 (qemu)info migrate Check if the migrate is active and not failed.
Check host vm can receive packet before migration done.
Query stats of migrate in monitor, check status of migration, when the status is completed, then the migration is done:
host# (qemu)info migrate host# (qemu) Migration status: completed
After live migration, go to the backup server and check if the virtio-pmd can continue to receive packets.:
Backup server # telnet localhost 5432
Log in then see the same screen from the host server, and check if the virtio-net can continue receive the packets.