<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Kvm on Daniel Corneschi</title><link>https://blog.corneschi.ro/tags/kvm/</link><description>Recent content in Kvm on Daniel Corneschi</description><generator>Hugo</generator><language>en</language><copyright>Daniel Corneschi</copyright><lastBuildDate>Sat, 10 Oct 2026 11:07:45 +0300</lastBuildDate><atom:link href="https://blog.corneschi.ro/tags/kvm/index.xml" rel="self" type="application/rss+xml"/><item><title>KVM / virsh Cheatsheet</title><link>https://blog.corneschi.ro/cheatsheet/kvm/</link><pubDate>Sat, 10 Oct 2026 00:00:00 +0000</pubDate><guid>https://blog.corneschi.ro/cheatsheet/kvm/</guid><description>&lt;h2 id="architecture"&gt;Architecture&lt;/h2&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;libvirt&lt;/strong&gt; (&lt;code&gt;virsh&lt;/code&gt;, &lt;code&gt;virt-install&lt;/code&gt;, &lt;code&gt;virt-manager&lt;/code&gt;) starts and manages one &lt;strong&gt;QEMU&lt;/strong&gt; process per VM.&lt;/li&gt;&#10;&lt;li&gt;QEMU runs the guest&amp;rsquo;s CPU through the &lt;strong&gt;KVM&lt;/strong&gt; kernel module, via &lt;code&gt;ioctl()&lt;/code&gt; calls on &lt;code&gt;/dev/kvm&lt;/code&gt;. KVM uses the CPU&amp;rsquo;s VT-x or AMD-V extensions.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Emulated NIC (e1000, VM 1):&lt;/strong&gt; every packet goes through the NIC emulated by QEMU in user space, then to the VM&amp;rsquo;s &lt;strong&gt;tap&lt;/strong&gt; device in the host (&lt;code&gt;vnet0&lt;/code&gt;, … in &lt;code&gt;virsh domiflist&lt;/code&gt;).&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;virtio-net (VM 2):&lt;/strong&gt; with &lt;strong&gt;vhost-net&lt;/strong&gt;, which libvirt uses by default when &lt;code&gt;/dev/vhost-net&lt;/code&gt; exists, packets go from the guest&amp;rsquo;s virtqueues straight to a vhost-net kernel thread and the tap device. QEMU only sets it up, which is why virtio is much faster (see Recommended Settings).&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Bridge:&lt;/strong&gt; the tap devices are ports of a Linux bridge. With your own &lt;strong&gt;&lt;code&gt;br0&lt;/code&gt;&lt;/strong&gt;, the physical NIC is a port of the same bridge. libvirt&amp;rsquo;s NAT network &lt;strong&gt;&lt;code&gt;virbr0&lt;/code&gt;&lt;/strong&gt; (&lt;code&gt;virsh net-info default&lt;/code&gt;) has no physical port: the host routes and NATs its traffic (nftables or iptables) before it reaches the NIC.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;a href="kvm-architecture.svg" title="Open the diagram full size"&gt;&lt;img src="https://blog.corneschi.ro/cheatsheet/kvm/kvm-architecture.svg" alt="KVM architecture: libvirt starts one QEMU process per VM. An emulated e1000 NIC sends packets through QEMU in user space to a tap device; virtio-net with vhost-net sends them from the guest’s virtqueues straight to the vhost-net thread in the host kernel. Tap devices are ports of a Linux bridge: br0 has the physical NIC as a port, virbr0 is routed and NATed by the host. QEMU uses the KVM module through /dev/kvm" loading="lazy" decoding="async"&gt;&#10;&lt;/a&gt;&lt;/p&gt;</description></item></channel></rss>