<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>QEMU on iMil.net</title>
    <link>http://imil.net/blog/tags/qemu/</link>
    <description>Recent content in QEMU on iMil.net</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Thu, 23 Jan 2025 18:18:00 +0100</lastBuildDate>
    <atom:link href="http://imil.net/blog/tags/qemu/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Build A MMIO Booting Debian VM Out Of Cloud Images</title>
      <link>http://imil.net/blog/posts/2025/not-so-smol-debian/</link>
      <pubDate>Thu, 23 Jan 2025 18:18:00 +0100</pubDate>
      <guid>http://imil.net/blog/posts/2025/not-so-smol-debian/</guid>
      <description>&lt;p&gt;As you might be aware of, I am working on a minimal &lt;em&gt;BSD/UNIX&lt;/em&gt; system called &lt;a href=&#34;https://smolBSD.org&#34;&gt;smolBSD&lt;/a&gt;. It is based on the &lt;a href=&#34;https://NetBSD.org&#34;&gt;NetBSD&lt;/a&gt; operating system, and its main target is virtual machines, more specifically &lt;a href=&#34;https://www.qemu.org/docs/master/system/i386/microvm.html&#34;&gt;microvm&lt;/a&gt;s. This system is capable of fully booting the OS in less than one second using a specially trimmed kernel along with small, specialized root systems.&lt;br&gt;&#xA;I was stunned to learn (but am I wrong?) that this work does not seem to have an equivalent, not even in the Linux world. &lt;a href=&#34;https://www.freebsd.org/status/report-2022-07-2022-09/firecracker/&#34;&gt;FreeBSD Firecracker support&lt;/a&gt; sure permits to boot a kernel is about the same time my &lt;a href=&#34;https://github.com/NetBSD/src/compare/trunk...NetBSDfr:NetBSD-src:nbfr_master&#34;&gt;NetBSD hacked kernel&lt;/a&gt; does, but there&amp;rsquo;s no work around s slim and task dedicated root filesystem.&lt;/p&gt;</description>
    </item>
    <item>
      <title>NetBSD as a Kubernetes Pod</title>
      <link>http://imil.net/blog/posts/2023/netbsd-as-a-k8s-pod/</link>
      <pubDate>Mon, 23 Oct 2023 11:46:31 +0200</pubDate>
      <guid>http://imil.net/blog/posts/2023/netbsd-as-a-k8s-pod/</guid>
      <description>&lt;p&gt;&lt;strong&gt;2025/01 Update&lt;/strong&gt; &lt;a href=&#34;https://github.com/NetBSDfr/smolBSD/tree/main/k8s&#34;&gt;https://github.com/NetBSDfr/smolBSD/tree/main/k8s&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I had to do it.&lt;br&gt;&#xA;So here&amp;rsquo;s how to run a &lt;em&gt;NetBSD&lt;/em&gt; micro-vm as&amp;hellip; a &lt;em&gt;Kubernetes&lt;/em&gt; pod.&lt;/p&gt;&#xA;&lt;p&gt;First thing is to modify the &lt;a href=&#34;https://imil.net/blog/posts/2023/netbsd-as-a-docker-container/&#34;&gt;start script from the previous article&lt;/a&gt; in order to add &lt;em&gt;Docker&lt;/em&gt;-style networking, i.e. port forwarding from the host to the micro-vm. This is done using the &lt;code&gt;hostfwd&lt;/code&gt; flag in &lt;em&gt;qemu&lt;/em&gt;&amp;rsquo;s &lt;code&gt;-netdev&lt;/code&gt; parameter&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-shell&#34; data-lang=&#34;shell&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;#!/bin/sh&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;kernel&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;$1&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;img&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;${&lt;/span&gt;2&lt;span style=&#34;color:#66d9ef&#34;&gt;:-&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;root.img&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt; -n &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;$3&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; drive2&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;-drive file=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;${&lt;/span&gt;3&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;,if=virtio&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;qemu-system-x86_64 -enable-kvm -m &lt;span style=&#34;color:#ae81ff&#34;&gt;256&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;        -kernel $kernel -append &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;console=com root=ld0a&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;        -serial mon:stdio -display none &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;        -drive file&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;${&lt;/span&gt;img&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;,if&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;virtio $drive2 &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;        -netdev user,id&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;net0,hostfwd&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;tcp::8080-:80 -device virtio-net,netdev&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;net0&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;a href=&#34;https://imil.net/blog/posts/2023/netbsd-as-a-docker-container/&#34;&gt;In the previous experience&lt;/a&gt; we mapped the kernel and the root image from the host using &lt;em&gt;Docker&lt;/em&gt;&amp;rsquo;s &lt;code&gt;-v&lt;/code&gt; parameter, and while it&amp;rsquo;s possible to map files from the host using a &lt;em&gt;Kubernetes&lt;/em&gt; &lt;code&gt;volume&lt;/code&gt;, we will bundle &lt;em&gt;NetBSD&lt;/em&gt; these files into the &lt;em&gt;Docker&lt;/em&gt;  image to make things easier.&lt;br&gt;&#xA;Please refer to &lt;a href=&#34;https://gitlab.com/iMil/mksmolnb#example-of-an-image-used-to-create-an-nginx-microvm-with-sailor&#34;&gt;mksmolnb&lt;/a&gt; documentation to learn how to produce a minimal &lt;code&gt;nginx&lt;/code&gt; micro-vm.&lt;/p&gt;</description>
    </item>
    <item>
      <title>NetBSD as a Docker Container</title>
      <link>http://imil.net/blog/posts/2023/netbsd-as-a-docker-container/</link>
      <pubDate>Fri, 20 Oct 2023 08:27:47 +0200</pubDate>
      <guid>http://imil.net/blog/posts/2023/netbsd-as-a-docker-container/</guid>
      <description>&lt;p&gt;I have &lt;a href=&#34;https://gitlab.com/iMil/mksmolnb&#34;&gt;this little toy project&lt;/a&gt; for quite a while now, and I have this idea of handling a fleet of &lt;em&gt;NetBSD&lt;/em&gt; micro-vms with &lt;em&gt;Kubernetes&lt;/em&gt; since I started my new job in which I am caring a &lt;em&gt;k8s&lt;/em&gt; cluster.&lt;/p&gt;&#xA;&lt;p&gt;I came to realize that starting a &lt;em&gt;smolBSD&lt;/em&gt; micro-vm with &lt;em&gt;Docker&lt;/em&gt; was not so difficult after all. Using &lt;code&gt;mksmolnb&lt;/code&gt;&amp;rsquo;s &lt;a href=&#34;https://gitlab.com/iMil/mksmolnb/-/blob/main/startnb.sh?ref_type=heads&#34;&gt;startnb.sh&lt;/a&gt; I came up with this very simple &lt;code&gt;Dockerfile&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-dockerfile&#34; data-lang=&#34;dockerfile&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;FROM&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;alpine:latest&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;RUN&lt;/span&gt; apk add --quiet --no-cache qemu-system-x86_64 iproute2 bridge-utils&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;COPY&lt;/span&gt; startnb.sh ./&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;COPY&lt;/span&gt; qemu/qemu-ifup qemu/qemu-ifdown /etc/&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;CMD&lt;/span&gt; /startnb.sh /netbsd-SMOL &lt;span style=&#34;color:#e6db74&#34;&gt;${&lt;/span&gt;IMG&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;${&lt;/span&gt;DISK&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;qemu-ifup&lt;/code&gt; being a simple copy of Debian&amp;rsquo;s &lt;code&gt;/etc/qemu-ifup&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>QEMU/KVM Shorter Command Line</title>
      <link>http://imil.net/blog/posts/2020/qemu-kvm-command-line/</link>
      <pubDate>Fri, 10 Jul 2020 10:56:29 +0200</pubDate>
      <guid>http://imil.net/blog/posts/2020/qemu-kvm-command-line/</guid>
      <description>&lt;p&gt;I keep reading overcomplicated &lt;a href=&#34;https://www.qemu.org/&#34;&gt;QEMU&lt;/a&gt;/&lt;a href=&#34;https://www.linux-kvm.org/page/Main_Page&#34;&gt;KVM&lt;/a&gt; command lines, when really, to start a &lt;a href=&#34;https://www.linux-kvm.org/page/Virtio&#34;&gt;VirtIO&lt;/a&gt; disk and bridged &lt;em&gt;VirtIO&lt;/em&gt; &lt;em&gt;NIC&lt;/em&gt; virtual machine, only this command is needed:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$ sudo qemu-system-x86_64 -enable-kvm -m &lt;span style=&#34;color:#ae81ff&#34;&gt;1024&lt;/span&gt; -cpu host -daemonize &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;  -drive file&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;mydisk.img,if&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;virtio &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;  -net nic,model&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;virtio -net tap,ifname&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;tap0&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;&#xA;&lt;li&gt;drive type is &lt;code&gt;virtio&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;nic&lt;/em&gt; model is &lt;code&gt;virtio&lt;/code&gt; and the interface is of &lt;code&gt;tap&lt;/code&gt; type, this will summon &lt;code&gt;/etc/qemu-ifup&lt;/code&gt; to attach the interface to your bridge.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Depending on your &lt;a href=&#34;https://www.qemu.org/&#34;&gt;QEMU&lt;/a&gt; installation, either this will fire up a window showing your virtual machine booting, or start a &lt;a href=&#34;https://www.tightvnc.com/&#34;&gt;VNC&lt;/a&gt; server on port &lt;code&gt;5900&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>KVM/QEMU, rtl8139 et Segmentation Fault</title>
      <link>http://imil.net/blog/posts/2008/kvmqemu-rtl8139-et-segmentation-fault/</link>
      <pubDate>Fri, 26 Sep 2008 00:09:41 +0000</pubDate>
      <guid>http://imil.net/blog/posts/2008/kvmqemu-rtl8139-et-segmentation-fault/</guid>
      <description>&lt;p&gt;Depuis un petit moment, je constate que les derniers builds du QEMU contenus dans KVM explosent en vol au démarrage de la VM. Flemmard, je continuais donc à utiliser le QEMU de la version 68 qui, lui, fonctionnait. Et puis ça a fini par vraiment me démanger. Je comprend à grands renforts de &lt;code&gt;gdb&lt;/code&gt; que lorsque l&amp;rsquo;output &lt;code&gt;SDL&lt;/code&gt; est activé &lt;strong&gt;en même temps&lt;/strong&gt; que le support d&amp;rsquo;une carte réseau virtuelle, QEMU &lt;em&gt;coredumpe&lt;/em&gt;.&#xA;À tout hasard, j&amp;rsquo;essaye de passer à un modele de carte virtuelle different de la &lt;code&gt;rtl8139&lt;/code&gt; émulée par defaut, puisque les dernieres versions de QEMU/KVM en supportent desormais bien plus qu&amp;rsquo;auparavant, et là, bingo, plus de &lt;em&gt;Segmentation Fault&lt;/em&gt;. Ainsi, le démarrage de mes VMs NetBSD ressemble désormais à ceci :&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
