Purpose:
- To install a KVM with a physical network interface instead of virtual NIC
Target Audience:
- For whom has experience with KVM, Linux, container and want to know how to install KVM with PF NIC.
Pre-request:
- Hardware requirement: Host + 1 VM with 4 vCPU, 4096MB RAM and 20GB disk for each VM
- Install CentOS 7.x OS and yum update to latest version on the host machine
- Install KVM related packages
Install KVM with PF:
Download the CentOS iso file:
Login as a root and download the iso file as:
# wget http://ftp.twaren.net/Linux/CentOS/7/isos/x86_64/CentOS-7-x86_64-Minimal-2009.iso
Setting up IOMMU: (Here is the example of CentOS7 as host)
- In the grub boot up menu file (/etc/default/grub for CentOs7), please append the following text in GRUB_CMDLINE_LINUX:
In the file /etc/default/grub
GRUB_CMDLINE_LINUX=".......... intel_iommu=on iommu=pt"
# grub2-mkconfig -o /boot/grub2/grub.cfg
# reboot
Find the PF that you want to bind to the KVM:
# lspci | grep Eth
02:00.0 Ethernet controller: Intel Corporation Ethernet Controller XL710 for 40GbE backplane (rev 02)
04:00.0 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
04:00.1 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
04:00.2 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
04:00.3 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
81:00.0 Ethernet controller: Intel Corporation Ethernet Controller XL710 for 40GbE backplane (rev 02)
83:00.0 Ethernet controller: Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection (rev 01)
83:00.1 Ethernet controller: Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection (rev 01)
If we want to use "04:00.3 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)" as the PF:
# virsh nodedev-list | grep 04_00_3
pci_0000_04_00_3
Create a VM with PF:
- Create a script for creating the virtual machine:
# cat create-vm-pf.sh
#!/bin/sh
if [ -z "$1" ] ;
then
echo Specify a virtual-machine name.
exit 1
fi
sudo virt-install \
--name $1 \
--ram 4096 \
--disk path=/home/images/$1.img,size=20 \
--vcpus 4 \
--os-type linux \
--os-variant centos7.0 \
--network network=default --hostdev=pci_0000_04_00_3 \
--graphics none \
--console pty,target_type=serial \
--location='/root/CentOS-7-x86_64-Minimal-2009.iso' \
--extra-args 'console=ttyS0,115200n8 serial'
# chmod +x create-vm-pf.sh
# ./create-vm-pf.sh centos7-pf
Follow the centos7 to finish the installation (Use text mode to install)
Reboot after finish the installation, login and check the PF:
CentOS Linux 7 (Core)
Kernel 3.10.0-862.el7.x86_64 on an x86_64
centos7-pf login: root
Password:
[root@centos7-pf ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 52:54:00:b4:93:af brd ff:ff:ff:ff:ff:ff
3: ens7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 74:fe:48:19:44:26 brd ff:ff:ff:ff:ff:ff
inet 172.17.10.98/23 brd 172.17.11.255 scope global noprefixroute dynamic ens7
valid_lft 172791sec preferred_lft 172791sec
inet6 fe80::50a2:740d:5957:69ad/64 scope link noprefixroute dynamic
valid_lft 2591992sec preferred_lft 604792sec
--- End of installation of KVM with PF ---
Comments
0 comments
Please sign in to leave a comment.