<?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=Ckotichas</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=Ckotichas"/>
	<link rel="alternate" type="text/html" href="https://linux-kvm.org/page/Special:Contributions/Ckotichas"/>
	<updated>2026-04-05T23:14:18Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.5</generator>
	<entry>
		<id>https://linux-kvm.org/index.php?title=KVM_Features&amp;diff=173905</id>
		<title>KVM Features</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=KVM_Features&amp;diff=173905"/>
		<updated>2018-03-10T10:20:25Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= KVM-Features =&lt;br /&gt;
&lt;br /&gt;
This is a possibly incomplete list of KVM features, together with their status. Feel free to update any of them as you see fit.&lt;br /&gt;
&lt;br /&gt;
As a guideline, there is a feature description template in [[FeatureDescription/Template|here]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* [[MonitorProtocol|QMP]] - Qemu Monitor Protocol&lt;br /&gt;
* [[KSM|KSM]] - Kernel Samepage Merging&lt;br /&gt;
* [[KVMClock|KVM Paravirtual Clock]] - A paravirtual timesource for KVM&lt;br /&gt;
* [[CPUHotPlug|CPU Hotplug support]] - Adding CPU&#039;s on the fly&lt;br /&gt;
* [[pcihotplug|PCI Hotplug support]] - Adding PCI devices on the fly&lt;br /&gt;
* [[VMchannel_Requirements | vmchannel ]] - Communication channel between the host and guests&lt;br /&gt;
* [[migration]] - Migrating virtual machines&lt;br /&gt;
* [[Nested Guests]] - Running virtual machines within virtual machines&lt;br /&gt;
* [[VhostNet|vhost]] - &lt;br /&gt;
* [[scsi|SCSI disk emulation]] - &lt;br /&gt;
* [[virtio|Virtio Devices]] - &lt;br /&gt;
* [[CPU clustering]] - &lt;br /&gt;
* [[hpet]] - &lt;br /&gt;
* [[Device assignment]] - &lt;br /&gt;
* [[pxe boot]] - &lt;br /&gt;
* [[iscsi boot]] - &lt;br /&gt;
* [[x2apic]] -&lt;br /&gt;
* [[Floppy]] -&lt;br /&gt;
* [[cdrom|CDROM]] - &lt;br /&gt;
* [[USB]] -&lt;br /&gt;
* [[UsbPassthrough|USB host device passthrough]] - &lt;br /&gt;
* [[Sound]] -&lt;br /&gt;
* [[UserspaceIrqchip|Userspace irqchip emulation]] -&lt;br /&gt;
* [[UserspacePit|Userspace pit emulation]] -&lt;br /&gt;
* [[Balloon|Balloon memory driver]] -  &lt;br /&gt;
* [[LargePages|Large pages support]] -&lt;br /&gt;
* [[StableABI|Stable Guest ABI]] -&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=KVM_Features&amp;diff=173904</id>
		<title>KVM Features</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=KVM_Features&amp;diff=173904"/>
		<updated>2018-03-10T10:19:44Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= KVM-Features =&lt;br /&gt;
&lt;br /&gt;
This is a possibly incomplete list of KVM features, together with their status. Feel free to update any of them as you see fit.&lt;br /&gt;
&lt;br /&gt;
As a guideline, there is a feature description template in [[FeatureDescription/Template|here]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* [[MonitorProtocol|QMP]] - Qemu Monitor Protocol&lt;br /&gt;
* [[KSM|KSM]] - Kernel Samepage Merging&lt;br /&gt;
* [[KVMClock|Kvm Paravirtual Clock]] - A Paravirtual timesource for KVM&lt;br /&gt;
* [[CPUHotPlug|CPU Hotplug support]] - Adding CPU&#039;s on the fly&lt;br /&gt;
* [[pcihotplug|PCI Hotplug support]] - Adding PCI devices on the fly&lt;br /&gt;
* [[VMchannel_Requirements | vmchannel ]] - Communication channel between the host and guests&lt;br /&gt;
* [[migration]] - Migrating virtual machines&lt;br /&gt;
* [[Nested Guests]] - Running virtual machines within virtual machines&lt;br /&gt;
* [[VhostNet|vhost]] - &lt;br /&gt;
* [[scsi|SCSI disk emulation]] - &lt;br /&gt;
* [[virtio|Virtio Devices]] - &lt;br /&gt;
* [[CPU clustering]] - &lt;br /&gt;
* [[hpet]] - &lt;br /&gt;
* [[Device assignment]] - &lt;br /&gt;
* [[pxe boot]] - &lt;br /&gt;
* [[iscsi boot]] - &lt;br /&gt;
* [[x2apic]] -&lt;br /&gt;
* [[Floppy]] -&lt;br /&gt;
* [[cdrom|CDROM]] - &lt;br /&gt;
* [[USB]] -&lt;br /&gt;
* [[UsbPassthrough|USB host device passthrough]] - &lt;br /&gt;
* [[Sound]] -&lt;br /&gt;
* [[UserspaceIrqchip|Userspace irqchip emulation]] -&lt;br /&gt;
* [[UserspacePit|Userspace pit emulation]] -&lt;br /&gt;
* [[Balloon|Balloon memory driver]] -  &lt;br /&gt;
* [[LargePages|Large pages support]] -&lt;br /&gt;
* [[StableABI|Stable Guest ABI]] -&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Sound&amp;diff=173903</id>
		<title>Sound</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Sound&amp;diff=173903"/>
		<updated>2018-03-10T10:16:39Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Windows XP ==&lt;br /&gt;
Windows XP recognizes QEMU&#039;s emulated Ensoniq AudioPCI ES1370 device automatically.&lt;br /&gt;
== Windows Vista ==&lt;br /&gt;
TBD&lt;br /&gt;
== Windows 7 ==&lt;br /&gt;
Intel 82801AA AC97 emulation works with Windows 7, but is detected as a &amp;quot;Multimedia Audio Controller&amp;quot; device. The correct driver can be installed through the Device Manager menu by selecting &amp;quot;Update Driver&amp;quot; in the device&#039;s Properties window. Windows will automatically obtain the correct driver from the internet.&lt;br /&gt;
&lt;br /&gt;
ENSONIQ AudioPCI ES1370 emulation is also recognised by Windows with the same process, but the driver is prone to crashing.&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Windows7Install&amp;diff=173902</id>
		<title>Windows7Install</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Windows7Install&amp;diff=173902"/>
		<updated>2018-03-10T10:05:24Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
Some facts:&lt;br /&gt;
* Installing Windows 7 with IDE drivers requires about 12 hours (qemu-kvm 0.12.5)&lt;br /&gt;
* Windows 7 can be installed with virtio disk (requires guest drivers during installation)&lt;br /&gt;
* Windows 7 64-bit requires signed drivers (available from August 2010 - thanks to RedHat)&lt;br /&gt;
* Installation with virtio drivers works well, but Windows might not reboot at the end (see troubleshooting)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Signed guest drivers are available here:&lt;br /&gt;
* https://fedoraproject.org/wiki/Windows_Virtio_Drivers&lt;br /&gt;
&lt;br /&gt;
= Installation steps =&lt;br /&gt;
* Download the guest drivers&lt;br /&gt;
* Configure the virtual disk as virtio&lt;br /&gt;
* Start the installation&lt;br /&gt;
** When the installer asks you to select a drive, load the virtio driver (viostor)&lt;br /&gt;
** The installation should take 45 to 60 minutes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t want to swap the CD, configure 2 CD-ROM devices. Use the guest drivers disc as the first CD-ROM device, and Windows installation disc as the second device, or else it won&#039;t boot.&lt;br /&gt;
&lt;br /&gt;
Once installed, if you did choose virtio for the network card, you will also need to update the driver.&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
&lt;br /&gt;
== Cannot boot - broken MBR ==&lt;br /&gt;
Upon reboot, the screen displays: &lt;br /&gt;
&amp;lt;div style=&amp;quot;border:1px solid gray; background:black;color:white;padding: 10px;width:500px;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Starting SeaBIOS (version 0.5.1-20100825_131917-polaris)&lt;br /&gt;
&lt;br /&gt;
Booting from Hard Disk...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The libvirt log shows&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
kvm: unhandled exit 80000021&lt;br /&gt;
kvm_run returned -22&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The solution is to reinstall the MBR. Here is a tutorial for doing this: http://www.sevenforums.com/tutorials/20864-mbr-restore-windows-7-master-boot-record.html&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Windows7Install&amp;diff=173901</id>
		<title>Windows7Install</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Windows7Install&amp;diff=173901"/>
		<updated>2018-03-10T10:01:29Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
Some facts:&lt;br /&gt;
* Installing Windows 7 with IDE drivers requires about 12 hours (qemu-kvm 0.12.5)&lt;br /&gt;
* Windows 7 can be installed with virtio disk (requires guest drivers during installation)&lt;br /&gt;
* Windows 7 64-bit requires signed drivers (available from August 2010 - thanks to RedHat)&lt;br /&gt;
* Installation with virtio drivers works well, but Windows might not reboot at the end (see troubleshooting)&lt;br /&gt;
&lt;br /&gt;
Signed guest drivers are available here:&lt;br /&gt;
* https://fedoraproject.org/wiki/Windows_Virtio_Drivers&lt;br /&gt;
&lt;br /&gt;
= Installation steps =&lt;br /&gt;
* Download the guest drivers&lt;br /&gt;
* Configure the virtual disk as virtio&lt;br /&gt;
* Start the installation&lt;br /&gt;
** When the installer asks you to select a drive, load the virtio driver (viostor)&lt;br /&gt;
** The installation should take 45 to 60 minutes&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t want to swap the CD, configure 2 CD-ROMs. Use the guest drivers as first CD-ROM, and Windows installation disk as second, else it won&#039;t boot.&lt;br /&gt;
&lt;br /&gt;
Once installed, if you did choose virtio for the network card, you will also need to update the driver.&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
&lt;br /&gt;
== Cannot boot - broken MBR ==&lt;br /&gt;
Upon reboot, the screen displays: &lt;br /&gt;
&amp;lt;div style=&amp;quot;border:1px solid gray; background:black;color:white;padding: 10px;width:500px;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Starting SeaBIOS (version 0.5.1-20100825_131917-polaris)&lt;br /&gt;
&lt;br /&gt;
Booting from Hard Disk...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The libvirt log shows&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
kvm: unhandled exit 80000021&lt;br /&gt;
kvm_run returned -22&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The solution is to reinstall the MBR. Here is a tutorial for doing this: http://www.sevenforums.com/tutorials/20864-mbr-restore-windows-7-master-boot-record.html&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=HOWTO&amp;diff=173804</id>
		<title>HOWTO</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=HOWTO&amp;diff=173804"/>
		<updated>2017-01-20T03:23:35Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* Operating System related */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Howto&#039;s =&lt;br /&gt;
&lt;br /&gt;
== General ==&lt;br /&gt;
* [http://www.ibm.com/support/knowledgecenter/linuxonibm/liabq/liabqquick.htm IBM PowerKVM: Quick Start Guides for installing PowerKVM]&lt;br /&gt;
* [http://www.ibm.com/support/knowledgecenter/linuxonibm/liabo/liabokickoff.htm IBM PowerKVM]&lt;br /&gt;
* [http://www.ibm.com/support/knowledgecenter/linuxonibm/liaai/kvminstall/liaaikvminstallstart.htm IBM Linux Blueprint: Quick Start Guide for installing and running KVM]&lt;br /&gt;
* [[HOWTO1 | Getting KVM to run on your machine]]&lt;br /&gt;
* [[Choose the right kvm &amp;amp; kernel version]]&lt;br /&gt;
* [[How To Migrate From Vmware To KVM]]&lt;br /&gt;
* [http://www.scribd.com/doc/17380947/Migrating-from-UML-to-Xen-and-Kernel-Based-Virtual-Machines Migrating User Mode Linux to Xen and KVM]&lt;br /&gt;
&lt;br /&gt;
== Network related ==&lt;br /&gt;
&lt;br /&gt;
* [[Networking| Setting guest network]]&lt;br /&gt;
* [[NetConsole| set up a network console]]&lt;br /&gt;
&lt;br /&gt;
== Hardware related ==&lt;br /&gt;
&lt;br /&gt;
* [[How to assign devices with VT-d in KVM]]&lt;br /&gt;
* [[Enable VT-X on Mac Pro (Early 2008)]] &lt;br /&gt;
&lt;br /&gt;
=== USB ===&lt;br /&gt;
* [[USB Host Device Assigned to Guest]]&lt;br /&gt;
* [[usb related]]&lt;br /&gt;
&lt;br /&gt;
=== Ethernet ===&lt;br /&gt;
* [[ethernet_related]]&lt;br /&gt;
&lt;br /&gt;
=== PCI ===&lt;br /&gt;
* [[hotadd pci devices]]&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
* Using [[Sound]] in the guest&lt;br /&gt;
&lt;br /&gt;
=== Display ===&lt;br /&gt;
* Using qxl and [[SPICE]] in the guest&lt;br /&gt;
&lt;br /&gt;
=== virtio ===&lt;br /&gt;
&lt;br /&gt;
* [[boot from virtio block device]]&lt;br /&gt;
* [[Using VirtIO NIC|use virtio_net interface]] in the guest (Debian)&lt;br /&gt;
&lt;br /&gt;
=== vhost ===&lt;br /&gt;
* [[UsingVhost|Using vhost]]&lt;br /&gt;
&lt;br /&gt;
=== cdrom ===&lt;br /&gt;
* [[Change cdrom| Changing disks in the cdrom drive]]&lt;br /&gt;
&lt;br /&gt;
=== sharing files with the host ===&lt;br /&gt;
* Using [[9p virtio]] to share files between host and guest&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operating System related ==&lt;br /&gt;
&lt;br /&gt;
=== Gentoo ===&lt;br /&gt;
* [http://wiki.gentoo.org/wiki/QEMU Wiki article].&lt;br /&gt;
* [[KvmOnGentoo|KVM on Gentoo hosts]]&lt;br /&gt;
&lt;br /&gt;
=== Ubuntu ===&lt;br /&gt;
* [http://www.howtoforge.com/using-kvm-on-ubuntu-gutsy-gibbon using-kvm-on-ubuntu-gutsy-gibbon]&lt;br /&gt;
* [[AnthonyLiguori/Networking| Setting up NAT with KVM in Ubuntu]]&lt;br /&gt;
* [https://help.ubuntu.com/community/KVM Running Guest Systems on Ubuntu 7.04 Feisty Fawn]&lt;br /&gt;
* [http://www.howtoforge.com/virtualization-with-kvm-on-ubuntu-9.04 Virtualization With KVM On Ubuntu 9.04 Jaunty]&lt;br /&gt;
&lt;br /&gt;
=== Fedora ===&lt;br /&gt;
* [http://fedoraproject.org/wiki/Virtualization_Quick_Start Fedora Virt Quick Start]&lt;br /&gt;
&lt;br /&gt;
=== Arch ===&lt;br /&gt;
* [http://wiki.archlinux.org/index.php/Kvm Setting up KVM on Arch]&lt;br /&gt;
* [http://wiki.archlinux.org/index.php/Qemu Detailed QEMU Tutorial ]&lt;br /&gt;
&lt;br /&gt;
=== RHEL/CentOS 7 ===&lt;br /&gt;
* [http://linux.dell.com/files/whitepapers/KVM_Virtualization_in_RHEL_7_Made_Easy.pdf KVM Virtualization in RHEL 7 Made Easy]&lt;br /&gt;
&lt;br /&gt;
=== BSD ===&lt;br /&gt;
* [http://www.linux-kvm.org/page/BSD KVM on BSD, FreeBSD]&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
* [[WindowsGuestDrivers|Information about guest drivers]]&lt;br /&gt;
* [[Windows7Install|Install Windows 7]]&lt;br /&gt;
* [http://wp.libpf.com/?p=186 Windows 7 as guest on Debian squeeze] - with libvirt&#039;s virt-install recipe and virtio disk driver step-by-step instructions&lt;br /&gt;
* [http://www.returnbooleantrue.com/2015/04/making-your-windows-kvm-guest-boxes-fly.html Installing virtio drivers in Windows for Ubuntu hosts]&lt;br /&gt;
&lt;br /&gt;
=== Windows Vista ===&lt;br /&gt;
* [[Vista Networking Workaround]]&lt;br /&gt;
&lt;br /&gt;
== Scripting &amp;amp; Software ==&lt;br /&gt;
* [[HowToConfigScript|Configuration Script for KVM]] - a complete management utility, configuration file format, and init script.&lt;br /&gt;
* [http://www.roessner-net.com/?p=219 Another script for KVM] - Init scripts for kvm, using it with time scheduled start order (German)&lt;br /&gt;
* [[simple shell script to manage your virtual machine with bridged networking]]&lt;br /&gt;
* [http://www.papercut.com/blog/chris/2008/11/14/using-kvm-to-securely-host-servers-in-a-dmz/ Hosting your VMs in a DMZ] - a management and configuration script to assist with setting up a VM in a semi-secured demilitarized zone.&lt;br /&gt;
* [http://pve.proxmox.com/wiki/Bare-metal_ISO_Installer Bare-metal] installer with KVM&lt;br /&gt;
* [[kvmtools|Python scripts to manage qemu-kvm guest from cmdline]] - yet another qemu-kvm script &lt;br /&gt;
* [https://github.com/tmartinfr/kvm-simple-init kvm-simple-init] - Simple init script to manage KVM virtual machines&lt;br /&gt;
&lt;br /&gt;
=== libvirt ===&lt;br /&gt;
&lt;br /&gt;
* [[Running libvirt with KVM]]&lt;br /&gt;
&lt;br /&gt;
== Other ==&lt;br /&gt;
&lt;br /&gt;
* [[HOWTO VMGL]] - OpenGL support for Linux guests&lt;br /&gt;
&lt;br /&gt;
[[Category:Docs]][[Category:HowTo]]&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Choose_the_right_kvm_%26_kernel_version&amp;diff=173803</id>
		<title>Choose the right kvm &amp; kernel version</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Choose_the_right_kvm_%26_kernel_version&amp;diff=173803"/>
		<updated>2017-01-20T03:19:04Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* Three Components */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Three Components ==&lt;br /&gt;
&lt;br /&gt;
A functional KVM system consists of three main components:&lt;br /&gt;
&lt;br /&gt;
* Linux Module&lt;br /&gt;
* User Space Application&lt;br /&gt;
* Guest Virtio Driver&lt;br /&gt;
&lt;br /&gt;
== Linux Module ==&lt;br /&gt;
&lt;br /&gt;
KVM requires a few kernel modules in order to support full virtualization. Most distributions contain these modules by default, but they may need to be loaded manually. You can check if the KVM module is currently loaded with:&lt;br /&gt;
&lt;br /&gt;
 lsmod | grep kvm&lt;br /&gt;
&lt;br /&gt;
If the module is not loaded, simply issue:&lt;br /&gt;
&lt;br /&gt;
 modprobe kvm&lt;br /&gt;
&lt;br /&gt;
You may also need to load the appropriate module for your processor:&lt;br /&gt;
&lt;br /&gt;
 modprobe kvm_intel  # Intel processors&lt;br /&gt;
 modprobe kvm_amd    # AMD processors&lt;br /&gt;
&lt;br /&gt;
=== Guest virtio driver ===&lt;br /&gt;
&lt;br /&gt;
Generally, there are no special requirements for the guest operating system. If you are using para-virtualized disks or network adapters however, make sure you have loaded the virtio_pci.ko, virtio_rng.ko, virtio_blk.ko, and virtio_net.ko modules (available since kernel version 2.6.25).&lt;br /&gt;
&lt;br /&gt;
Refer to [[Virtio]] for more information&lt;br /&gt;
&lt;br /&gt;
[[Category:Architecture]][[Category:Docs]][[Category:Historical]][[Category:HowTo]]&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Choose_the_right_kvm_%26_kernel_version&amp;diff=173802</id>
		<title>Choose the right kvm &amp; kernel version</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Choose_the_right_kvm_%26_kernel_version&amp;diff=173802"/>
		<updated>2017-01-20T03:16:59Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* Linux Module */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Three Components ==&lt;br /&gt;
&lt;br /&gt;
To make it work, you need to get the right version for three components:&lt;br /&gt;
&lt;br /&gt;
* Linux Module&lt;br /&gt;
* User Space Application&lt;br /&gt;
* Guest Virtio Driver   &lt;br /&gt;
&lt;br /&gt;
== Linux Module ==&lt;br /&gt;
&lt;br /&gt;
KVM requires a few kernel modules in order to support full virtualization. Most distributions contain these modules by default, but they may need to be loaded manually. You can check if the KVM module is currently loaded with:&lt;br /&gt;
&lt;br /&gt;
 lsmod | grep kvm&lt;br /&gt;
&lt;br /&gt;
If the module is not loaded, simply issue:&lt;br /&gt;
&lt;br /&gt;
 modprobe kvm&lt;br /&gt;
&lt;br /&gt;
You may also need to load the appropriate module for your processor:&lt;br /&gt;
&lt;br /&gt;
 modprobe kvm_intel  # Intel processors&lt;br /&gt;
 modprobe kvm_amd    # AMD processors&lt;br /&gt;
&lt;br /&gt;
=== Guest virtio driver ===&lt;br /&gt;
&lt;br /&gt;
Generally, there are no special requirements for the guest operating system. If you are using para-virtualized disks or network adapters however, make sure you have loaded the virtio_pci.ko, virtio_rng.ko, virtio_blk.ko, and virtio_net.ko modules (available since kernel version 2.6.25).&lt;br /&gt;
&lt;br /&gt;
Refer to [[Virtio]] for more information&lt;br /&gt;
&lt;br /&gt;
[[Category:Architecture]][[Category:Docs]][[Category:Historical]][[Category:HowTo]]&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=HOWTO&amp;diff=173801</id>
		<title>HOWTO</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=HOWTO&amp;diff=173801"/>
		<updated>2017-01-20T02:54:52Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* General */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Howto&#039;s =&lt;br /&gt;
&lt;br /&gt;
== General ==&lt;br /&gt;
* [http://www.ibm.com/support/knowledgecenter/linuxonibm/liabq/liabqquick.htm IBM PowerKVM: Quick Start Guides for installing PowerKVM]&lt;br /&gt;
* [http://www.ibm.com/support/knowledgecenter/linuxonibm/liabo/liabokickoff.htm IBM PowerKVM]&lt;br /&gt;
* [http://www.ibm.com/support/knowledgecenter/linuxonibm/liaai/kvminstall/liaaikvminstallstart.htm IBM Linux Blueprint: Quick Start Guide for installing and running KVM]&lt;br /&gt;
* [[HOWTO1 | Getting KVM to run on your machine]]&lt;br /&gt;
* [[Choose the right kvm &amp;amp; kernel version]]&lt;br /&gt;
* [[How To Migrate From Vmware To KVM]]&lt;br /&gt;
* [http://www.scribd.com/doc/17380947/Migrating-from-UML-to-Xen-and-Kernel-Based-Virtual-Machines Migrating User Mode Linux to Xen and KVM]&lt;br /&gt;
&lt;br /&gt;
== Network related ==&lt;br /&gt;
&lt;br /&gt;
* [[Networking| Setting guest network]]&lt;br /&gt;
* [[NetConsole| set up a network console]]&lt;br /&gt;
&lt;br /&gt;
== Hardware related ==&lt;br /&gt;
&lt;br /&gt;
* [[How to assign devices with VT-d in KVM]]&lt;br /&gt;
* [[Enable VT-X on Mac Pro (Early 2008)]] &lt;br /&gt;
&lt;br /&gt;
=== USB ===&lt;br /&gt;
* [[USB Host Device Assigned to Guest]]&lt;br /&gt;
* [[usb related]]&lt;br /&gt;
&lt;br /&gt;
=== Ethernet ===&lt;br /&gt;
* [[ethernet_related]]&lt;br /&gt;
&lt;br /&gt;
=== PCI ===&lt;br /&gt;
* [[hotadd pci devices]]&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
* Using [[Sound]] in the guest&lt;br /&gt;
&lt;br /&gt;
=== Display ===&lt;br /&gt;
* Using qxl and [[SPICE]] in the guest&lt;br /&gt;
&lt;br /&gt;
=== virtio ===&lt;br /&gt;
&lt;br /&gt;
* [[boot from virtio block device]]&lt;br /&gt;
* [[Using VirtIO NIC|use virtio_net interface]] in the guest (Debian)&lt;br /&gt;
&lt;br /&gt;
=== vhost ===&lt;br /&gt;
* [[UsingVhost|Using vhost]]&lt;br /&gt;
&lt;br /&gt;
=== cdrom ===&lt;br /&gt;
* [[Change cdrom| Changing disks in the cdrom drive]]&lt;br /&gt;
&lt;br /&gt;
=== sharing files with the host ===&lt;br /&gt;
* Using [[9p virtio]] to share files between host and guest&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operating System related ==&lt;br /&gt;
&lt;br /&gt;
=== Gentoo ===&lt;br /&gt;
* Gentoo has [http://wiki.gentoo.org/wiki/QEMU good page about qemu/kvm in their wiki].&lt;br /&gt;
* [[KvmOnGentoo|KVM on Gentoo hosts]]&lt;br /&gt;
&lt;br /&gt;
=== Ubuntu ===&lt;br /&gt;
* [http://www.howtoforge.com/using-kvm-on-ubuntu-gutsy-gibbon using-kvm-on-ubuntu-gutsy-gibbon]&lt;br /&gt;
* [[AnthonyLiguori/Networking| Setting up NAT with KVM in Ubuntu]]&lt;br /&gt;
* [https://help.ubuntu.com/community/KVM Running Guest Systems on Ubuntu 7.04 Feisty Fawn]&lt;br /&gt;
* [http://www.howtoforge.com/virtualization-with-kvm-on-ubuntu-9.04 Virtualization With KVM On Ubuntu 9.04 Jaunty]&lt;br /&gt;
&lt;br /&gt;
=== Fedora ===&lt;br /&gt;
* [http://fedoraproject.org/wiki/Virtualization_Quick_Start Fedora Virt Quick Start]&lt;br /&gt;
&lt;br /&gt;
=== ArchLinux ===&lt;br /&gt;
* [http://wiki.archlinux.org/index.php/Kvm Setting up KVM on ArchLinux]&lt;br /&gt;
* [http://wiki.archlinux.org/index.php/Qemu Detailed QEMU Tutorial ]&lt;br /&gt;
&lt;br /&gt;
=== RHEL/CentOS 7 ===&lt;br /&gt;
* [http://linux.dell.com/files/whitepapers/KVM_Virtualization_in_RHEL_7_Made_Easy.pdf KVM Virtualization in RHEL 7 Made Easy]&lt;br /&gt;
&lt;br /&gt;
=== BSD ===&lt;br /&gt;
* [http://www.linux-kvm.org/page/BSD KVM on BSD, FreeBSD]&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
* [[WindowsGuestDrivers|Information about guest drivers]]&lt;br /&gt;
* [[Windows7Install|Install Windows 7]]&lt;br /&gt;
* [http://wp.libpf.com/?p=186 Windows 7 as guest on Debian squeeze] - with libvirt&#039;s virt-install recipe and virtio disk driver step-by-step instructions&lt;br /&gt;
* [http://www.returnbooleantrue.com/2015/04/making-your-windows-kvm-guest-boxes-fly.html Installing virtio drivers in Windows for Ubuntu hosts]&lt;br /&gt;
&lt;br /&gt;
=== Windows Vista ===&lt;br /&gt;
* [[Vista Networking Workaround]]&lt;br /&gt;
&lt;br /&gt;
== Scripting &amp;amp; Software ==&lt;br /&gt;
* [[HowToConfigScript|Configuration Script for KVM]] - a complete management utility, configuration file format, and init script.&lt;br /&gt;
* [http://www.roessner-net.com/?p=219 Another script for KVM] - Init scripts for kvm, using it with time scheduled start order (German)&lt;br /&gt;
* [[simple shell script to manage your virtual machine with bridged networking]]&lt;br /&gt;
* [http://www.papercut.com/blog/chris/2008/11/14/using-kvm-to-securely-host-servers-in-a-dmz/ Hosting your VMs in a DMZ] - a management and configuration script to assist with setting up a VM in a semi-secured demilitarized zone.&lt;br /&gt;
* [http://pve.proxmox.com/wiki/Bare-metal_ISO_Installer Bare-metal] installer with KVM&lt;br /&gt;
* [[kvmtools|Python scripts to manage qemu-kvm guest from cmdline]] - yet another qemu-kvm script &lt;br /&gt;
* [https://github.com/tmartinfr/kvm-simple-init kvm-simple-init] - Simple init script to manage KVM virtual machines&lt;br /&gt;
&lt;br /&gt;
=== libvirt ===&lt;br /&gt;
&lt;br /&gt;
* [[Running libvirt with KVM]]&lt;br /&gt;
&lt;br /&gt;
== Other ==&lt;br /&gt;
&lt;br /&gt;
* [[HOWTO VMGL]] - OpenGL support for Linux guests&lt;br /&gt;
&lt;br /&gt;
[[Category:Docs]][[Category:HowTo]]&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=KVM_Features&amp;diff=173800</id>
		<title>KVM Features</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=KVM_Features&amp;diff=173800"/>
		<updated>2017-01-20T02:50:53Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* KVM-Features */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= KVM-Features =&lt;br /&gt;
&lt;br /&gt;
This is a possibly incomplete list of KVM features, together with their status. Feel free to update any of them as you see fit.&lt;br /&gt;
&lt;br /&gt;
As a guideline, there is a feature description template in [[FeatureDescription/Template|here]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* [[MonitorProtocol|QMP]] - Qemu Monitor Protocol&lt;br /&gt;
* [[KSM|KSM]] - Kernel Samepage Merging&lt;br /&gt;
* [[KVMClock|Kvm Paravirtual Clock]] - A Paravirtual timesource for KVM&lt;br /&gt;
* [[CPUHotPlug|CPU Hotplug support]] - Adding cpus on the fly&lt;br /&gt;
* [[pcihotplug|PCI Hotplug support]] - Adding pci devices on the fly&lt;br /&gt;
* [[VMchannel_Requirements | vmchannel ]] - Communication channel between the host and guests&lt;br /&gt;
* [[migration]] - Migrating Virtual Machines&lt;br /&gt;
* [[VhostNet|vhost]] - &lt;br /&gt;
* [[scsi|SCSI disk emulation]] - &lt;br /&gt;
* [[virtio|Virtio Devices]] - &lt;br /&gt;
* [[CPU clustering]] - &lt;br /&gt;
* [[hpet]] - &lt;br /&gt;
* [[Device assignment]] - &lt;br /&gt;
* [[pxe boot]] - &lt;br /&gt;
* [[iscsi boot]] - &lt;br /&gt;
* [[x2apic]] -&lt;br /&gt;
* [[Floppy]] -&lt;br /&gt;
* [[cdrom|CDROM]] - &lt;br /&gt;
* [[USB]] -&lt;br /&gt;
* [[UsbPassthrough|USB host device passthrough]] - &lt;br /&gt;
* [[Sound]] -&lt;br /&gt;
* [[UserspaceIrqchip|Userspace irqchip emulation]] -&lt;br /&gt;
* [[UserspacePit|Userspace pit emulation]] -&lt;br /&gt;
* [[Balloon|Balloon memory driver]] -  &lt;br /&gt;
* [[LargePages|Large pages support]] -&lt;br /&gt;
* [[StableABI|Stable Guest ABI]] -&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=KVM_Features&amp;diff=173799</id>
		<title>KVM Features</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=KVM_Features&amp;diff=173799"/>
		<updated>2017-01-20T02:48:43Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* KVM-Features */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= KVM-Features =&lt;br /&gt;
&lt;br /&gt;
This is a possibly incomplete list of KVM features, together with their status. Feel free to update any of them as you see fit.&lt;br /&gt;
&lt;br /&gt;
As a guideline, there is a feature description template in [[FeatureDescription/Template|here]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* [[MonitorProtocol|QMP]] - Qemu Monitor Protocol&lt;br /&gt;
* [[KSM|KSM]] - Kernel Samepage Merging&lt;br /&gt;
* [[KVMClock|Kvm Paravirtual Clock]] - A Paravirtual timesource for KVM&lt;br /&gt;
* [[CPUHotPlug|CPU Hotplug support]] - Adding cpus on the fly&lt;br /&gt;
* [[pcihotplug|PCI Hotplug support]] - Adding pci devices on the fly&lt;br /&gt;
* [[VMchannel_Requirements | vmchannel ]] - Communication channel between the host and guests&lt;br /&gt;
* [[migration]] - Migrating Virtual Machines&lt;br /&gt;
* [[VhostNet|vhost]] - &lt;br /&gt;
* [[scsi|SCSI disk emulation]] - &lt;br /&gt;
* [[virtio|Virtio Devices]] - &lt;br /&gt;
* [[CPU clustering]] - &lt;br /&gt;
* [[hpet]] - &lt;br /&gt;
* [[Device assignment]] - &lt;br /&gt;
* [[pxe boot]] - &lt;br /&gt;
* [[iscsi boot]] - &lt;br /&gt;
* [[x2apic]] -&lt;br /&gt;
* [[Floppy]] -&lt;br /&gt;
* [[CDROM]] - &lt;br /&gt;
* [[USB]] -&lt;br /&gt;
* [[UsbPassthrough|USB host device passthrough]] - &lt;br /&gt;
* [[Sound]] -&lt;br /&gt;
* [[UserspaceIrqchip|Userspace Irqchip emulation]] -&lt;br /&gt;
* [[UserspacePit|Userspace pit emulation]] -&lt;br /&gt;
* [[Balloon|Balloon memory driver]] -  &lt;br /&gt;
* [[LargePages|Large pages support]] -&lt;br /&gt;
* [[StableABI|Stable Guest ABI]] -&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=VGA_device_assignment&amp;diff=173798</id>
		<title>VGA device assignment</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=VGA_device_assignment&amp;diff=173798"/>
		<updated>2017-01-20T02:44:19Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* Open issues */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Assigning physical VGA adapters =&lt;br /&gt;
&lt;br /&gt;
It would appear that assigning modern PCI/PCIe VGA adapters should not be any different from [[How_to_assign_devices_with_VT-d_in_KVM|passing through normal PCI devices]]. But there are additional challenges to solve, specifically related to legacy VGA requirements and proprietary mechanisms to relocate I/O regions of the adapters. Moreover, some QEMU and SeaBIOS deficits contribute to the current situation that things rarely work out of the box.&lt;br /&gt;
&lt;br /&gt;
== Open issues ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Insufficient PCI window size&#039;&#039;&#039;&amp;lt;br&amp;gt;This is a fixable SeaBIOS limitation. Patches are currently under development by [http://www.kraxel.org/cgit/seabios/log/?h=kraxel.q35&amp;amp;id=99ff4d141d5a460eaf20fe2d4d13117c888eae15 Gerd Hoffmann].&lt;br /&gt;
* &#039;&#039;&#039;Non-standard I/O region remapping&#039;&#039;&#039;&amp;lt;br&amp;gt;Some NVIDIA Quadro adapters are known to be affected by this, but probably only during early boot. A workaround could be identity mapping, i.e. locating the memory BARs in the guest at the same locations as on the host. Of course, this breaks if the guest OS or guest drivers decide to remap them.&lt;br /&gt;
* &#039;&#039;&#039;Legacy VGA support&#039;&#039;&#039;&amp;lt;br&amp;gt;In order to get boot messages of the guest BIOS, boot loader, or early OS stages, access to the legacy VGA PIO and MMIO regions need to be forwarded to the passed-through adapter. Moreover, the VBIOS of the adapter must be bootable inside the guest. As a result, the following aspects will need to be addressed:&lt;br /&gt;
** &#039;&#039;&#039;Legacy VGA pass-through&#039;&#039;&#039;&amp;lt;br&amp;gt;QEMU requires patches to forward guest access to legacy VGA via the assigned adapter.&lt;br /&gt;
** &#039;&#039;&#039;PAM/SRAM QEMU breakage&#039;&#039;&#039;&amp;lt;br&amp;gt;Current QEMU contains broken code that prevents access to legacy VGA even if the adapter is emulated but differently initialized (test case: -vga none -device VGA)&lt;br /&gt;
** &#039;&#039;&#039;Legacy VGA arbitration&#039;&#039;&#039;&amp;lt;br&amp;gt;As the legacy IO resources cannot be remapped, access needs to be switched between guests and the host on demand. The Linux kernel provides a VGA arbiter for this purpose, but it is not used consistently by all involved parties. Moreover, QEMU also requires additional patches to support this.&lt;br /&gt;
** &#039;&#039;&#039;VBIOS ROM access&#039;&#039;&#039;&amp;lt;br&amp;gt;To re-run the POST procedures of the assigned adapter inside the guest, the proper VBIOS ROM image has to be used. However, when passing through the primary adapter of the host, Linux provides only access to the shadowed version of the VBIOS which may differ from the pre-POST version (due to modifications applied during POST). This has been observed with NVIDIA Quadro adapters. A workaround is to retrieve the VBIOS from the adapter while it is in secondary mode and use this saved image (-device pci-assign,...,romfile=...). But even that may fail, either due to problems of the host chipset or BIOS (e.g. host kernel complains about an unmappable ROM BAR).&lt;br /&gt;
&lt;br /&gt;
== Potential tweaks &amp;amp; tricks ==&lt;br /&gt;
&lt;br /&gt;
* Some adapters may advertise MSI support even if that feature does not work properly. In that case, KVM will use MSI on the host side unconditionally unless instructed to follow the guest driver usage via -device pci-assign,...,prefer_msi=off.&lt;br /&gt;
&lt;br /&gt;
== Success stories ==&lt;br /&gt;
&lt;br /&gt;
Despite all existing problems, some users have already succeeded in utilizing pass-through functionality for various VGA adapters:&lt;br /&gt;
&lt;br /&gt;
* [http://thread.gmane.org/gmane.comp.emulators.kvm.devel/94524 Radeon HD 7870]&lt;br /&gt;
* [http://thread.gmane.org/gmane.comp.emulators.kvm.devel/104760 Radeon HD 7750]&lt;br /&gt;
* [http://thread.gmane.org/gmane.comp.emulators.kvm.devel/72987 Radeon HD 6950 with patched SeaBIOS]&lt;br /&gt;
* [http://tavi-tech.blogspot.com.au/2012/05/vga-passthrough-kvm-fedora-17-and.html Radeon HD 6770]&lt;br /&gt;
* [http://thread.gmane.org/gmane.comp.emulators.kvm.devel/71981 Radeon HD 5850]&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=VGA_device_assignment&amp;diff=173797</id>
		<title>VGA device assignment</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=VGA_device_assignment&amp;diff=173797"/>
		<updated>2017-01-20T02:43:28Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* Assigning physical VGA adapters */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Assigning physical VGA adapters =&lt;br /&gt;
&lt;br /&gt;
It would appear that assigning modern PCI/PCIe VGA adapters should not be any different from [[How_to_assign_devices_with_VT-d_in_KVM|passing through normal PCI devices]]. But there are additional challenges to solve, specifically related to legacy VGA requirements and proprietary mechanisms to relocate I/O regions of the adapters. Moreover, some QEMU and SeaBIOS deficits contribute to the current situation that things rarely work out of the box.&lt;br /&gt;
&lt;br /&gt;
== Open issues ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Insufficient PCI window size&#039;&#039;&#039;&amp;lt;br&amp;gt;This is a fixable SeaBIOS limitation. Patches are currently under development by [http://www.kraxel.org/cgit/seabios/log/?h=kraxel.q35&amp;amp;id=99ff4d141d5a460eaf20fe2d4d13117c888eae15 Gerd Hoffmann]&lt;br /&gt;
* &#039;&#039;&#039;Non-standard I/O region remapping&#039;&#039;&#039;&amp;lt;br&amp;gt;Some NVIDIA Quadro adapters are known to be affected by this, but probably only during early boot. A workaround could be identity mapping, i.e. locating the memory BARs in the guest at the same locations as on the host. Of course, this breaks if the guest OS or guest drivers decide to remap them.&lt;br /&gt;
* &#039;&#039;&#039;Legacy VGA support&#039;&#039;&#039;&amp;lt;br&amp;gt;In order to get boot messages of the guest BIOS, boot loader, or early OS stages, access to the legacy VGA PIO and MMIO regions need to be forwarded to the passed-through adapter. Moreover, the VBIOS of the adapter must be bootable inside the guest. As a result, the following aspects will need to be addressed:&lt;br /&gt;
** &#039;&#039;&#039;Legacy VGA pass-through&#039;&#039;&#039;&amp;lt;br&amp;gt;QEMU requires patches to forward guest access to legacy VGA via the assigned adapter.&lt;br /&gt;
** &#039;&#039;&#039;PAM/SRAM QEMU breakage&#039;&#039;&#039;&amp;lt;br&amp;gt;Current QEMU contains broken code that prevents access to legacy VGA even if the adapter is emulated but differently initialized (test case: -vga none -device VGA)&lt;br /&gt;
** &#039;&#039;&#039;Legacy VGA arbitration&#039;&#039;&#039;&amp;lt;br&amp;gt;As the legacy IO resources cannot be remapped, access needs to be switched between guests and the host on demand. The Linux kernel provides a VGA arbiter for this purpose, but it is not used consistently by all involved parties. Moreover, QEMU also requires additional patches to support this.&lt;br /&gt;
** &#039;&#039;&#039;VBIOS ROM access&#039;&#039;&#039;&amp;lt;br&amp;gt;To re-run the POST procedures of the assigned adapter inside the guest, the proper VBIOS ROM image has to be used. However, when passing through the primary adapter of the host, Linux provides only access to the shadowed version of the VBIOS which may differ from the pre-POST version (due to modifications applied during POST). This has been observed with NVIDIA Quadro adapters. A workaround is to retrieve the VBIOS from the adapter while it is in secondary mode and use this saved image (-device pci-assign,...,romfile=...). But even that may fail, either due to problems of the host chipset or BIOS (e.g. host kernel complains about an unmappable ROM BAR).&lt;br /&gt;
&lt;br /&gt;
== Potential tweaks &amp;amp; tricks ==&lt;br /&gt;
&lt;br /&gt;
* Some adapters may advertise MSI support even if that feature does not work properly. In that case, KVM will use MSI on the host side unconditionally unless instructed to follow the guest driver usage via -device pci-assign,...,prefer_msi=off.&lt;br /&gt;
&lt;br /&gt;
== Success stories ==&lt;br /&gt;
&lt;br /&gt;
Despite all existing problems, some users have already succeeded in utilizing pass-through functionality for various VGA adapters:&lt;br /&gt;
&lt;br /&gt;
* [http://thread.gmane.org/gmane.comp.emulators.kvm.devel/94524 Radeon HD 7870]&lt;br /&gt;
* [http://thread.gmane.org/gmane.comp.emulators.kvm.devel/104760 Radeon HD 7750]&lt;br /&gt;
* [http://thread.gmane.org/gmane.comp.emulators.kvm.devel/72987 Radeon HD 6950 with patched SeaBIOS]&lt;br /&gt;
* [http://tavi-tech.blogspot.com.au/2012/05/vga-passthrough-kvm-fedora-17-and.html Radeon HD 6770]&lt;br /&gt;
* [http://thread.gmane.org/gmane.comp.emulators.kvm.devel/71981 Radeon HD 5850]&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Networking&amp;diff=173674</id>
		<title>Networking</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Networking&amp;diff=173674"/>
		<updated>2016-07-25T00:40:21Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* Public Bridge */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Configuring Guest Networking =&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 documentation about networking in qemu. This page will try to explain how to configure the most frequent types of networking needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== User Networking ==&lt;br /&gt;
&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;
&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, then the user needs to have rw access to /dev/kvm&lt;br /&gt;
* In order for the guest to be able to access the internet or a local network, the host system must be able to access these resources as well&lt;br /&gt;
&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-level (a.k.a slirp) networking:&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img&lt;br /&gt;
&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;
* The 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 an rtl8139-based network interface.&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 the other address of the host to connect to.&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, then the user needs to have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&lt;br /&gt;
 ip&lt;br /&gt;
 brctl (deprecated). Use ip link instead&lt;br /&gt;
 tunctl (deprecated). Use ip tuntap and ip link instead&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;
 # ip link add br0 type bridge&lt;br /&gt;
 # brctl addbr br0 (deprecated)&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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;
         # tunctl -u `whoami` -t $1 (use ip tuntap instead!)&lt;br /&gt;
         ip tuntap add $1 mode tap user `whoami`&lt;br /&gt;
         ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         # brctl addif $switch $1 (use ip link instead!)&lt;br /&gt;
         ip link set $switch master $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 qemu-ifup as root, then consider using sudo&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;
== Public Bridge ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; The method shown here will not work with all wireless drivers as they might 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 IP addresses 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;
&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 kvm as root, then the user must have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&lt;br /&gt;
 ip&lt;br /&gt;
 brctl (deprecated, use ip link instead)&lt;br /&gt;
 tunctl (deprecated, use ip tuntap instead)&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;
&lt;br /&gt;
&#039;&#039;&#039;Solution 1: Using Distribution-Specific Scripts&#039;&#039;&#039;&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
!RedHat&lt;br /&gt;
!Debian&lt;br /&gt;
!SuSE&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 an IP address.&lt;br /&gt;
&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 Configuration&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* You need to create a bridge, e-g:&lt;br /&gt;
 # ip link add br0 type bridge&lt;br /&gt;
 # brctl addbr br0 (deprecated, use ip link instead!)&lt;br /&gt;
&lt;br /&gt;
* Add one of your physical interface to the bridge, e-g for eth0:&lt;br /&gt;
 # ip link set eth0 master br0&lt;br /&gt;
 # brctl addif br0 eth0 (deprecated, use ip link instead!)&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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;
         #tunctl -u `whoami` -t $1&lt;br /&gt;
         ip tuntap add $1 mode tap user `whoami`&lt;br /&gt;
         ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         #brctl addif $switch $1&lt;br /&gt;
         ip link set $1 master $switch&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;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* If you don&#039;t want to run qemu-ifup as root, then consider using sudo&lt;br /&gt;
* Each guest on the network must have a different MAC address&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;
== Routing with iptables ==&lt;br /&gt;
&lt;br /&gt;
With this method, you can connect your guest vm to a tap device in your host. Then you can set iptables rules in your host so that it acts as a router and firewall for your guest.&lt;br /&gt;
&lt;br /&gt;
Routing is done simply by setting the default route on the client to the IP address of the host, allowing IP forwarding, and setting a route to the tap device of the client on the host.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Host-side: Allow IPv4 forwarding and add a route to the guest (could be put in a script, but the route has to be added after the guest 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;
&lt;br /&gt;
*Guest-side: Set the default gateway to the IP address of the host (make sure the host and guest IP addresses are in the same subnet):&lt;br /&gt;
&lt;br /&gt;
 route add default gw &amp;lt;ip-of-host&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Note: If the host is not on the same subnet as the guest, then you must manually add the route to the host before you create the 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;
== VDE ==&lt;br /&gt;
&lt;br /&gt;
Another option is using VDE (Virtual Distributed Ethernet).&lt;br /&gt;
&lt;br /&gt;
More information will be provided later.&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 comparisons between VFIO passthrough and virtio are discussed in [[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>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=How_to_assign_devices_with_VT-d_in_KVM&amp;diff=173673</id>
		<title>How to assign devices with VT-d in KVM</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=How_to_assign_devices_with_VT-d_in_KVM&amp;diff=173673"/>
		<updated>2016-07-25T00:34:18Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* VT-d device hotplug */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= How to assign devices with VT-d in KVM =&lt;br /&gt;
&lt;br /&gt;
== VT-d support ==&lt;br /&gt;
* In order to assign devices in KVM, you&#039;ll need a system which supports VT-d, not to be confused with the VT-x support of your CPU. VT-d needs to be supported by both your motherboard chipset and your CPU.&lt;br /&gt;
&lt;br /&gt;
* If you are in doubt whether your motherboard or CPU supports VT-d, the Xen VT-d wiki has some information about VT-d enabled chipsets, motherboards, and CPUs:&lt;br /&gt;
        http://wiki.xenproject.org/wiki/VTdHowTo&lt;br /&gt;
&lt;br /&gt;
* If your hardware does not have an IOMMU (known as &amp;quot;Intel VT-d&amp;quot; on Intel-based machines and &amp;quot;AMD I/O Virtualization Technology&amp;quot; on AMD-based machines), you will not be able to assign devices in KVM.&lt;br /&gt;
&lt;br /&gt;
* Assigning graphics cards is not officially supported at the moment, but there has been some success passing through a secondary Radeon HD 5850 as a VM&#039;s secondary display.&lt;br /&gt;
&lt;br /&gt;
== Assigning the device ==&lt;br /&gt;
&#039;&#039;&#039;1. Modify the kernel config&#039;&#039;&#039;&lt;br /&gt;
* Navigate to the kernel source code directory (usually located in /usr/src/linux) and configure the kernel:&lt;br /&gt;
      cd /usr/src/linux&lt;br /&gt;
      make menuconfig&lt;br /&gt;
* Navigate to &amp;quot;Bus options (PCI etc.)&amp;quot; and enable the following options:&lt;br /&gt;
      Support for DMA Remapping Devices&lt;br /&gt;
      Enable DMA Remapping Devices&lt;br /&gt;
      PCI Stub driver&lt;br /&gt;
* Optionally, this can also be enabled:&lt;br /&gt;
      Support for Interrupt Remapping&lt;br /&gt;
* Save the changes and exit&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2. Build the kernel&#039;&#039;&#039;&lt;br /&gt;
      make&lt;br /&gt;
      make modules_install&lt;br /&gt;
      make install&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Reboot and verify that your system has IOMMU support&#039;&#039;&#039;&lt;br /&gt;
* AMD-based machines:&lt;br /&gt;
      dmesg | grep AMD-Vi&lt;br /&gt;
      ...&lt;br /&gt;
      AMD-Vi: Enabling IOMMU at 0000:00:00.2 cap 0x40&lt;br /&gt;
      AMD-Vi: Lazy IO/TLB flushing enabled&lt;br /&gt;
      AMD-Vi: Initialized for Passthrough Mode&lt;br /&gt;
      ...&lt;br /&gt;
* Intel-based machines:&lt;br /&gt;
      dmesg | grep -e DMAR -e IOMMU&lt;br /&gt;
      ...&lt;br /&gt;
      DMAR:DRHD base: 0x000000feb03000 flags: 0x0&lt;br /&gt;
      IOMMU feb03000: ver 1:0 cap c9008020e30260 ecap 1000&lt;br /&gt;
      ...&lt;br /&gt;
Note: If you get no output, you will need to fix this before moving on. Try the following:&lt;br /&gt;
* Verify that your hardware supports VT-d and that it has been enabled in the BIOS.&lt;br /&gt;
* Check dmesg for errors suggesting that the BIOS is broken.&lt;br /&gt;
* CONFIG_DMAR_DEFAULT_ON is not set. Pass one of the following commands as a kernel parameter:&lt;br /&gt;
      intel_iommu=on      # Intel only&lt;br /&gt;
      iommu=pt iommu=1    # AMD only&lt;br /&gt;
Note: The kernel parameter can be passed temporarily using the GRUB menu by highlighting the OS, pressing &amp;quot;e&amp;quot;, and appending the parameter to the end of the line beginning with &amp;quot;linux&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4. Unbind the device from the host kernel driver (Example: PCI device 01:00.0)&lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
* Load the PCI Stub Driver if it is compiled as a module&lt;br /&gt;
      modprobe pci_stub&lt;br /&gt;
      lspci -n&lt;br /&gt;
&lt;br /&gt;
* Locate the entry for device 01:00.0 and note the vendor and device ID (8086:10b9 in this example)&lt;br /&gt;
      ...&lt;br /&gt;
      01:00.0 0200: 8086:10b9 (rev 06)&lt;br /&gt;
      ...&lt;br /&gt;
&lt;br /&gt;
* Place this information in the following files:&lt;br /&gt;
      echo &amp;quot;8086 10b9&amp;quot; &amp;gt; /sys/bus/pci/drivers/pci-stub/new_id&lt;br /&gt;
      echo &amp;quot;0000:01:00.0&amp;quot; &amp;gt; /sys/bus/pci/devices/0000:01:00.0/driver/unbind&lt;br /&gt;
      echo &amp;quot;0000:01:00.0&amp;quot; &amp;gt; /sys/bus/pci/drivers/pci-stub/bind&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;5. Load the KVM modules&#039;&#039;&#039;&lt;br /&gt;
      modprobe kvm&lt;br /&gt;
      modprobe kvm-intel&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;6. Assign the device&#039;&#039;&#039;&lt;br /&gt;
      /usr/local/bin/qemu-system-x86_64 -m 512 -boot c -net none -hda /root/ia32e_rhel5u1.img -device pci-assign,host=01:00.0&lt;br /&gt;
&lt;br /&gt;
== VT-d device hotplug ==&lt;br /&gt;
With VT-d, KVM also supports hotplugging devices on the guest. In the guest command interface (accessible with Ctrl+Alt+2), you can use the following commands to add/remove devices on the guest:&lt;br /&gt;
* Add&lt;br /&gt;
    device_add pci-assign,host=01:00.0,id=mydevice&lt;br /&gt;
* Remove&lt;br /&gt;
    device_del mydevice&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
* VT-d spec specifies that all conventional PCI devices behind a PCIe-to PCI/PCI-X bridge or conventional PCI bridge can only be collectively assigned to the same guest. PCIe devices do not have this restriction.&lt;br /&gt;
* If the device doesn&#039;t support MSI, and it shares IRQ with other devices, then it cannot be assigned due to host irq sharing for assigned devices is not supported. You will get warning message when you assign it. Notice this also apply to the devices which only support MSI-X.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Docs]][[Category:HowTo]][[Category:Devices]]&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=How_to_assign_devices_with_VT-d_in_KVM&amp;diff=173672</id>
		<title>How to assign devices with VT-d in KVM</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=How_to_assign_devices_with_VT-d_in_KVM&amp;diff=173672"/>
		<updated>2016-07-25T00:28:16Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* Assigning the device */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= How to assign devices with VT-d in KVM =&lt;br /&gt;
&lt;br /&gt;
== VT-d support ==&lt;br /&gt;
* In order to assign devices in KVM, you&#039;ll need a system which supports VT-d, not to be confused with the VT-x support of your CPU. VT-d needs to be supported by both your motherboard chipset and your CPU.&lt;br /&gt;
&lt;br /&gt;
* If you are in doubt whether your motherboard or CPU supports VT-d, the Xen VT-d wiki has some information about VT-d enabled chipsets, motherboards, and CPUs:&lt;br /&gt;
        http://wiki.xenproject.org/wiki/VTdHowTo&lt;br /&gt;
&lt;br /&gt;
* If your hardware does not have an IOMMU (known as &amp;quot;Intel VT-d&amp;quot; on Intel-based machines and &amp;quot;AMD I/O Virtualization Technology&amp;quot; on AMD-based machines), you will not be able to assign devices in KVM.&lt;br /&gt;
&lt;br /&gt;
* Assigning graphics cards is not officially supported at the moment, but there has been some success passing through a secondary Radeon HD 5850 as a VM&#039;s secondary display.&lt;br /&gt;
&lt;br /&gt;
== Assigning the device ==&lt;br /&gt;
&#039;&#039;&#039;1. Modify the kernel config&#039;&#039;&#039;&lt;br /&gt;
* Navigate to the kernel source code directory (usually located in /usr/src/linux) and configure the kernel:&lt;br /&gt;
      cd /usr/src/linux&lt;br /&gt;
      make menuconfig&lt;br /&gt;
* Navigate to &amp;quot;Bus options (PCI etc.)&amp;quot; and enable the following options:&lt;br /&gt;
      Support for DMA Remapping Devices&lt;br /&gt;
      Enable DMA Remapping Devices&lt;br /&gt;
      PCI Stub driver&lt;br /&gt;
* Optionally, this can also be enabled:&lt;br /&gt;
      Support for Interrupt Remapping&lt;br /&gt;
* Save the changes and exit&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2. Build the kernel&#039;&#039;&#039;&lt;br /&gt;
      make&lt;br /&gt;
      make modules_install&lt;br /&gt;
      make install&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Reboot and verify that your system has IOMMU support&#039;&#039;&#039;&lt;br /&gt;
* AMD-based machines:&lt;br /&gt;
      dmesg | grep AMD-Vi&lt;br /&gt;
      ...&lt;br /&gt;
      AMD-Vi: Enabling IOMMU at 0000:00:00.2 cap 0x40&lt;br /&gt;
      AMD-Vi: Lazy IO/TLB flushing enabled&lt;br /&gt;
      AMD-Vi: Initialized for Passthrough Mode&lt;br /&gt;
      ...&lt;br /&gt;
* Intel-based machines:&lt;br /&gt;
      dmesg | grep -e DMAR -e IOMMU&lt;br /&gt;
      ...&lt;br /&gt;
      DMAR:DRHD base: 0x000000feb03000 flags: 0x0&lt;br /&gt;
      IOMMU feb03000: ver 1:0 cap c9008020e30260 ecap 1000&lt;br /&gt;
      ...&lt;br /&gt;
Note: If you get no output, you will need to fix this before moving on. Try the following:&lt;br /&gt;
* Verify that your hardware supports VT-d and that it has been enabled in the BIOS.&lt;br /&gt;
* Check dmesg for errors suggesting that the BIOS is broken.&lt;br /&gt;
* CONFIG_DMAR_DEFAULT_ON is not set. Pass one of the following commands as a kernel parameter:&lt;br /&gt;
      intel_iommu=on      # Intel only&lt;br /&gt;
      iommu=pt iommu=1    # AMD only&lt;br /&gt;
Note: The kernel parameter can be passed temporarily using the GRUB menu by highlighting the OS, pressing &amp;quot;e&amp;quot;, and appending the parameter to the end of the line beginning with &amp;quot;linux&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4. Unbind the device from the host kernel driver (Example: PCI device 01:00.0)&lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
* Load the PCI Stub Driver if it is compiled as a module&lt;br /&gt;
      modprobe pci_stub&lt;br /&gt;
      lspci -n&lt;br /&gt;
&lt;br /&gt;
* Locate the entry for device 01:00.0 and note the vendor and device ID (8086:10b9 in this example)&lt;br /&gt;
      ...&lt;br /&gt;
      01:00.0 0200: 8086:10b9 (rev 06)&lt;br /&gt;
      ...&lt;br /&gt;
&lt;br /&gt;
* Place this information in the following files:&lt;br /&gt;
      echo &amp;quot;8086 10b9&amp;quot; &amp;gt; /sys/bus/pci/drivers/pci-stub/new_id&lt;br /&gt;
      echo &amp;quot;0000:01:00.0&amp;quot; &amp;gt; /sys/bus/pci/devices/0000:01:00.0/driver/unbind&lt;br /&gt;
      echo &amp;quot;0000:01:00.0&amp;quot; &amp;gt; /sys/bus/pci/drivers/pci-stub/bind&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;5. Load the KVM modules&#039;&#039;&#039;&lt;br /&gt;
      modprobe kvm&lt;br /&gt;
      modprobe kvm-intel&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;6. Assign the device&#039;&#039;&#039;&lt;br /&gt;
      /usr/local/bin/qemu-system-x86_64 -m 512 -boot c -net none -hda /root/ia32e_rhel5u1.img -device pci-assign,host=01:00.0&lt;br /&gt;
&lt;br /&gt;
== VT-d device hotplug ==&lt;br /&gt;
KVM also supports hotplug devices with VT-d to guest. In guest command interface (you can press Ctrl+Alt+2 to enter it), you can use following command to hot add/remove devices to/from guest:&lt;br /&gt;
* hot add:&lt;br /&gt;
        device_add pci-assign,host=01:00.0,id=mydevice&lt;br /&gt;
* hot remove:&lt;br /&gt;
        device_del mydevice&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
* VT-d spec specifies that all conventional PCI devices behind a PCIe-to PCI/PCI-X bridge or conventional PCI bridge can only be collectively assigned to the same guest. PCIe devices do not have this restriction.&lt;br /&gt;
* If the device doesn&#039;t support MSI, and it shares IRQ with other devices, then it cannot be assigned due to host irq sharing for assigned devices is not supported. You will get warning message when you assign it. Notice this also apply to the devices which only support MSI-X.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Docs]][[Category:HowTo]][[Category:Devices]]&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=How_to_assign_devices_with_VT-d_in_KVM&amp;diff=173671</id>
		<title>How to assign devices with VT-d in KVM</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=How_to_assign_devices_with_VT-d_in_KVM&amp;diff=173671"/>
		<updated>2016-07-25T00:27:10Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* How to assign devices with VT-d in KVM */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= How to assign devices with VT-d in KVM =&lt;br /&gt;
&lt;br /&gt;
== VT-d support ==&lt;br /&gt;
* In order to assign devices in KVM, you&#039;ll need a system which supports VT-d, not to be confused with the VT-x support of your CPU. VT-d needs to be supported by both your motherboard chipset and your CPU.&lt;br /&gt;
&lt;br /&gt;
* If you are in doubt whether your motherboard or CPU supports VT-d, the Xen VT-d wiki has some information about VT-d enabled chipsets, motherboards, and CPUs:&lt;br /&gt;
        http://wiki.xenproject.org/wiki/VTdHowTo&lt;br /&gt;
&lt;br /&gt;
* If your hardware does not have an IOMMU (known as &amp;quot;Intel VT-d&amp;quot; on Intel-based machines and &amp;quot;AMD I/O Virtualization Technology&amp;quot; on AMD-based machines), you will not be able to assign devices in KVM.&lt;br /&gt;
&lt;br /&gt;
* Assigning graphics cards is not officially supported at the moment, but there has been some success passing through a secondary Radeon HD 5850 as a VM&#039;s secondary display.&lt;br /&gt;
&lt;br /&gt;
== How to assign devices with VT-d in KVM ==&lt;br /&gt;
&#039;&#039;&#039;1. Modify the kernel config&#039;&#039;&#039;&lt;br /&gt;
* Navigate to the kernel source code directory (usually located in /usr/src/linux) and configure the kernel:&lt;br /&gt;
      cd /usr/src/linux&lt;br /&gt;
      make menuconfig&lt;br /&gt;
* Navigate to &amp;quot;Bus options (PCI etc.)&amp;quot; and enable the following options:&lt;br /&gt;
      Support for DMA Remapping Devices&lt;br /&gt;
      Enable DMA Remapping Devices&lt;br /&gt;
      PCI Stub driver&lt;br /&gt;
* Optionally, this can also be enabled:&lt;br /&gt;
      Support for Interrupt Remapping&lt;br /&gt;
* Save the changes and exit&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2. Build the kernel&#039;&#039;&#039;&lt;br /&gt;
      make&lt;br /&gt;
      make modules_install&lt;br /&gt;
      make install&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Reboot and verify that your system has IOMMU support&#039;&#039;&#039;&lt;br /&gt;
* AMD-based machines:&lt;br /&gt;
      dmesg | grep AMD-Vi&lt;br /&gt;
      ...&lt;br /&gt;
      AMD-Vi: Enabling IOMMU at 0000:00:00.2 cap 0x40&lt;br /&gt;
      AMD-Vi: Lazy IO/TLB flushing enabled&lt;br /&gt;
      AMD-Vi: Initialized for Passthrough Mode&lt;br /&gt;
      ...&lt;br /&gt;
* Intel-based machines:&lt;br /&gt;
      dmesg | grep -e DMAR -e IOMMU&lt;br /&gt;
      ...&lt;br /&gt;
      DMAR:DRHD base: 0x000000feb03000 flags: 0x0&lt;br /&gt;
      IOMMU feb03000: ver 1:0 cap c9008020e30260 ecap 1000&lt;br /&gt;
      ...&lt;br /&gt;
Note: If you get no output, you will need to fix this before moving on. Try the following:&lt;br /&gt;
* Verify that your hardware supports VT-d and that it has been enabled in the BIOS.&lt;br /&gt;
* Check dmesg for errors suggesting that the BIOS is broken.&lt;br /&gt;
* CONFIG_DMAR_DEFAULT_ON is not set. Pass one of the following commands as a kernel parameter:&lt;br /&gt;
      intel_iommu=on      # Intel only&lt;br /&gt;
      iommu=pt iommu=1    # AMD only&lt;br /&gt;
Note: The kernel parameter can be passed temporarily using the GRUB menu by highlighting the OS, pressing &amp;quot;e&amp;quot;, and appending the parameter to the end of the line beginning with &amp;quot;linux&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4. Unbind the device from the host kernel driver (Example: PCI device 01:00.0)&lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
* Load the PCI Stub Driver if it is compiled as a module&lt;br /&gt;
      modprobe pci_stub&lt;br /&gt;
      lspci -n&lt;br /&gt;
&lt;br /&gt;
* Locate the entry for device 01:00.0 and note the vendor and device ID (8086:10b9 in this example)&lt;br /&gt;
      ...&lt;br /&gt;
      01:00.0 0200: 8086:10b9 (rev 06)&lt;br /&gt;
      ...&lt;br /&gt;
&lt;br /&gt;
* Place this information in the following files:&lt;br /&gt;
      echo &amp;quot;8086 10b9&amp;quot; &amp;gt; /sys/bus/pci/drivers/pci-stub/new_id&lt;br /&gt;
      echo &amp;quot;0000:01:00.0&amp;quot; &amp;gt; /sys/bus/pci/devices/0000:01:00.0/driver/unbind&lt;br /&gt;
      echo &amp;quot;0000:01:00.0&amp;quot; &amp;gt; /sys/bus/pci/drivers/pci-stub/bind&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;5. Load the KVM modules&#039;&#039;&#039;&lt;br /&gt;
      modprobe kvm&lt;br /&gt;
      modprobe kvm-intel&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;6. Assign the device&#039;&#039;&#039;&lt;br /&gt;
      /usr/local/bin/qemu-system-x86_64 -m 512 -boot c -net none -hda /root/ia32e_rhel5u1.img -device pci-assign,host=01:00.0&lt;br /&gt;
&lt;br /&gt;
== VT-d device hotplug ==&lt;br /&gt;
KVM also supports hotplug devices with VT-d to guest. In guest command interface (you can press Ctrl+Alt+2 to enter it), you can use following command to hot add/remove devices to/from guest:&lt;br /&gt;
* hot add:&lt;br /&gt;
        device_add pci-assign,host=01:00.0,id=mydevice&lt;br /&gt;
* hot remove:&lt;br /&gt;
        device_del mydevice&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
* VT-d spec specifies that all conventional PCI devices behind a PCIe-to PCI/PCI-X bridge or conventional PCI bridge can only be collectively assigned to the same guest. PCIe devices do not have this restriction.&lt;br /&gt;
* If the device doesn&#039;t support MSI, and it shares IRQ with other devices, then it cannot be assigned due to host irq sharing for assigned devices is not supported. You will get warning message when you assign it. Notice this also apply to the devices which only support MSI-X.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Docs]][[Category:HowTo]][[Category:Devices]]&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=How_to_assign_devices_with_VT-d_in_KVM&amp;diff=173670</id>
		<title>How to assign devices with VT-d in KVM</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=How_to_assign_devices_with_VT-d_in_KVM&amp;diff=173670"/>
		<updated>2016-07-24T23:20:07Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* Assigning device to guest */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= How to assign devices with VT-d in KVM =&lt;br /&gt;
&lt;br /&gt;
== VT-d support ==&lt;br /&gt;
* In order to assign devices in KVM, you&#039;ll need a system which supports VT-d, not to be confused with the VT-x support of your CPU. VT-d needs to be supported by both your motherboard chipset and your CPU.&lt;br /&gt;
&lt;br /&gt;
* If you are in doubt whether your motherboard or CPU supports VT-d, the Xen VT-d wiki has some information about VT-d enabled chipsets, motherboards, and CPUs:&lt;br /&gt;
        http://wiki.xenproject.org/wiki/VTdHowTo&lt;br /&gt;
&lt;br /&gt;
* If your hardware does not have an IOMMU (known as &amp;quot;Intel VT-d&amp;quot; on Intel-based machines and &amp;quot;AMD I/O Virtualization Technology&amp;quot; on AMD-based machines), you will not be able to assign devices in KVM.&lt;br /&gt;
&lt;br /&gt;
* Assigning graphics cards is not officially supported at the moment, but there has been some success passing through a secondary Radeon HD 5850 as a VM&#039;s secondary display.&lt;br /&gt;
&lt;br /&gt;
== Assigning device to guest ==&lt;br /&gt;
&#039;&#039;&#039;1. Modify the kernel config&#039;&#039;&#039;&lt;br /&gt;
* make menuconfig&lt;br /&gt;
* set &amp;quot;Bus options (PCI etc.)&amp;quot; -&amp;gt; &amp;quot;Support for DMA Remapping Devices&amp;quot; to &amp;quot;*&amp;quot;&lt;br /&gt;
* set &amp;quot;Bus options (PCI etc.)&amp;quot; -&amp;gt; &amp;quot;Enable DMA Remapping Devices&amp;quot; to &amp;quot;*&amp;quot;&lt;br /&gt;
* set &amp;quot;Bus options (PCI etc.)&amp;quot; -&amp;gt; &amp;quot;PCI Stub driver&amp;quot; to &amp;quot;*&amp;quot;&lt;br /&gt;
* optional setting:&lt;br /&gt;
        set &amp;quot;Bus options (PCI etc.)&amp;quot; -&amp;gt; &amp;quot;Support for Interrupt Remapping&amp;quot; to &amp;quot;*&amp;quot;&lt;br /&gt;
* exit/save&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;2. Build the kernel&#039;&#039;&#039;&lt;br /&gt;
* make&lt;br /&gt;
* make modules_install&lt;br /&gt;
* make install&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Reboot and verify that your system has IOMMU support&#039;&#039;&#039;&lt;br /&gt;
* AMD Machine&lt;br /&gt;
** dmesg | grep AMD-Vi&lt;br /&gt;
      ...&lt;br /&gt;
      AMD-Vi: Enabling IOMMU at 0000:00:00.2 cap 0x40&lt;br /&gt;
      AMD-Vi: Lazy IO/TLB flushing enabled&lt;br /&gt;
      AMD-Vi: Initialized for Passthrough Mode&lt;br /&gt;
      ...&lt;br /&gt;
* Intel Machine&lt;br /&gt;
** dmesg | grep -e DMAR -e IOMMU&lt;br /&gt;
      ...&lt;br /&gt;
      DMAR:DRHD base: 0x000000feb03000 flags: 0x0&lt;br /&gt;
      IOMMU feb03000: ver 1:0 cap c9008020e30260 ecap 1000&lt;br /&gt;
      ...&lt;br /&gt;
* If you get no output you&#039;ll need to fix this before moving on. Check if your hardware supports VT-d and check that it has been enabled in BIOS.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; If you still get an error &amp;quot;No IOMMU found.&amp;quot;  Check dmesg for errors suggesting your BIOS is broken. Another possible reason: &lt;br /&gt;
CONFIG_DMAR_DEFAULT_ON is not set. In that case, pass &amp;quot;intel_iommu=on&amp;quot; as kernel parameter to enable it. AMD uses different kernel parameter than Intel, on AMD you will need to pass &amp;quot;iommu=pt iommu=1&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4. Unbind the device from the host kernel driver (Example: PCI device 01:00.0)&lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
* Load the PCI Stub Driver if it is compiled as a module&lt;br /&gt;
        modprobe pci_stub&lt;br /&gt;
* lspci -n&lt;br /&gt;
* locate the entry for device 01:00.0 and note down the vendor &amp;amp; device ID 8086:10b9&lt;br /&gt;
        ...&lt;br /&gt;
        01:00.0 0200: 8086:10b9 (rev 06)&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
* echo &amp;quot;8086 10b9&amp;quot; &amp;gt; /sys/bus/pci/drivers/pci-stub/new_id&lt;br /&gt;
* echo 0000:01:00.0 &amp;gt; /sys/bus/pci/devices/0000:01:00.0/driver/unbind&lt;br /&gt;
* echo 0000:01:00.0 &amp;gt; /sys/bus/pci/drivers/pci-stub/bind&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;5. Load the KVM modules&#039;&#039;&#039;&lt;br /&gt;
* modprobe kvm&lt;br /&gt;
* modprobe kvm-intel&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;6. Assign the device&#039;&#039;&#039;&lt;br /&gt;
* /usr/local/bin/qemu-system-x86_64 -m 512 -boot c -net none -hda /root/ia32e_rhel5u1.img -device pci-assign,host=01:00.0&lt;br /&gt;
&lt;br /&gt;
== VT-d device hotplug ==&lt;br /&gt;
KVM also supports hotplug devices with VT-d to guest. In guest command interface (you can press Ctrl+Alt+2 to enter it), you can use following command to hot add/remove devices to/from guest:&lt;br /&gt;
* hot add:&lt;br /&gt;
        device_add pci-assign,host=01:00.0,id=mydevice&lt;br /&gt;
* hot remove:&lt;br /&gt;
        device_del mydevice&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
* VT-d spec specifies that all conventional PCI devices behind a PCIe-to PCI/PCI-X bridge or conventional PCI bridge can only be collectively assigned to the same guest. PCIe devices do not have this restriction.&lt;br /&gt;
* If the device doesn&#039;t support MSI, and it shares IRQ with other devices, then it cannot be assigned due to host irq sharing for assigned devices is not supported. You will get warning message when you assign it. Notice this also apply to the devices which only support MSI-X.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Docs]][[Category:HowTo]][[Category:Devices]]&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=How_to_assign_devices_with_VT-d_in_KVM&amp;diff=173669</id>
		<title>How to assign devices with VT-d in KVM</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=How_to_assign_devices_with_VT-d_in_KVM&amp;diff=173669"/>
		<updated>2016-07-24T23:16:46Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* VT-d support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= How to assign devices with VT-d in KVM =&lt;br /&gt;
&lt;br /&gt;
== VT-d support ==&lt;br /&gt;
* In order to assign devices in KVM, you&#039;ll need a system which supports VT-d, not to be confused with the VT-x support of your CPU. VT-d needs to be supported by both your motherboard chipset and your CPU.&lt;br /&gt;
&lt;br /&gt;
* If you are in doubt whether your motherboard or CPU supports VT-d, the Xen VT-d wiki has some information about VT-d enabled chipsets, motherboards, and CPUs:&lt;br /&gt;
        http://wiki.xenproject.org/wiki/VTdHowTo&lt;br /&gt;
&lt;br /&gt;
* If your hardware does not have an IOMMU (known as &amp;quot;Intel VT-d&amp;quot; on Intel-based machines and &amp;quot;AMD I/O Virtualization Technology&amp;quot; on AMD-based machines), you will not be able to assign devices in KVM.&lt;br /&gt;
&lt;br /&gt;
* Assigning graphics cards is not officially supported at the moment, but there has been some success passing through a secondary Radeon HD 5850 as a VM&#039;s secondary display.&lt;br /&gt;
&lt;br /&gt;
== Assigning device to guest ==&lt;br /&gt;
&#039;&#039;&#039;1. Modifying kernel config:&#039;&#039;&#039;&lt;br /&gt;
* make menuconfig&lt;br /&gt;
* set &amp;quot;Bus options (PCI etc.)&amp;quot; -&amp;gt; &amp;quot;Support for DMA Remapping Devices&amp;quot; to &amp;quot;*&amp;quot;&lt;br /&gt;
* set &amp;quot;Bus options (PCI etc.)&amp;quot; -&amp;gt; &amp;quot;Enable DMA Remapping Devices&amp;quot; to &amp;quot;*&amp;quot;&lt;br /&gt;
* set &amp;quot;Bus options (PCI etc.)&amp;quot; -&amp;gt; &amp;quot;PCI Stub driver&amp;quot; to &amp;quot;*&amp;quot;&lt;br /&gt;
* optional setting:&lt;br /&gt;
        set &amp;quot;Bus options (PCI etc.)&amp;quot; -&amp;gt; &amp;quot;Support for Interrupt Remapping&amp;quot; to &amp;quot;*&amp;quot;&lt;br /&gt;
* exit/save&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;2. build kernel:&#039;&#039;&#039;&lt;br /&gt;
* make&lt;br /&gt;
* make modules_install&lt;br /&gt;
* make install&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. reboot and verify that your system has IOMMU support&#039;&#039;&#039;&lt;br /&gt;
* AMD Machine&lt;br /&gt;
** dmesg | grep AMD-Vi&lt;br /&gt;
      ...&lt;br /&gt;
      AMD-Vi: Enabling IOMMU at 0000:00:00.2 cap 0x40&lt;br /&gt;
      AMD-Vi: Lazy IO/TLB flushing enabled&lt;br /&gt;
      AMD-Vi: Initialized for Passthrough Mode&lt;br /&gt;
      ...&lt;br /&gt;
* Intel Machine&lt;br /&gt;
** dmesg | grep -e DMAR -e IOMMU&lt;br /&gt;
      ...&lt;br /&gt;
      DMAR:DRHD base: 0x000000feb03000 flags: 0x0&lt;br /&gt;
      IOMMU feb03000: ver 1:0 cap c9008020e30260 ecap 1000&lt;br /&gt;
      ...&lt;br /&gt;
* If you get no output you&#039;ll need to fix this before moving on. Check if your hardware supports VT-d and check that it has been enabled in BIOS.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; If you still get an error &amp;quot;No IOMMU found.&amp;quot;  Check dmesg for errors suggesting your BIOS is broken. Another possible reason: &lt;br /&gt;
CONFIG_DMAR_DEFAULT_ON is not set. In that case, pass &amp;quot;intel_iommu=on&amp;quot; as kernel parameter to enable it. AMD uses different kernel parameter than Intel, on AMD you need to pass &amp;quot;iommu=pt iommu=1&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4. unbind device from host kernel driver (example PCI device 01:00.0)&lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
* Load the PCI Stub Driver if it is compiled as a module&lt;br /&gt;
        modprobe pci_stub&lt;br /&gt;
* lspci -n&lt;br /&gt;
* locate the entry for device 01:00.0 and note down the vendor &amp;amp; device ID 8086:10b9&lt;br /&gt;
        ...&lt;br /&gt;
        01:00.0 0200: 8086:10b9 (rev 06)&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
* echo &amp;quot;8086 10b9&amp;quot; &amp;gt; /sys/bus/pci/drivers/pci-stub/new_id&lt;br /&gt;
* echo 0000:01:00.0 &amp;gt; /sys/bus/pci/devices/0000:01:00.0/driver/unbind&lt;br /&gt;
* echo 0000:01:00.0 &amp;gt; /sys/bus/pci/drivers/pci-stub/bind&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;5. load KVM modules:&#039;&#039;&#039;&lt;br /&gt;
* modprobe kvm&lt;br /&gt;
* modprobe kvm-intel&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;6. assign device:&#039;&#039;&#039;&lt;br /&gt;
* /usr/local/bin/qemu-system-x86_64 -m 512 -boot c -net none -hda /root/ia32e_rhel5u1.img -device pci-assign,host=01:00.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== VT-d device hotplug ==&lt;br /&gt;
KVM also supports hotplug devices with VT-d to guest. In guest command interface (you can press Ctrl+Alt+2 to enter it), you can use following command to hot add/remove devices to/from guest:&lt;br /&gt;
* hot add:&lt;br /&gt;
        device_add pci-assign,host=01:00.0,id=mydevice&lt;br /&gt;
* hot remove:&lt;br /&gt;
        device_del mydevice&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
* VT-d spec specifies that all conventional PCI devices behind a PCIe-to PCI/PCI-X bridge or conventional PCI bridge can only be collectively assigned to the same guest. PCIe devices do not have this restriction.&lt;br /&gt;
* If the device doesn&#039;t support MSI, and it shares IRQ with other devices, then it cannot be assigned due to host irq sharing for assigned devices is not supported. You will get warning message when you assign it. Notice this also apply to the devices which only support MSI-X.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Docs]][[Category:HowTo]][[Category:Devices]]&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Change_cdrom&amp;diff=173582</id>
		<title>Change cdrom</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Change_cdrom&amp;diff=173582"/>
		<updated>2015-12-26T01:12:28Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Qemu provides a way to change the iso in the virtual cdrom device via the monitor interface (Ctrl+Alt+2).&lt;br /&gt;
&lt;br /&gt;
 QEMU 0.10.5 monitor - type &#039;help&#039; for more information&lt;br /&gt;
 (qemu)&lt;br /&gt;
&lt;br /&gt;
The commands you&#039;ll want to use are &#039;&#039;&#039;info block&#039;&#039;&#039;, &#039;&#039;&#039;eject&#039;&#039;&#039;, and &#039;&#039;&#039;change&#039;&#039;&#039;.  First we need to determine which block device is the cdrom device you are interested in.  Issue the &#039;&#039;&#039;info block&#039;&#039;&#039; command and look for cdrom devices.&lt;br /&gt;
&lt;br /&gt;
 (qemu) info block&lt;br /&gt;
 ide0-hd0: type=hd removable=0 file=/dev/null ro=0 drv=host_device encrypted=0&lt;br /&gt;
 ide1-cd0: type=cdrom removable=1 locked=0 [not inserted]&lt;br /&gt;
 floppy0: type=floppy removable=1 locked=0 [not inserted]&lt;br /&gt;
 sd0: type=floppy removable=1 locked=0 [not inserted]&lt;br /&gt;
&lt;br /&gt;
ide1-cd0 is the only cdrom device in this example and there isn&#039;t any media inserted.  To change the iso, we issue the &#039;&#039;&#039;change&#039;&#039;&#039; command supplying the device name (ide1-cd0) and the path to the new iso file.&lt;br /&gt;
&lt;br /&gt;
 (qemu) change ide1-cd0 /tmp/dsl-4.4.10.iso &lt;br /&gt;
 (qemu) info block&lt;br /&gt;
 ide0-hd0: type=hd removable=0 file=/dev/null ro=0 drv=host_device encrypted=0&lt;br /&gt;
 ide1-cd0: type=cdrom removable=1 locked=0 file=/tmp/dsl-4.4.10.iso ro=0  drv=raw encrypted=0&lt;br /&gt;
 floppy0: type=floppy removable=1 locked=0 [not inserted]&lt;br /&gt;
 sd0: type=floppy removable=1 locked=0 [not inserted]&lt;br /&gt;
 (qemu) &lt;br /&gt;
&lt;br /&gt;
In case you already have a cdrom in the drive you need to &#039;&#039;&#039;eject&#039;&#039;&#039; the current iso first before issuing the &#039;&#039;&#039;change&#039;&#039;&#039; command.  The &#039;&#039;&#039;eject&#039;&#039;&#039; command takes the name of the cdrom block device.&lt;br /&gt;
&lt;br /&gt;
 (qemu) eject ide1-cd0&lt;br /&gt;
 (qemu) info block&lt;br /&gt;
 ide0-hd0: type=hd removable=0 file=/dev/null ro=0 drv=host_device encrypted=0&lt;br /&gt;
 ide1-cd0: type=cdrom removable=1 locked=0 [not inserted]&lt;br /&gt;
 floppy0: type=floppy removable=1 locked=0 [not inserted]&lt;br /&gt;
 sd0: type=floppy removable=1 locked=0 [not inserted]&lt;br /&gt;
 (qemu) change ide1-cd0 /tmp/fedora11.iso &lt;br /&gt;
 (qemu) info block&lt;br /&gt;
 ide0-hd0: type=hd removable=0 file=/dev/null ro=0 drv=host_device encrypted=0&lt;br /&gt;
 ide1-cd0: type=cdrom removable=1 locked=0 file=/tmp/fedora11.iso ro=0 drv=raw  encrypted=0&lt;br /&gt;
 floppy0: type=floppy removable=1 locked=0 [not inserted]&lt;br /&gt;
 sd0: type=floppy removable=1 locked=0 [not inserted]&lt;br /&gt;
&lt;br /&gt;
[[Category:HowTo]][[Category:Docs]][[Category:Devices]]&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Networking&amp;diff=173578</id>
		<title>Networking</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Networking&amp;diff=173578"/>
		<updated>2015-11-22T04:46:14Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* User Networking */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Configuring Guest Networking =&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 documentation about networking in qemu. This page will try to explain how to configure the most frequent types of networking needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== User Networking ==&lt;br /&gt;
&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;
&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, then the user needs to have rw access to /dev/kvm&lt;br /&gt;
* In order for the guest to be able to access the internet or a local network, the host system must be able to access these resources as well&lt;br /&gt;
&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-level (a.k.a slirp) networking:&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img&lt;br /&gt;
&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;
* The 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 an rtl8139-based network interface.&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 the other address of the host to connect to.&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, then the user needs to have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&lt;br /&gt;
 ip&lt;br /&gt;
 brctl&lt;br /&gt;
 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;
 # brctl addbr br0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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;
         tunctl -u `whoami` -t $1&lt;br /&gt;
         ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         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 qemu-ifup as root, then consider using sudo&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;
== Public Bridge ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; The method shown here will not work with most (if not 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;
&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 kvm as root, then the user must have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&lt;br /&gt;
 ip&lt;br /&gt;
 brctl&lt;br /&gt;
 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;
&lt;br /&gt;
&#039;&#039;&#039;Solution 1: Using Distribution-Specific Scripts&#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 an IP address.&lt;br /&gt;
&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 Configuration&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* You need to create a bridge, e-g:&lt;br /&gt;
 # 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;
 # brctl addif br0 eth0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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;
         tunctl -u `whoami` -t $1&lt;br /&gt;
         ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         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;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* If you don&#039;t want to run qemu-ifup as root, then consider using sudo&lt;br /&gt;
* Each guest on the network must have a different MAC address&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;
== Routing with iptables ==&lt;br /&gt;
&lt;br /&gt;
With this method, you can connect your guest vm to a tap device in your host. Then you can set iptables rules in your host so that it acts as a router and firewall for your guest.&lt;br /&gt;
&lt;br /&gt;
Routing is done simply by setting the default route on the client to the IP address of the host, allowing IP forwarding, and setting a route to the tap device of the client on the host.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Host-side: Allow IPv4 forwarding and add a route to the guest (could be put in a script, but the route has to be added after the guest 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;
&lt;br /&gt;
*Guest-side: Set the default gateway to the IP address of the host (make sure the host and guest IP addresses are in the same subnet):&lt;br /&gt;
&lt;br /&gt;
 route add default gw &amp;lt;ip-of-host&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Note: If the host is not on the same subnet as the guest, then you must manually add the route to the host before you create the 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;
== VDE ==&lt;br /&gt;
&lt;br /&gt;
Another option is using VDE (Virtual Distributed Ethernet).&lt;br /&gt;
&lt;br /&gt;
More information will be provided later.&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 comparisons between VFIO passthrough and virtio are discussed in [[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>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Networking&amp;diff=173577</id>
		<title>Networking</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Networking&amp;diff=173577"/>
		<updated>2015-11-22T04:42:42Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* User Networking */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Configuring Guest Networking =&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 documentation about networking in qemu. This page will try to explain how to configure the most frequent types of networking needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== User Networking ==&lt;br /&gt;
&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;
&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, then the user 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;
&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-level (a.k.a slirp) networking:&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img&lt;br /&gt;
&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;
* The 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 an rtl8139-based network interface.&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 the other address of the host to connect to.&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, then the user needs to have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&lt;br /&gt;
 ip&lt;br /&gt;
 brctl&lt;br /&gt;
 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;
 # brctl addbr br0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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;
         tunctl -u `whoami` -t $1&lt;br /&gt;
         ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         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 qemu-ifup as root, then consider using sudo&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;
== Public Bridge ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; The method shown here will not work with most (if not 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;
&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 kvm as root, then the user must have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&lt;br /&gt;
 ip&lt;br /&gt;
 brctl&lt;br /&gt;
 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;
&lt;br /&gt;
&#039;&#039;&#039;Solution 1: Using Distribution-Specific Scripts&#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 an IP address.&lt;br /&gt;
&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 Configuration&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* You need to create a bridge, e-g:&lt;br /&gt;
 # 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;
 # brctl addif br0 eth0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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;
         tunctl -u `whoami` -t $1&lt;br /&gt;
         ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         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;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* If you don&#039;t want to run qemu-ifup as root, then consider using sudo&lt;br /&gt;
* Each guest on the network must have a different MAC address&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;
== Routing with iptables ==&lt;br /&gt;
&lt;br /&gt;
With this method, you can connect your guest vm to a tap device in your host. Then you can set iptables rules in your host so that it acts as a router and firewall for your guest.&lt;br /&gt;
&lt;br /&gt;
Routing is done simply by setting the default route on the client to the IP address of the host, allowing IP forwarding, and setting a route to the tap device of the client on the host.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Host-side: Allow IPv4 forwarding and add a route to the guest (could be put in a script, but the route has to be added after the guest 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;
&lt;br /&gt;
*Guest-side: Set the default gateway to the IP address of the host (make sure the host and guest IP addresses are in the same subnet):&lt;br /&gt;
&lt;br /&gt;
 route add default gw &amp;lt;ip-of-host&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Note: If the host is not on the same subnet as the guest, then you must manually add the route to the host before you create the 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;
== VDE ==&lt;br /&gt;
&lt;br /&gt;
Another option is using VDE (Virtual Distributed Ethernet).&lt;br /&gt;
&lt;br /&gt;
More information will be provided later.&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 comparisons between VFIO passthrough and virtio are discussed in [[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>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Networking&amp;diff=173576</id>
		<title>Networking</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Networking&amp;diff=173576"/>
		<updated>2015-11-22T04:37:31Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* VDE */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Configuring Guest Networking =&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 documentation about networking in qemu. This page will try to explain how to configure the most frequent types of networking needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== User Networking ==&lt;br /&gt;
&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;
&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, then the user 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;
&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-level (a.k.a slirp) networking:&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img&lt;br /&gt;
&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;
* The 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 the other address of the host to connect to.&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, then the user needs to have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&lt;br /&gt;
 ip&lt;br /&gt;
 brctl&lt;br /&gt;
 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;
 # brctl addbr br0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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;
         tunctl -u `whoami` -t $1&lt;br /&gt;
         ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         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 qemu-ifup as root, then consider using sudo&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;
== Public Bridge ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; The method shown here will not work with most (if not 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;
&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 kvm as root, then the user must have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&lt;br /&gt;
 ip&lt;br /&gt;
 brctl&lt;br /&gt;
 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;
&lt;br /&gt;
&#039;&#039;&#039;Solution 1: Using Distribution-Specific Scripts&#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 an IP address.&lt;br /&gt;
&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 Configuration&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* You need to create a bridge, e-g:&lt;br /&gt;
 # 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;
 # brctl addif br0 eth0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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;
         tunctl -u `whoami` -t $1&lt;br /&gt;
         ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         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;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* If you don&#039;t want to run qemu-ifup as root, then consider using sudo&lt;br /&gt;
* Each guest on the network must have a different MAC address&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;
== Routing with iptables ==&lt;br /&gt;
&lt;br /&gt;
With this method, you can connect your guest vm to a tap device in your host. Then you can set iptables rules in your host so that it acts as a router and firewall for your guest.&lt;br /&gt;
&lt;br /&gt;
Routing is done simply by setting the default route on the client to the IP address of the host, allowing IP forwarding, and setting a route to the tap device of the client on the host.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Host-side: Allow IPv4 forwarding and add a route to the guest (could be put in a script, but the route has to be added after the guest 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;
&lt;br /&gt;
*Guest-side: Set the default gateway to the IP address of the host (make sure the host and guest IP addresses are in the same subnet):&lt;br /&gt;
&lt;br /&gt;
 route add default gw &amp;lt;ip-of-host&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Note: If the host is not on the same subnet as the guest, then you must manually add the route to the host before you create the 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;
== VDE ==&lt;br /&gt;
&lt;br /&gt;
Another option is using VDE (Virtual Distributed Ethernet).&lt;br /&gt;
&lt;br /&gt;
More information will be provided later.&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 comparisons between VFIO passthrough and virtio are discussed in [[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>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Networking&amp;diff=173575</id>
		<title>Networking</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Networking&amp;diff=173575"/>
		<updated>2015-11-22T04:33:26Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* Routing with iptables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Configuring Guest Networking =&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 documentation about networking in qemu. This page will try to explain how to configure the most frequent types of networking needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== User Networking ==&lt;br /&gt;
&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;
&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, then the user 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;
&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-level (a.k.a slirp) networking:&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img&lt;br /&gt;
&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;
* The 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 the other address of the host to connect to.&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, then the user needs to have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&lt;br /&gt;
 ip&lt;br /&gt;
 brctl&lt;br /&gt;
 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;
 # brctl addbr br0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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;
         tunctl -u `whoami` -t $1&lt;br /&gt;
         ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         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 qemu-ifup as root, then consider using sudo&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;
== Public Bridge ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; The method shown here will not work with most (if not 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;
&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 kvm as root, then the user must have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&lt;br /&gt;
 ip&lt;br /&gt;
 brctl&lt;br /&gt;
 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;
&lt;br /&gt;
&#039;&#039;&#039;Solution 1: Using Distribution-Specific Scripts&#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 an IP address.&lt;br /&gt;
&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 Configuration&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* You need to create a bridge, e-g:&lt;br /&gt;
 # 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;
 # brctl addif br0 eth0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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;
         tunctl -u `whoami` -t $1&lt;br /&gt;
         ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         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;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* If you don&#039;t want to run qemu-ifup as root, then consider using sudo&lt;br /&gt;
* Each guest on the network must have a different MAC address&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;
== Routing with iptables ==&lt;br /&gt;
&lt;br /&gt;
With this method, you can connect your guest vm to a tap device in your host. Then you can set iptables rules in your host so that it acts as a router and firewall for your guest.&lt;br /&gt;
&lt;br /&gt;
Routing is done simply by setting the default route on the client to the IP address of the host, allowing IP forwarding, and setting a route to the tap device of the client on the host.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Host-side: Allow IPv4 forwarding and add a route to the guest (could be put in a script, but the route has to be added after the guest 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;
&lt;br /&gt;
*Guest-side: Set the default gateway to the IP address of the host (make sure the host and guest IP addresses are in the same subnet):&lt;br /&gt;
&lt;br /&gt;
 route add default gw &amp;lt;ip-of-host&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Note: If the host is not on the same subnet as the guest, then you must manually add the route to the host before you create the 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;
== 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 comparisons between VFIO passthrough and virtio are discussed in [[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>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Networking&amp;diff=173574</id>
		<title>Networking</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Networking&amp;diff=173574"/>
		<updated>2015-11-22T04:30:08Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* Routing with iptables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Configuring Guest Networking =&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 documentation about networking in qemu. This page will try to explain how to configure the most frequent types of networking needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== User Networking ==&lt;br /&gt;
&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;
&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, then the user 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;
&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-level (a.k.a slirp) networking:&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img&lt;br /&gt;
&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;
* The 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 the other address of the host to connect to.&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, then the user needs to have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&lt;br /&gt;
 ip&lt;br /&gt;
 brctl&lt;br /&gt;
 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;
 # brctl addbr br0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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;
         tunctl -u `whoami` -t $1&lt;br /&gt;
         ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         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 qemu-ifup as root, then consider using sudo&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;
== Public Bridge ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; The method shown here will not work with most (if not 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;
&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 kvm as root, then the user must have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&lt;br /&gt;
 ip&lt;br /&gt;
 brctl&lt;br /&gt;
 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;
&lt;br /&gt;
&#039;&#039;&#039;Solution 1: Using Distribution-Specific Scripts&#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 an IP address.&lt;br /&gt;
&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 Configuration&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* You need to create a bridge, e-g:&lt;br /&gt;
 # 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;
 # brctl addif br0 eth0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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;
         tunctl -u `whoami` -t $1&lt;br /&gt;
         ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         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;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* If you don&#039;t want to run qemu-ifup as root, then consider using sudo&lt;br /&gt;
* Each guest on the network must have a different MAC address&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;
== Routing with iptables ==&lt;br /&gt;
&lt;br /&gt;
With this method, you can connect your guest vm to a tap device in your host. Then you can set iptables rules in your host so that it acts as a router and firewall for your guest.&lt;br /&gt;
&lt;br /&gt;
Routing would be done simply by creating the default route on the client to the IP address of the host, 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;
*Host-side: Allow IPv4 forwarding and add a route to the guest (could be put in a script, but the route has to be added after the guest 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;
*Guest-side: Set the default gateway to the IP address of the host (make sure the host and guest IP addresses are in the same subnet):&lt;br /&gt;
&lt;br /&gt;
 route add default gw &amp;lt;ip-of-host&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Note: If the host is not on the same subnet as the guest, then you must manually add the route to the host before you create the 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;
== 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 comparisons between VFIO passthrough and virtio are discussed in [[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>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Networking&amp;diff=173573</id>
		<title>Networking</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Networking&amp;diff=173573"/>
		<updated>2015-11-22T04:15:20Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* Configuring Guest Networking */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Configuring Guest Networking =&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 documentation about networking in qemu. This page will try to explain how to configure the most frequent types of networking needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== User Networking ==&lt;br /&gt;
&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;
&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, then the user 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;
&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-level (a.k.a slirp) networking:&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img&lt;br /&gt;
&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;
* The 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 the other address of the host to connect to.&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, then the user needs to have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&lt;br /&gt;
 ip&lt;br /&gt;
 brctl&lt;br /&gt;
 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;
 # brctl addbr br0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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;
         tunctl -u `whoami` -t $1&lt;br /&gt;
         ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         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 qemu-ifup as root, then consider using sudo&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;
== Public Bridge ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; The method shown here will not work with most (if not 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;
&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 kvm as root, then the user must have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&lt;br /&gt;
 ip&lt;br /&gt;
 brctl&lt;br /&gt;
 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;
&lt;br /&gt;
&#039;&#039;&#039;Solution 1: Using Distribution-Specific Scripts&#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 an IP address.&lt;br /&gt;
&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 Configuration&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* You need to create a bridge, e-g:&lt;br /&gt;
 # 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;
 # brctl addif br0 eth0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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;
         tunctl -u `whoami` -t $1&lt;br /&gt;
         ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         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;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* If you don&#039;t want to run qemu-ifup as root, then consider using sudo&lt;br /&gt;
* Each guest on the network must have a different MAC address&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;
== 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 comparisons between VFIO passthrough and virtio are discussed in [[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>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Networking&amp;diff=173572</id>
		<title>Networking</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Networking&amp;diff=173572"/>
		<updated>2015-11-22T04:12:42Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* Public Bridge */&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;
&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;
&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, then the user 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;
&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-level (a.k.a slirp) networking:&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img&lt;br /&gt;
&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;
* The 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 the other address of the host to connect to.&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, then the user needs to have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&lt;br /&gt;
 ip&lt;br /&gt;
 brctl&lt;br /&gt;
 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;
 # brctl addbr br0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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;
         tunctl -u `whoami` -t $1&lt;br /&gt;
         ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         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 qemu-ifup as root, then consider using sudo&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;
== Public Bridge ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; The method shown here will not work with most (if not 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;
&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 kvm as root, then the user must have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&lt;br /&gt;
 ip&lt;br /&gt;
 brctl&lt;br /&gt;
 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;
&lt;br /&gt;
&#039;&#039;&#039;Solution 1: Using Distribution-Specific Scripts&#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 an IP address.&lt;br /&gt;
&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 Configuration&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* You need to create a bridge, e-g:&lt;br /&gt;
 # 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;
 # brctl addif br0 eth0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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;
         tunctl -u `whoami` -t $1&lt;br /&gt;
         ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         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;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* If you don&#039;t want to run qemu-ifup as root, then consider using sudo&lt;br /&gt;
* Each guest on the network must have a different MAC address&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;
== 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 comparisons between VFIO passthrough and virtio are discussed in [[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>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Networking&amp;diff=173571</id>
		<title>Networking</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Networking&amp;diff=173571"/>
		<updated>2015-11-22T04:06:19Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* Private Virtual Bridge */&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;
&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;
&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, then the user 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;
&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-level (a.k.a slirp) networking:&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img&lt;br /&gt;
&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;
* The 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 the other address of the host to connect to.&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, then the user needs to have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&lt;br /&gt;
 ip&lt;br /&gt;
 brctl&lt;br /&gt;
 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;
 # brctl addbr br0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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;
         tunctl -u `whoami` -t $1&lt;br /&gt;
         ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         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 qemu-ifup as root, then consider using sudo&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;
== Public Bridge ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; The method shown here will not work with most (if not 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;
&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 kvm as root, then the user must have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&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;
&lt;br /&gt;
&#039;&#039;&#039;Solution 1: Using Distribution-Specific Scripts&#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 an ip address.&lt;br /&gt;
&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 Configuration&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* You need to create a bridge, e-g:&lt;br /&gt;
 # /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;
 # /usr/sbin/brctl addif br0 eth0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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/sbin/tunctl -u `whoami` -t $1&lt;br /&gt;
         /sbin/ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         /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;
&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&lt;br /&gt;
* Each guest on the network must have a different MAC address&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;
== 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 comparisons between VFIO passthrough and virtio are discussed in [[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>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Networking&amp;diff=173570</id>
		<title>Networking</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Networking&amp;diff=173570"/>
		<updated>2015-11-22T03:57:27Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* User Networking */&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;
&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;
&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, then the user 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;
&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-level (a.k.a slirp) networking:&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img&lt;br /&gt;
&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;
* The 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 the other address of the host to connect to.&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, then the user 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;
== Public Bridge ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; The method shown here will not work with most (if not 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;
&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 kvm as root, then the user must have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&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;
&lt;br /&gt;
&#039;&#039;&#039;Solution 1: Using Distribution-Specific Scripts&#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 an ip address.&lt;br /&gt;
&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 Configuration&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* You need to create a bridge, e-g:&lt;br /&gt;
 # /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;
 # /usr/sbin/brctl addif br0 eth0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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/sbin/tunctl -u `whoami` -t $1&lt;br /&gt;
         /sbin/ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         /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;
&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&lt;br /&gt;
* Each guest on the network must have a different MAC address&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;
== 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 comparisons between VFIO passthrough and virtio are discussed in [[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>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Networking&amp;diff=173569</id>
		<title>Networking</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Networking&amp;diff=173569"/>
		<updated>2015-11-22T03:53:55Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* 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;
&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;
&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;
&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-level (a.k.a slirp) networking:&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img&lt;br /&gt;
&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;
* The 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 the other address of the host to connect to.&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, then the user 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;
== Public Bridge ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; The method shown here will not work with most (if not 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;
&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 kvm as root, then the user must have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&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;
&lt;br /&gt;
&#039;&#039;&#039;Solution 1: Using Distribution-Specific Scripts&#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 an ip address.&lt;br /&gt;
&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 Configuration&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* You need to create a bridge, e-g:&lt;br /&gt;
 # /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;
 # /usr/sbin/brctl addif br0 eth0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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/sbin/tunctl -u `whoami` -t $1&lt;br /&gt;
         /sbin/ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         /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;
&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&lt;br /&gt;
* Each guest on the network must have a different MAC address&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;
== 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 comparisons between VFIO passthrough and virtio are discussed in [[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>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Networking&amp;diff=173568</id>
		<title>Networking</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Networking&amp;diff=173568"/>
		<updated>2015-11-22T03:52:23Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* 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;
&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;
&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;
&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-level (a.k.a slirp) networking:&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img&lt;br /&gt;
&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;
* The 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 the other address of the host to connect to.&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, then the user 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;
== Public Bridge ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; The method shown here will not work with most (if not 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;
&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 kvm as root, then the user must have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&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;
&lt;br /&gt;
&#039;&#039;&#039;Solution 1: Using Distribution-Specific Scripts&#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 an ip address.&lt;br /&gt;
&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 Configuration&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* You need to create a bridge, e-g:&lt;br /&gt;
 # /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;
 # /usr/sbin/brctl addif br0 eth0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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/sbin/tunctl -u `whoami` -t $1&lt;br /&gt;
         /sbin/ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         /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;
&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&lt;br /&gt;
* Each guest on the network must have a different MAC address&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;
== 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 comparisons 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>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Networking&amp;diff=173567</id>
		<title>Networking</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Networking&amp;diff=173567"/>
		<updated>2015-11-22T03:51:01Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* User Networking */&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;
&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;
&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;
&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-level (a.k.a slirp) networking:&lt;br /&gt;
 qemu-system-x86_64 -hda /path/to/hda.img&lt;br /&gt;
&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;
* The 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 the other address of the host to connect to.&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, then the user 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;
== Public Bridge ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; The method shown here will not work with most (if not 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;
&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 kvm as root, then the user must have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&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;
&lt;br /&gt;
&#039;&#039;&#039;Solution 1: Using Distribution-Specific Scripts&#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 an ip address.&lt;br /&gt;
&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 Configuration&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* You need to create a bridge, e-g:&lt;br /&gt;
 # /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;
 # /usr/sbin/brctl addif br0 eth0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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/sbin/tunctl -u `whoami` -t $1&lt;br /&gt;
         /sbin/ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         /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;
&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&lt;br /&gt;
* Each guest on the network must have a different MAC address&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;
== 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>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Networking&amp;diff=173566</id>
		<title>Networking</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Networking&amp;diff=173566"/>
		<updated>2015-11-22T03:45:13Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* Public Bridge */&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, then the user 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;
== Public Bridge ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; The method shown here will not work with most (if not 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;
&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 kvm as root, then the user must have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&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;
&lt;br /&gt;
&#039;&#039;&#039;Solution 1: Using Distribution-Specific Scripts&#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 an ip address.&lt;br /&gt;
&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 Configuration&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* You need to create a bridge, e-g:&lt;br /&gt;
 # /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;
 # /usr/sbin/brctl addif br0 eth0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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/sbin/tunctl -u `whoami` -t $1&lt;br /&gt;
         /sbin/ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         /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;
&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&lt;br /&gt;
* Each guest on the network must have a different MAC address&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;
== 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>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Networking&amp;diff=173565</id>
		<title>Networking</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Networking&amp;diff=173565"/>
		<updated>2015-11-22T03:41:55Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* Public Bridge */&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, then the user 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;
== Public Bridge ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; The method shown here will not work with most (if not 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 kvm as root, then the user must have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&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 Distribution-Specific Scripts&#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 an 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 Configuration&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* You need to create a bridge, e-g:&lt;br /&gt;
 # /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;
 # /usr/sbin/brctl addif br0 eth0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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/sbin/tunctl -u `whoami` -t $1&lt;br /&gt;
         /sbin/ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         /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;
== 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>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Networking&amp;diff=173564</id>
		<title>Networking</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Networking&amp;diff=173564"/>
		<updated>2015-11-22T03:40:48Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* Private Virtual Bridge */&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, then the user 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;
== public bridge ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; The method shown here will not work with most (if not 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 kvm as root, then the user must have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&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 Distribution-Specific Scripts&#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 an 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 Configuration&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* You need to create a bridge, e-g:&lt;br /&gt;
 # /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;
 # /usr/sbin/brctl addif br0 eth0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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/sbin/tunctl -u `whoami` -t $1&lt;br /&gt;
         /sbin/ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         /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;
== 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>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Networking&amp;diff=173563</id>
		<title>Networking</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Networking&amp;diff=173563"/>
		<updated>2015-11-22T03:38:44Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* public bridge */&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 method shown here will not work with most (if not 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 kvm as root, then the user must have rw access to /dev/kvm&lt;br /&gt;
* The following commands must be installed on the host system and executed as root:&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 Distribution-Specific Scripts&#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 an 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 Configuration&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* You need to create a bridge, e-g:&lt;br /&gt;
 # /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;
 # /usr/sbin/brctl addif br0 eth0&lt;br /&gt;
&lt;br /&gt;
* You need a qemu-ifup script containing the following (run as root):&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/sbin/tunctl -u `whoami` -t $1&lt;br /&gt;
         /sbin/ip link set $1 up&lt;br /&gt;
         sleep 0.5s&lt;br /&gt;
         /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;
== 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>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=FAQ&amp;diff=173561</id>
		<title>FAQ</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=FAQ&amp;diff=173561"/>
		<updated>2015-11-08T20:03:43Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* When connecting to a VNC terminal, a &amp;quot;rect too big&amp;quot; message appears and the VNC session disconnects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=FAQ=&lt;br /&gt;
__TOC__&lt;br /&gt;
== Preparing to use KVM ==&lt;br /&gt;
=== What do I need to use KVM? ===&lt;br /&gt;
You will need an x86 machine running a recent Linux kernel on an Intel processor with VT (virtualization technology) extensions, or an AMD processor with SVM extensions (also called AMD-V). Xen has a [http://wiki.xensource.com/xenwiki/HVM_Compatible_Processors complete list] of compatible processors. For Intel processors, see also [http://ark.intel.com/VTList.aspx the Intel® Virtualization Technology List].&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
=== Are 64-bit processors supported under KVM? ===&lt;br /&gt;
Yes they are supported and will allow you to run 32-bit and 64-bit guests.&lt;br /&gt;
&lt;br /&gt;
See also &#039;&#039;&#039;Can KVM run a 32-bit guest on a 64-bit host? What about PAE?&#039;&#039;&#039; below.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What is Intel VT / AMD-V / hvm? ===&lt;br /&gt;
[http://www.intel.com/technology/itj/2006/v10i3/1-hardware/6-vt-x-vt-i-solutions.htm Intel VT] and [http://www.amd.com/us-en/Processors/ProductInformation/0,,30_118_8826_14287,00.html AMD&#039;s AMD-V] are instruction set extensions that provide hardware assistance to virtual machine monitors. They enable running fully isolated virtual machines at native hardware speeds, for some workloads.&lt;br /&gt;
&lt;br /&gt;
HVM (for Hardware Virtual Machine) is a vendor-neutral term often used to designate the x86 instruction set extensions.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Where do I get my kvm kernel modules from? ===&lt;br /&gt;
&lt;br /&gt;
See the [[Getting the kvm kernel modules]] page.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How can I tell if I have Intel VT or AMD-V? ===&lt;br /&gt;
With a recent enough Linux kernel, run the command:&lt;br /&gt;
&lt;br /&gt;
 . egrep &#039;^flags.*(vmx|svm)&#039; /proc/cpuinfo&lt;br /&gt;
&lt;br /&gt;
If something shows up, you have VT. You can also check the processor model name (in `/proc/cpuinfo`) in the vendor&#039;s web site.&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
*  You&#039;ll never see (vmx|svm) in /proc/cpuinfo if you&#039;re currently running in  in a dom0 or domU.&amp;lt;br /&amp;gt; The Xen hypervisor suppresses these flags in order to prevent hijacking.&lt;br /&gt;
* Some manufacturers disable VT in the machine&#039;s BIOS, in such a way that it cannot be re-enabled.&lt;br /&gt;
* `/proc/cpuinfo` only shows virtualization capabilities starting with Linux 2.6.15 (Intel) and Linux 2.6.16 (AMD). Use the `uname -r` command to query your kernel version.&lt;br /&gt;
In case of doubt, contact your hardware vendor.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== &amp;quot;KVM: disabled by BIOS&amp;quot; error ===&lt;br /&gt;
Check if there is an option to enable it in the BIOS. If not, look for a more recent BIOS on the vendor&#039;s web site.&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
* On some hardware (e-g HP nx6320), you need to power-off/power-on the machine after enabling virtualization in the BIOS.&lt;br /&gt;
* Enabling some BIOS features may break VT support on some hardware (e-g Enabling Intel AMT on a Thinkpad T500 will prevent kvm-intel from loading with &amp;quot;disabled by bios&amp;quot;)&lt;br /&gt;
* On some Dell hardware, you also need to disable &amp;quot;Trusted Execution&amp;quot;, otherwise VT will not be enabled.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How can I use AMD-V extension? ===&lt;br /&gt;
 modprobe kvm-amd&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What user space tools does KVM use? ===&lt;br /&gt;
KVM uses a slightly modified [http://www.nongnu.org/qemu QEMU] program to instantiate the virtual machine. Once running, a virtual machine is just a regular process. You can use `top(1), kill(1), taskset(1)` and similar tools to manage virtual machines.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What virtual disk formats can KVM use? ===&lt;br /&gt;
KVM inherits a wealth of disk formats support from QEMU; it supports raw images, the native QEMU format (qcow2), VMware format, and many more.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How do I use KVM on a headless machine (without a local GUI?) ===&lt;br /&gt;
Install a management tool such as virt-manager on a remote machine.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Are there management tools available to help me manage my virtual machines? ===&lt;br /&gt;
Yes.  Please see the [[Management Tools]] page for some links.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
== Using KVM ==&lt;br /&gt;
=== How can I use KVM with a non-privileged user? ===&lt;br /&gt;
The cleanest way is probably to create a group, say &#039;&#039;kvm&#039;&#039;, and add the user(s) to that group. Then you will need change /dev/kvm to owned by group &#039;&#039;kvm&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
On a system that runs udev, you will probably need to add the following line somewhere in your udev configuration so it will automatically give the right group to the newly created device (i-e for ubuntu add a line to &#039;&#039;/etc/udev/rules.d/40-permissions.rules&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 KERNEL==&amp;quot;kvm&amp;quot;, GROUP=&amp;quot;kvm&amp;quot;&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How can I get the most performance out of KVM? ===&lt;br /&gt;
&lt;br /&gt;
See the [[Tuning KVM]] page.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Is KVM stable? ===&lt;br /&gt;
KVM is stable and used in production.  As with most open source projects, development snapshots are less stable than the stable release series.&lt;br /&gt;
&lt;br /&gt;
If your name is Andreas Mohr, you&#039;re reporting bugs in the wrong place.&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== That&#039;s alright, but can I really use it for my daily use? ===&lt;br /&gt;
Sure. We continuously run the most often-used OSes and configurations and if anything breaks for the developers, it&#039;s fixed as soon as it was broken. See the [[Guest Support Status]] and [[Host Support Status]] pages to find out more. Please update them with success stories so that new users would benefit from the experience of the community.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How about production use? ===&lt;br /&gt;
For production use, it&#039;s recommended you use the KVM modules shipped by the distribution you&#039;re using to ensure stability. As mentioned above, it&#039;s tempting to use new features, but you never know of (unwanted) surprises hidden away. It&#039;ll be best if you can run the development snapshots with non-critical production load, so that the latest releases are stable for you when you decide to deploy them.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What happens if I kill -9 a VM process? ===&lt;br /&gt;
From the guest&#039;s perspective, it is as if you yanked the power cord out. From the host&#039;s perspective, the process is killed and all resources it uses are reclaimed.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I need help to setup the network for my guest ===&lt;br /&gt;
You can have a look to the [[Networking]] page of this wiki for informations on the most classical networking setup for the guests. You can also refer to the QEMU documentation.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Where can I find more documention... ===&lt;br /&gt;
Most usability issues are covered in the QEMU [http://www.nongnu.org/qemu/user-doc.html documentation].  There is also an extensive [http://qemu-buch.de/cgi-bin/moin.cgi/FrequentlyAskedQuestions FAQ] (old vanished link: [http://kidsquid.com/cgi-bin/moin.cgi/FrequentlyAskedQuestions FAQ]).&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
=== How can I check that I&#039;m not falling back to QEMU with no hardware acceleration? ===&lt;br /&gt;
&lt;br /&gt;
If you think that you might not be using the hardware acceleration provided by the KVM module, here are a few steps to help you check this.&lt;br /&gt;
&lt;br /&gt;
First of all, check that you don&#039;t have messages such as:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 qemu-system-x86_64 -hda myvm.qcow2&lt;br /&gt;
 open /dev/kvm: No such file or directory&lt;br /&gt;
 Could not initialize KVM, will disable KVM support&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In that case, you can check that:&lt;br /&gt;
* the modules are correctly loaded &amp;lt;code&amp;gt;lsmod|grep kvm&lt;br /&gt;
* you don&#039;t have a &amp;quot;KVM: disabled by BIOS&amp;quot; line in the output of dmesg&lt;br /&gt;
* /dev/kvm exists and you have the correct rights to use it&lt;br /&gt;
&lt;br /&gt;
Other ways to do the diagnostic:&lt;br /&gt;
* if you have access to the QEMU monitor (Ctrl-Alt-2, use Ctrl-Alt-1 to get back to the VM display), enter the &amp;quot;info kvm&amp;quot; command and it should respond with &amp;quot;KVM support: enabled&amp;quot;&lt;br /&gt;
* the right-end columns of the output from &amp;lt;code&amp;gt;lsmod|grep kvm&amp;lt;/code&amp;gt; on the host system, once the VM is started should show only non zero values. The value on the line corresponding to the architecture specific module (e-g kvm_intel, kvm_amd) show the number of VM using the module. For instance, if I have 2 VM running using the KVM module on a machine with vt, it will report:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 lsmod|grep kvm&lt;br /&gt;
 kvm_intel              44896  2&lt;br /&gt;
 kvm                   159656  1 kvm_intel&lt;br /&gt;
&lt;br /&gt;
===  When connecting to a VNC terminal, a &amp;quot;rect too big&amp;quot; message appears and the VNC session disconnects ===&lt;br /&gt;
This happens because of a VNC protocol flaw on the way on-the-fly pixel format changes are handled (more info at [http://www.mail-archive.com/qemu-devel@nongnu.org/msg04879.html this thread]). If you are using TigerVNC, you can avoid this problem by disabling on-the-fly selection of pixel encoding, using the &amp;lt;tt&amp;gt;-AutoSelect=0&amp;lt;/tt&amp;gt; command-line option of vncviewer. You may also want to check the encoding options on the vncviewer man page, as this will disable automatic selection of encoding based on connection speed.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&#039;&#039;&#039;How do I set up the network such that my guest is accessible from other machines?&#039;&#039;&#039; or&lt;br /&gt;
&lt;br /&gt;
=== My guest network is stuck what should I do? ===&lt;br /&gt;
KVM uses QEMU for its device emulation. Consult the [http://qemu-project.org/Documentation/Networking QEMU network wiki page] for detailed network setup instructions.&lt;br /&gt;
&lt;br /&gt;
One would probably be interested in the Root Networking Mode page and the Network Bridge page.&lt;br /&gt;
&lt;br /&gt;
Guest-side network lockups (fortunately restartable) may be happening due to tun/tap bridging erroneous MAC address reconfiguration on host side, see RHEL bug #571991 and others.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I&#039;m experiencing timer drift issues in my VM guests, what to do? ===&lt;br /&gt;
&lt;br /&gt;
Especially in case of networked systems (e.g. via NFS or Samba) it is very important to ensure stable operation of timing (both system timer and RTC).&lt;br /&gt;
Tell-tale signs of related trouble in VMs (apparently qemu/KVM/VMWare etc. are all affected) are e.g.&lt;br /&gt;
&amp;quot;make[2]: Warning: File `XXXXX/cmakelists_rebuilder.stamp&#039; has modification time 0.37 s in the future&amp;quot;&lt;br /&gt;
&amp;quot;Clock skew detected. Your build may be incomplete.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[http://maemovmware.garage.maemo.org/2nd_edition/requirements_documentation.html Maemo docs] state that it&#039;s important to disable UTC and set the correct time zone, however I don&#039;t really see how that would help in case of diverging host/guest clocks.&lt;br /&gt;
IMHO much more useful and important is to configure properly working NTP server (chrony recommended, or ntpd) on both host and guest.&lt;br /&gt;
The single most decisive trick IMHO is to specify the &#039;&#039;&#039;host&#039;&#039;&#039; NTP server as the main entry within guest VM instead of &amp;quot;foreign&amp;quot; NTP servers, to make sure to achieve the most precise coupling between these two related systems (timing drift vs. other systems does not matter nearly as much as a tight time precision for inner host/guest system interaction e.g. in the case of NFS/Samba shares etc.).&lt;br /&gt;
For verification, see chronyc &amp;quot;sources -v&amp;quot;, &amp;quot;tracking&amp;quot; (&amp;quot;System time&amp;quot; row) commands.&lt;br /&gt;
&lt;br /&gt;
After having applied this very tight NTP coupling, this seems to finally have gotten rid of make&#039;s time drift warnings.&lt;br /&gt;
&lt;br /&gt;
Perhaps qemu&#039;s -tdf (timing drift fix) option magically manages to help in your case, too.&lt;br /&gt;
&lt;br /&gt;
See also [https://espace.cern.ch/it-faqs/Lists/faqs/DispForm.aspx?ID=368 Faqs: I received a message about &amp;quot;clock skew&amp;quot;].&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
=== I get &amp;quot;rtc interrupts lost&amp;quot; messages, and the guest is very slow? ===&lt;br /&gt;
Try setting &amp;lt;code&amp;gt;CONFIG_HPET_EMULATE_RTC=y&amp;lt;/code&amp;gt; in your host &amp;lt;code&amp;gt;.config&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I get an &amp;quot;Exception 13&amp;quot; or &amp;quot;Exception 12&amp;quot; message while booting a guest OS on my Intel host ===&lt;br /&gt;
See the [[Intel Real Mode Emulation Problems]] page.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I have VMware/Parallels/VirtualBox installed and when I modprobe KVM, my system deadlocks. ===&lt;br /&gt;
Neither Intel VT nor AMD-V provide a mechanism to determine whether software is currently using the hardware virtualization extensions.  This means that if you have two kernel modules loaded attempting to use hardware virtualization extensions, very bad things will happen.  If you are using another type of virtualization software and experience any sort of weirdness with KVM, make sure you can reproduce the problem without the kernel modules for that software loaded before you report a bug in KVM.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== There&#039;s nothing on QEMU/KVM screen, but it&#039;s not hanged! I&#039;m trying to install Kubuntu. ===&lt;br /&gt;
Try to run kvm with -std-vga option. It helps if guest operating system uses framebuffer mode like Kubuntu/Ubuntu.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== When I click the guest operating system window, mouse is grabbed. How can I get mouse to not to do that? OR Mouse doesn&#039;t show up / doesn&#039;t work in the guest. What do I do? ===&lt;br /&gt;
From #qemu wiki, try to run kvm/qemu with&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 -usb -usbdevice tablet&lt;br /&gt;
If that doesn&#039;t work, try this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 $ export SDL_VIDEO_X11_DGAMOUSE=0&lt;br /&gt;
(from http://wiki.clug.org.za/wiki/QEMU_mouse_not_working )&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
== General KVM information ==&lt;br /&gt;
=== What is the difference between KVM and Xen? ===&lt;br /&gt;
Xen is an external hypervisor; it assumes control of the machine and divides resources among guests. On the other hand, KVM is part of Linux and uses the regular Linux scheduler and memory management. This means that KVM is much smaller and simpler to use; it is also more featureful; for example KVM can swap guests to disk in order to free RAM.&lt;br /&gt;
&lt;br /&gt;
KVM only run on processors that supports x86 hvm (vt/svm instructions set) whereas Xen also allows running modified operating systems on non-hvm x86 processors using a technique called paravirtualization. KVM does not support paravirtualization for CPU but may support paravirtualization for device drivers to improve I/O performance.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What is the difference between KVM and VMware? ===&lt;br /&gt;
VMware is a proprietary product. KVM is Free Software released under the GPL.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What is the difference between KVM and QEMU? ===&lt;br /&gt;
QEMU uses emulation; KVM uses processor extensions (HVM) for virtualization.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Do you have a port of KVM for Windows? ===&lt;br /&gt;
Not officially.&lt;br /&gt;
&lt;br /&gt;
Kazushi Takahashi has been working on an experimental version though, called WinKVM, available [http://github.com/ddk50/winkvm here].&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What kernel version does it work with? ===&lt;br /&gt;
It depends on what version of KVM you are using. The last release of KVM should work with any recent kernel (2.6.17 and above), older releases even older kernels.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How much RAM do I need? ===&lt;br /&gt;
You will need enough memory to let the guest run comfortably while keeping enough for the host. 1GB is probably a minimum configuration for the host OS.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Is dynamic memory management for guests supported? ===&lt;br /&gt;
This is a broad topic covering a few areas.&lt;br /&gt;
&lt;br /&gt;
A. KVM only allocates memory as the guest tries to use it. Once it&#039;s allocated, KVM keeps it. Some guests (namely Microsoft guests) zero all memory at boot time. So they will use all memory.&lt;br /&gt;
&lt;br /&gt;
B. Certain guests (only Linux at the moment) have a balloon driver, so the host can have the guest allocate a certain amount of memory which the guest won&#039;t be able to use anymore and it can then be freed on the host. Ballooning is controlled in the host via the [http://www.nongnu.org/qemu/qemu-doc.html#SEC12 balloon monitor command].&lt;br /&gt;
&lt;br /&gt;
C. Some hosts (presently only RHEL5.4 / CentOS 5.4) have a feature called KSM (Kernel Sharedpage Merging), which collapses together identical pages; this requires kernel support on the host, as well as a kvm new enough to opt in to the behavior. As some guest platforms (most notably Windows) zero out free&#039;d memory, such pages are trivially collapsed. The ksmctl command needs to be used to enable KSM; alternately, the ksmtuned service found in Fedora 12 can be run to dynamically adjust KSM&#039;s aggressiveness based on the amount of free memory available&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What OSs can I run inside KVM VM? ===&lt;br /&gt;
Several.  See the [[Guest Support Status]] page for details. Note that several Linux flavors are known to hang on Intel processors during startup. Workaround is to disable splash screens in grub.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Does KVM support a live migration feature to move virtual machines from one host to another without downtime? ===&lt;br /&gt;
Yes.  See the [[Migration]] page for details.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Does KVM support live migration from an AMD host to an Intel host and back? ===&lt;br /&gt;
Yes.  There may be issues on 32-bit Intel hosts which don&#039;t support NX (or XD), but for 64-bit hosts back and forth migration should work well. Migration of 32-bit guests should work between 32-bit hosts and 64-bit hosts.&lt;br /&gt;
If one of your hosts does not support NX, you may consider disabling NX when starting the guest on a NX-capable system. You can do it by passing &amp;quot;-cpu qemu64,-nx&amp;quot; parameter to the guest.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Can KVM run a 32-bit guest on a 64-bit host? What about PAE? ===&lt;br /&gt;
KVM supports 32-bit guests on 64-bit hosts, and any combination of PAE and non-PAE guests and hosts. The only unsupported combination is a 64-bit guest on a 32-bit host.&lt;br /&gt;
&lt;br /&gt;
If you are running a Windows Virtual Machine and have problems enabling PAE in your guest see the [[Windows PAE Workaround]] page.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Is it possible to use a host&#039;s USB devices within a guest? ===&lt;br /&gt;
Yes, this method is described in detail [http://www.linux-kvm.org/page/USB_Host_Device_Assigned_to_Guest here].&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Can I have higher or widescreen resolutions (eg 1680 x 1050) in KVM? ===&lt;br /&gt;
Use the -vga std parameter while starting the VM to allow high resolution and widescreen displays.&lt;br /&gt;
&lt;br /&gt;
If the resolution you want to use is not available, you can patch the corresponding source files (see http://article.gmane.org/gmane.comp.emulators.kvm.devel/13557 as a reference), or send a mail to the KVM mailing list if you are not able to patch the source yourself.&lt;br /&gt;
&lt;br /&gt;
When using Windows as guest OS and not having issues with people violating the GPL you might want to use the driver from the VBEMP x86 project (http://www.bearwindows.boot-land.net/vbemp.htm) which is based on ReactOS code.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Does KVM support SMP hosts? ===&lt;br /&gt;
Yes.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Does KVM support SMP guests? ===&lt;br /&gt;
Yes. Up to 16 CPUs can be specified using the -smp option.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Is the name &#039;KVM&#039; trademarked? ===&lt;br /&gt;
No.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I compiled a new kernel for my KVM client and the ethernet interface is not recognized ===&lt;br /&gt;
You can specify alternative network interfaces to qemu with the &#039;&#039;-net nic,model=&#039;&#039; parameter. For example, &#039;&#039;-net nic,model=rtl8139&#039;&#039; would enable a device with the Realtek 8139 chipset.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I can&#039;t ping from guest to host or vice versa. How can I access the host? ===&lt;br /&gt;
The ping command may not go through in this circumstance, but you may be able to access the host in another way. For example, you can access a host running Apache by entering its IP address into a browser within the guest.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
[[Category:Docs]][[Category:HowTo]]&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=FAQ&amp;diff=173560</id>
		<title>FAQ</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=FAQ&amp;diff=173560"/>
		<updated>2015-11-08T20:01:57Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* When connecting to a VNC Terminal, a &amp;quot;rect too big&amp;quot; message appears and the VNC Session disconnects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=FAQ=&lt;br /&gt;
__TOC__&lt;br /&gt;
== Preparing to use KVM ==&lt;br /&gt;
=== What do I need to use KVM? ===&lt;br /&gt;
You will need an x86 machine running a recent Linux kernel on an Intel processor with VT (virtualization technology) extensions, or an AMD processor with SVM extensions (also called AMD-V). Xen has a [http://wiki.xensource.com/xenwiki/HVM_Compatible_Processors complete list] of compatible processors. For Intel processors, see also [http://ark.intel.com/VTList.aspx the Intel® Virtualization Technology List].&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
=== Are 64-bit processors supported under KVM? ===&lt;br /&gt;
Yes they are supported and will allow you to run 32-bit and 64-bit guests.&lt;br /&gt;
&lt;br /&gt;
See also &#039;&#039;&#039;Can KVM run a 32-bit guest on a 64-bit host? What about PAE?&#039;&#039;&#039; below.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What is Intel VT / AMD-V / hvm? ===&lt;br /&gt;
[http://www.intel.com/technology/itj/2006/v10i3/1-hardware/6-vt-x-vt-i-solutions.htm Intel VT] and [http://www.amd.com/us-en/Processors/ProductInformation/0,,30_118_8826_14287,00.html AMD&#039;s AMD-V] are instruction set extensions that provide hardware assistance to virtual machine monitors. They enable running fully isolated virtual machines at native hardware speeds, for some workloads.&lt;br /&gt;
&lt;br /&gt;
HVM (for Hardware Virtual Machine) is a vendor-neutral term often used to designate the x86 instruction set extensions.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Where do I get my kvm kernel modules from? ===&lt;br /&gt;
&lt;br /&gt;
See the [[Getting the kvm kernel modules]] page.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How can I tell if I have Intel VT or AMD-V? ===&lt;br /&gt;
With a recent enough Linux kernel, run the command:&lt;br /&gt;
&lt;br /&gt;
 . egrep &#039;^flags.*(vmx|svm)&#039; /proc/cpuinfo&lt;br /&gt;
&lt;br /&gt;
If something shows up, you have VT. You can also check the processor model name (in `/proc/cpuinfo`) in the vendor&#039;s web site.&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
*  You&#039;ll never see (vmx|svm) in /proc/cpuinfo if you&#039;re currently running in  in a dom0 or domU.&amp;lt;br /&amp;gt; The Xen hypervisor suppresses these flags in order to prevent hijacking.&lt;br /&gt;
* Some manufacturers disable VT in the machine&#039;s BIOS, in such a way that it cannot be re-enabled.&lt;br /&gt;
* `/proc/cpuinfo` only shows virtualization capabilities starting with Linux 2.6.15 (Intel) and Linux 2.6.16 (AMD). Use the `uname -r` command to query your kernel version.&lt;br /&gt;
In case of doubt, contact your hardware vendor.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== &amp;quot;KVM: disabled by BIOS&amp;quot; error ===&lt;br /&gt;
Check if there is an option to enable it in the BIOS. If not, look for a more recent BIOS on the vendor&#039;s web site.&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
* On some hardware (e-g HP nx6320), you need to power-off/power-on the machine after enabling virtualization in the BIOS.&lt;br /&gt;
* Enabling some BIOS features may break VT support on some hardware (e-g Enabling Intel AMT on a Thinkpad T500 will prevent kvm-intel from loading with &amp;quot;disabled by bios&amp;quot;)&lt;br /&gt;
* On some Dell hardware, you also need to disable &amp;quot;Trusted Execution&amp;quot;, otherwise VT will not be enabled.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How can I use AMD-V extension? ===&lt;br /&gt;
 modprobe kvm-amd&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What user space tools does KVM use? ===&lt;br /&gt;
KVM uses a slightly modified [http://www.nongnu.org/qemu QEMU] program to instantiate the virtual machine. Once running, a virtual machine is just a regular process. You can use `top(1), kill(1), taskset(1)` and similar tools to manage virtual machines.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What virtual disk formats can KVM use? ===&lt;br /&gt;
KVM inherits a wealth of disk formats support from QEMU; it supports raw images, the native QEMU format (qcow2), VMware format, and many more.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How do I use KVM on a headless machine (without a local GUI?) ===&lt;br /&gt;
Install a management tool such as virt-manager on a remote machine.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Are there management tools available to help me manage my virtual machines? ===&lt;br /&gt;
Yes.  Please see the [[Management Tools]] page for some links.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
== Using KVM ==&lt;br /&gt;
=== How can I use KVM with a non-privileged user? ===&lt;br /&gt;
The cleanest way is probably to create a group, say &#039;&#039;kvm&#039;&#039;, and add the user(s) to that group. Then you will need change /dev/kvm to owned by group &#039;&#039;kvm&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
On a system that runs udev, you will probably need to add the following line somewhere in your udev configuration so it will automatically give the right group to the newly created device (i-e for ubuntu add a line to &#039;&#039;/etc/udev/rules.d/40-permissions.rules&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 KERNEL==&amp;quot;kvm&amp;quot;, GROUP=&amp;quot;kvm&amp;quot;&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How can I get the most performance out of KVM? ===&lt;br /&gt;
&lt;br /&gt;
See the [[Tuning KVM]] page.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Is KVM stable? ===&lt;br /&gt;
KVM is stable and used in production.  As with most open source projects, development snapshots are less stable than the stable release series.&lt;br /&gt;
&lt;br /&gt;
If your name is Andreas Mohr, you&#039;re reporting bugs in the wrong place.&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== That&#039;s alright, but can I really use it for my daily use? ===&lt;br /&gt;
Sure. We continuously run the most often-used OSes and configurations and if anything breaks for the developers, it&#039;s fixed as soon as it was broken. See the [[Guest Support Status]] and [[Host Support Status]] pages to find out more. Please update them with success stories so that new users would benefit from the experience of the community.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How about production use? ===&lt;br /&gt;
For production use, it&#039;s recommended you use the KVM modules shipped by the distribution you&#039;re using to ensure stability. As mentioned above, it&#039;s tempting to use new features, but you never know of (unwanted) surprises hidden away. It&#039;ll be best if you can run the development snapshots with non-critical production load, so that the latest releases are stable for you when you decide to deploy them.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What happens if I kill -9 a VM process? ===&lt;br /&gt;
From the guest&#039;s perspective, it is as if you yanked the power cord out. From the host&#039;s perspective, the process is killed and all resources it uses are reclaimed.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I need help to setup the network for my guest ===&lt;br /&gt;
You can have a look to the [[Networking]] page of this wiki for informations on the most classical networking setup for the guests. You can also refer to the QEMU documentation.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Where can I find more documention... ===&lt;br /&gt;
Most usability issues are covered in the QEMU [http://www.nongnu.org/qemu/user-doc.html documentation].  There is also an extensive [http://qemu-buch.de/cgi-bin/moin.cgi/FrequentlyAskedQuestions FAQ] (old vanished link: [http://kidsquid.com/cgi-bin/moin.cgi/FrequentlyAskedQuestions FAQ]).&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
=== How can I check that I&#039;m not falling back to QEMU with no hardware acceleration? ===&lt;br /&gt;
&lt;br /&gt;
If you think that you might not be using the hardware acceleration provided by the KVM module, here are a few steps to help you check this.&lt;br /&gt;
&lt;br /&gt;
First of all, check that you don&#039;t have messages such as:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 qemu-system-x86_64 -hda myvm.qcow2&lt;br /&gt;
 open /dev/kvm: No such file or directory&lt;br /&gt;
 Could not initialize KVM, will disable KVM support&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In that case, you can check that:&lt;br /&gt;
* the modules are correctly loaded &amp;lt;code&amp;gt;lsmod|grep kvm&lt;br /&gt;
* you don&#039;t have a &amp;quot;KVM: disabled by BIOS&amp;quot; line in the output of dmesg&lt;br /&gt;
* /dev/kvm exists and you have the correct rights to use it&lt;br /&gt;
&lt;br /&gt;
Other ways to do the diagnostic:&lt;br /&gt;
* if you have access to the QEMU monitor (Ctrl-Alt-2, use Ctrl-Alt-1 to get back to the VM display), enter the &amp;quot;info kvm&amp;quot; command and it should respond with &amp;quot;KVM support: enabled&amp;quot;&lt;br /&gt;
* the right-end columns of the output from &amp;lt;code&amp;gt;lsmod|grep kvm&amp;lt;/code&amp;gt; on the host system, once the VM is started should show only non zero values. The value on the line corresponding to the architecture specific module (e-g kvm_intel, kvm_amd) show the number of VM using the module. For instance, if I have 2 VM running using the KVM module on a machine with vt, it will report:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 lsmod|grep kvm&lt;br /&gt;
 kvm_intel              44896  2&lt;br /&gt;
 kvm                   159656  1 kvm_intel&lt;br /&gt;
&lt;br /&gt;
===  When connecting to a VNC Terminal, a &amp;quot;rect too big&amp;quot; message appears and the VNC Session disconnects ===&lt;br /&gt;
This happens because of a VNC protocol flaw on the way on-the-fly pixel format changes are handled (more info at [http://www.mail-archive.com/qemu-devel@nongnu.org/msg04879.html this thread]). If you are using TigerVNC, you can avoid this problem by disabling on-the-fly selection of pixel encoding, using the &amp;lt;tt&amp;gt;-AutoSelect=0&amp;lt;/tt&amp;gt; command-line option of vncviewer. You may also want to check the encoding options on the vncviewer man page, as this will disable automatic selection of encoding based on connection speed.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&#039;&#039;&#039;How do I set up the network such that my guest is accessible from other machines?&#039;&#039;&#039; or&lt;br /&gt;
&lt;br /&gt;
=== My guest network is stuck what should I do? ===&lt;br /&gt;
KVM uses QEMU for its device emulation. Consult the [http://qemu-project.org/Documentation/Networking QEMU network wiki page] for detailed network setup instructions.&lt;br /&gt;
&lt;br /&gt;
One would probably be interested in the Root Networking Mode page and the Network Bridge page.&lt;br /&gt;
&lt;br /&gt;
Guest-side network lockups (fortunately restartable) may be happening due to tun/tap bridging erroneous MAC address reconfiguration on host side, see RHEL bug #571991 and others.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I&#039;m experiencing timer drift issues in my VM guests, what to do? ===&lt;br /&gt;
&lt;br /&gt;
Especially in case of networked systems (e.g. via NFS or Samba) it is very important to ensure stable operation of timing (both system timer and RTC).&lt;br /&gt;
Tell-tale signs of related trouble in VMs (apparently qemu/KVM/VMWare etc. are all affected) are e.g.&lt;br /&gt;
&amp;quot;make[2]: Warning: File `XXXXX/cmakelists_rebuilder.stamp&#039; has modification time 0.37 s in the future&amp;quot;&lt;br /&gt;
&amp;quot;Clock skew detected. Your build may be incomplete.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[http://maemovmware.garage.maemo.org/2nd_edition/requirements_documentation.html Maemo docs] state that it&#039;s important to disable UTC and set the correct time zone, however I don&#039;t really see how that would help in case of diverging host/guest clocks.&lt;br /&gt;
IMHO much more useful and important is to configure properly working NTP server (chrony recommended, or ntpd) on both host and guest.&lt;br /&gt;
The single most decisive trick IMHO is to specify the &#039;&#039;&#039;host&#039;&#039;&#039; NTP server as the main entry within guest VM instead of &amp;quot;foreign&amp;quot; NTP servers, to make sure to achieve the most precise coupling between these two related systems (timing drift vs. other systems does not matter nearly as much as a tight time precision for inner host/guest system interaction e.g. in the case of NFS/Samba shares etc.).&lt;br /&gt;
For verification, see chronyc &amp;quot;sources -v&amp;quot;, &amp;quot;tracking&amp;quot; (&amp;quot;System time&amp;quot; row) commands.&lt;br /&gt;
&lt;br /&gt;
After having applied this very tight NTP coupling, this seems to finally have gotten rid of make&#039;s time drift warnings.&lt;br /&gt;
&lt;br /&gt;
Perhaps qemu&#039;s -tdf (timing drift fix) option magically manages to help in your case, too.&lt;br /&gt;
&lt;br /&gt;
See also [https://espace.cern.ch/it-faqs/Lists/faqs/DispForm.aspx?ID=368 Faqs: I received a message about &amp;quot;clock skew&amp;quot;].&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
=== I get &amp;quot;rtc interrupts lost&amp;quot; messages, and the guest is very slow? ===&lt;br /&gt;
Try setting &amp;lt;code&amp;gt;CONFIG_HPET_EMULATE_RTC=y&amp;lt;/code&amp;gt; in your host &amp;lt;code&amp;gt;.config&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I get an &amp;quot;Exception 13&amp;quot; or &amp;quot;Exception 12&amp;quot; message while booting a guest OS on my Intel host ===&lt;br /&gt;
See the [[Intel Real Mode Emulation Problems]] page.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I have VMware/Parallels/VirtualBox installed and when I modprobe KVM, my system deadlocks. ===&lt;br /&gt;
Neither Intel VT nor AMD-V provide a mechanism to determine whether software is currently using the hardware virtualization extensions.  This means that if you have two kernel modules loaded attempting to use hardware virtualization extensions, very bad things will happen.  If you are using another type of virtualization software and experience any sort of weirdness with KVM, make sure you can reproduce the problem without the kernel modules for that software loaded before you report a bug in KVM.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== There&#039;s nothing on QEMU/KVM screen, but it&#039;s not hanged! I&#039;m trying to install Kubuntu. ===&lt;br /&gt;
Try to run kvm with -std-vga option. It helps if guest operating system uses framebuffer mode like Kubuntu/Ubuntu.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== When I click the guest operating system window, mouse is grabbed. How can I get mouse to not to do that? OR Mouse doesn&#039;t show up / doesn&#039;t work in the guest. What do I do? ===&lt;br /&gt;
From #qemu wiki, try to run kvm/qemu with&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 -usb -usbdevice tablet&lt;br /&gt;
If that doesn&#039;t work, try this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 $ export SDL_VIDEO_X11_DGAMOUSE=0&lt;br /&gt;
(from http://wiki.clug.org.za/wiki/QEMU_mouse_not_working )&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
== General KVM information ==&lt;br /&gt;
=== What is the difference between KVM and Xen? ===&lt;br /&gt;
Xen is an external hypervisor; it assumes control of the machine and divides resources among guests. On the other hand, KVM is part of Linux and uses the regular Linux scheduler and memory management. This means that KVM is much smaller and simpler to use; it is also more featureful; for example KVM can swap guests to disk in order to free RAM.&lt;br /&gt;
&lt;br /&gt;
KVM only run on processors that supports x86 hvm (vt/svm instructions set) whereas Xen also allows running modified operating systems on non-hvm x86 processors using a technique called paravirtualization. KVM does not support paravirtualization for CPU but may support paravirtualization for device drivers to improve I/O performance.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What is the difference between KVM and VMware? ===&lt;br /&gt;
VMware is a proprietary product. KVM is Free Software released under the GPL.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What is the difference between KVM and QEMU? ===&lt;br /&gt;
QEMU uses emulation; KVM uses processor extensions (HVM) for virtualization.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Do you have a port of KVM for Windows? ===&lt;br /&gt;
Not officially.&lt;br /&gt;
&lt;br /&gt;
Kazushi Takahashi has been working on an experimental version though, called WinKVM, available [http://github.com/ddk50/winkvm here].&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What kernel version does it work with? ===&lt;br /&gt;
It depends on what version of KVM you are using. The last release of KVM should work with any recent kernel (2.6.17 and above), older releases even older kernels.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How much RAM do I need? ===&lt;br /&gt;
You will need enough memory to let the guest run comfortably while keeping enough for the host. 1GB is probably a minimum configuration for the host OS.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Is dynamic memory management for guests supported? ===&lt;br /&gt;
This is a broad topic covering a few areas.&lt;br /&gt;
&lt;br /&gt;
A. KVM only allocates memory as the guest tries to use it. Once it&#039;s allocated, KVM keeps it. Some guests (namely Microsoft guests) zero all memory at boot time. So they will use all memory.&lt;br /&gt;
&lt;br /&gt;
B. Certain guests (only Linux at the moment) have a balloon driver, so the host can have the guest allocate a certain amount of memory which the guest won&#039;t be able to use anymore and it can then be freed on the host. Ballooning is controlled in the host via the [http://www.nongnu.org/qemu/qemu-doc.html#SEC12 balloon monitor command].&lt;br /&gt;
&lt;br /&gt;
C. Some hosts (presently only RHEL5.4 / CentOS 5.4) have a feature called KSM (Kernel Sharedpage Merging), which collapses together identical pages; this requires kernel support on the host, as well as a kvm new enough to opt in to the behavior. As some guest platforms (most notably Windows) zero out free&#039;d memory, such pages are trivially collapsed. The ksmctl command needs to be used to enable KSM; alternately, the ksmtuned service found in Fedora 12 can be run to dynamically adjust KSM&#039;s aggressiveness based on the amount of free memory available&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What OSs can I run inside KVM VM? ===&lt;br /&gt;
Several.  See the [[Guest Support Status]] page for details. Note that several Linux flavors are known to hang on Intel processors during startup. Workaround is to disable splash screens in grub.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Does KVM support a live migration feature to move virtual machines from one host to another without downtime? ===&lt;br /&gt;
Yes.  See the [[Migration]] page for details.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Does KVM support live migration from an AMD host to an Intel host and back? ===&lt;br /&gt;
Yes.  There may be issues on 32-bit Intel hosts which don&#039;t support NX (or XD), but for 64-bit hosts back and forth migration should work well. Migration of 32-bit guests should work between 32-bit hosts and 64-bit hosts.&lt;br /&gt;
If one of your hosts does not support NX, you may consider disabling NX when starting the guest on a NX-capable system. You can do it by passing &amp;quot;-cpu qemu64,-nx&amp;quot; parameter to the guest.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Can KVM run a 32-bit guest on a 64-bit host? What about PAE? ===&lt;br /&gt;
KVM supports 32-bit guests on 64-bit hosts, and any combination of PAE and non-PAE guests and hosts. The only unsupported combination is a 64-bit guest on a 32-bit host.&lt;br /&gt;
&lt;br /&gt;
If you are running a Windows Virtual Machine and have problems enabling PAE in your guest see the [[Windows PAE Workaround]] page.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Is it possible to use a host&#039;s USB devices within a guest? ===&lt;br /&gt;
Yes, this method is described in detail [http://www.linux-kvm.org/page/USB_Host_Device_Assigned_to_Guest here].&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Can I have higher or widescreen resolutions (eg 1680 x 1050) in KVM? ===&lt;br /&gt;
Use the -vga std parameter while starting the VM to allow high resolution and widescreen displays.&lt;br /&gt;
&lt;br /&gt;
If the resolution you want to use is not available, you can patch the corresponding source files (see http://article.gmane.org/gmane.comp.emulators.kvm.devel/13557 as a reference), or send a mail to the KVM mailing list if you are not able to patch the source yourself.&lt;br /&gt;
&lt;br /&gt;
When using Windows as guest OS and not having issues with people violating the GPL you might want to use the driver from the VBEMP x86 project (http://www.bearwindows.boot-land.net/vbemp.htm) which is based on ReactOS code.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Does KVM support SMP hosts? ===&lt;br /&gt;
Yes.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Does KVM support SMP guests? ===&lt;br /&gt;
Yes. Up to 16 CPUs can be specified using the -smp option.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Is the name &#039;KVM&#039; trademarked? ===&lt;br /&gt;
No.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I compiled a new kernel for my KVM client and the ethernet interface is not recognized ===&lt;br /&gt;
You can specify alternative network interfaces to qemu with the &#039;&#039;-net nic,model=&#039;&#039; parameter. For example, &#039;&#039;-net nic,model=rtl8139&#039;&#039; would enable a device with the Realtek 8139 chipset.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I can&#039;t ping from guest to host or vice versa. How can I access the host? ===&lt;br /&gt;
The ping command may not go through in this circumstance, but you may be able to access the host in another way. For example, you can access a host running Apache by entering its IP address into a browser within the guest.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
[[Category:Docs]][[Category:HowTo]]&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=FAQ&amp;diff=173559</id>
		<title>FAQ</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=FAQ&amp;diff=173559"/>
		<updated>2015-11-08T19:57:46Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* Is it possible to use a host&amp;#039;s USB devices within a guest? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=FAQ=&lt;br /&gt;
__TOC__&lt;br /&gt;
== Preparing to use KVM ==&lt;br /&gt;
=== What do I need to use KVM? ===&lt;br /&gt;
You will need an x86 machine running a recent Linux kernel on an Intel processor with VT (virtualization technology) extensions, or an AMD processor with SVM extensions (also called AMD-V). Xen has a [http://wiki.xensource.com/xenwiki/HVM_Compatible_Processors complete list] of compatible processors. For Intel processors, see also [http://ark.intel.com/VTList.aspx the Intel® Virtualization Technology List].&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
=== Are 64-bit processors supported under KVM? ===&lt;br /&gt;
Yes they are supported and will allow you to run 32-bit and 64-bit guests.&lt;br /&gt;
&lt;br /&gt;
See also &#039;&#039;&#039;Can KVM run a 32-bit guest on a 64-bit host? What about PAE?&#039;&#039;&#039; below.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What is Intel VT / AMD-V / hvm? ===&lt;br /&gt;
[http://www.intel.com/technology/itj/2006/v10i3/1-hardware/6-vt-x-vt-i-solutions.htm Intel VT] and [http://www.amd.com/us-en/Processors/ProductInformation/0,,30_118_8826_14287,00.html AMD&#039;s AMD-V] are instruction set extensions that provide hardware assistance to virtual machine monitors. They enable running fully isolated virtual machines at native hardware speeds, for some workloads.&lt;br /&gt;
&lt;br /&gt;
HVM (for Hardware Virtual Machine) is a vendor-neutral term often used to designate the x86 instruction set extensions.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Where do I get my kvm kernel modules from? ===&lt;br /&gt;
&lt;br /&gt;
See the [[Getting the kvm kernel modules]] page.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How can I tell if I have Intel VT or AMD-V? ===&lt;br /&gt;
With a recent enough Linux kernel, run the command:&lt;br /&gt;
&lt;br /&gt;
 . egrep &#039;^flags.*(vmx|svm)&#039; /proc/cpuinfo&lt;br /&gt;
&lt;br /&gt;
If something shows up, you have VT. You can also check the processor model name (in `/proc/cpuinfo`) in the vendor&#039;s web site.&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
*  You&#039;ll never see (vmx|svm) in /proc/cpuinfo if you&#039;re currently running in  in a dom0 or domU.&amp;lt;br /&amp;gt; The Xen hypervisor suppresses these flags in order to prevent hijacking.&lt;br /&gt;
* Some manufacturers disable VT in the machine&#039;s BIOS, in such a way that it cannot be re-enabled.&lt;br /&gt;
* `/proc/cpuinfo` only shows virtualization capabilities starting with Linux 2.6.15 (Intel) and Linux 2.6.16 (AMD). Use the `uname -r` command to query your kernel version.&lt;br /&gt;
In case of doubt, contact your hardware vendor.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== &amp;quot;KVM: disabled by BIOS&amp;quot; error ===&lt;br /&gt;
Check if there is an option to enable it in the BIOS. If not, look for a more recent BIOS on the vendor&#039;s web site.&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
* On some hardware (e-g HP nx6320), you need to power-off/power-on the machine after enabling virtualization in the BIOS.&lt;br /&gt;
* Enabling some BIOS features may break VT support on some hardware (e-g Enabling Intel AMT on a Thinkpad T500 will prevent kvm-intel from loading with &amp;quot;disabled by bios&amp;quot;)&lt;br /&gt;
* On some Dell hardware, you also need to disable &amp;quot;Trusted Execution&amp;quot;, otherwise VT will not be enabled.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How can I use AMD-V extension? ===&lt;br /&gt;
 modprobe kvm-amd&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What user space tools does KVM use? ===&lt;br /&gt;
KVM uses a slightly modified [http://www.nongnu.org/qemu QEMU] program to instantiate the virtual machine. Once running, a virtual machine is just a regular process. You can use `top(1), kill(1), taskset(1)` and similar tools to manage virtual machines.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What virtual disk formats can KVM use? ===&lt;br /&gt;
KVM inherits a wealth of disk formats support from QEMU; it supports raw images, the native QEMU format (qcow2), VMware format, and many more.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How do I use KVM on a headless machine (without a local GUI?) ===&lt;br /&gt;
Install a management tool such as virt-manager on a remote machine.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Are there management tools available to help me manage my virtual machines? ===&lt;br /&gt;
Yes.  Please see the [[Management Tools]] page for some links.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
== Using KVM ==&lt;br /&gt;
=== How can I use KVM with a non-privileged user? ===&lt;br /&gt;
The cleanest way is probably to create a group, say &#039;&#039;kvm&#039;&#039;, and add the user(s) to that group. Then you will need change /dev/kvm to owned by group &#039;&#039;kvm&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
On a system that runs udev, you will probably need to add the following line somewhere in your udev configuration so it will automatically give the right group to the newly created device (i-e for ubuntu add a line to &#039;&#039;/etc/udev/rules.d/40-permissions.rules&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 KERNEL==&amp;quot;kvm&amp;quot;, GROUP=&amp;quot;kvm&amp;quot;&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How can I get the most performance out of KVM? ===&lt;br /&gt;
&lt;br /&gt;
See the [[Tuning KVM]] page.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Is KVM stable? ===&lt;br /&gt;
KVM is stable and used in production.  As with most open source projects, development snapshots are less stable than the stable release series.&lt;br /&gt;
&lt;br /&gt;
If your name is Andreas Mohr, you&#039;re reporting bugs in the wrong place.&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== That&#039;s alright, but can I really use it for my daily use? ===&lt;br /&gt;
Sure. We continuously run the most often-used OSes and configurations and if anything breaks for the developers, it&#039;s fixed as soon as it was broken. See the [[Guest Support Status]] and [[Host Support Status]] pages to find out more. Please update them with success stories so that new users would benefit from the experience of the community.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How about production use? ===&lt;br /&gt;
For production use, it&#039;s recommended you use the KVM modules shipped by the distribution you&#039;re using to ensure stability. As mentioned above, it&#039;s tempting to use new features, but you never know of (unwanted) surprises hidden away. It&#039;ll be best if you can run the development snapshots with non-critical production load, so that the latest releases are stable for you when you decide to deploy them.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What happens if I kill -9 a VM process? ===&lt;br /&gt;
From the guest&#039;s perspective, it is as if you yanked the power cord out. From the host&#039;s perspective, the process is killed and all resources it uses are reclaimed.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I need help to setup the network for my guest ===&lt;br /&gt;
You can have a look to the [[Networking]] page of this wiki for informations on the most classical networking setup for the guests. You can also refer to the QEMU documentation.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Where can I find more documention... ===&lt;br /&gt;
Most usability issues are covered in the QEMU [http://www.nongnu.org/qemu/user-doc.html documentation].  There is also an extensive [http://qemu-buch.de/cgi-bin/moin.cgi/FrequentlyAskedQuestions FAQ] (old vanished link: [http://kidsquid.com/cgi-bin/moin.cgi/FrequentlyAskedQuestions FAQ]).&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
=== How can I check that I&#039;m not falling back to QEMU with no hardware acceleration? ===&lt;br /&gt;
&lt;br /&gt;
If you think that you might not be using the hardware acceleration provided by the KVM module, here are a few steps to help you check this.&lt;br /&gt;
&lt;br /&gt;
First of all, check that you don&#039;t have messages such as:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 qemu-system-x86_64 -hda myvm.qcow2&lt;br /&gt;
 open /dev/kvm: No such file or directory&lt;br /&gt;
 Could not initialize KVM, will disable KVM support&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In that case, you can check that:&lt;br /&gt;
* the modules are correctly loaded &amp;lt;code&amp;gt;lsmod|grep kvm&lt;br /&gt;
* you don&#039;t have a &amp;quot;KVM: disabled by BIOS&amp;quot; line in the output of dmesg&lt;br /&gt;
* /dev/kvm exists and you have the correct rights to use it&lt;br /&gt;
&lt;br /&gt;
Other ways to do the diagnostic:&lt;br /&gt;
* if you have access to the QEMU monitor (Ctrl-Alt-2, use Ctrl-Alt-1 to get back to the VM display), enter the &amp;quot;info kvm&amp;quot; command and it should respond with &amp;quot;KVM support: enabled&amp;quot;&lt;br /&gt;
* the right-end columns of the output from &amp;lt;code&amp;gt;lsmod|grep kvm&amp;lt;/code&amp;gt; on the host system, once the VM is started should show only non zero values. The value on the line corresponding to the architecture specific module (e-g kvm_intel, kvm_amd) show the number of VM using the module. For instance, if I have 2 VM running using the KVM module on a machine with vt, it will report:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 lsmod|grep kvm&lt;br /&gt;
 kvm_intel              44896  2&lt;br /&gt;
 kvm                   159656  1 kvm_intel&lt;br /&gt;
&lt;br /&gt;
=== &amp;quot;rect too big&amp;quot; Message when using VNC Display ===&lt;br /&gt;
When connection to a VNC Terminal, a &amp;quot;rect too big&amp;quot; message appears, and the VNC Session disconnects.&lt;br /&gt;
&lt;br /&gt;
This happens because of a VNC protocol flaw on the way on-the-fly pixel format changes are handled (more info at [http://www.mail-archive.com/qemu-devel@nongnu.org/msg04879.html this thread]). If you are using TigerVNC, you can avoid this problem by disabling on-the-fly selection of pixel encoding, using the &amp;lt;tt&amp;gt;-AutoSelect=0&amp;lt;/tt&amp;gt; command-line option of vncviewer. You may also want to check the encoding options on the vncviewer man page, as this will disable automatic selection of encoding based on connection speed.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&#039;&#039;&#039;How do I set up the network such that my guest is accessible from other machines?&#039;&#039;&#039; or&lt;br /&gt;
&lt;br /&gt;
=== My guest network is stuck what should I do? ===&lt;br /&gt;
KVM uses QEMU for its device emulation. Consult the [http://qemu-project.org/Documentation/Networking QEMU network wiki page] for detailed network setup instructions.&lt;br /&gt;
&lt;br /&gt;
One would probably be interested in the Root Networking Mode page and the Network Bridge page.&lt;br /&gt;
&lt;br /&gt;
Guest-side network lockups (fortunately restartable) may be happening due to tun/tap bridging erroneous MAC address reconfiguration on host side, see RHEL bug #571991 and others.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I&#039;m experiencing timer drift issues in my VM guests, what to do? ===&lt;br /&gt;
&lt;br /&gt;
Especially in case of networked systems (e.g. via NFS or Samba) it is very important to ensure stable operation of timing (both system timer and RTC).&lt;br /&gt;
Tell-tale signs of related trouble in VMs (apparently qemu/KVM/VMWare etc. are all affected) are e.g.&lt;br /&gt;
&amp;quot;make[2]: Warning: File `XXXXX/cmakelists_rebuilder.stamp&#039; has modification time 0.37 s in the future&amp;quot;&lt;br /&gt;
&amp;quot;Clock skew detected. Your build may be incomplete.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[http://maemovmware.garage.maemo.org/2nd_edition/requirements_documentation.html Maemo docs] state that it&#039;s important to disable UTC and set the correct time zone, however I don&#039;t really see how that would help in case of diverging host/guest clocks.&lt;br /&gt;
IMHO much more useful and important is to configure properly working NTP server (chrony recommended, or ntpd) on both host and guest.&lt;br /&gt;
The single most decisive trick IMHO is to specify the &#039;&#039;&#039;host&#039;&#039;&#039; NTP server as the main entry within guest VM instead of &amp;quot;foreign&amp;quot; NTP servers, to make sure to achieve the most precise coupling between these two related systems (timing drift vs. other systems does not matter nearly as much as a tight time precision for inner host/guest system interaction e.g. in the case of NFS/Samba shares etc.).&lt;br /&gt;
For verification, see chronyc &amp;quot;sources -v&amp;quot;, &amp;quot;tracking&amp;quot; (&amp;quot;System time&amp;quot; row) commands.&lt;br /&gt;
&lt;br /&gt;
After having applied this very tight NTP coupling, this seems to finally have gotten rid of make&#039;s time drift warnings.&lt;br /&gt;
&lt;br /&gt;
Perhaps qemu&#039;s -tdf (timing drift fix) option magically manages to help in your case, too.&lt;br /&gt;
&lt;br /&gt;
See also [https://espace.cern.ch/it-faqs/Lists/faqs/DispForm.aspx?ID=368 Faqs: I received a message about &amp;quot;clock skew&amp;quot;].&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
=== I get &amp;quot;rtc interrupts lost&amp;quot; messages, and the guest is very slow? ===&lt;br /&gt;
Try setting &amp;lt;code&amp;gt;CONFIG_HPET_EMULATE_RTC=y&amp;lt;/code&amp;gt; in your host &amp;lt;code&amp;gt;.config&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I get an &amp;quot;Exception 13&amp;quot; or &amp;quot;Exception 12&amp;quot; message while booting a guest OS on my Intel host ===&lt;br /&gt;
See the [[Intel Real Mode Emulation Problems]] page.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I have VMware/Parallels/VirtualBox installed and when I modprobe KVM, my system deadlocks. ===&lt;br /&gt;
Neither Intel VT nor AMD-V provide a mechanism to determine whether software is currently using the hardware virtualization extensions.  This means that if you have two kernel modules loaded attempting to use hardware virtualization extensions, very bad things will happen.  If you are using another type of virtualization software and experience any sort of weirdness with KVM, make sure you can reproduce the problem without the kernel modules for that software loaded before you report a bug in KVM.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== There&#039;s nothing on QEMU/KVM screen, but it&#039;s not hanged! I&#039;m trying to install Kubuntu. ===&lt;br /&gt;
Try to run kvm with -std-vga option. It helps if guest operating system uses framebuffer mode like Kubuntu/Ubuntu.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== When I click the guest operating system window, mouse is grabbed. How can I get mouse to not to do that? OR Mouse doesn&#039;t show up / doesn&#039;t work in the guest. What do I do? ===&lt;br /&gt;
From #qemu wiki, try to run kvm/qemu with&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 -usb -usbdevice tablet&lt;br /&gt;
If that doesn&#039;t work, try this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 $ export SDL_VIDEO_X11_DGAMOUSE=0&lt;br /&gt;
(from http://wiki.clug.org.za/wiki/QEMU_mouse_not_working )&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
== General KVM information ==&lt;br /&gt;
=== What is the difference between KVM and Xen? ===&lt;br /&gt;
Xen is an external hypervisor; it assumes control of the machine and divides resources among guests. On the other hand, KVM is part of Linux and uses the regular Linux scheduler and memory management. This means that KVM is much smaller and simpler to use; it is also more featureful; for example KVM can swap guests to disk in order to free RAM.&lt;br /&gt;
&lt;br /&gt;
KVM only run on processors that supports x86 hvm (vt/svm instructions set) whereas Xen also allows running modified operating systems on non-hvm x86 processors using a technique called paravirtualization. KVM does not support paravirtualization for CPU but may support paravirtualization for device drivers to improve I/O performance.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What is the difference between KVM and VMware? ===&lt;br /&gt;
VMware is a proprietary product. KVM is Free Software released under the GPL.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What is the difference between KVM and QEMU? ===&lt;br /&gt;
QEMU uses emulation; KVM uses processor extensions (HVM) for virtualization.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Do you have a port of KVM for Windows? ===&lt;br /&gt;
Not officially.&lt;br /&gt;
&lt;br /&gt;
Kazushi Takahashi has been working on an experimental version though, called WinKVM, available [http://github.com/ddk50/winkvm here].&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What kernel version does it work with? ===&lt;br /&gt;
It depends on what version of KVM you are using. The last release of KVM should work with any recent kernel (2.6.17 and above), older releases even older kernels.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How much RAM do I need? ===&lt;br /&gt;
You will need enough memory to let the guest run comfortably while keeping enough for the host. 1GB is probably a minimum configuration for the host OS.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Is dynamic memory management for guests supported? ===&lt;br /&gt;
This is a broad topic covering a few areas.&lt;br /&gt;
&lt;br /&gt;
A. KVM only allocates memory as the guest tries to use it. Once it&#039;s allocated, KVM keeps it. Some guests (namely Microsoft guests) zero all memory at boot time. So they will use all memory.&lt;br /&gt;
&lt;br /&gt;
B. Certain guests (only Linux at the moment) have a balloon driver, so the host can have the guest allocate a certain amount of memory which the guest won&#039;t be able to use anymore and it can then be freed on the host. Ballooning is controlled in the host via the [http://www.nongnu.org/qemu/qemu-doc.html#SEC12 balloon monitor command].&lt;br /&gt;
&lt;br /&gt;
C. Some hosts (presently only RHEL5.4 / CentOS 5.4) have a feature called KSM (Kernel Sharedpage Merging), which collapses together identical pages; this requires kernel support on the host, as well as a kvm new enough to opt in to the behavior. As some guest platforms (most notably Windows) zero out free&#039;d memory, such pages are trivially collapsed. The ksmctl command needs to be used to enable KSM; alternately, the ksmtuned service found in Fedora 12 can be run to dynamically adjust KSM&#039;s aggressiveness based on the amount of free memory available&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What OSs can I run inside KVM VM? ===&lt;br /&gt;
Several.  See the [[Guest Support Status]] page for details. Note that several Linux flavors are known to hang on Intel processors during startup. Workaround is to disable splash screens in grub.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Does KVM support a live migration feature to move virtual machines from one host to another without downtime? ===&lt;br /&gt;
Yes.  See the [[Migration]] page for details.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Does KVM support live migration from an AMD host to an Intel host and back? ===&lt;br /&gt;
Yes.  There may be issues on 32-bit Intel hosts which don&#039;t support NX (or XD), but for 64-bit hosts back and forth migration should work well. Migration of 32-bit guests should work between 32-bit hosts and 64-bit hosts.&lt;br /&gt;
If one of your hosts does not support NX, you may consider disabling NX when starting the guest on a NX-capable system. You can do it by passing &amp;quot;-cpu qemu64,-nx&amp;quot; parameter to the guest.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Can KVM run a 32-bit guest on a 64-bit host? What about PAE? ===&lt;br /&gt;
KVM supports 32-bit guests on 64-bit hosts, and any combination of PAE and non-PAE guests and hosts. The only unsupported combination is a 64-bit guest on a 32-bit host.&lt;br /&gt;
&lt;br /&gt;
If you are running a Windows Virtual Machine and have problems enabling PAE in your guest see the [[Windows PAE Workaround]] page.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Is it possible to use a host&#039;s USB devices within a guest? ===&lt;br /&gt;
Yes, this method is described in detail [http://www.linux-kvm.org/page/USB_Host_Device_Assigned_to_Guest here].&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Can I have higher or widescreen resolutions (eg 1680 x 1050) in KVM? ===&lt;br /&gt;
Use the -vga std parameter while starting the VM to allow high resolution and widescreen displays.&lt;br /&gt;
&lt;br /&gt;
If the resolution you want to use is not available, you can patch the corresponding source files (see http://article.gmane.org/gmane.comp.emulators.kvm.devel/13557 as a reference), or send a mail to the KVM mailing list if you are not able to patch the source yourself.&lt;br /&gt;
&lt;br /&gt;
When using Windows as guest OS and not having issues with people violating the GPL you might want to use the driver from the VBEMP x86 project (http://www.bearwindows.boot-land.net/vbemp.htm) which is based on ReactOS code.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Does KVM support SMP hosts? ===&lt;br /&gt;
Yes.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Does KVM support SMP guests? ===&lt;br /&gt;
Yes. Up to 16 CPUs can be specified using the -smp option.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Is the name &#039;KVM&#039; trademarked? ===&lt;br /&gt;
No.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I compiled a new kernel for my KVM client and the ethernet interface is not recognized ===&lt;br /&gt;
You can specify alternative network interfaces to qemu with the &#039;&#039;-net nic,model=&#039;&#039; parameter. For example, &#039;&#039;-net nic,model=rtl8139&#039;&#039; would enable a device with the Realtek 8139 chipset.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I can&#039;t ping from guest to host or vice versa. How can I access the host? ===&lt;br /&gt;
The ping command may not go through in this circumstance, but you may be able to access the host in another way. For example, you can access a host running Apache by entering its IP address into a browser within the guest.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
[[Category:Docs]][[Category:HowTo]]&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=FAQ&amp;diff=173558</id>
		<title>FAQ</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=FAQ&amp;diff=173558"/>
		<updated>2015-11-08T19:51:50Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* I compiled a new kernel for my KVM client and the ethernet interface is not recognized */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=FAQ=&lt;br /&gt;
__TOC__&lt;br /&gt;
== Preparing to use KVM ==&lt;br /&gt;
=== What do I need to use KVM? ===&lt;br /&gt;
You will need an x86 machine running a recent Linux kernel on an Intel processor with VT (virtualization technology) extensions, or an AMD processor with SVM extensions (also called AMD-V). Xen has a [http://wiki.xensource.com/xenwiki/HVM_Compatible_Processors complete list] of compatible processors. For Intel processors, see also [http://ark.intel.com/VTList.aspx the Intel® Virtualization Technology List].&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
=== Are 64-bit processors supported under KVM? ===&lt;br /&gt;
Yes they are supported and will allow you to run 32-bit and 64-bit guests.&lt;br /&gt;
&lt;br /&gt;
See also &#039;&#039;&#039;Can KVM run a 32-bit guest on a 64-bit host? What about PAE?&#039;&#039;&#039; below.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What is Intel VT / AMD-V / hvm? ===&lt;br /&gt;
[http://www.intel.com/technology/itj/2006/v10i3/1-hardware/6-vt-x-vt-i-solutions.htm Intel VT] and [http://www.amd.com/us-en/Processors/ProductInformation/0,,30_118_8826_14287,00.html AMD&#039;s AMD-V] are instruction set extensions that provide hardware assistance to virtual machine monitors. They enable running fully isolated virtual machines at native hardware speeds, for some workloads.&lt;br /&gt;
&lt;br /&gt;
HVM (for Hardware Virtual Machine) is a vendor-neutral term often used to designate the x86 instruction set extensions.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Where do I get my kvm kernel modules from? ===&lt;br /&gt;
&lt;br /&gt;
See the [[Getting the kvm kernel modules]] page.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How can I tell if I have Intel VT or AMD-V? ===&lt;br /&gt;
With a recent enough Linux kernel, run the command:&lt;br /&gt;
&lt;br /&gt;
 . egrep &#039;^flags.*(vmx|svm)&#039; /proc/cpuinfo&lt;br /&gt;
&lt;br /&gt;
If something shows up, you have VT. You can also check the processor model name (in `/proc/cpuinfo`) in the vendor&#039;s web site.&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
*  You&#039;ll never see (vmx|svm) in /proc/cpuinfo if you&#039;re currently running in  in a dom0 or domU.&amp;lt;br /&amp;gt; The Xen hypervisor suppresses these flags in order to prevent hijacking.&lt;br /&gt;
* Some manufacturers disable VT in the machine&#039;s BIOS, in such a way that it cannot be re-enabled.&lt;br /&gt;
* `/proc/cpuinfo` only shows virtualization capabilities starting with Linux 2.6.15 (Intel) and Linux 2.6.16 (AMD). Use the `uname -r` command to query your kernel version.&lt;br /&gt;
In case of doubt, contact your hardware vendor.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== &amp;quot;KVM: disabled by BIOS&amp;quot; error ===&lt;br /&gt;
Check if there is an option to enable it in the BIOS. If not, look for a more recent BIOS on the vendor&#039;s web site.&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
* On some hardware (e-g HP nx6320), you need to power-off/power-on the machine after enabling virtualization in the BIOS.&lt;br /&gt;
* Enabling some BIOS features may break VT support on some hardware (e-g Enabling Intel AMT on a Thinkpad T500 will prevent kvm-intel from loading with &amp;quot;disabled by bios&amp;quot;)&lt;br /&gt;
* On some Dell hardware, you also need to disable &amp;quot;Trusted Execution&amp;quot;, otherwise VT will not be enabled.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How can I use AMD-V extension? ===&lt;br /&gt;
 modprobe kvm-amd&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What user space tools does KVM use? ===&lt;br /&gt;
KVM uses a slightly modified [http://www.nongnu.org/qemu QEMU] program to instantiate the virtual machine. Once running, a virtual machine is just a regular process. You can use `top(1), kill(1), taskset(1)` and similar tools to manage virtual machines.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What virtual disk formats can KVM use? ===&lt;br /&gt;
KVM inherits a wealth of disk formats support from QEMU; it supports raw images, the native QEMU format (qcow2), VMware format, and many more.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How do I use KVM on a headless machine (without a local GUI?) ===&lt;br /&gt;
Install a management tool such as virt-manager on a remote machine.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Are there management tools available to help me manage my virtual machines? ===&lt;br /&gt;
Yes.  Please see the [[Management Tools]] page for some links.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
== Using KVM ==&lt;br /&gt;
=== How can I use KVM with a non-privileged user? ===&lt;br /&gt;
The cleanest way is probably to create a group, say &#039;&#039;kvm&#039;&#039;, and add the user(s) to that group. Then you will need change /dev/kvm to owned by group &#039;&#039;kvm&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
On a system that runs udev, you will probably need to add the following line somewhere in your udev configuration so it will automatically give the right group to the newly created device (i-e for ubuntu add a line to &#039;&#039;/etc/udev/rules.d/40-permissions.rules&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 KERNEL==&amp;quot;kvm&amp;quot;, GROUP=&amp;quot;kvm&amp;quot;&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How can I get the most performance out of KVM? ===&lt;br /&gt;
&lt;br /&gt;
See the [[Tuning KVM]] page.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Is KVM stable? ===&lt;br /&gt;
KVM is stable and used in production.  As with most open source projects, development snapshots are less stable than the stable release series.&lt;br /&gt;
&lt;br /&gt;
If your name is Andreas Mohr, you&#039;re reporting bugs in the wrong place.&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== That&#039;s alright, but can I really use it for my daily use? ===&lt;br /&gt;
Sure. We continuously run the most often-used OSes and configurations and if anything breaks for the developers, it&#039;s fixed as soon as it was broken. See the [[Guest Support Status]] and [[Host Support Status]] pages to find out more. Please update them with success stories so that new users would benefit from the experience of the community.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How about production use? ===&lt;br /&gt;
For production use, it&#039;s recommended you use the KVM modules shipped by the distribution you&#039;re using to ensure stability. As mentioned above, it&#039;s tempting to use new features, but you never know of (unwanted) surprises hidden away. It&#039;ll be best if you can run the development snapshots with non-critical production load, so that the latest releases are stable for you when you decide to deploy them.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What happens if I kill -9 a VM process? ===&lt;br /&gt;
From the guest&#039;s perspective, it is as if you yanked the power cord out. From the host&#039;s perspective, the process is killed and all resources it uses are reclaimed.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I need help to setup the network for my guest ===&lt;br /&gt;
You can have a look to the [[Networking]] page of this wiki for informations on the most classical networking setup for the guests. You can also refer to the QEMU documentation.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Where can I find more documention... ===&lt;br /&gt;
Most usability issues are covered in the QEMU [http://www.nongnu.org/qemu/user-doc.html documentation].  There is also an extensive [http://qemu-buch.de/cgi-bin/moin.cgi/FrequentlyAskedQuestions FAQ] (old vanished link: [http://kidsquid.com/cgi-bin/moin.cgi/FrequentlyAskedQuestions FAQ]).&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
=== How can I check that I&#039;m not falling back to QEMU with no hardware acceleration? ===&lt;br /&gt;
&lt;br /&gt;
If you think that you might not be using the hardware acceleration provided by the KVM module, here are a few steps to help you check this.&lt;br /&gt;
&lt;br /&gt;
First of all, check that you don&#039;t have messages such as:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 qemu-system-x86_64 -hda myvm.qcow2&lt;br /&gt;
 open /dev/kvm: No such file or directory&lt;br /&gt;
 Could not initialize KVM, will disable KVM support&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In that case, you can check that:&lt;br /&gt;
* the modules are correctly loaded &amp;lt;code&amp;gt;lsmod|grep kvm&lt;br /&gt;
* you don&#039;t have a &amp;quot;KVM: disabled by BIOS&amp;quot; line in the output of dmesg&lt;br /&gt;
* /dev/kvm exists and you have the correct rights to use it&lt;br /&gt;
&lt;br /&gt;
Other ways to do the diagnostic:&lt;br /&gt;
* if you have access to the QEMU monitor (Ctrl-Alt-2, use Ctrl-Alt-1 to get back to the VM display), enter the &amp;quot;info kvm&amp;quot; command and it should respond with &amp;quot;KVM support: enabled&amp;quot;&lt;br /&gt;
* the right-end columns of the output from &amp;lt;code&amp;gt;lsmod|grep kvm&amp;lt;/code&amp;gt; on the host system, once the VM is started should show only non zero values. The value on the line corresponding to the architecture specific module (e-g kvm_intel, kvm_amd) show the number of VM using the module. For instance, if I have 2 VM running using the KVM module on a machine with vt, it will report:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 lsmod|grep kvm&lt;br /&gt;
 kvm_intel              44896  2&lt;br /&gt;
 kvm                   159656  1 kvm_intel&lt;br /&gt;
&lt;br /&gt;
=== &amp;quot;rect too big&amp;quot; Message when using VNC Display ===&lt;br /&gt;
When connection to a VNC Terminal, a &amp;quot;rect too big&amp;quot; message appears, and the VNC Session disconnects.&lt;br /&gt;
&lt;br /&gt;
This happens because of a VNC protocol flaw on the way on-the-fly pixel format changes are handled (more info at [http://www.mail-archive.com/qemu-devel@nongnu.org/msg04879.html this thread]). If you are using TigerVNC, you can avoid this problem by disabling on-the-fly selection of pixel encoding, using the &amp;lt;tt&amp;gt;-AutoSelect=0&amp;lt;/tt&amp;gt; command-line option of vncviewer. You may also want to check the encoding options on the vncviewer man page, as this will disable automatic selection of encoding based on connection speed.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&#039;&#039;&#039;How do I set up the network such that my guest is accessible from other machines?&#039;&#039;&#039; or&lt;br /&gt;
&lt;br /&gt;
=== My guest network is stuck what should I do? ===&lt;br /&gt;
KVM uses QEMU for its device emulation. Consult the [http://qemu-project.org/Documentation/Networking QEMU network wiki page] for detailed network setup instructions.&lt;br /&gt;
&lt;br /&gt;
One would probably be interested in the Root Networking Mode page and the Network Bridge page.&lt;br /&gt;
&lt;br /&gt;
Guest-side network lockups (fortunately restartable) may be happening due to tun/tap bridging erroneous MAC address reconfiguration on host side, see RHEL bug #571991 and others.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I&#039;m experiencing timer drift issues in my VM guests, what to do? ===&lt;br /&gt;
&lt;br /&gt;
Especially in case of networked systems (e.g. via NFS or Samba) it is very important to ensure stable operation of timing (both system timer and RTC).&lt;br /&gt;
Tell-tale signs of related trouble in VMs (apparently qemu/KVM/VMWare etc. are all affected) are e.g.&lt;br /&gt;
&amp;quot;make[2]: Warning: File `XXXXX/cmakelists_rebuilder.stamp&#039; has modification time 0.37 s in the future&amp;quot;&lt;br /&gt;
&amp;quot;Clock skew detected. Your build may be incomplete.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[http://maemovmware.garage.maemo.org/2nd_edition/requirements_documentation.html Maemo docs] state that it&#039;s important to disable UTC and set the correct time zone, however I don&#039;t really see how that would help in case of diverging host/guest clocks.&lt;br /&gt;
IMHO much more useful and important is to configure properly working NTP server (chrony recommended, or ntpd) on both host and guest.&lt;br /&gt;
The single most decisive trick IMHO is to specify the &#039;&#039;&#039;host&#039;&#039;&#039; NTP server as the main entry within guest VM instead of &amp;quot;foreign&amp;quot; NTP servers, to make sure to achieve the most precise coupling between these two related systems (timing drift vs. other systems does not matter nearly as much as a tight time precision for inner host/guest system interaction e.g. in the case of NFS/Samba shares etc.).&lt;br /&gt;
For verification, see chronyc &amp;quot;sources -v&amp;quot;, &amp;quot;tracking&amp;quot; (&amp;quot;System time&amp;quot; row) commands.&lt;br /&gt;
&lt;br /&gt;
After having applied this very tight NTP coupling, this seems to finally have gotten rid of make&#039;s time drift warnings.&lt;br /&gt;
&lt;br /&gt;
Perhaps qemu&#039;s -tdf (timing drift fix) option magically manages to help in your case, too.&lt;br /&gt;
&lt;br /&gt;
See also [https://espace.cern.ch/it-faqs/Lists/faqs/DispForm.aspx?ID=368 Faqs: I received a message about &amp;quot;clock skew&amp;quot;].&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
=== I get &amp;quot;rtc interrupts lost&amp;quot; messages, and the guest is very slow? ===&lt;br /&gt;
Try setting &amp;lt;code&amp;gt;CONFIG_HPET_EMULATE_RTC=y&amp;lt;/code&amp;gt; in your host &amp;lt;code&amp;gt;.config&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I get an &amp;quot;Exception 13&amp;quot; or &amp;quot;Exception 12&amp;quot; message while booting a guest OS on my Intel host ===&lt;br /&gt;
See the [[Intel Real Mode Emulation Problems]] page.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I have VMware/Parallels/VirtualBox installed and when I modprobe KVM, my system deadlocks. ===&lt;br /&gt;
Neither Intel VT nor AMD-V provide a mechanism to determine whether software is currently using the hardware virtualization extensions.  This means that if you have two kernel modules loaded attempting to use hardware virtualization extensions, very bad things will happen.  If you are using another type of virtualization software and experience any sort of weirdness with KVM, make sure you can reproduce the problem without the kernel modules for that software loaded before you report a bug in KVM.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== There&#039;s nothing on QEMU/KVM screen, but it&#039;s not hanged! I&#039;m trying to install Kubuntu. ===&lt;br /&gt;
Try to run kvm with -std-vga option. It helps if guest operating system uses framebuffer mode like Kubuntu/Ubuntu.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== When I click the guest operating system window, mouse is grabbed. How can I get mouse to not to do that? OR Mouse doesn&#039;t show up / doesn&#039;t work in the guest. What do I do? ===&lt;br /&gt;
From #qemu wiki, try to run kvm/qemu with&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 -usb -usbdevice tablet&lt;br /&gt;
If that doesn&#039;t work, try this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 $ export SDL_VIDEO_X11_DGAMOUSE=0&lt;br /&gt;
(from http://wiki.clug.org.za/wiki/QEMU_mouse_not_working )&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
== General KVM information ==&lt;br /&gt;
=== What is the difference between KVM and Xen? ===&lt;br /&gt;
Xen is an external hypervisor; it assumes control of the machine and divides resources among guests. On the other hand, KVM is part of Linux and uses the regular Linux scheduler and memory management. This means that KVM is much smaller and simpler to use; it is also more featureful; for example KVM can swap guests to disk in order to free RAM.&lt;br /&gt;
&lt;br /&gt;
KVM only run on processors that supports x86 hvm (vt/svm instructions set) whereas Xen also allows running modified operating systems on non-hvm x86 processors using a technique called paravirtualization. KVM does not support paravirtualization for CPU but may support paravirtualization for device drivers to improve I/O performance.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What is the difference between KVM and VMware? ===&lt;br /&gt;
VMware is a proprietary product. KVM is Free Software released under the GPL.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What is the difference between KVM and QEMU? ===&lt;br /&gt;
QEMU uses emulation; KVM uses processor extensions (HVM) for virtualization.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Do you have a port of KVM for Windows? ===&lt;br /&gt;
Not officially.&lt;br /&gt;
&lt;br /&gt;
Kazushi Takahashi has been working on an experimental version though, called WinKVM, available [http://github.com/ddk50/winkvm here].&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What kernel version does it work with? ===&lt;br /&gt;
It depends on what version of KVM you are using. The last release of KVM should work with any recent kernel (2.6.17 and above), older releases even older kernels.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How much RAM do I need? ===&lt;br /&gt;
You will need enough memory to let the guest run comfortably while keeping enough for the host. 1GB is probably a minimum configuration for the host OS.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Is dynamic memory management for guests supported? ===&lt;br /&gt;
This is a broad topic covering a few areas.&lt;br /&gt;
&lt;br /&gt;
A. KVM only allocates memory as the guest tries to use it. Once it&#039;s allocated, KVM keeps it. Some guests (namely Microsoft guests) zero all memory at boot time. So they will use all memory.&lt;br /&gt;
&lt;br /&gt;
B. Certain guests (only Linux at the moment) have a balloon driver, so the host can have the guest allocate a certain amount of memory which the guest won&#039;t be able to use anymore and it can then be freed on the host. Ballooning is controlled in the host via the [http://www.nongnu.org/qemu/qemu-doc.html#SEC12 balloon monitor command].&lt;br /&gt;
&lt;br /&gt;
C. Some hosts (presently only RHEL5.4 / CentOS 5.4) have a feature called KSM (Kernel Sharedpage Merging), which collapses together identical pages; this requires kernel support on the host, as well as a kvm new enough to opt in to the behavior. As some guest platforms (most notably Windows) zero out free&#039;d memory, such pages are trivially collapsed. The ksmctl command needs to be used to enable KSM; alternately, the ksmtuned service found in Fedora 12 can be run to dynamically adjust KSM&#039;s aggressiveness based on the amount of free memory available&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What OSs can I run inside KVM VM? ===&lt;br /&gt;
Several.  See the [[Guest Support Status]] page for details. Note that several Linux flavors are known to hang on Intel processors during startup. Workaround is to disable splash screens in grub.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Does KVM support a live migration feature to move virtual machines from one host to another without downtime? ===&lt;br /&gt;
Yes.  See the [[Migration]] page for details.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Does KVM support live migration from an AMD host to an Intel host and back? ===&lt;br /&gt;
Yes.  There may be issues on 32-bit Intel hosts which don&#039;t support NX (or XD), but for 64-bit hosts back and forth migration should work well. Migration of 32-bit guests should work between 32-bit hosts and 64-bit hosts.&lt;br /&gt;
If one of your hosts does not support NX, you may consider disabling NX when starting the guest on a NX-capable system. You can do it by passing &amp;quot;-cpu qemu64,-nx&amp;quot; parameter to the guest.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Can KVM run a 32-bit guest on a 64-bit host? What about PAE? ===&lt;br /&gt;
KVM supports 32-bit guests on 64-bit hosts, and any combination of PAE and non-PAE guests and hosts. The only unsupported combination is a 64-bit guest on a 32-bit host.&lt;br /&gt;
&lt;br /&gt;
If you are running a Windows Virtual Machine and have problems enabling PAE in your guest see the [[Windows PAE Workaround]] page.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Is it possible to use USB devices with a guest OS? ===&lt;br /&gt;
Yes, look up how to do it with QEMU, it&#039;s the same way.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Can I have higher or widescreen resolutions (eg 1680 x 1050) in KVM? ===&lt;br /&gt;
Use the -vga std parameter while starting the VM to allow high resolution and widescreen displays.&lt;br /&gt;
&lt;br /&gt;
If the resolution you want to use is not available, you can patch the corresponding source files (see http://article.gmane.org/gmane.comp.emulators.kvm.devel/13557 as a reference), or send a mail to the KVM mailing list if you are not able to patch the source yourself.&lt;br /&gt;
&lt;br /&gt;
When using Windows as guest OS and not having issues with people violating the GPL you might want to use the driver from the VBEMP x86 project (http://www.bearwindows.boot-land.net/vbemp.htm) which is based on ReactOS code.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Does KVM support SMP hosts? ===&lt;br /&gt;
Yes.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Does KVM support SMP guests? ===&lt;br /&gt;
Yes. Up to 16 CPUs can be specified using the -smp option.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Is the name &#039;KVM&#039; trademarked? ===&lt;br /&gt;
No.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I compiled a new kernel for my KVM client and the ethernet interface is not recognized ===&lt;br /&gt;
You can specify alternative network interfaces to qemu with the &#039;&#039;-net nic,model=&#039;&#039; parameter. For example, &#039;&#039;-net nic,model=rtl8139&#039;&#039; would enable a device with the Realtek 8139 chipset.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I can&#039;t ping from guest to host or vice versa. How can I access the host? ===&lt;br /&gt;
The ping command may not go through in this circumstance, but you may be able to access the host in another way. For example, you can access a host running Apache by entering its IP address into a browser within the guest.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
[[Category:Docs]][[Category:HowTo]]&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=FAQ&amp;diff=173557</id>
		<title>FAQ</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=FAQ&amp;diff=173557"/>
		<updated>2015-11-08T19:39:13Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* I can&amp;#039;t ping from guest to host or vice versa. How can I access the host? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=FAQ=&lt;br /&gt;
__TOC__&lt;br /&gt;
== Preparing to use KVM ==&lt;br /&gt;
=== What do I need to use KVM? ===&lt;br /&gt;
You will need an x86 machine running a recent Linux kernel on an Intel processor with VT (virtualization technology) extensions, or an AMD processor with SVM extensions (also called AMD-V). Xen has a [http://wiki.xensource.com/xenwiki/HVM_Compatible_Processors complete list] of compatible processors. For Intel processors, see also [http://ark.intel.com/VTList.aspx the Intel® Virtualization Technology List].&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
=== Are 64-bit processors supported under KVM? ===&lt;br /&gt;
Yes they are supported and will allow you to run 32-bit and 64-bit guests.&lt;br /&gt;
&lt;br /&gt;
See also &#039;&#039;&#039;Can KVM run a 32-bit guest on a 64-bit host? What about PAE?&#039;&#039;&#039; below.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What is Intel VT / AMD-V / hvm? ===&lt;br /&gt;
[http://www.intel.com/technology/itj/2006/v10i3/1-hardware/6-vt-x-vt-i-solutions.htm Intel VT] and [http://www.amd.com/us-en/Processors/ProductInformation/0,,30_118_8826_14287,00.html AMD&#039;s AMD-V] are instruction set extensions that provide hardware assistance to virtual machine monitors. They enable running fully isolated virtual machines at native hardware speeds, for some workloads.&lt;br /&gt;
&lt;br /&gt;
HVM (for Hardware Virtual Machine) is a vendor-neutral term often used to designate the x86 instruction set extensions.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Where do I get my kvm kernel modules from? ===&lt;br /&gt;
&lt;br /&gt;
See the [[Getting the kvm kernel modules]] page.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How can I tell if I have Intel VT or AMD-V? ===&lt;br /&gt;
With a recent enough Linux kernel, run the command:&lt;br /&gt;
&lt;br /&gt;
 . egrep &#039;^flags.*(vmx|svm)&#039; /proc/cpuinfo&lt;br /&gt;
&lt;br /&gt;
If something shows up, you have VT. You can also check the processor model name (in `/proc/cpuinfo`) in the vendor&#039;s web site.&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
*  You&#039;ll never see (vmx|svm) in /proc/cpuinfo if you&#039;re currently running in  in a dom0 or domU.&amp;lt;br /&amp;gt; The Xen hypervisor suppresses these flags in order to prevent hijacking.&lt;br /&gt;
* Some manufacturers disable VT in the machine&#039;s BIOS, in such a way that it cannot be re-enabled.&lt;br /&gt;
* `/proc/cpuinfo` only shows virtualization capabilities starting with Linux 2.6.15 (Intel) and Linux 2.6.16 (AMD). Use the `uname -r` command to query your kernel version.&lt;br /&gt;
In case of doubt, contact your hardware vendor.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== &amp;quot;KVM: disabled by BIOS&amp;quot; error ===&lt;br /&gt;
Check if there is an option to enable it in the BIOS. If not, look for a more recent BIOS on the vendor&#039;s web site.&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
* On some hardware (e-g HP nx6320), you need to power-off/power-on the machine after enabling virtualization in the BIOS.&lt;br /&gt;
* Enabling some BIOS features may break VT support on some hardware (e-g Enabling Intel AMT on a Thinkpad T500 will prevent kvm-intel from loading with &amp;quot;disabled by bios&amp;quot;)&lt;br /&gt;
* On some Dell hardware, you also need to disable &amp;quot;Trusted Execution&amp;quot;, otherwise VT will not be enabled.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How can I use AMD-V extension? ===&lt;br /&gt;
 modprobe kvm-amd&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What user space tools does KVM use? ===&lt;br /&gt;
KVM uses a slightly modified [http://www.nongnu.org/qemu QEMU] program to instantiate the virtual machine. Once running, a virtual machine is just a regular process. You can use `top(1), kill(1), taskset(1)` and similar tools to manage virtual machines.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What virtual disk formats can KVM use? ===&lt;br /&gt;
KVM inherits a wealth of disk formats support from QEMU; it supports raw images, the native QEMU format (qcow2), VMware format, and many more.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How do I use KVM on a headless machine (without a local GUI?) ===&lt;br /&gt;
Install a management tool such as virt-manager on a remote machine.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Are there management tools available to help me manage my virtual machines? ===&lt;br /&gt;
Yes.  Please see the [[Management Tools]] page for some links.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
== Using KVM ==&lt;br /&gt;
=== How can I use KVM with a non-privileged user? ===&lt;br /&gt;
The cleanest way is probably to create a group, say &#039;&#039;kvm&#039;&#039;, and add the user(s) to that group. Then you will need change /dev/kvm to owned by group &#039;&#039;kvm&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
On a system that runs udev, you will probably need to add the following line somewhere in your udev configuration so it will automatically give the right group to the newly created device (i-e for ubuntu add a line to &#039;&#039;/etc/udev/rules.d/40-permissions.rules&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 KERNEL==&amp;quot;kvm&amp;quot;, GROUP=&amp;quot;kvm&amp;quot;&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How can I get the most performance out of KVM? ===&lt;br /&gt;
&lt;br /&gt;
See the [[Tuning KVM]] page.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Is KVM stable? ===&lt;br /&gt;
KVM is stable and used in production.  As with most open source projects, development snapshots are less stable than the stable release series.&lt;br /&gt;
&lt;br /&gt;
If your name is Andreas Mohr, you&#039;re reporting bugs in the wrong place.&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== That&#039;s alright, but can I really use it for my daily use? ===&lt;br /&gt;
Sure. We continuously run the most often-used OSes and configurations and if anything breaks for the developers, it&#039;s fixed as soon as it was broken. See the [[Guest Support Status]] and [[Host Support Status]] pages to find out more. Please update them with success stories so that new users would benefit from the experience of the community.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How about production use? ===&lt;br /&gt;
For production use, it&#039;s recommended you use the KVM modules shipped by the distribution you&#039;re using to ensure stability. As mentioned above, it&#039;s tempting to use new features, but you never know of (unwanted) surprises hidden away. It&#039;ll be best if you can run the development snapshots with non-critical production load, so that the latest releases are stable for you when you decide to deploy them.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What happens if I kill -9 a VM process? ===&lt;br /&gt;
From the guest&#039;s perspective, it is as if you yanked the power cord out. From the host&#039;s perspective, the process is killed and all resources it uses are reclaimed.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I need help to setup the network for my guest ===&lt;br /&gt;
You can have a look to the [[Networking]] page of this wiki for informations on the most classical networking setup for the guests. You can also refer to the QEMU documentation.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Where can I find more documention... ===&lt;br /&gt;
Most usability issues are covered in the QEMU [http://www.nongnu.org/qemu/user-doc.html documentation].  There is also an extensive [http://qemu-buch.de/cgi-bin/moin.cgi/FrequentlyAskedQuestions FAQ] (old vanished link: [http://kidsquid.com/cgi-bin/moin.cgi/FrequentlyAskedQuestions FAQ]).&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
=== How can I check that I&#039;m not falling back to QEMU with no hardware acceleration? ===&lt;br /&gt;
&lt;br /&gt;
If you think that you might not be using the hardware acceleration provided by the KVM module, here are a few steps to help you check this.&lt;br /&gt;
&lt;br /&gt;
First of all, check that you don&#039;t have messages such as:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 qemu-system-x86_64 -hda myvm.qcow2&lt;br /&gt;
 open /dev/kvm: No such file or directory&lt;br /&gt;
 Could not initialize KVM, will disable KVM support&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In that case, you can check that:&lt;br /&gt;
* the modules are correctly loaded &amp;lt;code&amp;gt;lsmod|grep kvm&lt;br /&gt;
* you don&#039;t have a &amp;quot;KVM: disabled by BIOS&amp;quot; line in the output of dmesg&lt;br /&gt;
* /dev/kvm exists and you have the correct rights to use it&lt;br /&gt;
&lt;br /&gt;
Other ways to do the diagnostic:&lt;br /&gt;
* if you have access to the QEMU monitor (Ctrl-Alt-2, use Ctrl-Alt-1 to get back to the VM display), enter the &amp;quot;info kvm&amp;quot; command and it should respond with &amp;quot;KVM support: enabled&amp;quot;&lt;br /&gt;
* the right-end columns of the output from &amp;lt;code&amp;gt;lsmod|grep kvm&amp;lt;/code&amp;gt; on the host system, once the VM is started should show only non zero values. The value on the line corresponding to the architecture specific module (e-g kvm_intel, kvm_amd) show the number of VM using the module. For instance, if I have 2 VM running using the KVM module on a machine with vt, it will report:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 lsmod|grep kvm&lt;br /&gt;
 kvm_intel              44896  2&lt;br /&gt;
 kvm                   159656  1 kvm_intel&lt;br /&gt;
&lt;br /&gt;
=== &amp;quot;rect too big&amp;quot; Message when using VNC Display ===&lt;br /&gt;
When connection to a VNC Terminal, a &amp;quot;rect too big&amp;quot; message appears, and the VNC Session disconnects.&lt;br /&gt;
&lt;br /&gt;
This happens because of a VNC protocol flaw on the way on-the-fly pixel format changes are handled (more info at [http://www.mail-archive.com/qemu-devel@nongnu.org/msg04879.html this thread]). If you are using TigerVNC, you can avoid this problem by disabling on-the-fly selection of pixel encoding, using the &amp;lt;tt&amp;gt;-AutoSelect=0&amp;lt;/tt&amp;gt; command-line option of vncviewer. You may also want to check the encoding options on the vncviewer man page, as this will disable automatic selection of encoding based on connection speed.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&#039;&#039;&#039;How do I set up the network such that my guest is accessible from other machines?&#039;&#039;&#039; or&lt;br /&gt;
&lt;br /&gt;
=== My guest network is stuck what should I do? ===&lt;br /&gt;
KVM uses QEMU for its device emulation. Consult the [http://qemu-project.org/Documentation/Networking QEMU network wiki page] for detailed network setup instructions.&lt;br /&gt;
&lt;br /&gt;
One would probably be interested in the Root Networking Mode page and the Network Bridge page.&lt;br /&gt;
&lt;br /&gt;
Guest-side network lockups (fortunately restartable) may be happening due to tun/tap bridging erroneous MAC address reconfiguration on host side, see RHEL bug #571991 and others.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I&#039;m experiencing timer drift issues in my VM guests, what to do? ===&lt;br /&gt;
&lt;br /&gt;
Especially in case of networked systems (e.g. via NFS or Samba) it is very important to ensure stable operation of timing (both system timer and RTC).&lt;br /&gt;
Tell-tale signs of related trouble in VMs (apparently qemu/KVM/VMWare etc. are all affected) are e.g.&lt;br /&gt;
&amp;quot;make[2]: Warning: File `XXXXX/cmakelists_rebuilder.stamp&#039; has modification time 0.37 s in the future&amp;quot;&lt;br /&gt;
&amp;quot;Clock skew detected. Your build may be incomplete.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[http://maemovmware.garage.maemo.org/2nd_edition/requirements_documentation.html Maemo docs] state that it&#039;s important to disable UTC and set the correct time zone, however I don&#039;t really see how that would help in case of diverging host/guest clocks.&lt;br /&gt;
IMHO much more useful and important is to configure properly working NTP server (chrony recommended, or ntpd) on both host and guest.&lt;br /&gt;
The single most decisive trick IMHO is to specify the &#039;&#039;&#039;host&#039;&#039;&#039; NTP server as the main entry within guest VM instead of &amp;quot;foreign&amp;quot; NTP servers, to make sure to achieve the most precise coupling between these two related systems (timing drift vs. other systems does not matter nearly as much as a tight time precision for inner host/guest system interaction e.g. in the case of NFS/Samba shares etc.).&lt;br /&gt;
For verification, see chronyc &amp;quot;sources -v&amp;quot;, &amp;quot;tracking&amp;quot; (&amp;quot;System time&amp;quot; row) commands.&lt;br /&gt;
&lt;br /&gt;
After having applied this very tight NTP coupling, this seems to finally have gotten rid of make&#039;s time drift warnings.&lt;br /&gt;
&lt;br /&gt;
Perhaps qemu&#039;s -tdf (timing drift fix) option magically manages to help in your case, too.&lt;br /&gt;
&lt;br /&gt;
See also [https://espace.cern.ch/it-faqs/Lists/faqs/DispForm.aspx?ID=368 Faqs: I received a message about &amp;quot;clock skew&amp;quot;].&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
=== I get &amp;quot;rtc interrupts lost&amp;quot; messages, and the guest is very slow? ===&lt;br /&gt;
Try setting &amp;lt;code&amp;gt;CONFIG_HPET_EMULATE_RTC=y&amp;lt;/code&amp;gt; in your host &amp;lt;code&amp;gt;.config&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I get an &amp;quot;Exception 13&amp;quot; or &amp;quot;Exception 12&amp;quot; message while booting a guest OS on my Intel host ===&lt;br /&gt;
See the [[Intel Real Mode Emulation Problems]] page.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I have VMware/Parallels/VirtualBox installed and when I modprobe KVM, my system deadlocks. ===&lt;br /&gt;
Neither Intel VT nor AMD-V provide a mechanism to determine whether software is currently using the hardware virtualization extensions.  This means that if you have two kernel modules loaded attempting to use hardware virtualization extensions, very bad things will happen.  If you are using another type of virtualization software and experience any sort of weirdness with KVM, make sure you can reproduce the problem without the kernel modules for that software loaded before you report a bug in KVM.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== There&#039;s nothing on QEMU/KVM screen, but it&#039;s not hanged! I&#039;m trying to install Kubuntu. ===&lt;br /&gt;
Try to run kvm with -std-vga option. It helps if guest operating system uses framebuffer mode like Kubuntu/Ubuntu.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== When I click the guest operating system window, mouse is grabbed. How can I get mouse to not to do that? OR Mouse doesn&#039;t show up / doesn&#039;t work in the guest. What do I do? ===&lt;br /&gt;
From #qemu wiki, try to run kvm/qemu with&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 -usb -usbdevice tablet&lt;br /&gt;
If that doesn&#039;t work, try this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 $ export SDL_VIDEO_X11_DGAMOUSE=0&lt;br /&gt;
(from http://wiki.clug.org.za/wiki/QEMU_mouse_not_working )&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
== General KVM information ==&lt;br /&gt;
=== What is the difference between KVM and Xen? ===&lt;br /&gt;
Xen is an external hypervisor; it assumes control of the machine and divides resources among guests. On the other hand, KVM is part of Linux and uses the regular Linux scheduler and memory management. This means that KVM is much smaller and simpler to use; it is also more featureful; for example KVM can swap guests to disk in order to free RAM.&lt;br /&gt;
&lt;br /&gt;
KVM only run on processors that supports x86 hvm (vt/svm instructions set) whereas Xen also allows running modified operating systems on non-hvm x86 processors using a technique called paravirtualization. KVM does not support paravirtualization for CPU but may support paravirtualization for device drivers to improve I/O performance.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What is the difference between KVM and VMware? ===&lt;br /&gt;
VMware is a proprietary product. KVM is Free Software released under the GPL.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What is the difference between KVM and QEMU? ===&lt;br /&gt;
QEMU uses emulation; KVM uses processor extensions (HVM) for virtualization.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Do you have a port of KVM for Windows? ===&lt;br /&gt;
Not officially.&lt;br /&gt;
&lt;br /&gt;
Kazushi Takahashi has been working on an experimental version though, called WinKVM, available [http://github.com/ddk50/winkvm here].&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What kernel version does it work with? ===&lt;br /&gt;
It depends on what version of KVM you are using. The last release of KVM should work with any recent kernel (2.6.17 and above), older releases even older kernels.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How much RAM do I need? ===&lt;br /&gt;
You will need enough memory to let the guest run comfortably while keeping enough for the host. 1GB is probably a minimum configuration for the host OS.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Is dynamic memory management for guests supported? ===&lt;br /&gt;
This is a broad topic covering a few areas.&lt;br /&gt;
&lt;br /&gt;
A. KVM only allocates memory as the guest tries to use it. Once it&#039;s allocated, KVM keeps it. Some guests (namely Microsoft guests) zero all memory at boot time. So they will use all memory.&lt;br /&gt;
&lt;br /&gt;
B. Certain guests (only Linux at the moment) have a balloon driver, so the host can have the guest allocate a certain amount of memory which the guest won&#039;t be able to use anymore and it can then be freed on the host. Ballooning is controlled in the host via the [http://www.nongnu.org/qemu/qemu-doc.html#SEC12 balloon monitor command].&lt;br /&gt;
&lt;br /&gt;
C. Some hosts (presently only RHEL5.4 / CentOS 5.4) have a feature called KSM (Kernel Sharedpage Merging), which collapses together identical pages; this requires kernel support on the host, as well as a kvm new enough to opt in to the behavior. As some guest platforms (most notably Windows) zero out free&#039;d memory, such pages are trivially collapsed. The ksmctl command needs to be used to enable KSM; alternately, the ksmtuned service found in Fedora 12 can be run to dynamically adjust KSM&#039;s aggressiveness based on the amount of free memory available&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What OSs can I run inside KVM VM? ===&lt;br /&gt;
Several.  See the [[Guest Support Status]] page for details. Note that several Linux flavors are known to hang on Intel processors during startup. Workaround is to disable splash screens in grub.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Does KVM support a live migration feature to move virtual machines from one host to another without downtime? ===&lt;br /&gt;
Yes.  See the [[Migration]] page for details.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Does KVM support live migration from an AMD host to an Intel host and back? ===&lt;br /&gt;
Yes.  There may be issues on 32-bit Intel hosts which don&#039;t support NX (or XD), but for 64-bit hosts back and forth migration should work well. Migration of 32-bit guests should work between 32-bit hosts and 64-bit hosts.&lt;br /&gt;
If one of your hosts does not support NX, you may consider disabling NX when starting the guest on a NX-capable system. You can do it by passing &amp;quot;-cpu qemu64,-nx&amp;quot; parameter to the guest.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Can KVM run a 32-bit guest on a 64-bit host? What about PAE? ===&lt;br /&gt;
KVM supports 32-bit guests on 64-bit hosts, and any combination of PAE and non-PAE guests and hosts. The only unsupported combination is a 64-bit guest on a 32-bit host.&lt;br /&gt;
&lt;br /&gt;
If you are running a Windows Virtual Machine and have problems enabling PAE in your guest see the [[Windows PAE Workaround]] page.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Is it possible to use USB devices with a guest OS? ===&lt;br /&gt;
Yes, look up how to do it with QEMU, it&#039;s the same way.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Can I have higher or widescreen resolutions (eg 1680 x 1050) in KVM? ===&lt;br /&gt;
Use the -vga std parameter while starting the VM to allow high resolution and widescreen displays.&lt;br /&gt;
&lt;br /&gt;
If the resolution you want to use is not available, you can patch the corresponding source files (see http://article.gmane.org/gmane.comp.emulators.kvm.devel/13557 as a reference), or send a mail to the KVM mailing list if you are not able to patch the source yourself.&lt;br /&gt;
&lt;br /&gt;
When using Windows as guest OS and not having issues with people violating the GPL you might want to use the driver from the VBEMP x86 project (http://www.bearwindows.boot-land.net/vbemp.htm) which is based on ReactOS code.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Does KVM support SMP hosts? ===&lt;br /&gt;
Yes.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Does KVM support SMP guests? ===&lt;br /&gt;
Yes. Up to 16 CPUs can be specified using the -smp option.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Is the name &#039;KVM&#039; trademarked? ===&lt;br /&gt;
No.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I compiled a new kernel for my KVM client, and the ethernet interface is not recognized ===&lt;br /&gt;
you can tell qemu to emulate e.g. the 8139 with model=rtl8139&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I can&#039;t ping from guest to host or vice versa. How can I access the host? ===&lt;br /&gt;
The ping command may not go through in this circumstance, but you may be able to access the host in another way. For example, you can access a host running Apache by entering its IP address into a browser within the guest.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
[[Category:Docs]][[Category:HowTo]]&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=FAQ&amp;diff=173556</id>
		<title>FAQ</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=FAQ&amp;diff=173556"/>
		<updated>2015-11-08T19:28:18Z</updated>

		<summary type="html">&lt;p&gt;Ckotichas: /* Are 64-bit processors supported under KVM? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=FAQ=&lt;br /&gt;
__TOC__&lt;br /&gt;
== Preparing to use KVM ==&lt;br /&gt;
=== What do I need to use KVM? ===&lt;br /&gt;
You will need an x86 machine running a recent Linux kernel on an Intel processor with VT (virtualization technology) extensions, or an AMD processor with SVM extensions (also called AMD-V). Xen has a [http://wiki.xensource.com/xenwiki/HVM_Compatible_Processors complete list] of compatible processors. For Intel processors, see also [http://ark.intel.com/VTList.aspx the Intel® Virtualization Technology List].&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
=== Are 64-bit processors supported under KVM? ===&lt;br /&gt;
Yes they are supported and will allow you to run 32-bit and 64-bit guests.&lt;br /&gt;
&lt;br /&gt;
See also &#039;&#039;&#039;Can KVM run a 32-bit guest on a 64-bit host? What about PAE?&#039;&#039;&#039; below.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What is Intel VT / AMD-V / hvm? ===&lt;br /&gt;
[http://www.intel.com/technology/itj/2006/v10i3/1-hardware/6-vt-x-vt-i-solutions.htm Intel VT] and [http://www.amd.com/us-en/Processors/ProductInformation/0,,30_118_8826_14287,00.html AMD&#039;s AMD-V] are instruction set extensions that provide hardware assistance to virtual machine monitors. They enable running fully isolated virtual machines at native hardware speeds, for some workloads.&lt;br /&gt;
&lt;br /&gt;
HVM (for Hardware Virtual Machine) is a vendor-neutral term often used to designate the x86 instruction set extensions.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Where do I get my kvm kernel modules from? ===&lt;br /&gt;
&lt;br /&gt;
See the [[Getting the kvm kernel modules]] page.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How can I tell if I have Intel VT or AMD-V? ===&lt;br /&gt;
With a recent enough Linux kernel, run the command:&lt;br /&gt;
&lt;br /&gt;
 . egrep &#039;^flags.*(vmx|svm)&#039; /proc/cpuinfo&lt;br /&gt;
&lt;br /&gt;
If something shows up, you have VT. You can also check the processor model name (in `/proc/cpuinfo`) in the vendor&#039;s web site.&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
*  You&#039;ll never see (vmx|svm) in /proc/cpuinfo if you&#039;re currently running in  in a dom0 or domU.&amp;lt;br /&amp;gt; The Xen hypervisor suppresses these flags in order to prevent hijacking.&lt;br /&gt;
* Some manufacturers disable VT in the machine&#039;s BIOS, in such a way that it cannot be re-enabled.&lt;br /&gt;
* `/proc/cpuinfo` only shows virtualization capabilities starting with Linux 2.6.15 (Intel) and Linux 2.6.16 (AMD). Use the `uname -r` command to query your kernel version.&lt;br /&gt;
In case of doubt, contact your hardware vendor.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== &amp;quot;KVM: disabled by BIOS&amp;quot; error ===&lt;br /&gt;
Check if there is an option to enable it in the BIOS. If not, look for a more recent BIOS on the vendor&#039;s web site.&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
* On some hardware (e-g HP nx6320), you need to power-off/power-on the machine after enabling virtualization in the BIOS.&lt;br /&gt;
* Enabling some BIOS features may break VT support on some hardware (e-g Enabling Intel AMT on a Thinkpad T500 will prevent kvm-intel from loading with &amp;quot;disabled by bios&amp;quot;)&lt;br /&gt;
* On some Dell hardware, you also need to disable &amp;quot;Trusted Execution&amp;quot;, otherwise VT will not be enabled.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How can I use AMD-V extension? ===&lt;br /&gt;
 modprobe kvm-amd&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What user space tools does KVM use? ===&lt;br /&gt;
KVM uses a slightly modified [http://www.nongnu.org/qemu QEMU] program to instantiate the virtual machine. Once running, a virtual machine is just a regular process. You can use `top(1), kill(1), taskset(1)` and similar tools to manage virtual machines.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What virtual disk formats can KVM use? ===&lt;br /&gt;
KVM inherits a wealth of disk formats support from QEMU; it supports raw images, the native QEMU format (qcow2), VMware format, and many more.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How do I use KVM on a headless machine (without a local GUI?) ===&lt;br /&gt;
Install a management tool such as virt-manager on a remote machine.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Are there management tools available to help me manage my virtual machines? ===&lt;br /&gt;
Yes.  Please see the [[Management Tools]] page for some links.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
== Using KVM ==&lt;br /&gt;
=== How can I use KVM with a non-privileged user? ===&lt;br /&gt;
The cleanest way is probably to create a group, say &#039;&#039;kvm&#039;&#039;, and add the user(s) to that group. Then you will need change /dev/kvm to owned by group &#039;&#039;kvm&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
On a system that runs udev, you will probably need to add the following line somewhere in your udev configuration so it will automatically give the right group to the newly created device (i-e for ubuntu add a line to &#039;&#039;/etc/udev/rules.d/40-permissions.rules&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 KERNEL==&amp;quot;kvm&amp;quot;, GROUP=&amp;quot;kvm&amp;quot;&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How can I get the most performance out of KVM? ===&lt;br /&gt;
&lt;br /&gt;
See the [[Tuning KVM]] page.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Is KVM stable? ===&lt;br /&gt;
KVM is stable and used in production.  As with most open source projects, development snapshots are less stable than the stable release series.&lt;br /&gt;
&lt;br /&gt;
If your name is Andreas Mohr, you&#039;re reporting bugs in the wrong place.&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== That&#039;s alright, but can I really use it for my daily use? ===&lt;br /&gt;
Sure. We continuously run the most often-used OSes and configurations and if anything breaks for the developers, it&#039;s fixed as soon as it was broken. See the [[Guest Support Status]] and [[Host Support Status]] pages to find out more. Please update them with success stories so that new users would benefit from the experience of the community.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How about production use? ===&lt;br /&gt;
For production use, it&#039;s recommended you use the KVM modules shipped by the distribution you&#039;re using to ensure stability. As mentioned above, it&#039;s tempting to use new features, but you never know of (unwanted) surprises hidden away. It&#039;ll be best if you can run the development snapshots with non-critical production load, so that the latest releases are stable for you when you decide to deploy them.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What happens if I kill -9 a VM process? ===&lt;br /&gt;
From the guest&#039;s perspective, it is as if you yanked the power cord out. From the host&#039;s perspective, the process is killed and all resources it uses are reclaimed.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I need help to setup the network for my guest ===&lt;br /&gt;
You can have a look to the [[Networking]] page of this wiki for informations on the most classical networking setup for the guests. You can also refer to the QEMU documentation.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Where can I find more documention... ===&lt;br /&gt;
Most usability issues are covered in the QEMU [http://www.nongnu.org/qemu/user-doc.html documentation].  There is also an extensive [http://qemu-buch.de/cgi-bin/moin.cgi/FrequentlyAskedQuestions FAQ] (old vanished link: [http://kidsquid.com/cgi-bin/moin.cgi/FrequentlyAskedQuestions FAQ]).&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
=== How can I check that I&#039;m not falling back to QEMU with no hardware acceleration? ===&lt;br /&gt;
&lt;br /&gt;
If you think that you might not be using the hardware acceleration provided by the KVM module, here are a few steps to help you check this.&lt;br /&gt;
&lt;br /&gt;
First of all, check that you don&#039;t have messages such as:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 qemu-system-x86_64 -hda myvm.qcow2&lt;br /&gt;
 open /dev/kvm: No such file or directory&lt;br /&gt;
 Could not initialize KVM, will disable KVM support&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In that case, you can check that:&lt;br /&gt;
* the modules are correctly loaded &amp;lt;code&amp;gt;lsmod|grep kvm&lt;br /&gt;
* you don&#039;t have a &amp;quot;KVM: disabled by BIOS&amp;quot; line in the output of dmesg&lt;br /&gt;
* /dev/kvm exists and you have the correct rights to use it&lt;br /&gt;
&lt;br /&gt;
Other ways to do the diagnostic:&lt;br /&gt;
* if you have access to the QEMU monitor (Ctrl-Alt-2, use Ctrl-Alt-1 to get back to the VM display), enter the &amp;quot;info kvm&amp;quot; command and it should respond with &amp;quot;KVM support: enabled&amp;quot;&lt;br /&gt;
* the right-end columns of the output from &amp;lt;code&amp;gt;lsmod|grep kvm&amp;lt;/code&amp;gt; on the host system, once the VM is started should show only non zero values. The value on the line corresponding to the architecture specific module (e-g kvm_intel, kvm_amd) show the number of VM using the module. For instance, if I have 2 VM running using the KVM module on a machine with vt, it will report:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 lsmod|grep kvm&lt;br /&gt;
 kvm_intel              44896  2&lt;br /&gt;
 kvm                   159656  1 kvm_intel&lt;br /&gt;
&lt;br /&gt;
=== &amp;quot;rect too big&amp;quot; Message when using VNC Display ===&lt;br /&gt;
When connection to a VNC Terminal, a &amp;quot;rect too big&amp;quot; message appears, and the VNC Session disconnects.&lt;br /&gt;
&lt;br /&gt;
This happens because of a VNC protocol flaw on the way on-the-fly pixel format changes are handled (more info at [http://www.mail-archive.com/qemu-devel@nongnu.org/msg04879.html this thread]). If you are using TigerVNC, you can avoid this problem by disabling on-the-fly selection of pixel encoding, using the &amp;lt;tt&amp;gt;-AutoSelect=0&amp;lt;/tt&amp;gt; command-line option of vncviewer. You may also want to check the encoding options on the vncviewer man page, as this will disable automatic selection of encoding based on connection speed.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&#039;&#039;&#039;How do I set up the network such that my guest is accessible from other machines?&#039;&#039;&#039; or&lt;br /&gt;
&lt;br /&gt;
=== My guest network is stuck what should I do? ===&lt;br /&gt;
KVM uses QEMU for its device emulation. Consult the [http://qemu-project.org/Documentation/Networking QEMU network wiki page] for detailed network setup instructions.&lt;br /&gt;
&lt;br /&gt;
One would probably be interested in the Root Networking Mode page and the Network Bridge page.&lt;br /&gt;
&lt;br /&gt;
Guest-side network lockups (fortunately restartable) may be happening due to tun/tap bridging erroneous MAC address reconfiguration on host side, see RHEL bug #571991 and others.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I&#039;m experiencing timer drift issues in my VM guests, what to do? ===&lt;br /&gt;
&lt;br /&gt;
Especially in case of networked systems (e.g. via NFS or Samba) it is very important to ensure stable operation of timing (both system timer and RTC).&lt;br /&gt;
Tell-tale signs of related trouble in VMs (apparently qemu/KVM/VMWare etc. are all affected) are e.g.&lt;br /&gt;
&amp;quot;make[2]: Warning: File `XXXXX/cmakelists_rebuilder.stamp&#039; has modification time 0.37 s in the future&amp;quot;&lt;br /&gt;
&amp;quot;Clock skew detected. Your build may be incomplete.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[http://maemovmware.garage.maemo.org/2nd_edition/requirements_documentation.html Maemo docs] state that it&#039;s important to disable UTC and set the correct time zone, however I don&#039;t really see how that would help in case of diverging host/guest clocks.&lt;br /&gt;
IMHO much more useful and important is to configure properly working NTP server (chrony recommended, or ntpd) on both host and guest.&lt;br /&gt;
The single most decisive trick IMHO is to specify the &#039;&#039;&#039;host&#039;&#039;&#039; NTP server as the main entry within guest VM instead of &amp;quot;foreign&amp;quot; NTP servers, to make sure to achieve the most precise coupling between these two related systems (timing drift vs. other systems does not matter nearly as much as a tight time precision for inner host/guest system interaction e.g. in the case of NFS/Samba shares etc.).&lt;br /&gt;
For verification, see chronyc &amp;quot;sources -v&amp;quot;, &amp;quot;tracking&amp;quot; (&amp;quot;System time&amp;quot; row) commands.&lt;br /&gt;
&lt;br /&gt;
After having applied this very tight NTP coupling, this seems to finally have gotten rid of make&#039;s time drift warnings.&lt;br /&gt;
&lt;br /&gt;
Perhaps qemu&#039;s -tdf (timing drift fix) option magically manages to help in your case, too.&lt;br /&gt;
&lt;br /&gt;
See also [https://espace.cern.ch/it-faqs/Lists/faqs/DispForm.aspx?ID=368 Faqs: I received a message about &amp;quot;clock skew&amp;quot;].&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
=== I get &amp;quot;rtc interrupts lost&amp;quot; messages, and the guest is very slow? ===&lt;br /&gt;
Try setting &amp;lt;code&amp;gt;CONFIG_HPET_EMULATE_RTC=y&amp;lt;/code&amp;gt; in your host &amp;lt;code&amp;gt;.config&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I get an &amp;quot;Exception 13&amp;quot; or &amp;quot;Exception 12&amp;quot; message while booting a guest OS on my Intel host ===&lt;br /&gt;
See the [[Intel Real Mode Emulation Problems]] page.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I have VMware/Parallels/VirtualBox installed and when I modprobe KVM, my system deadlocks. ===&lt;br /&gt;
Neither Intel VT nor AMD-V provide a mechanism to determine whether software is currently using the hardware virtualization extensions.  This means that if you have two kernel modules loaded attempting to use hardware virtualization extensions, very bad things will happen.  If you are using another type of virtualization software and experience any sort of weirdness with KVM, make sure you can reproduce the problem without the kernel modules for that software loaded before you report a bug in KVM.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== There&#039;s nothing on QEMU/KVM screen, but it&#039;s not hanged! I&#039;m trying to install Kubuntu. ===&lt;br /&gt;
Try to run kvm with -std-vga option. It helps if guest operating system uses framebuffer mode like Kubuntu/Ubuntu.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== When I click the guest operating system window, mouse is grabbed. How can I get mouse to not to do that? OR Mouse doesn&#039;t show up / doesn&#039;t work in the guest. What do I do? ===&lt;br /&gt;
From #qemu wiki, try to run kvm/qemu with&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 -usb -usbdevice tablet&lt;br /&gt;
If that doesn&#039;t work, try this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 $ export SDL_VIDEO_X11_DGAMOUSE=0&lt;br /&gt;
(from http://wiki.clug.org.za/wiki/QEMU_mouse_not_working )&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
== General KVM information ==&lt;br /&gt;
=== What is the difference between KVM and Xen? ===&lt;br /&gt;
Xen is an external hypervisor; it assumes control of the machine and divides resources among guests. On the other hand, KVM is part of Linux and uses the regular Linux scheduler and memory management. This means that KVM is much smaller and simpler to use; it is also more featureful; for example KVM can swap guests to disk in order to free RAM.&lt;br /&gt;
&lt;br /&gt;
KVM only run on processors that supports x86 hvm (vt/svm instructions set) whereas Xen also allows running modified operating systems on non-hvm x86 processors using a technique called paravirtualization. KVM does not support paravirtualization for CPU but may support paravirtualization for device drivers to improve I/O performance.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What is the difference between KVM and VMware? ===&lt;br /&gt;
VMware is a proprietary product. KVM is Free Software released under the GPL.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What is the difference between KVM and QEMU? ===&lt;br /&gt;
QEMU uses emulation; KVM uses processor extensions (HVM) for virtualization.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Do you have a port of KVM for Windows? ===&lt;br /&gt;
Not officially.&lt;br /&gt;
&lt;br /&gt;
Kazushi Takahashi has been working on an experimental version though, called WinKVM, available [http://github.com/ddk50/winkvm here].&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What kernel version does it work with? ===&lt;br /&gt;
It depends on what version of KVM you are using. The last release of KVM should work with any recent kernel (2.6.17 and above), older releases even older kernels.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== How much RAM do I need? ===&lt;br /&gt;
You will need enough memory to let the guest run comfortably while keeping enough for the host. 1GB is probably a minimum configuration for the host OS.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Is dynamic memory management for guests supported? ===&lt;br /&gt;
This is a broad topic covering a few areas.&lt;br /&gt;
&lt;br /&gt;
A. KVM only allocates memory as the guest tries to use it. Once it&#039;s allocated, KVM keeps it. Some guests (namely Microsoft guests) zero all memory at boot time. So they will use all memory.&lt;br /&gt;
&lt;br /&gt;
B. Certain guests (only Linux at the moment) have a balloon driver, so the host can have the guest allocate a certain amount of memory which the guest won&#039;t be able to use anymore and it can then be freed on the host. Ballooning is controlled in the host via the [http://www.nongnu.org/qemu/qemu-doc.html#SEC12 balloon monitor command].&lt;br /&gt;
&lt;br /&gt;
C. Some hosts (presently only RHEL5.4 / CentOS 5.4) have a feature called KSM (Kernel Sharedpage Merging), which collapses together identical pages; this requires kernel support on the host, as well as a kvm new enough to opt in to the behavior. As some guest platforms (most notably Windows) zero out free&#039;d memory, such pages are trivially collapsed. The ksmctl command needs to be used to enable KSM; alternately, the ksmtuned service found in Fedora 12 can be run to dynamically adjust KSM&#039;s aggressiveness based on the amount of free memory available&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== What OSs can I run inside KVM VM? ===&lt;br /&gt;
Several.  See the [[Guest Support Status]] page for details. Note that several Linux flavors are known to hang on Intel processors during startup. Workaround is to disable splash screens in grub.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Does KVM support a live migration feature to move virtual machines from one host to another without downtime? ===&lt;br /&gt;
Yes.  See the [[Migration]] page for details.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Does KVM support live migration from an AMD host to an Intel host and back? ===&lt;br /&gt;
Yes.  There may be issues on 32-bit Intel hosts which don&#039;t support NX (or XD), but for 64-bit hosts back and forth migration should work well. Migration of 32-bit guests should work between 32-bit hosts and 64-bit hosts.&lt;br /&gt;
If one of your hosts does not support NX, you may consider disabling NX when starting the guest on a NX-capable system. You can do it by passing &amp;quot;-cpu qemu64,-nx&amp;quot; parameter to the guest.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Can KVM run a 32-bit guest on a 64-bit host? What about PAE? ===&lt;br /&gt;
KVM supports 32-bit guests on 64-bit hosts, and any combination of PAE and non-PAE guests and hosts. The only unsupported combination is a 64-bit guest on a 32-bit host.&lt;br /&gt;
&lt;br /&gt;
If you are running a Windows Virtual Machine and have problems enabling PAE in your guest see the [[Windows PAE Workaround]] page.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Is it possible to use USB devices with a guest OS? ===&lt;br /&gt;
Yes, look up how to do it with QEMU, it&#039;s the same way.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Can I have higher or widescreen resolutions (eg 1680 x 1050) in KVM? ===&lt;br /&gt;
Use the -vga std parameter while starting the VM to allow high resolution and widescreen displays.&lt;br /&gt;
&lt;br /&gt;
If the resolution you want to use is not available, you can patch the corresponding source files (see http://article.gmane.org/gmane.comp.emulators.kvm.devel/13557 as a reference), or send a mail to the KVM mailing list if you are not able to patch the source yourself.&lt;br /&gt;
&lt;br /&gt;
When using Windows as guest OS and not having issues with people violating the GPL you might want to use the driver from the VBEMP x86 project (http://www.bearwindows.boot-land.net/vbemp.htm) which is based on ReactOS code.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Does KVM support SMP hosts? ===&lt;br /&gt;
Yes.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Does KVM support SMP guests? ===&lt;br /&gt;
Yes. Up to 16 CPUs can be specified using the -smp option.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== Is the name &#039;KVM&#039; trademarked? ===&lt;br /&gt;
No.&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I compiled a new kernel for my KVM client, and the ethernet interface is not recognized ===&lt;br /&gt;
you can tell qemu to emulate e.g. the 8139 with model=rtl8139&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
=== I can&#039;t ping from host to guest or vice versa. How can I access the host please? ===&lt;br /&gt;
ping does not go through, but I suppose you can access the host in some way, i.e. you can navigate for sure internet(e.g. firefox) if host can&lt;br /&gt;
&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
[[Category:Docs]][[Category:HowTo]]&lt;/div&gt;</summary>
		<author><name>Ckotichas</name></author>
	</entry>
</feed>