<?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 Roberto Selbach</title><link>https://rselbach.com/tags/kvm/</link><description>Recent content in Kvm on Roberto Selbach</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Wed, 25 Jun 2008 20:45:00 +0000</lastBuildDate><atom:link href="https://rselbach.com/tags/kvm/index.xml" rel="self" type="application/rss+xml"/><item><title>Idle Host, Busy Guest</title><link>https://rselbach.com/idle-host-busy-guest/</link><pubDate>Wed, 25 Jun 2008 20:45:00 +0000</pubDate><guid>https://rselbach.com/idle-host-busy-guest/</guid><description>&lt;p&gt;My laptop stayed warm with an apparently idle KVM guest running. The guest reported nearly no processor use, and the host showed only small bursts, so I first blamed inaccurate temperature sensors. Sensors are convenient suspects because they cannot write rebuttals.&lt;/p&gt;
&lt;p&gt;I stopped services in the guest one by one. A periodic timer user was waking it frequently, but even a minimal guest produced more activity than expected. Virtual timer interrupts, emulated devices and host-side handling all require exits from guest execution. An idle guest is therefore not necessarily an idle host.&lt;/p&gt;
&lt;p&gt;Tickless operation helps when the guest kernel can avoid unnecessary periodic ticks and when KVM presents timers accurately enough for longer idle periods. It cannot eliminate device emulation or a program requesting frequent wakeups. The host must also be tickless while idle; saving ticks in one layer and generating them in the other is elaborate bookkeeping, not power management.&lt;/p&gt;
&lt;p&gt;After using a tickless guest kernel and disabling a polling monitor, host wakeups dropped and the machine cooled. Timekeeping remained the thing to watch: aggressive experiments are worthless if the guest clock drifts or timers fire late.&lt;/p&gt;
&lt;p&gt;My conclusion is to shut down unused guests on battery and to measure host wakeups, not merely guest CPU percentage. For a guest that must remain available, remove polling and use appropriate virtual devices where supported. Virtualization can make a machine appear to be doing nothing in two operating systems simultaneously while the processor is, with admirable professionalism, doing work for both.&lt;/p&gt;</description></item><item><title>KVM Needs the Right Bottleneck</title><link>https://rselbach.com/kvm-needs-the-right-bottleneck/</link><pubDate>Wed, 14 Nov 2007 20:25:00 +0000</pubDate><guid>https://rselbach.com/kvm-needs-the-right-bottleneck/</guid><description>&lt;p&gt;I created a KVM guest to test packages without sacrificing another partition. The installer booted, the guest saw a disk, and I congratulated myself until copying files inside it reduced the entire machine to sludge.&lt;/p&gt;
&lt;p&gt;My first attempt was to add more guest memory and another virtual processor. The copy became no faster, while the host began swapping. This is a reliable way to make two operating systems unhappy with one setting.&lt;/p&gt;
&lt;p&gt;KVM uses the processor&amp;rsquo;s virtualization extensions to run guest code directly in a special execution mode. That avoids translating every ordinary instruction, but devices are a different matter. The guest still talks to emulated hardware, and each operation may require work in the userspace machine emulator and the host kernel. My slow copy was dominated by the virtual disk path, not by a shortage of arithmetic.&lt;/p&gt;
&lt;p&gt;Moving the guest image off the host&amp;rsquo;s busy system disk helped. Using a simpler virtual disk setup and avoiding unnecessary host caching also made behavior more consistent, though the safest setting depends on what guarantees the storage actually provides. I am not going to trade filesystem integrity for a prettier benchmark. The benchmark will not visit me in hospital.&lt;/p&gt;
&lt;p&gt;Preallocating space also avoided some pauses caused by repeatedly extending a sparse image during installation.&lt;/p&gt;
&lt;p&gt;Processor support also needs verification rather than assumption. The KVM modules must load, virtualization must be enabled by firmware, and the host kernel needs the appropriate architecture module. Once that path works, compute-heavy tasks can be surprisingly close to native speed. Graphics and storage remain much more obviously virtual.&lt;/p&gt;
&lt;p&gt;For my package-testing guest, one virtual processor and enough memory to avoid guest swapping are sufficient. The host must retain enough memory for its own cache and applications. I now measure CPU, host disk activity and swapping separately before changing the virtual machine configuration.&lt;/p&gt;
&lt;p&gt;KVM is already useful because it fits into Linux rather than requiring a separate host operating environment. It is not a declaration that every emulated device is free. My practical conclusion is to size the guest modestly and find the actual bottleneck. Adding virtual hardware to cure slow virtual I/O only creates a more lavishly furnished traffic jam.&lt;/p&gt;</description></item><item><title>KVM After 2.6.20</title><link>https://rselbach.com/kvm-after-2-6-20/</link><pubDate>Thu, 08 Feb 2007 21:27:00 +0000</pubDate><guid>https://rselbach.com/kvm-after-2-6-20/</guid><description>&lt;p&gt;Linux 2.6.20 was released this week with KVM included, so I tried booting a small guest rather than merely reading patches. The first attempt failed immediately because the processor&amp;rsquo;s virtualisation support was disabled in the firmware. Progress began with entering setup, which keeps systems programming humble.&lt;/p&gt;
&lt;p&gt;KVM uses the processor&amp;rsquo;s hardware virtualisation extensions and exposes a kernel interface through &lt;code&gt;/dev/kvm&lt;/code&gt;. A user-space program supplies the virtual machine&amp;rsquo;s device model and asks the kernel to run virtual CPUs. This is not a complete machine monitor appearing from one kernel option; kernel and user space divide the work.&lt;/p&gt;
&lt;p&gt;The basic checks on this Intel test box were:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;grep vmx /proc/cpuinfo
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;modprobe kvm
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;modprobe kvm-intel
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ls -l /dev/kvm
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;On an AMD processor I would look for &lt;code&gt;svm&lt;/code&gt; and use the corresponding module. Seeing the flag is necessary but not always sufficient, because firmware can still disable the facility.&lt;/p&gt;
&lt;p&gt;After loading the modules, I launched a guest image with the available QEMU KVM support and watched the kernel log in another terminal. The guest booted, though virtual disk and network performance are not conclusions I can draw from ten minutes and one ageing drive.&lt;/p&gt;
&lt;p&gt;I prefer this architecture because putting CPU execution support behind a kernel interface lets normal Linux scheduling and memory management participate, while device emulation remains in user space where a failure is less likely to take the host with it. The caveat is that the boundary can impose overhead, hardware support varies, and young interfaces may change as use exposes mistakes.&lt;/p&gt;
&lt;p&gt;Security deserves restraint too. Hardware isolation is not a promise that a hostile guest can never escape. Device emulation processes parse guest-controlled input, and kernel code now manages another complicated processor mode. I am treating guests as isolated test systems, not as magical bags into which all risk disappears.&lt;/p&gt;
&lt;p&gt;The useful result today is narrow: with 2.6.20, suitable hardware, enabled firmware support, kernel modules, and matching user space, a Linux host can run a hardware-assisted guest. Whether KVM becomes the preferred general solution will depend on performance, management tools, and how gracefully it handles less cooperative machines.&lt;/p&gt;
&lt;p&gt;For now it boots. In infrastructure experiments, reaching a login prompt is the traditional point at which confidence rises faster than evidence.&lt;/p&gt;</description></item></channel></rss>