Target model:
- Guest VM with virtio NIC(eth0) and sr-iov VF NIC(eth1).
1. Create VF NIC in Host
1.1 Detect current SR-IOV network card information for VF creation.
- lspci show PCI device information such as PCI Bus:Device:Function.
- Following example shows that p4p1 is located at 04:00.0 (Bus:Device:Function).
1.2 Create VF using sysfs.
- recently, creating VF is done by sysfs
2. Create Bridge Interface
Usually if you install libvirt package, virbr0 is already created.
make sure, p4p1 and p4p1_0 has no IP addresses.
3. Create VM with libvirt
- make sure, you have correct root disk image.
sriov.xml
virsh create sriov.xml
<domain type="kvm">
<name>sriov-vm</name>
<memory>2097152</memory>
<vcpu>4</vcpu>
<sysinfo type="smbios">
<system>
<entry name="manufacturer">Sunshout</entry>
<entry name="product">KVM</entry>
<entry name="version">2013.4</entry>
</system>
</sysinfo>
<os>
<type>hvm</type>
<boot dev="hd"/>
<smbios mode="sysinfo"/>
</os>
<features>
<acpi/>
<apic/>
</features>
<clock offset="utc">
<timer name="pit" tickpolicy="delay"/>
<timer name="rtc" tickpolicy="catchup"/>
</clock>
<cpu mode="host-model" match="exact"/>
<devices>
<disk type="file" device="disk">
<driver name="qemu" type="qcow2" cache="none"/>
<source file="/storage/sriov.img"/>
<target bus="virtio" dev="vda"/>
</disk>
<interface type='bridge'>
<mac address='52:54:00:23:04:52'/>
<model type="virtio"/>
<source bridge="virbr0"/>
</interface>
<interface type='hostdev' managed='yes'>
<source>
<address type='pci' domain='0x0' bus='0x04' slot='0x10' function='0x0' />
</source>
</interface>
<serial type="pty"/>
<input type="tablet" bus="usb"/>
<graphics type="vnc" autoport="yes" keymap="en-us" listen="127.0.0.1"/>
</devices>
</domain>
CLI 를 사용할 경우
$ echo "8086 10ed" > /sys/bus/pci/drivers/pci-stub/new_id
$ echo 0000:04:10.0 > /sys/bus/pci/devices/0000\:04\:10.0/driver/unbind
$ echo 0000:04:10.0 > /sys/bus/pci/drivers/pci-stub/bind
$ /usr/local/bin/qemu-system-x86_64 -m 1024 -smp 1 --enable-kvm /storage/sriov.img -device pci-assign,host=04:10.0