<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://linux-kvm.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Robert</id>
	<title>KVM - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://linux-kvm.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Robert"/>
	<link rel="alternate" type="text/html" href="https://linux-kvm.org/page/Special:Contributions/Robert"/>
	<updated>2026-06-09T04:33:30Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.5</generator>
	<entry>
		<id>https://linux-kvm.org/index.php?title=VFIO_vs_virtio&amp;diff=173244</id>
		<title>VFIO vs virtio</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=VFIO_vs_virtio&amp;diff=173244"/>
		<updated>2015-05-12T02:54:39Z</updated>

		<summary type="html">&lt;p&gt;Robert: Robert moved page VFIO vs virtio to 10G NIC performance: VFIO vs virtio: More accurate name&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[10G NIC performance: VFIO vs virtio]]&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173243</id>
		<title>10G NIC performance: VFIO vs virtio</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173243"/>
		<updated>2015-05-12T02:54:39Z</updated>

		<summary type="html">&lt;p&gt;Robert: Robert moved page VFIO vs virtio to 10G NIC performance: VFIO vs virtio: More accurate name&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We did some experiment trying to measure network performance overhead in virtualization environment, comparing between VFIO passthrough and virtio approaches.&lt;br /&gt;
&lt;br /&gt;
== Test Topology ==&lt;br /&gt;
&lt;br /&gt;
2 Intel Grantley-EP platforms (Xeon E5-2697 v3) connected by 10G link; memory 96 G.&amp;lt;br /&amp;gt;&lt;br /&gt;
NIC: Intel 82599ES [http://ark.intel.com/products/41282/Intel-82599ES-10-Gigabit-Ethernet-Controller]&amp;lt;br /&amp;gt;&lt;br /&gt;
Test Tool: iperf &amp;lt;br /&amp;gt;&lt;br /&gt;
OS: RHEL 7.1 &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Result summary ==&lt;br /&gt;
*In native environment, iperf can get &#039;&#039;&#039;9.4&#039;&#039;&#039; Gbps throughput. Since iperf is a SW packet generator and normal process shall it be, this a reasonable number.&lt;br /&gt;
*With VFIO passthrough, network performance is also &#039;&#039;&#039;9.4&#039;&#039;&#039; Gbps; i.e., we cannot observe overhead in virtualization environment with VFIO passthrough method, in context of typical SW network user application.&lt;br /&gt;
*With virtio approach, if proper configured (details see below), network performance can also achieve &#039;&#039;&#039;9.4&#039;&#039;&#039; Gbps; otherwise, poor performance will be &#039;&#039;&#039;3.6&#039;&#039;&#039; Gbps.&lt;br /&gt;
&lt;br /&gt;
=== Some references first ===&lt;br /&gt;
SR-IOV[http://www.intel.com/content/www/us/en/network-adapters/virtualization.html]&amp;lt;br /&amp;gt;&lt;br /&gt;
vt-d assignment[[How_to_assign_devices_with_VT-d_in_KVM]]&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Here is the details about each kind of configuration.&lt;br /&gt;
&lt;br /&gt;
== VFIO passthrough VF (SR-IOV) to guest ==&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
#You NIC supports SR-IOV (how to check? see below)&lt;br /&gt;
#driver (usually igb or ixgb) loaded with &#039;max_vfs=&amp;lt;num&amp;gt;&#039; (better to modinfo to check accurate parameter name)&lt;br /&gt;
#kernel modules needed: NIC driver, vfio-pci module, intel-iommu module&lt;br /&gt;
&lt;br /&gt;
=== Check if your NIC supports SR-IOV ===&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;nowiki&amp;gt;lspci -s &amp;lt;NIC_BDF&amp;gt; -vvv | grep -i &amp;quot;Single Root I/O Virtualization&amp;quot;&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Assign the VF to a guest ===&lt;br /&gt;
Unbind from igbvf driver and Bind to VFIO driver&lt;br /&gt;
#unbind from previous driver (take igbvf device for example)&lt;br /&gt;
#;echo &amp;lt;vf_BDF&amp;gt; &amp;gt; /sys/bus/pci/device/&amp;lt;vf_BDF&amp;gt;/driver/unbind&lt;br /&gt;
#;lspci -s  &amp;lt;vf_BDF&amp;gt; -n      //to get its number&lt;br /&gt;
#://it will return like below&lt;br /&gt;
#;&amp;lt;nowiki&amp;gt;0a:13.3 0200: 8086:1520 (rev 01)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
#://8086 1520 is its numeric number&lt;br /&gt;
#bind to vfio-pci driver&lt;br /&gt;
#;echo 8086 1520 &amp;gt; /sys/bus/pci/drivers/vfio-pci/new_id&lt;br /&gt;
	&lt;br /&gt;
Now you can see this device is bound to vfio-pci driver&amp;lt;br /&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;lspci -s &amp;lt;vf_BDF&amp;gt; -k&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create guest with direct passthrough via VFIO framework&amp;lt;br /&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;nowiki&amp;gt;qemu-kvm -m 16G -smp 8 -net none -device vfio-pci,host=81:10.0 -drive file=/var/lib/libvirt/images/rhel7.1.img,if=virtio -nographic&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br /&amp;gt;&#039;-net none&#039; tells qemu not emulate network devices&lt;br /&gt;
&amp;lt;br /&amp;gt;&#039;-device vfio-pci,host=&#039; designate a vfio-pci device and the device&#039;s host BDF&lt;br /&gt;
&lt;br /&gt;
== Virtio ==&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
virtio compiled in kernel (RHEL7.1 native kernel already have them)&lt;br /&gt;
	CONFIG_VIRTIO=m&lt;br /&gt;
	CONFIG_VIRTIO_RING=m&lt;br /&gt;
	CONFIG_VIRTIO_PCI=m&lt;br /&gt;
	CONFIG_VIRTIO_BALLOON=m&lt;br /&gt;
	CONFIG_VIRTIO_BLK=m&lt;br /&gt;
	CONFIG_VIRTIO_NET=m&lt;br /&gt;
&lt;br /&gt;
Create guest with direct passthrough via VFIO framework&amp;lt;br /&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;nowiki&amp;gt;qemu-kvm -m 16G -smp 8 -device virtio-net-pci,netdev=net0 -netdev tap,id=net0,script=/etc/qemu-ifup -drive file=/var/lib/libvirt/images/rhel7.1.img,if=virtio –nographic&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Poor performance configuration ====&lt;br /&gt;
&amp;lt;br /&amp;gt;&#039;&#039;&#039;&amp;lt;nowiki&amp;gt;qemu-kvm -m 16G -smp 8 -net nic,model=virtio -net tap,script=/etc/qemu-ifup -drive file=/var/lib/libvirt/images/rhel7.1.img,if=virtio –nographic&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br /&amp;gt;If not use &amp;lt;nowiki&amp;gt;&#039;-device virtio-net-pci&#039;&amp;lt;/nowiki&amp;gt; option, performance will be 3.6 Gbps.&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173242</id>
		<title>10G NIC performance: VFIO vs virtio</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173242"/>
		<updated>2015-05-12T02:53:15Z</updated>

		<summary type="html">&lt;p&gt;Robert: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We did some experiment trying to measure network performance overhead in virtualization environment, comparing between VFIO passthrough and virtio approaches.&lt;br /&gt;
&lt;br /&gt;
== Test Topology ==&lt;br /&gt;
&lt;br /&gt;
2 Intel Grantley-EP platforms (Xeon E5-2697 v3) connected by 10G link; memory 96 G.&amp;lt;br /&amp;gt;&lt;br /&gt;
NIC: Intel 82599ES [http://ark.intel.com/products/41282/Intel-82599ES-10-Gigabit-Ethernet-Controller]&amp;lt;br /&amp;gt;&lt;br /&gt;
Test Tool: iperf &amp;lt;br /&amp;gt;&lt;br /&gt;
OS: RHEL 7.1 &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Result summary ==&lt;br /&gt;
*In native environment, iperf can get &#039;&#039;&#039;9.4&#039;&#039;&#039; Gbps throughput. Since iperf is a SW packet generator and normal process shall it be, this a reasonable number.&lt;br /&gt;
*With VFIO passthrough, network performance is also &#039;&#039;&#039;9.4&#039;&#039;&#039; Gbps; i.e., we cannot observe overhead in virtualization environment with VFIO passthrough method, in context of typical SW network user application.&lt;br /&gt;
*With virtio approach, if proper configured (details see below), network performance can also achieve &#039;&#039;&#039;9.4&#039;&#039;&#039; Gbps; otherwise, poor performance will be &#039;&#039;&#039;3.6&#039;&#039;&#039; Gbps.&lt;br /&gt;
&lt;br /&gt;
=== Some references first ===&lt;br /&gt;
SR-IOV[http://www.intel.com/content/www/us/en/network-adapters/virtualization.html]&amp;lt;br /&amp;gt;&lt;br /&gt;
vt-d assignment[[How_to_assign_devices_with_VT-d_in_KVM]]&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Here is the details about each kind of configuration.&lt;br /&gt;
&lt;br /&gt;
== VFIO passthrough VF (SR-IOV) to guest ==&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
#You NIC supports SR-IOV (how to check? see below)&lt;br /&gt;
#driver (usually igb or ixgb) loaded with &#039;max_vfs=&amp;lt;num&amp;gt;&#039; (better to modinfo to check accurate parameter name)&lt;br /&gt;
#kernel modules needed: NIC driver, vfio-pci module, intel-iommu module&lt;br /&gt;
&lt;br /&gt;
=== Check if your NIC supports SR-IOV ===&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;nowiki&amp;gt;lspci -s &amp;lt;NIC_BDF&amp;gt; -vvv | grep -i &amp;quot;Single Root I/O Virtualization&amp;quot;&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Assign the VF to a guest ===&lt;br /&gt;
Unbind from igbvf driver and Bind to VFIO driver&lt;br /&gt;
#unbind from previous driver (take igbvf device for example)&lt;br /&gt;
#;echo &amp;lt;vf_BDF&amp;gt; &amp;gt; /sys/bus/pci/device/&amp;lt;vf_BDF&amp;gt;/driver/unbind&lt;br /&gt;
#;lspci -s  &amp;lt;vf_BDF&amp;gt; -n      //to get its number&lt;br /&gt;
#://it will return like below&lt;br /&gt;
#;&amp;lt;nowiki&amp;gt;0a:13.3 0200: 8086:1520 (rev 01)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
#://8086 1520 is its numeric number&lt;br /&gt;
#bind to vfio-pci driver&lt;br /&gt;
#;echo 8086 1520 &amp;gt; /sys/bus/pci/drivers/vfio-pci/new_id&lt;br /&gt;
	&lt;br /&gt;
Now you can see this device is bound to vfio-pci driver&amp;lt;br /&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;lspci -s &amp;lt;vf_BDF&amp;gt; -k&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create guest with direct passthrough via VFIO framework&amp;lt;br /&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;nowiki&amp;gt;qemu-kvm -m 16G -smp 8 -net none -device vfio-pci,host=81:10.0 -drive file=/var/lib/libvirt/images/rhel7.1.img,if=virtio -nographic&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br /&amp;gt;&#039;-net none&#039; tells qemu not emulate network devices&lt;br /&gt;
&amp;lt;br /&amp;gt;&#039;-device vfio-pci,host=&#039; designate a vfio-pci device and the device&#039;s host BDF&lt;br /&gt;
&lt;br /&gt;
== Virtio ==&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
virtio compiled in kernel (RHEL7.1 native kernel already have them)&lt;br /&gt;
	CONFIG_VIRTIO=m&lt;br /&gt;
	CONFIG_VIRTIO_RING=m&lt;br /&gt;
	CONFIG_VIRTIO_PCI=m&lt;br /&gt;
	CONFIG_VIRTIO_BALLOON=m&lt;br /&gt;
	CONFIG_VIRTIO_BLK=m&lt;br /&gt;
	CONFIG_VIRTIO_NET=m&lt;br /&gt;
&lt;br /&gt;
Create guest with direct passthrough via VFIO framework&amp;lt;br /&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;nowiki&amp;gt;qemu-kvm -m 16G -smp 8 -device virtio-net-pci,netdev=net0 -netdev tap,id=net0,script=/etc/qemu-ifup -drive file=/var/lib/libvirt/images/rhel7.1.img,if=virtio –nographic&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Poor performance configuration ====&lt;br /&gt;
&amp;lt;br /&amp;gt;&#039;&#039;&#039;&amp;lt;nowiki&amp;gt;qemu-kvm -m 16G -smp 8 -net nic,model=virtio -net tap,script=/etc/qemu-ifup -drive file=/var/lib/libvirt/images/rhel7.1.img,if=virtio –nographic&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br /&amp;gt;If not use &amp;lt;nowiki&amp;gt;&#039;-device virtio-net-pci&#039;&amp;lt;/nowiki&amp;gt; option, performance will be 3.6 Gbps.&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=User_talk:Robert&amp;diff=173241</id>
		<title>User talk:Robert</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=User_talk:Robert&amp;diff=173241"/>
		<updated>2015-05-12T02:49:30Z</updated>

		<summary type="html">&lt;p&gt;Robert: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hello {{PAGENAME}},&lt;br /&gt;
Thank you for your recent additions. However, note that due to incessant spam, we had to disable posting of http links by default and hence, any edits that had http links have automatically been rejected :( I have added the necessary permissions to your account so that you can post http henceforth. Please get in touch if you have any questions.&lt;br /&gt;
Thanks&lt;br /&gt;
[[User:Bsd|bsd]] ([[User talk:Bsd|talk]]) 16:56, 11 May 2015 (UTC)&lt;br /&gt;
: Thanks. I was wondering why my contents cannot be saved sometimes. I see now. --[[User:Robert|Robert]] ([[User talk:Robert|talk]]) 02:49, 12 May 2015 (UTC)&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173208</id>
		<title>10G NIC performance: VFIO vs virtio</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173208"/>
		<updated>2015-05-11T11:00:16Z</updated>

		<summary type="html">&lt;p&gt;Robert: finalize&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We did some experiment trying to measure network performance overhead in virtualization environment, comparing between VFIO passthrough and virtio approaches.&lt;br /&gt;
&lt;br /&gt;
== Test Topology ==&lt;br /&gt;
&lt;br /&gt;
2 Intel Grantley-EP platforms (Xeon E5-2697 v3) connected by 10G link; memory 96 G.&amp;lt;br /&amp;gt;&lt;br /&gt;
NIC: Intel 82599ES&amp;lt;br /&amp;gt;&lt;br /&gt;
Test Tool: iperf &amp;lt;br /&amp;gt;&lt;br /&gt;
OS: RHEL 7.1 &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Result summary ==&lt;br /&gt;
*In native environment, iperf can get &#039;&#039;&#039;9.4&#039;&#039;&#039; Gbps throughput. Since iperf is a SW packet generator and normal process shall it be, this a reasonable number.&lt;br /&gt;
*With VFIO passthrough, network performance is also &#039;&#039;&#039;9.4&#039;&#039;&#039; Gbps; i.e., we cannot observe overhead in virtualization environment with VFIO passthrough method, in context of typical SW network user application.&lt;br /&gt;
*With virtio approach, if proper configured (details see below), network performance can also achieve &#039;&#039;&#039;9.4&#039;&#039;&#039; Gbps; otherwise, poor performance will be &#039;&#039;&#039;3.6&#039;&#039;&#039; Gbps.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Here is the details about each kind of configuration.&lt;br /&gt;
&lt;br /&gt;
== VFIO passthrough VF (SR-IOV) to guest ==&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
#You NIC supports SR-IOV (how to check? see below)&lt;br /&gt;
#driver (usually igb or ixgb) loaded with &#039;max_vfs=&amp;lt;num&amp;gt;&#039; (better to modinfo to check accurate parameter name)&lt;br /&gt;
#kernel modules needed: NIC driver, vfio-pci module, intel-iommu module&lt;br /&gt;
&lt;br /&gt;
=== Check if your NIC supports SR-IOV ===&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;nowiki&amp;gt;lspci -s &amp;lt;NIC_BDF&amp;gt; -vvv | grep -i &amp;quot;Single Root I/O Virtualization&amp;quot;&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Assign the VF to a guest ===&lt;br /&gt;
Unbind from igbvf driver and Bind to VFIO driver&lt;br /&gt;
#unbind from previous driver (take igbvf device for example)&lt;br /&gt;
#;echo &amp;lt;vf_BDF&amp;gt; &amp;gt; /sys/bus/pci/device/&amp;lt;vf_BDF&amp;gt;/driver/unbind&lt;br /&gt;
#;lspci -s  &amp;lt;vf_BDF&amp;gt; -n      //to get its number&lt;br /&gt;
#://it will return like below&lt;br /&gt;
#;&amp;lt;nowiki&amp;gt;0a:13.3 0200: 8086:1520 (rev 01)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
#://8086 1520 is its numeric number&lt;br /&gt;
#bind to vfio-pci driver&lt;br /&gt;
#;echo 8086 1520 &amp;gt; /sys/bus/pci/drivers/vfio-pci/new_id&lt;br /&gt;
	&lt;br /&gt;
Now you can see this device is bound to vfio-pci driver&amp;lt;br /&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;lspci -s &amp;lt;vf_BDF&amp;gt; -k&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create guest with direct passthrough via VFIO framework&amp;lt;br /&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;nowiki&amp;gt;qemu-kvm -m 16G -smp 8 -net none -device vfio-pci,host=81:10.0 -drive file=/var/lib/libvirt/images/rhel7.1.img,if=virtio -nographic&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br /&amp;gt;&#039;-net none&#039; tells qemu not emulate network devices&lt;br /&gt;
&amp;lt;br /&amp;gt;&#039;-device vfio-pci,host=&#039; designate a vfio-pci device and the device&#039;s host BDF&lt;br /&gt;
&lt;br /&gt;
== Virtio ==&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
virtio compiled in kernel (RHEL7.1 native kernel already have them)&lt;br /&gt;
	CONFIG_VIRTIO=m&lt;br /&gt;
	CONFIG_VIRTIO_RING=m&lt;br /&gt;
	CONFIG_VIRTIO_PCI=m&lt;br /&gt;
	CONFIG_VIRTIO_BALLOON=m&lt;br /&gt;
	CONFIG_VIRTIO_BLK=m&lt;br /&gt;
	CONFIG_VIRTIO_NET=m&lt;br /&gt;
&lt;br /&gt;
Create guest with direct passthrough via VFIO framework&amp;lt;br /&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;nowiki&amp;gt;qemu-kvm -m 16G -smp 8 -device virtio-net-pci,netdev=net0 -netdev tap,id=net0,script=/etc/qemu-ifup -drive file=/var/lib/libvirt/images/rhel7.1.img,if=virtio –nographic&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Poor performance configuration ====&lt;br /&gt;
&amp;lt;br /&amp;gt;&#039;&#039;&#039;&amp;lt;nowiki&amp;gt;qemu-kvm -m 16G -smp 8 -net nic,model=virtio -net tap,script=/etc/qemu-ifup -drive file=/var/lib/libvirt/images/rhel7.1.img,if=virtio –nographic&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br /&amp;gt;If not use &amp;lt;nowiki&amp;gt;&#039;-device virtio-net-pci&#039;&amp;lt;/nowiki&amp;gt; option, performance will be 3.6 Gbps.&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173207</id>
		<title>10G NIC performance: VFIO vs virtio</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173207"/>
		<updated>2015-05-11T10:56:03Z</updated>

		<summary type="html">&lt;p&gt;Robert: More fine tune&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We did some experiment trying to measure network performance overhead in virtualization environment, comparing between VFIO passthrough and virtio approaches.&lt;br /&gt;
&lt;br /&gt;
== Test Topology ==&lt;br /&gt;
&lt;br /&gt;
2 Intel Grantley-EP platforms (Xeon E5-2697 v3) connected by 10G link; memory 96 G.&amp;lt;br /&amp;gt;&lt;br /&gt;
NIC: Intel 82599ES&amp;lt;br /&amp;gt;&lt;br /&gt;
Test Tool: iperf &amp;lt;br /&amp;gt;&lt;br /&gt;
OS: RHEL 7.1 &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Result summary ==&lt;br /&gt;
*In native environment, iperf can get 9.4 Gbps throughput. Since iperf is a SW packet generator and normal process shall it be, this a reasonable number.&lt;br /&gt;
*With VFIO passthrough, network performance is also 9.4 Gbps; i.e., we cannot observe overhead in virtualization environment with VFIO passthrough method, in context of typical SW network user application.&lt;br /&gt;
*With virtio approach, if proper configured (details see below), network performance can also achieve 9.4 Gbps.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Here is the details about each kind of configuration.&lt;br /&gt;
&lt;br /&gt;
== VFIO passthrough VF (SR-IOV) to guest ==&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
#You NIC supports SR-IOV (how to check? see below)&lt;br /&gt;
#driver (usually igb or ixgb) loaded with &#039;max_vfs=&amp;lt;num&amp;gt;&#039; (better to modinfo to check accurate parameter name)&lt;br /&gt;
#kernel modules needed: NIC driver, vfio-pci module, intel-iommu module&lt;br /&gt;
&lt;br /&gt;
=== Check if your NIC supports SR-IOV ===&lt;br /&gt;
lspci -s &amp;lt;NIC_BDF&amp;gt; -vvv | grep -i &amp;quot;Single Root I/O Virtualization&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Assign the VF to a guest ===&lt;br /&gt;
Unbind from igbvf driver and Bind to VFIO driver&lt;br /&gt;
#unbind from previous driver (take igbvf device for example)&lt;br /&gt;
#;echo &amp;lt;vf_BDF&amp;gt; &amp;gt; /sys/bus/pci/device/&amp;lt;vf_BDF&amp;gt;/driver/unbind&lt;br /&gt;
#;lspci -s  &amp;lt;vf_BDF&amp;gt; -n      //to get its number&lt;br /&gt;
#://it will return like below&lt;br /&gt;
#;&amp;lt;nowiki&amp;gt;0a:13.3 0200: 8086:1520 (rev 01)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
#://8086 1520 is its numeric number&lt;br /&gt;
#bind to vfio-pci driver&lt;br /&gt;
#;echo 8086 1520 &amp;gt; /sys/bus/pci/drivers/vfio-pci/new_id&lt;br /&gt;
	&lt;br /&gt;
Now you can see this device is bound to vfio-pci driver&amp;lt;br /&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;lspci -s &amp;lt;vf_BDF&amp;gt; -k&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create guest with direct passthrough via VFIO framework&amp;lt;br /&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;nowiki&amp;gt;qemu-kvm -m 16G -smp 8 -net none -device vfio-pci,host=81:10.0 -drive file=/var/lib/libvirt/images/rhel7.1.img,if=virtio -nographic&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br /&amp;gt;&#039;-net none&#039; tells qemu not emulate network devices&lt;br /&gt;
&amp;lt;br /&amp;gt;&#039;-device vfio-pci,host=&#039; designate a vfio-pci device and the device&#039;s host BDF&lt;br /&gt;
&lt;br /&gt;
== Virtio ==&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
virtio compiled in kernel (RHEL7.1 native kernel already have them)&lt;br /&gt;
	CONFIG_VIRTIO=m&lt;br /&gt;
	CONFIG_VIRTIO_RING=m&lt;br /&gt;
	CONFIG_VIRTIO_PCI=m&lt;br /&gt;
	CONFIG_VIRTIO_BALLOON=m&lt;br /&gt;
	CONFIG_VIRTIO_BLK=m&lt;br /&gt;
	CONFIG_VIRTIO_NET=m&lt;br /&gt;
&lt;br /&gt;
Create guest with direct passthrough via VFIO framework&amp;lt;br /&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;nowiki&amp;gt;qemu-kvm -m 16G -smp 8 -device virtio-net-pci,netdev=net0 -netdev tap,id=net0,script=/etc/qemu-ifup -drive file=/var/lib/libvirt/images/rhel7.1.img,if=virtio –nographic&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Poor performance configuration ====&lt;br /&gt;
&amp;lt;br /&amp;gt;&#039;&#039;&#039;&amp;lt;nowiki&amp;gt;qemu-kvm -m 16G -smp 8 -net nic,model=virtio -net tap,script=/etc/qemu-ifup -drive file=/var/lib/libvirt/images/rhel7.1.img,if=virtio –nographic&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br /&amp;gt;If not use &amp;lt;nowiki&amp;gt;&#039;-device virtio-net-pci&#039;&amp;lt;/nowiki&amp;gt; option, performance will be 3.6 Gbps.&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173206</id>
		<title>10G NIC performance: VFIO vs virtio</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173206"/>
		<updated>2015-05-11T10:50:22Z</updated>

		<summary type="html">&lt;p&gt;Robert: virtio part complete&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We did some experiment trying to measure network performance overhead in virtualization environment, comparing between VFIO passthrough and virtio approaches.&lt;br /&gt;
&lt;br /&gt;
== Test Topology ==&lt;br /&gt;
&lt;br /&gt;
2 Intel Grantley-EP platforms (Xeon E5-2697 v3) connected by 10G link; memory 96 G.&lt;br /&gt;
&lt;br /&gt;
NIC: Intel 82599ES&lt;br /&gt;
&lt;br /&gt;
Test Tool: iperf&lt;br /&gt;
&lt;br /&gt;
OS: RHEL 7.1&lt;br /&gt;
&lt;br /&gt;
== Result summary ==&lt;br /&gt;
*In native environment, iperf can get 9.4 Gbps throughput. Since iperf is a SW packet generator and normal process shall it be, this a reasonable number.&lt;br /&gt;
*With VFIO passthrough, network performance is also 9.4 Gbps; i.e., we cannot observe overhead in virtualization environment with VFIO passthrough method, in context of typical SW network user application.&lt;br /&gt;
*With virtio approach, if proper configured (details see below), network performance can also achieve 9.4 Gbps.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Here is the details about each kind of configuration.&lt;br /&gt;
&lt;br /&gt;
== VFIO passthrough VF (SR-IOV) to guest ==&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
#You NIC supports SR-IOV (how to check? see below)&lt;br /&gt;
#driver (usually igb or ixgb) loaded with &#039;max_vfs=&amp;lt;num&amp;gt;&#039; (better to modinfo to check accurate parameter name)&lt;br /&gt;
#kernel modules needed: NIC driver, vfio-pci module, intel-iommu module&lt;br /&gt;
&lt;br /&gt;
=== Check if your NIC supports SR-IOV ===&lt;br /&gt;
lspci -s &amp;lt;NIC_BDF&amp;gt; -vvv | grep -i &amp;quot;Single Root I/O Virtualization&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Assign the VF to a guest ===&lt;br /&gt;
Unbind from igbvf driver and Bind to VFIO driver&lt;br /&gt;
#unbind from previous driver (take igbvf device for example)&lt;br /&gt;
#;echo &amp;lt;vf_BDF&amp;gt; &amp;gt; /sys/bus/pci/device/&amp;lt;vf_BDF&amp;gt;/driver/unbind&lt;br /&gt;
#;lspci -s  &amp;lt;vf_BDF&amp;gt; -n      //to get its number&lt;br /&gt;
#://it will return like below&lt;br /&gt;
#;&amp;lt;nowiki&amp;gt;0a:13.3 0200: 8086:1520 (rev 01)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
#://8086 1520 is its numeric number&lt;br /&gt;
#bind to vfio-pci driver&lt;br /&gt;
#;echo 8086 1520 &amp;gt; /sys/bus/pci/drivers/vfio-pci/new_id&lt;br /&gt;
	&lt;br /&gt;
Now you can see this device is bound to vfio-pci driver&amp;lt;br /&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;lspci -s &amp;lt;vf_BDF&amp;gt; -k&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create guest with direct passthrough via VFIO framework&amp;lt;br /&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;nowiki&amp;gt;qemu-kvm -m 16G -smp 8 -net none -device vfio-pci,host=81:10.0 -drive file=/var/lib/libvirt/images/rhel7.1.img,if=virtio -nographic&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br /&amp;gt;&#039;-net none&#039; tells qemu not emulate network devices&lt;br /&gt;
&amp;lt;br /&amp;gt;&#039;-device vfio-pci,host=&#039; designate a vfio-pci device and the device&#039;s host BDF&lt;br /&gt;
&lt;br /&gt;
== Virtio ==&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
virtio compiled in kernel (RHEL7.1 native kernel already have them)&lt;br /&gt;
	CONFIG_VIRTIO=m&lt;br /&gt;
	CONFIG_VIRTIO_RING=m&lt;br /&gt;
	CONFIG_VIRTIO_PCI=m&lt;br /&gt;
	CONFIG_VIRTIO_BALLOON=m&lt;br /&gt;
	CONFIG_VIRTIO_BLK=m&lt;br /&gt;
	CONFIG_VIRTIO_NET=m&lt;br /&gt;
&lt;br /&gt;
Create guest with direct passthrough via VFIO framework&amp;lt;br /&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;nowiki&amp;gt;qemu-kvm -m 16G -smp 8 -device virtio-net-pci,netdev=net0 -netdev tap,id=net0,script=/etc/qemu-ifup -drive file=/var/lib/libvirt/images/rhel7.1.img,if=virtio –nographic&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Poor performance configuration ====&amp;lt;br /&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;nowiki&amp;gt;qemu-kvm -m 16G -smp 8 -net nic,model=virtio -net tap,script=/etc/qemu-ifup -drive file=/var/lib/libvirt/images/rhel7.1.img,if=virtio –nographic&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
If not use &amp;lt;nowiki&amp;gt;&#039;-device virtio-net-pci&#039;&amp;lt;/nowiki&amp;gt; option, performance will be 3.6 Gbps.&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173205</id>
		<title>10G NIC performance: VFIO vs virtio</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173205"/>
		<updated>2015-05-11T10:44:56Z</updated>

		<summary type="html">&lt;p&gt;Robert: VFIO method completes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We did some experiment trying to measure network performance overhead in virtualization environment, comparing between VFIO passthrough and virtio approaches.&lt;br /&gt;
&lt;br /&gt;
== Test Topology ==&lt;br /&gt;
&lt;br /&gt;
2 Intel Grantley-EP platforms (Xeon E5-2697 v3) connected by 10G link; memory 96 G.&lt;br /&gt;
&lt;br /&gt;
NIC: Intel 82599ES&lt;br /&gt;
&lt;br /&gt;
Test Tool: iperf&lt;br /&gt;
&lt;br /&gt;
OS: RHEL 7.1&lt;br /&gt;
&lt;br /&gt;
== Result summary ==&lt;br /&gt;
*In native environment, iperf can get 9.4 Gbps throughput. Since iperf is a SW packet generator and normal process shall it be, this a reasonable number.&lt;br /&gt;
*With VFIO passthrough, network performance is also 9.4 Gbps; i.e., we cannot observe overhead in virtualization environment with VFIO passthrough method, in context of typical SW network user application.&lt;br /&gt;
*With virtio approach, if proper configured (details see below), network performance can also achieve 9.4 Gbps.&lt;br /&gt;
&lt;br /&gt;
Here is the details about each kind of configuration.&lt;br /&gt;
&lt;br /&gt;
== VFIO passthrough VF (SR-IOV) to guest ==&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
#You NIC supports SR-IOV (how to check? see below)&lt;br /&gt;
#driver (usually igb or ixgb) loaded with &#039;max_vfs=&amp;lt;num&amp;gt;&#039; (better to modinfo to check accurate parameter name)&lt;br /&gt;
#kernel modules needed: NIC driver, vfio-pci module, intel-iommu module&lt;br /&gt;
&lt;br /&gt;
=== Check if your NIC supports SR-IOV ===&lt;br /&gt;
lspci -s &amp;lt;NIC_BDF&amp;gt; -vvv | grep -i &amp;quot;Single Root I/O Virtualization&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Assign the VF to a guest ===&lt;br /&gt;
Unbind from igbvf driver and Bind to VFIO driver&lt;br /&gt;
#unbind from previous driver (take igbvf device for example)&lt;br /&gt;
#;echo &amp;lt;vf_BDF&amp;gt; &amp;gt; /sys/bus/pci/device/&amp;lt;vf_BDF&amp;gt;/driver/unbind&lt;br /&gt;
#;lspci -s  &amp;lt;vf_BDF&amp;gt; -n      //to get its number&lt;br /&gt;
#://it will return like below&lt;br /&gt;
#;&amp;lt;nowiki&amp;gt;0a:13.3 0200: 8086:1520 (rev 01)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
#://8086 1520 is its numeric number&lt;br /&gt;
#bind to vfio-pci driver&lt;br /&gt;
#;echo 8086 1520 &amp;gt; /sys/bus/pci/drivers/vfio-pci/new_id&lt;br /&gt;
	&lt;br /&gt;
Now you can see this device is bound to vfio-pci driver&amp;lt;br /&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;lspci -s &amp;lt;vf_BDF&amp;gt; -k&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create guest with direct passthrough via VFIO framework&amp;lt;br /&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;nowiki&amp;gt;qemu-kvm -m 16G -smp 8 -net none -device vfio-pci,host=81:10.0 -drive file=/var/lib/libvirt/images/rhel7.1.img,if=virtio -nographic&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br /&amp;gt;&#039;-net none&#039; tells qemu not emulate network devices&lt;br /&gt;
&amp;lt;br /&amp;gt;&#039;-device vfio-pci,host=&#039; designate a vfio-pci device and the device&#039;s host BDF&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173204</id>
		<title>10G NIC performance: VFIO vs virtio</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173204"/>
		<updated>2015-05-11T10:00:02Z</updated>

		<summary type="html">&lt;p&gt;Robert: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We did some experiment trying to measure network performance overhead in virtualization environment, comparing between VFIO passthrough and virtio approaches.&lt;br /&gt;
&lt;br /&gt;
== Test Topology ==&lt;br /&gt;
&lt;br /&gt;
2 Intel Grantley-EP platforms (Xeon E5-2697 v3) connected by 10G link; memory 96 G.&lt;br /&gt;
&lt;br /&gt;
NIC: Intel 82599ES&lt;br /&gt;
&lt;br /&gt;
Test Tool: iperf&lt;br /&gt;
&lt;br /&gt;
OS: RHEL 7.1&lt;br /&gt;
&lt;br /&gt;
== Result summary ==&lt;br /&gt;
*In native environment, iperf can get 9.4 Gbps throughput. Since iperf is a SW packet generator and normal process shall it be, this a reasonable number.&lt;br /&gt;
*With VFIO passthrough, network performance is also 9.4 Gbps; i.e., we cannot observe overhead in virtualization environment with VFIO passthrough method, in context of typical SW network user application.&lt;br /&gt;
*With virtio approach, if proper configured (details see below), network performance can also achieve 9.4 Gbps.&lt;br /&gt;
&lt;br /&gt;
Here is the details about each kind of configuration.&lt;br /&gt;
&lt;br /&gt;
== VFIO passthrough VF (SR-IOV) to guest ==&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
#You NIC supports SR-IOV (how to check? see below)&lt;br /&gt;
#driver (usually igb or ixgb) loaded with &#039;max_vfs=&amp;lt;num&amp;gt;&#039; (better to modinfo to check accurate parameter name)&lt;br /&gt;
#kernel modules needed: NIC driver, vfio-pci module, intel-iommu module&lt;br /&gt;
&lt;br /&gt;
=== Check if your NIC supports SR-IOV ===&lt;br /&gt;
lspci -s &amp;lt;NIC_BDF&amp;gt; -vvv | grep -i &amp;quot;Single Root I/O Virtualization&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Assign the VF to a guest ===&lt;br /&gt;
Unbind from igbvf driver and Bind to VFIO driver&lt;br /&gt;
#unbind from previous driver (take igbvf device for example)&lt;br /&gt;
#;echo &amp;lt;vf_BDF&amp;gt; &amp;gt; /sys/bus/pci/device/&amp;lt;vf_BDF&amp;gt;/driver/unbind&lt;br /&gt;
#;lspci -s  &amp;lt;vf_BDF&amp;gt; -n      //to get its number&lt;br /&gt;
#://it will return like below&lt;br /&gt;
#;&amp;lt;nowiki&amp;gt;0a:13.3 0200: 8086:1520 (rev 01)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
#://8086 1520 is its numeric number&lt;br /&gt;
#bind to vfio-pci driver&lt;br /&gt;
#;echo 8086 1520 &amp;gt; /sys/bus/pci/drivers/vfio-pci/new_id&lt;br /&gt;
	&lt;br /&gt;
Now you can see this device is bound to vfio-pci driver&amp;lt;br /&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;lspci -s &amp;lt;vf_BDF&amp;gt; -k&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173203</id>
		<title>10G NIC performance: VFIO vs virtio</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173203"/>
		<updated>2015-05-11T09:52:44Z</updated>

		<summary type="html">&lt;p&gt;Robert: fine tune&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We did some experiment trying to measure network performance overhead in virtualization environment, comparing between VFIO passthrough and virtio approaches.&lt;br /&gt;
&lt;br /&gt;
== Test Topology ==&lt;br /&gt;
&lt;br /&gt;
2 Intel Grantley-EP platforms (Xeon E5-2697 v3) connected by 10G link; memory 96 G.&lt;br /&gt;
&lt;br /&gt;
NIC: Intel 82599ES&lt;br /&gt;
&lt;br /&gt;
Test Tool: iperf&lt;br /&gt;
&lt;br /&gt;
OS: RHEL 7.1&lt;br /&gt;
&lt;br /&gt;
== Result summary ==&lt;br /&gt;
*In native environment, iperf can get 9.4 Gbps throughput. Since iperf is a SW packet generator and normal process shall it be, this a reasonable number.&lt;br /&gt;
*With VFIO passthrough, network performance is also 9.4 Gbps; i.e., we cannot observe overhead in virtualization environment with VFIO passthrough method, in context of typical SW network user application.&lt;br /&gt;
*With virtio approach, if proper configured (details see below), network performance can also achieve 9.4 Gbps.&lt;br /&gt;
&lt;br /&gt;
Here is the details about each kind of configuration.&lt;br /&gt;
&lt;br /&gt;
== VFIO passthrough VF (SR-IOV) to guest ==&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
#You NIC supports SR-IOV (how to check? see below)&lt;br /&gt;
#driver (usually igb or ixgb) loaded with &#039;max_vfs=&amp;lt;num&amp;gt;&#039; (better to modinfo to check accurate parameter name)&lt;br /&gt;
#kernel modules needed: NIC driver, vfio-pci module, intel-iommu module&lt;br /&gt;
&lt;br /&gt;
=== Check if your NIC supports SR-IOV ===&lt;br /&gt;
lspci -s &amp;lt;NIC_BDF&amp;gt; -vvv | grep -i &amp;quot;Single Root I/O Virtualization&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Assign the VF to a guest ===&lt;br /&gt;
Unbind from igbvf driver and Bind to VFIO driver&lt;br /&gt;
#unbind from previous driver (take igbvf device for example)&lt;br /&gt;
        echo &amp;lt;vf_BDF&amp;gt; &amp;gt; /sys/bus/pci/device/&amp;lt;vf_BDF&amp;gt;/driver/unbind&lt;br /&gt;
        lspci -s  &amp;lt;vf_BDF&amp;gt; -n      //to get its number&lt;br /&gt;
        //it will return like below&lt;br /&gt;
        0a:13.3 0200: 8086:1520 (rev 01)&lt;br /&gt;
        //8086 1520 is its numeric number&lt;br /&gt;
&lt;br /&gt;
#bind to vfio-pci driver&lt;br /&gt;
         echo 8086 1520 &amp;gt; /sys/bus/pci/drivers/vfio-pci/new_id&lt;br /&gt;
	&lt;br /&gt;
Now you can see this device is bound to vfio-pci driver&lt;br /&gt;
lspci -s &amp;lt;vf_BDF&amp;gt; -k&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173202</id>
		<title>10G NIC performance: VFIO vs virtio</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173202"/>
		<updated>2015-05-11T09:51:24Z</updated>

		<summary type="html">&lt;p&gt;Robert: format it&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We did some experiment trying to measure network performance overhead in virtualization environment, comparing between VFIO passthrough and virtio approaches.&lt;br /&gt;
&lt;br /&gt;
== Test Topology ==&lt;br /&gt;
&lt;br /&gt;
2 Intel Grantley-EP platforms (Xeon E5-2697 v3) connected by 10G link; memory 96 G.&lt;br /&gt;
&lt;br /&gt;
NIC: Intel 82599ES&lt;br /&gt;
&lt;br /&gt;
Test Tool: iperf&lt;br /&gt;
&lt;br /&gt;
OS: RHEL 7.1&lt;br /&gt;
&lt;br /&gt;
== Result summary ==&lt;br /&gt;
*In native environment, iperf can get 9.4 Gbps throughput. Since iperf is a SW packet generator and normal process shall it be, this a reasonable number.&lt;br /&gt;
*With VFIO passthrough, network performance is also 9.4 Gbps; i.e., we cannot observe overhead in virtualization environment with VFIO passthrough method, in context of typical SW network user application.&lt;br /&gt;
*With virtio approach, if proper configured (details see below), network performance can also achieve 9.4 Gbps.&lt;br /&gt;
&lt;br /&gt;
Here is the details about each kind of configuration.&lt;br /&gt;
&lt;br /&gt;
== VFIO passthrough VF (SR-IOV) to guest ==&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
#You NIC supports SR-IOV (how to check? see below)&lt;br /&gt;
#driver (usually igb or ixgb) loaded with &#039;max_vfs=&amp;lt;num&amp;gt;&#039; (better to modinfo to check accurate parameter name)&lt;br /&gt;
#kernel modules needed: NIC driver, vfio-pci module, intel-iommu module&lt;br /&gt;
&lt;br /&gt;
=== Check if your NIC supports SR-IOV ===&lt;br /&gt;
lspci -s &amp;lt;NIC_BDF&amp;gt; -vvv | grep -i &amp;quot;Single Root I/O Virtualization&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Assign the VF to a guest ===&lt;br /&gt;
Unbind from igbvf driver and Bind to VFIO driver&lt;br /&gt;
#unbind from previous driver (take igbvf device for example)&lt;br /&gt;
        echo &amp;lt;vf_BDF&amp;gt; &amp;gt; /sys/bus/pci/device/&amp;lt;vf_BDF&amp;gt;/driver/unbind&lt;br /&gt;
        lspci -s  &amp;lt;vf_BDF&amp;gt; -n      //to get its number&lt;br /&gt;
	//it will return like below&lt;br /&gt;
        0a:13.3 0200: 8086:1520 (rev 01)&lt;br /&gt;
	//8086 1520 is its numeric number&lt;br /&gt;
&lt;br /&gt;
#bind to vfio-pci driver&lt;br /&gt;
         echo 8086 1520 &amp;gt; /sys/bus/pci/drivers/vfio-pci/new_id&lt;br /&gt;
	&lt;br /&gt;
Now you can see this device is bound to vfio-pci driver&lt;br /&gt;
lspci -s &amp;lt;vf_BDF&amp;gt; -k&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173201</id>
		<title>10G NIC performance: VFIO vs virtio</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173201"/>
		<updated>2015-05-11T09:48:38Z</updated>

		<summary type="html">&lt;p&gt;Robert: VFIO&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We did some experiment trying to measure network performance overhead in virtualization environment, comparing between VFIO passthrough and virtio approaches.&lt;br /&gt;
&lt;br /&gt;
== Test Topology ==&lt;br /&gt;
&lt;br /&gt;
2 Intel Grantley-EP platforms (Xeon E5-2697 v3) connected by 10G link; memory 96 G.&lt;br /&gt;
&lt;br /&gt;
NIC: Intel 82599ES&lt;br /&gt;
&lt;br /&gt;
Test Tool: iperf&lt;br /&gt;
&lt;br /&gt;
OS: RHEL 7.1&lt;br /&gt;
&lt;br /&gt;
== Result summary ==&lt;br /&gt;
*In native environment, iperf can get 9.4 Gbps throughput. Since iperf is a SW packet generator and normal process shall it be, this a reasonable number.&lt;br /&gt;
*With VFIO passthrough, network performance is also 9.4 Gbps; i.e., we cannot observe overhead in virtualization environment with VFIO passthrough method, in context of typical SW network user application.&lt;br /&gt;
*With virtio approach, if proper configured (details see below), network performance can also achieve 9.4 Gbps.&lt;br /&gt;
&lt;br /&gt;
Here is the details about each kind of configuration.&lt;br /&gt;
&lt;br /&gt;
== VFIO passthrough VF (SR-IOV) to guest ==&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
#You NIC supports SR-IOV (how to check? see below)&lt;br /&gt;
#driver (usually igb or ixgb) loaded with &#039;max_vfs=&amp;lt;num&amp;gt;&#039; (better to modinfo to check accurate parameter name)&lt;br /&gt;
#kernel modules needed: NIC driver, vfio-pci module, intel-iommu module&lt;br /&gt;
&lt;br /&gt;
=== Check if your NIC supports SR-IOV ===&lt;br /&gt;
lspci -s &amp;lt;NIC_BDF&amp;gt; -vvv | grep -i &amp;quot;Single Root I/O Virtualization&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Assign the VF to a guest ===&lt;br /&gt;
Unbind from igbvf driver and Bind to VFIO driver&lt;br /&gt;
#unbind from previous driver (take igbvf device for example)&lt;br /&gt;
	echo &amp;lt;vf_BDF&amp;gt; &amp;gt; /sys/bus/pci/device/&amp;lt;vf_BDF&amp;gt;/driver/unbind&lt;br /&gt;
	lspci -s  &amp;lt;vf_BDF&amp;gt; -n      //to get its number&lt;br /&gt;
	//it will return like below&lt;br /&gt;
	0a:13.3 0200: 8086:1520 (rev 01)&lt;br /&gt;
	//8086 1520 is its numeric number&lt;br /&gt;
#bind to vfio-pci driver&lt;br /&gt;
	echo 8086 1520 &amp;gt; /sys/bus/pci/drivers/vfio-pci/new_id&lt;br /&gt;
	&lt;br /&gt;
Now you can see this device is bound to vfio-pci driver&lt;br /&gt;
lspci -s &amp;lt;vf_BDF&amp;gt; -k&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173200</id>
		<title>10G NIC performance: VFIO vs virtio</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173200"/>
		<updated>2015-05-11T09:44:02Z</updated>

		<summary type="html">&lt;p&gt;Robert: Result summary&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We did some experiment trying to measure network performance overhead in virtualization environment, comparing between VFIO passthrough and virtio approaches.&lt;br /&gt;
&lt;br /&gt;
== Test Topology ==&lt;br /&gt;
&lt;br /&gt;
2 Intel Grantley-EP platforms (Xeon E5-2697 v3) connected by 10G link; memory 96 G.&lt;br /&gt;
&lt;br /&gt;
NIC: Intel 82599ES&lt;br /&gt;
&lt;br /&gt;
Test Tool: iperf&lt;br /&gt;
&lt;br /&gt;
OS: RHEL 7.1&lt;br /&gt;
&lt;br /&gt;
== Result summary ==&lt;br /&gt;
*In native environment, iperf can get 9.4 Gbps throughput. Since iperf is a SW packet generator and normal process shall it be, this a reasonable number.&lt;br /&gt;
*With VFIO passthrough, network performance is also 9.4 Gbps; i.e., we cannot observe overhead in virtualization environment with VFIO passthrough method, in context of typical SW network user application.&lt;br /&gt;
*With virtio approach, if proper configured (details see below), network performance can also achieve 9.4 Gbps.&lt;br /&gt;
&lt;br /&gt;
Here is the details about each kind of configuration.&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173199</id>
		<title>10G NIC performance: VFIO vs virtio</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173199"/>
		<updated>2015-05-11T09:40:59Z</updated>

		<summary type="html">&lt;p&gt;Robert: So how about this?&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We did some experiment trying to measure network performance overhead in virtualization environment, comparing between VFIO passthrough and virtio approaches.&lt;br /&gt;
&lt;br /&gt;
== Test Topology ==&lt;br /&gt;
&lt;br /&gt;
2 Intel Grantley-EP platforms (Xeon E5-2697 v3) connected by 10G link; memory 96 G.&lt;br /&gt;
&lt;br /&gt;
NIC: Intel 82599ES&lt;br /&gt;
&lt;br /&gt;
Test Tool: iperf&lt;br /&gt;
&lt;br /&gt;
OS: RHEL 7.1&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173198</id>
		<title>10G NIC performance: VFIO vs virtio</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173198"/>
		<updated>2015-05-11T09:39:23Z</updated>

		<summary type="html">&lt;p&gt;Robert: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We did some experiment trying to measure network performance overhead in virtualization environment, comparing between VFIO passthrough and virtio approaches.&lt;br /&gt;
&lt;br /&gt;
I mean this.&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173197</id>
		<title>10G NIC performance: VFIO vs virtio</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173197"/>
		<updated>2015-05-11T09:38:21Z</updated>

		<summary type="html">&lt;p&gt;Robert: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We did some experiment trying to measure network performance overhead in virtualization environment, comparing between VFIO passthrough and virtio approaches.&lt;br /&gt;
&lt;br /&gt;
Test&lt;br /&gt;
Now&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=KVM:VFIO_V.S._virtio&amp;diff=173196</id>
		<title>KVM:VFIO V.S. virtio</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=KVM:VFIO_V.S._virtio&amp;diff=173196"/>
		<updated>2015-05-11T09:37:59Z</updated>

		<summary type="html">&lt;p&gt;Robert: Robert moved page KVM:VFIO V.S. virtio to VFIO vs virtio&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[VFIO vs virtio]]&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173195</id>
		<title>10G NIC performance: VFIO vs virtio</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173195"/>
		<updated>2015-05-11T09:37:59Z</updated>

		<summary type="html">&lt;p&gt;Robert: Robert moved page KVM:VFIO V.S. virtio to VFIO vs virtio&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We did some experiment trying to measure network performance overhead in virtualization environment, comparing between VFIO passthrough and virtio approaches.&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=VFIO_V.S._virtio&amp;diff=173194</id>
		<title>VFIO V.S. virtio</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=VFIO_V.S._virtio&amp;diff=173194"/>
		<updated>2015-05-11T09:24:42Z</updated>

		<summary type="html">&lt;p&gt;Robert: Robert moved page VFIO V.S. virtio to KVM:VFIO V.S. virtio&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[KVM:VFIO V.S. virtio]]&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173193</id>
		<title>10G NIC performance: VFIO vs virtio</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173193"/>
		<updated>2015-05-11T09:24:42Z</updated>

		<summary type="html">&lt;p&gt;Robert: Robert moved page VFIO V.S. virtio to KVM:VFIO V.S. virtio&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We did some experiment trying to measure network performance overhead in virtualization environment, comparing between VFIO passthrough and virtio approaches.&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173192</id>
		<title>10G NIC performance: VFIO vs virtio</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173192"/>
		<updated>2015-05-11T09:04:42Z</updated>

		<summary type="html">&lt;p&gt;Robert: 10G NIC performance&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We did some experiment trying to measure network performance overhead in virtualization environment, comparing between VFIO passthrough and virtio approaches.&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173191</id>
		<title>10G NIC performance: VFIO vs virtio</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173191"/>
		<updated>2015-05-11T09:02:55Z</updated>

		<summary type="html">&lt;p&gt;Robert: Init&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We did some experiment comparing KVM guest network performance between VFIO&lt;br /&gt;
&lt;br /&gt;
whywhy why&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Networking&amp;diff=173190</id>
		<title>Networking</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Networking&amp;diff=173190"/>
		<updated>2015-05-11T08:47:21Z</updated>

		<summary type="html">&lt;p&gt;Robert: /* performance */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Setting guest network =&lt;br /&gt;
&lt;br /&gt;
Guest (VM) networking in kvm is the same as in qemu, so it is possible to refer to other documentations about networking for qemu. This page will try to explain how to configure the most frequent types of network needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== User Networking ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Use case:&#039;&#039;&#039;&lt;br /&gt;
* You want a simple way for your virtual machine to access to the host, to the internet or to resources available on your local network.&lt;br /&gt;
* You don&#039;t need to access your guest from the network or from another guest.&lt;br /&gt;
* You are ready to take a huge performance hit.&lt;br /&gt;
* Warning: User networking does not support a number of networking features like ICMP.  Certain applications (like ping) may not function properly.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Prerequisites:&#039;&#039;&#039;&lt;br /&gt;
* You need kvm up and running&lt;br /&gt;
* If you don&#039;t want to run as root, the user you want to use needs to have rw access to /dev/kvm&lt;br /&gt;
* If you want to be able to access the internet or a local network, your host system must be able to access the internet or the local network&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solution:&#039;&#039;&#039;&lt;br /&gt;
* simply run your guest without specifying network parameters, which by default will create user-lever (a.k.a slirp) networking:&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* The IP address can be automatically assigned to the guest thanks to the DHCP service integrated in QEMU&lt;br /&gt;
* If you run multiple guests on the host, you don&#039;t need to specify a different MAC address for each guest&lt;br /&gt;
* The default is equivalent to this explicit setup:&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img -netdev user,id=user.0 -device e1000,netdev=user.0&lt;br /&gt;
* user.0 identifier above is just to connect the two halves into one, you may use any identifier you wish, such as &amp;quot;n&amp;quot; or &amp;quot;net0&amp;quot;.&lt;br /&gt;
* Use rtl8139 instead of e1000 to get 8139-series NIC.&lt;br /&gt;
* You can still access one specific port on the guest using the &amp;quot;hostfwd&amp;quot; option. This means e.g. if you want to transport a file with scp from host to guest, start the guest with &amp;quot;-device e1000,netdev=user.0 -netdev user,id=user.0,hostfwd=tcp::5555-:22&amp;quot;. Now you are forwarding the host port 5555 to the guest port 22. After starting up the guest, you can transport a file with e.g. &amp;quot;scp -P 5555 file.txt root@localhost:/tmp&amp;quot; from host to guest. Or you can also use other address of the host to connect to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== private virtual bridge ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Use case:&#039;&#039;&#039;&lt;br /&gt;
* You want to set up a private network between 2 or more virtual machines. This network won&#039;t be seen from the other virtual machines nor from the real network.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Prerequisites:&#039;&#039;&#039;&lt;br /&gt;
* You need kvm up and running&lt;br /&gt;
* If you don&#039;t want to run as root, the user you want to use needs to have rw access to /dev/kvm&lt;br /&gt;
* You need the following commands installed on your system, and if you don&#039;t want to run as root, the user you want to use needs to be able to sudo the following command:&lt;br /&gt;
 /sbin/ip&lt;br /&gt;
 /usr/sbin/brctl&lt;br /&gt;
 /usr/sbin/tunctl&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solution:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* You need to create a bridge, e-g:&lt;br /&gt;
 sudo /usr/sbin/brctl addbr br0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following:&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 set -x&lt;br /&gt;
 &lt;br /&gt;
 switch=br0&lt;br /&gt;
 &lt;br /&gt;
 if [ -n &amp;quot;$1&amp;quot; ];then&lt;br /&gt;
         /usr/bin/sudo /usr/sbin/tunctl -u `whoami` -t $1&lt;br /&gt;
         /usr/bin/sudo /sbin/ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         /usr/bin/sudo /usr/sbin/brctl addif $switch $1&lt;br /&gt;
         exit 0&lt;br /&gt;
 else&lt;br /&gt;
         echo &amp;quot;Error: no interface specified&amp;quot;&lt;br /&gt;
         exit 1&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
* Generate a MAC address, either manually or using:&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # generate a random mac address for the qemu nic&lt;br /&gt;
 printf &#039;DE:AD:BE:EF:%02X:%02X\n&#039; $((RANDOM%256)) $((RANDOM%256))&lt;br /&gt;
&lt;br /&gt;
* Run each guest with the following, replacing $macaddress with the value from the previous step&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img -device e1000,netdev=net0,mac=$macaddress -netdev tap,id=net0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* If you don&#039;t want to run as root, the qemu-ifup must be executable by the user you want to use&lt;br /&gt;
* You can either create a system-wide qemu-ifup in /etc/qemu-ifup or use another one. In the latter case, run&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img -device e1000,netdev=net0,mac=$macaddress -netdev tap,id=net0,script=/path/to/qemu-ifup&lt;br /&gt;
&lt;br /&gt;
* Each guest on the private virtual network must have a different MAC address&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== public bridge ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; The here shown method, will not work with most(all?) wireless drivers, as these do not support bridging.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Use case:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* You want to assign an IP address to your virtual machines and make them accessible from your local network&lt;br /&gt;
* You also want performance out of your virtual machine.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Prerequisites:&#039;&#039;&#039;&lt;br /&gt;
* You need kvm up and running&lt;br /&gt;
* If you don&#039;t want to run as root, the user you want to use needs to have rw access to /dev/kvm&lt;br /&gt;
* You need the following commands installed on your system, and if you don&#039;t want to run as root, the user you want to use needs to be able to sudo the following command:&lt;br /&gt;
 /sbin/ip&lt;br /&gt;
 /usr/sbin/brctl&lt;br /&gt;
 /usr/sbin/tunctl&lt;br /&gt;
&lt;br /&gt;
* Your host system must be able to access the internet or the local network&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solution 1: using distro sysconfig script&#039;&#039;&#039;&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
!RedHat&#039;s way&lt;br /&gt;
!Debian&#039;s way&lt;br /&gt;
!SuSE&#039;s way&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
* Edit /etc/sysconfig/network-scripts/ifcfg-eth0&lt;br /&gt;
** comment out BOOTPROTO&lt;br /&gt;
** Add BRIDGE=br0&lt;br /&gt;
* Create /etc/sysconfig/network-scripts/ifcfg-br0&lt;br /&gt;
** The content should be:&lt;br /&gt;
 DEVICE=br0&lt;br /&gt;
 BOOTPROTO=dhcp&lt;br /&gt;
 ONBOOT=yes&lt;br /&gt;
 TYPE=Bridge&lt;br /&gt;
|&lt;br /&gt;
/etc/network/interfaces&lt;br /&gt;
&lt;br /&gt;
 # Replace old eth0 config with br0&lt;br /&gt;
 auto &amp;lt;strike&amp;gt;eth0&amp;lt;/strike&amp;gt; br0&lt;br /&gt;
&lt;br /&gt;
 # Use old eth0 config for br0, plus bridge stuff&lt;br /&gt;
 iface br0 inet dhcp&lt;br /&gt;
     bridge_ports    eth0&lt;br /&gt;
     bridge_stp      off&lt;br /&gt;
     bridge_maxwait  0&lt;br /&gt;
     bridge_fd       0&lt;br /&gt;
&lt;br /&gt;
|&lt;br /&gt;
* Start YaST&lt;br /&gt;
* Go to Network Configuration&lt;br /&gt;
* Add new device -&amp;gt; Bridge&lt;br /&gt;
* Tick your existing network device&lt;br /&gt;
* done&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* /etc/init.d/networking restart&lt;br /&gt;
* The bridge br0 should get the ip address (either static/dhcp) while the physical eth0 is left without ip address.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLANs&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Please note that the rtl8139 virtual network interface driver does not support VLANs. If you want to use VLANs with your virtual machine, you must use another virtual network interface like virtio. &lt;br /&gt;
&lt;br /&gt;
When using VLANs on a setup like this and no traffic is getting through to your guest(s), you might want to do:&lt;br /&gt;
 # cd /proc/sys/net/bridge&lt;br /&gt;
 # ls&lt;br /&gt;
 bridge-nf-call-arptables  bridge-nf-call-iptables&lt;br /&gt;
 bridge-nf-call-ip6tables  bridge-nf-filter-vlan-tagged&lt;br /&gt;
 # for f in bridge-nf-*; do echo 0 &amp;gt; $f; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solution 2: manual&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* You need to create a bridge, e-g:&lt;br /&gt;
 sudo /usr/sbin/brctl addbr br0&lt;br /&gt;
&lt;br /&gt;
* Add one of your physical interface to the bridge, e-g for eth0:&lt;br /&gt;
 sudo /usr/sbin/brctl  addif br0 eth0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 set -x&lt;br /&gt;
 &lt;br /&gt;
 switch=br0&lt;br /&gt;
 &lt;br /&gt;
 if [ -n &amp;quot;$1&amp;quot; ];then&lt;br /&gt;
         /usr/bin/sudo /usr/sbin/tunctl -u `whoami` -t $1&lt;br /&gt;
         /usr/bin/sudo /sbin/ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         /usr/bin/sudo /usr/sbin/brctl addif $switch $1&lt;br /&gt;
         exit 0&lt;br /&gt;
 else&lt;br /&gt;
         echo &amp;quot;Error: no interface specified&amp;quot;&lt;br /&gt;
         exit 1&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
* Generate a MAC address, either manually or using:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 # generate a random mac address for the qemu nic&lt;br /&gt;
 printf &#039;DE:AD:BE:EF:%02X:%02X\n&#039; $((RANDOM%256)) $((RANDOM%256))&lt;br /&gt;
&lt;br /&gt;
* Run each guest with the following, replacing $macaddress with the value from the previous step&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img -device e1000,netdev=net0,mac=$macaddress -netdev tap,id=net0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* If you don&#039;t want to run as root, the qemu-ifup must be executable by the user you want to use&lt;br /&gt;
* You can either create a system-wide qemu-ifup in /etc/qemu-ifup or use another one. In the latter case, run&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img -device e1000,netdev=net0,mac=$macaddress -netdev tap,id=net0,script=/path/to/qemu-ifup&lt;br /&gt;
&lt;br /&gt;
* Each guest on the network must have a different MAC address&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== iptables/routing ==&lt;br /&gt;
&lt;br /&gt;
you can also connect your guest vm to a tap in your host. then setting iptables rules in your host to become a router + firewall for your vm.&lt;br /&gt;
&lt;br /&gt;
Routing would be done simply by creating the default route on the client to the IP of the host (and allowing IP forwarding) and setting a route to the tap? device of the client on the host.&lt;br /&gt;
&lt;br /&gt;
Test the setup beforehand:&lt;br /&gt;
&lt;br /&gt;
*Hostside: Allow IPv4 forwarding and add route to client (could be put in a script - route has to be added after the client has started):&lt;br /&gt;
&lt;br /&gt;
 sysctl -w net.ipv4.ip_forward=1                 # allow forwarding of IPv4&lt;br /&gt;
 route add -host &amp;lt;ip-of-client&amp;gt; dev &amp;lt;tap-device&amp;gt; # add route to the client&lt;br /&gt;
&lt;br /&gt;
*Clientside: Default GW of the client is of course then the host (&amp;lt;ip-of-host&amp;gt; has to be in same subnet as &amp;lt;ip-of-client&amp;gt; ...):&lt;br /&gt;
&lt;br /&gt;
 route add default gw &amp;lt;ip-of-host&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Clientside v2: If you host IP is not on the same subnet as &amp;lt;ip-of-client&amp;gt;, then you must manually add the route to host before you create default route:&lt;br /&gt;
&lt;br /&gt;
 route add -host &amp;lt;ip-of-host&amp;gt; dev &amp;lt;network-interface&amp;gt;&lt;br /&gt;
 route add default gw &amp;lt;ip-of-host&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== vde ==&lt;br /&gt;
&lt;br /&gt;
Another option is using vde (virtual distributed ethernet).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== performance ==&lt;br /&gt;
&lt;br /&gt;
Data on benchmarking results should go in here.&lt;br /&gt;
There&#039;s now a page dedicated to ideas for improving&lt;br /&gt;
[[Networking Performance]].&lt;br /&gt;
&lt;br /&gt;
Some 10G NIC performance comparison between VFIO passthrough and virtio [[VFIO vs virtio]]&lt;br /&gt;
&lt;br /&gt;
== Compatibility ==&lt;br /&gt;
&lt;br /&gt;
There&#039;s another, old and obsolete syntax of specifying network for virtual machines.  Above examples uses -netdev..-device model, old way used -net..-net pairs.  For example,&lt;br /&gt;
&lt;br /&gt;
 -netdev tap,id=net0 -device e1000,netdev=net0,mac=52:54:00:12:34:56&lt;br /&gt;
&lt;br /&gt;
is about the same as old&lt;br /&gt;
&lt;br /&gt;
 -net tap,vlan=0 -net nic,vlan=0,model=e1000,macaddr=52:54:00:12:34:56&lt;br /&gt;
&lt;br /&gt;
(note mac =&amp;gt; macaddr parameter change as well; vlan=0 is the default).&lt;br /&gt;
&lt;br /&gt;
Old way used the notion of &amp;quot;VLANs&amp;quot; - these are QEMU VLANS, which has nothing to do with 802.1q VLANs. Qemu VLANs are numbered starting with 0, and it&#039;s possible to connect one or more devices (either host side, like -net tap, or guest side, like -net nic) to each VLAN, and, in particular, it&#039;s possible to connect more than 2 devices to a VLAN.  Each device in a VLAN gets all traffic received by every device in it.  This model was very confusing for the user (especially when a guest has more than one NIC).&lt;br /&gt;
&lt;br /&gt;
In new model, each host side correspond to just one guest side, forming a pair of devices based on -netdev id=  and -device netdev= parameters.  It is less confusing, it is faster (because it&#039;s always 1:1 pair), and it supports more parameters than old -net..-net way.&lt;br /&gt;
&lt;br /&gt;
However, -net..-net is still supported, used widely, and mentioned in lots of various HOWTOs and guides around the world.  It is also a bit shorter and so faster to type.&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173189</id>
		<title>10G NIC performance: VFIO vs virtio</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=10G_NIC_performance:_VFIO_vs_virtio&amp;diff=173189"/>
		<updated>2015-05-11T07:35:50Z</updated>

		<summary type="html">&lt;p&gt;Robert: Created page with &amp;quot;We did some experiment comparing KVM guest network performance between VFIO&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We did some experiment comparing KVM guest network performance between VFIO&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Networking&amp;diff=173188</id>
		<title>Networking</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Networking&amp;diff=173188"/>
		<updated>2015-05-11T06:49:53Z</updated>

		<summary type="html">&lt;p&gt;Robert: /* performance */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Setting guest network =&lt;br /&gt;
&lt;br /&gt;
Guest (VM) networking in kvm is the same as in qemu, so it is possible to refer to other documentations about networking for qemu. This page will try to explain how to configure the most frequent types of network needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== User Networking ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Use case:&#039;&#039;&#039;&lt;br /&gt;
* You want a simple way for your virtual machine to access to the host, to the internet or to resources available on your local network.&lt;br /&gt;
* You don&#039;t need to access your guest from the network or from another guest.&lt;br /&gt;
* You are ready to take a huge performance hit.&lt;br /&gt;
* Warning: User networking does not support a number of networking features like ICMP.  Certain applications (like ping) may not function properly.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Prerequisites:&#039;&#039;&#039;&lt;br /&gt;
* You need kvm up and running&lt;br /&gt;
* If you don&#039;t want to run as root, the user you want to use needs to have rw access to /dev/kvm&lt;br /&gt;
* If you want to be able to access the internet or a local network, your host system must be able to access the internet or the local network&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solution:&#039;&#039;&#039;&lt;br /&gt;
* simply run your guest without specifying network parameters, which by default will create user-lever (a.k.a slirp) networking:&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* The IP address can be automatically assigned to the guest thanks to the DHCP service integrated in QEMU&lt;br /&gt;
* If you run multiple guests on the host, you don&#039;t need to specify a different MAC address for each guest&lt;br /&gt;
* The default is equivalent to this explicit setup:&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img -netdev user,id=user.0 -device e1000,netdev=user.0&lt;br /&gt;
* user.0 identifier above is just to connect the two halves into one, you may use any identifier you wish, such as &amp;quot;n&amp;quot; or &amp;quot;net0&amp;quot;.&lt;br /&gt;
* Use rtl8139 instead of e1000 to get 8139-series NIC.&lt;br /&gt;
* You can still access one specific port on the guest using the &amp;quot;hostfwd&amp;quot; option. This means e.g. if you want to transport a file with scp from host to guest, start the guest with &amp;quot;-device e1000,netdev=user.0 -netdev user,id=user.0,hostfwd=tcp::5555-:22&amp;quot;. Now you are forwarding the host port 5555 to the guest port 22. After starting up the guest, you can transport a file with e.g. &amp;quot;scp -P 5555 file.txt root@localhost:/tmp&amp;quot; from host to guest. Or you can also use other address of the host to connect to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== private virtual bridge ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Use case:&#039;&#039;&#039;&lt;br /&gt;
* You want to set up a private network between 2 or more virtual machines. This network won&#039;t be seen from the other virtual machines nor from the real network.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Prerequisites:&#039;&#039;&#039;&lt;br /&gt;
* You need kvm up and running&lt;br /&gt;
* If you don&#039;t want to run as root, the user you want to use needs to have rw access to /dev/kvm&lt;br /&gt;
* You need the following commands installed on your system, and if you don&#039;t want to run as root, the user you want to use needs to be able to sudo the following command:&lt;br /&gt;
 /sbin/ip&lt;br /&gt;
 /usr/sbin/brctl&lt;br /&gt;
 /usr/sbin/tunctl&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solution:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* You need to create a bridge, e-g:&lt;br /&gt;
 sudo /usr/sbin/brctl addbr br0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following:&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 set -x&lt;br /&gt;
 &lt;br /&gt;
 switch=br0&lt;br /&gt;
 &lt;br /&gt;
 if [ -n &amp;quot;$1&amp;quot; ];then&lt;br /&gt;
         /usr/bin/sudo /usr/sbin/tunctl -u `whoami` -t $1&lt;br /&gt;
         /usr/bin/sudo /sbin/ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         /usr/bin/sudo /usr/sbin/brctl addif $switch $1&lt;br /&gt;
         exit 0&lt;br /&gt;
 else&lt;br /&gt;
         echo &amp;quot;Error: no interface specified&amp;quot;&lt;br /&gt;
         exit 1&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
* Generate a MAC address, either manually or using:&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # generate a random mac address for the qemu nic&lt;br /&gt;
 printf &#039;DE:AD:BE:EF:%02X:%02X\n&#039; $((RANDOM%256)) $((RANDOM%256))&lt;br /&gt;
&lt;br /&gt;
* Run each guest with the following, replacing $macaddress with the value from the previous step&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img -device e1000,netdev=net0,mac=$macaddress -netdev tap,id=net0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* If you don&#039;t want to run as root, the qemu-ifup must be executable by the user you want to use&lt;br /&gt;
* You can either create a system-wide qemu-ifup in /etc/qemu-ifup or use another one. In the latter case, run&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img -device e1000,netdev=net0,mac=$macaddress -netdev tap,id=net0,script=/path/to/qemu-ifup&lt;br /&gt;
&lt;br /&gt;
* Each guest on the private virtual network must have a different MAC address&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== public bridge ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; The here shown method, will not work with most(all?) wireless drivers, as these do not support bridging.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Use case:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* You want to assign an IP address to your virtual machines and make them accessible from your local network&lt;br /&gt;
* You also want performance out of your virtual machine.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Prerequisites:&#039;&#039;&#039;&lt;br /&gt;
* You need kvm up and running&lt;br /&gt;
* If you don&#039;t want to run as root, the user you want to use needs to have rw access to /dev/kvm&lt;br /&gt;
* You need the following commands installed on your system, and if you don&#039;t want to run as root, the user you want to use needs to be able to sudo the following command:&lt;br /&gt;
 /sbin/ip&lt;br /&gt;
 /usr/sbin/brctl&lt;br /&gt;
 /usr/sbin/tunctl&lt;br /&gt;
&lt;br /&gt;
* Your host system must be able to access the internet or the local network&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solution 1: using distro sysconfig script&#039;&#039;&#039;&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
!RedHat&#039;s way&lt;br /&gt;
!Debian&#039;s way&lt;br /&gt;
!SuSE&#039;s way&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
* Edit /etc/sysconfig/network-scripts/ifcfg-eth0&lt;br /&gt;
** comment out BOOTPROTO&lt;br /&gt;
** Add BRIDGE=br0&lt;br /&gt;
* Create /etc/sysconfig/network-scripts/ifcfg-br0&lt;br /&gt;
** The content should be:&lt;br /&gt;
 DEVICE=br0&lt;br /&gt;
 BOOTPROTO=dhcp&lt;br /&gt;
 ONBOOT=yes&lt;br /&gt;
 TYPE=Bridge&lt;br /&gt;
|&lt;br /&gt;
/etc/network/interfaces&lt;br /&gt;
&lt;br /&gt;
 # Replace old eth0 config with br0&lt;br /&gt;
 auto &amp;lt;strike&amp;gt;eth0&amp;lt;/strike&amp;gt; br0&lt;br /&gt;
&lt;br /&gt;
 # Use old eth0 config for br0, plus bridge stuff&lt;br /&gt;
 iface br0 inet dhcp&lt;br /&gt;
     bridge_ports    eth0&lt;br /&gt;
     bridge_stp      off&lt;br /&gt;
     bridge_maxwait  0&lt;br /&gt;
     bridge_fd       0&lt;br /&gt;
&lt;br /&gt;
|&lt;br /&gt;
* Start YaST&lt;br /&gt;
* Go to Network Configuration&lt;br /&gt;
* Add new device -&amp;gt; Bridge&lt;br /&gt;
* Tick your existing network device&lt;br /&gt;
* done&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* /etc/init.d/networking restart&lt;br /&gt;
* The bridge br0 should get the ip address (either static/dhcp) while the physical eth0 is left without ip address.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLANs&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Please note that the rtl8139 virtual network interface driver does not support VLANs. If you want to use VLANs with your virtual machine, you must use another virtual network interface like virtio. &lt;br /&gt;
&lt;br /&gt;
When using VLANs on a setup like this and no traffic is getting through to your guest(s), you might want to do:&lt;br /&gt;
 # cd /proc/sys/net/bridge&lt;br /&gt;
 # ls&lt;br /&gt;
 bridge-nf-call-arptables  bridge-nf-call-iptables&lt;br /&gt;
 bridge-nf-call-ip6tables  bridge-nf-filter-vlan-tagged&lt;br /&gt;
 # for f in bridge-nf-*; do echo 0 &amp;gt; $f; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solution 2: manual&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* You need to create a bridge, e-g:&lt;br /&gt;
 sudo /usr/sbin/brctl addbr br0&lt;br /&gt;
&lt;br /&gt;
* Add one of your physical interface to the bridge, e-g for eth0:&lt;br /&gt;
 sudo /usr/sbin/brctl  addif br0 eth0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 set -x&lt;br /&gt;
 &lt;br /&gt;
 switch=br0&lt;br /&gt;
 &lt;br /&gt;
 if [ -n &amp;quot;$1&amp;quot; ];then&lt;br /&gt;
         /usr/bin/sudo /usr/sbin/tunctl -u `whoami` -t $1&lt;br /&gt;
         /usr/bin/sudo /sbin/ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         /usr/bin/sudo /usr/sbin/brctl addif $switch $1&lt;br /&gt;
         exit 0&lt;br /&gt;
 else&lt;br /&gt;
         echo &amp;quot;Error: no interface specified&amp;quot;&lt;br /&gt;
         exit 1&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
* Generate a MAC address, either manually or using:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 # generate a random mac address for the qemu nic&lt;br /&gt;
 printf &#039;DE:AD:BE:EF:%02X:%02X\n&#039; $((RANDOM%256)) $((RANDOM%256))&lt;br /&gt;
&lt;br /&gt;
* Run each guest with the following, replacing $macaddress with the value from the previous step&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img -device e1000,netdev=net0,mac=$macaddress -netdev tap,id=net0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* If you don&#039;t want to run as root, the qemu-ifup must be executable by the user you want to use&lt;br /&gt;
* You can either create a system-wide qemu-ifup in /etc/qemu-ifup or use another one. In the latter case, run&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img -device e1000,netdev=net0,mac=$macaddress -netdev tap,id=net0,script=/path/to/qemu-ifup&lt;br /&gt;
&lt;br /&gt;
* Each guest on the network must have a different MAC address&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== iptables/routing ==&lt;br /&gt;
&lt;br /&gt;
you can also connect your guest vm to a tap in your host. then setting iptables rules in your host to become a router + firewall for your vm.&lt;br /&gt;
&lt;br /&gt;
Routing would be done simply by creating the default route on the client to the IP of the host (and allowing IP forwarding) and setting a route to the tap? device of the client on the host.&lt;br /&gt;
&lt;br /&gt;
Test the setup beforehand:&lt;br /&gt;
&lt;br /&gt;
*Hostside: Allow IPv4 forwarding and add route to client (could be put in a script - route has to be added after the client has started):&lt;br /&gt;
&lt;br /&gt;
 sysctl -w net.ipv4.ip_forward=1                 # allow forwarding of IPv4&lt;br /&gt;
 route add -host &amp;lt;ip-of-client&amp;gt; dev &amp;lt;tap-device&amp;gt; # add route to the client&lt;br /&gt;
&lt;br /&gt;
*Clientside: Default GW of the client is of course then the host (&amp;lt;ip-of-host&amp;gt; has to be in same subnet as &amp;lt;ip-of-client&amp;gt; ...):&lt;br /&gt;
&lt;br /&gt;
 route add default gw &amp;lt;ip-of-host&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Clientside v2: If you host IP is not on the same subnet as &amp;lt;ip-of-client&amp;gt;, then you must manually add the route to host before you create default route:&lt;br /&gt;
&lt;br /&gt;
 route add -host &amp;lt;ip-of-host&amp;gt; dev &amp;lt;network-interface&amp;gt;&lt;br /&gt;
 route add default gw &amp;lt;ip-of-host&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== vde ==&lt;br /&gt;
&lt;br /&gt;
Another option is using vde (virtual distributed ethernet).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== performance ==&lt;br /&gt;
&lt;br /&gt;
Data on benchmarking results should go in here.&lt;br /&gt;
There&#039;s now a page dedicated to ideas for improving&lt;br /&gt;
[[Networking Performance]].&lt;br /&gt;
&lt;br /&gt;
Some 10G NIC performance comparison between VFIO passthrough and virtio [[VFIO V.S. virtio]]&lt;br /&gt;
&lt;br /&gt;
== Compatibility ==&lt;br /&gt;
&lt;br /&gt;
There&#039;s another, old and obsolete syntax of specifying network for virtual machines.  Above examples uses -netdev..-device model, old way used -net..-net pairs.  For example,&lt;br /&gt;
&lt;br /&gt;
 -netdev tap,id=net0 -device e1000,netdev=net0,mac=52:54:00:12:34:56&lt;br /&gt;
&lt;br /&gt;
is about the same as old&lt;br /&gt;
&lt;br /&gt;
 -net tap,vlan=0 -net nic,vlan=0,model=e1000,macaddr=52:54:00:12:34:56&lt;br /&gt;
&lt;br /&gt;
(note mac =&amp;gt; macaddr parameter change as well; vlan=0 is the default).&lt;br /&gt;
&lt;br /&gt;
Old way used the notion of &amp;quot;VLANs&amp;quot; - these are QEMU VLANS, which has nothing to do with 802.1q VLANs. Qemu VLANs are numbered starting with 0, and it&#039;s possible to connect one or more devices (either host side, like -net tap, or guest side, like -net nic) to each VLAN, and, in particular, it&#039;s possible to connect more than 2 devices to a VLAN.  Each device in a VLAN gets all traffic received by every device in it.  This model was very confusing for the user (especially when a guest has more than one NIC).&lt;br /&gt;
&lt;br /&gt;
In new model, each host side correspond to just one guest side, forming a pair of devices based on -netdev id=  and -device netdev= parameters.  It is less confusing, it is faster (because it&#039;s always 1:1 pair), and it supports more parameters than old -net..-net way.&lt;br /&gt;
&lt;br /&gt;
However, -net..-net is still supported, used widely, and mentioned in lots of various HOWTOs and guides around the world.  It is also a bit shorter and so faster to type.&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Tuning_KVM&amp;diff=173187</id>
		<title>Tuning KVM</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Tuning_KVM&amp;diff=173187"/>
		<updated>2015-05-08T08:29:38Z</updated>

		<summary type="html">&lt;p&gt;Robert: /* Networking */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== CPU Performance ==&lt;br /&gt;
&lt;br /&gt;
Modern processors come with a wide variety of performance enhancing features such as streaming instructions sets (sse) and other performance-enhancing instructions.  These features vary from processor to processor.&lt;br /&gt;
&lt;br /&gt;
QEMU and KVM default to a compatible subset of cpu features, so that if you change your host processor, or perform a live migration, the guest will see its cpu features unchanged.  This is great for compatibility but comes at a performance cost.&lt;br /&gt;
&lt;br /&gt;
To pass all available host processor features to the guest, use the command line switch&lt;br /&gt;
&lt;br /&gt;
  qemu &#039;&#039;&#039;-cpu host&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
if you wish to retain compatibility, you can expose selected features to your guest.  If all your hosts have these features, compatibility is retained:&lt;br /&gt;
&lt;br /&gt;
  qemu &#039;&#039;&#039;-cpu qemu64,+ssse3,+sse4.1,+sse4.2,+x2apic&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To see the difference between the capabilities of the host CPU versus the guest, just compare the output of the following commands on each system:&lt;br /&gt;
&lt;br /&gt;
   cat /proc/cpuinfo | grep flags | uniq&lt;br /&gt;
&lt;br /&gt;
For example, the default setting on a 64 bit host machine is  &amp;quot;-cpu qemu64&amp;quot;.&amp;lt;br /&amp;gt; This  includes the following flags:&lt;br /&gt;
&lt;br /&gt;
    fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx lm up pni hypervisor&lt;br /&gt;
&lt;br /&gt;
The host itself might support other flags like cx16, mmxext, and so on. &lt;br /&gt;
&lt;br /&gt;
See [http://blog.incase.de/index.php/cpu-feature-flags-and-their-meanings/  CPU Feature Flags And Their Meanings] (and other resources on the web) for more information.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Networking ==&lt;br /&gt;
&lt;br /&gt;
QEMU defaults to user-mode networking (slirp), which is available without prior setup and without administrative privileges on the host.  It is also unfortunately very slow.  To get high performance networking, switch to a bridged setup via the -net tap command line switches.&lt;br /&gt;
&lt;br /&gt;
  qemu -net nic,model=virtio,mac=... &#039;&#039;&#039;-net tap,ifname=...&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
  qemu -net nic,model=virtio,mac=... &#039;&#039;&#039;-net bridge,br=...,helper=/usr/local/libexec/qemu-bridge-helper&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Besides virtio, approach of vt-d passthrough give high (even higher) performance as well.&lt;br /&gt;
&lt;br /&gt;
  qemu &#039;&#039;&#039;-net none -device vfio-pci,host=...&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
QEMU also defaults to the RTL8139 network interface card (NIC) model.  Again this card is compatible with most guests, but does not offer the best performance.  If your guest supports it, switch to the virtio model:&lt;br /&gt;
&lt;br /&gt;
  qemu -net nic,&#039;&#039;&#039;model=virtio&#039;&#039;&#039;,mac=... -net tap,ifname=...&lt;br /&gt;
&lt;br /&gt;
== Storage ==&lt;br /&gt;
&lt;br /&gt;
QEMU supports a wide variety for storage formats and back-ends.  Easiest to use are the raw and qcow2 formats, but for the best performance it is best to use a raw partition.  You can create either a logical volume or a partition and assign it to the guest:&lt;br /&gt;
&lt;br /&gt;
  qemu -drive &#039;&#039;&#039;file=/dev/mapper/ImagesVolumeGroup-Guest1&#039;&#039;&#039;,cache=none,if=virtio&lt;br /&gt;
&lt;br /&gt;
QEMU also supports a wide variety of caching modes. If you&#039;re using raw volumes or partitions, it is best to avoid the cache completely, which reduces data copies and bus traffic:&lt;br /&gt;
&lt;br /&gt;
  qemu -drive file=/dev/mapper/ImagesVolumeGroup-Guest1,&#039;&#039;&#039;cache=none&#039;&#039;&#039;,if=virtio&lt;br /&gt;
&lt;br /&gt;
As with networking, QEMU supports several storage interfaces.  The default, IDE, is highly supported by guests but may be slow, especially with disk arrays.  If your guest supports it, use the virtio interface:&lt;br /&gt;
&lt;br /&gt;
  qemu -drive file=/dev/mapper/ImagesVolumeGroup-Guest1,cache=none,&#039;&#039;&#039;if=virtio&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Don&#039;t use the linux filesystem btrfs on the host for the image files. It will result in low IO performance. The kvm guest may even freeze when high IO traffic is done on the guest.&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Tuning_KVM&amp;diff=173186</id>
		<title>Tuning KVM</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Tuning_KVM&amp;diff=173186"/>
		<updated>2015-05-08T08:23:43Z</updated>

		<summary type="html">&lt;p&gt;Robert: /* Networking */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== CPU Performance ==&lt;br /&gt;
&lt;br /&gt;
Modern processors come with a wide variety of performance enhancing features such as streaming instructions sets (sse) and other performance-enhancing instructions.  These features vary from processor to processor.&lt;br /&gt;
&lt;br /&gt;
QEMU and KVM default to a compatible subset of cpu features, so that if you change your host processor, or perform a live migration, the guest will see its cpu features unchanged.  This is great for compatibility but comes at a performance cost.&lt;br /&gt;
&lt;br /&gt;
To pass all available host processor features to the guest, use the command line switch&lt;br /&gt;
&lt;br /&gt;
  qemu &#039;&#039;&#039;-cpu host&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
if you wish to retain compatibility, you can expose selected features to your guest.  If all your hosts have these features, compatibility is retained:&lt;br /&gt;
&lt;br /&gt;
  qemu &#039;&#039;&#039;-cpu qemu64,+ssse3,+sse4.1,+sse4.2,+x2apic&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To see the difference between the capabilities of the host CPU versus the guest, just compare the output of the following commands on each system:&lt;br /&gt;
&lt;br /&gt;
   cat /proc/cpuinfo | grep flags | uniq&lt;br /&gt;
&lt;br /&gt;
For example, the default setting on a 64 bit host machine is  &amp;quot;-cpu qemu64&amp;quot;.&amp;lt;br /&amp;gt; This  includes the following flags:&lt;br /&gt;
&lt;br /&gt;
    fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx lm up pni hypervisor&lt;br /&gt;
&lt;br /&gt;
The host itself might support other flags like cx16, mmxext, and so on. &lt;br /&gt;
&lt;br /&gt;
See [http://blog.incase.de/index.php/cpu-feature-flags-and-their-meanings/  CPU Feature Flags And Their Meanings] (and other resources on the web) for more information.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Networking ==&lt;br /&gt;
&lt;br /&gt;
QEMU defaults to user-mode networking (slirp), which is available without prior setup and without administrative privileges on the host.  It is also unfortunately very slow.  To get high performance networking, switch to a bridged setup via the -net tap command line switches.&lt;br /&gt;
&lt;br /&gt;
  qemu -net nic,model=virtio,mac=... &#039;&#039;&#039;-net tap,ifname=...&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
  qemu -net nic,model=virtio,mac=... &#039;&#039;&#039;-net bridge,br=...,helper=/usr/local/libexec/qemu-bridge-helper&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
QEMU also defaults to the RTL8139 network interface card (NIC) model.  Again this card is compatible with most guests, but does not offer the best performance.  If your guest supports it, switch to the virtio model:&lt;br /&gt;
&lt;br /&gt;
  qemu -net nic,&#039;&#039;&#039;model=virtio&#039;&#039;&#039;,mac=... -net tap,ifname=...&lt;br /&gt;
&lt;br /&gt;
== Storage ==&lt;br /&gt;
&lt;br /&gt;
QEMU supports a wide variety for storage formats and back-ends.  Easiest to use are the raw and qcow2 formats, but for the best performance it is best to use a raw partition.  You can create either a logical volume or a partition and assign it to the guest:&lt;br /&gt;
&lt;br /&gt;
  qemu -drive &#039;&#039;&#039;file=/dev/mapper/ImagesVolumeGroup-Guest1&#039;&#039;&#039;,cache=none,if=virtio&lt;br /&gt;
&lt;br /&gt;
QEMU also supports a wide variety of caching modes. If you&#039;re using raw volumes or partitions, it is best to avoid the cache completely, which reduces data copies and bus traffic:&lt;br /&gt;
&lt;br /&gt;
  qemu -drive file=/dev/mapper/ImagesVolumeGroup-Guest1,&#039;&#039;&#039;cache=none&#039;&#039;&#039;,if=virtio&lt;br /&gt;
&lt;br /&gt;
As with networking, QEMU supports several storage interfaces.  The default, IDE, is highly supported by guests but may be slow, especially with disk arrays.  If your guest supports it, use the virtio interface:&lt;br /&gt;
&lt;br /&gt;
  qemu -drive file=/dev/mapper/ImagesVolumeGroup-Guest1,cache=none,&#039;&#039;&#039;if=virtio&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Don&#039;t use the linux filesystem btrfs on the host for the image files. It will result in low IO performance. The kvm guest may even freeze when high IO traffic is done on the guest.&lt;/div&gt;</summary>
		<author><name>Robert</name></author>
	</entry>
</feed>