<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>QEMU-KVM on Ivon's Blog</title><link>https://ivonblog.com/en-us/tags/qemu-kvm/</link><description>Recent content in QEMU-KVM on Ivon's Blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</managingEditor><webMaster>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</webMaster><copyright>You are welcome to share articles of Ivon's Blog (ivonblog.com). Please include the original URL when citing articles, and abide by CC BY-NC-ND 4.0 license. For commercial use, please write an e-mail to me.</copyright><lastBuildDate>Tue, 23 Dec 2025 11:00:00 +0800</lastBuildDate><atom:link href="https://ivonblog.com/en-us/tags/qemu-kvm/index.xml" rel="self" type="application/rss+xml"/><item><title>Accelerate QEMU virtual machines in Termux with pKVM</title><link>https://ivonblog.com/en-us/posts/termux-qemu-system-tensor-linux/</link><pubDate>Tue, 23 Dec 2025 11:00:00 +0800</pubDate><author>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</author><guid>https://ivonblog.com/en-us/posts/termux-qemu-system-tensor-linux/</guid><description>&lt;!-- Co-translated by ChatGPT --&gt;
&lt;p&gt;I discussed the problem of running virtual machines on Android phones with Termux in &lt;a href="https://ivonblog.com/en-us/posts/termux-qemu-system-linux/" target="_blank" rel="noreferrer"&gt;Termux + QEMU Linux VM&lt;/a&gt;. The conclusion: it is slow as hell.&lt;/p&gt;
&lt;p&gt;Without KVM, everything depends on software emulation. The result is that you can only run 20-year-old Windows XP systems; modern operating systems are simply too heavy.&lt;/p&gt;
&lt;p&gt;Phones equipped with Google Tensor processors introduced pKVM after Android 15, which is the technology supported underneath the AVF framework.&lt;/p&gt;
&lt;p&gt;At the moment, except for Android 16&amp;rsquo;s experimental Debian Linux Terminal, ordinary apps cannot access pKVM. You need root privileges to enable pKVM.&lt;/p&gt;

&lt;h2 class="relative group"&gt;1. Install packages
 &lt;div id="1-install-packages" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#1-install-packages" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;With KVM acceleration, you should run a virtual machine of the same architecture. According to Termux developers, using the &lt;code&gt;qemu-system-aarch64-headless&lt;/code&gt; package can give you a pKVM-accelerated virtual machine.&lt;/p&gt;
&lt;p&gt;Install the following packages. On ARM machines, it is best to enable UEFI.&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pkg install qemu-system-aarch64-headless qemu-utils qemu-common ovmf sudo&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;There is no Virt Manager in the graphical interface, and the Libvirt service probably will not run, so we have to use &lt;a href="github.com/gujjwal00/avnc" &gt;AVNC&lt;/a&gt; to access the virtual machine display.&lt;/p&gt;

&lt;h2 class="relative group"&gt;2. Create a Linux virtual machine in Termux
 &lt;div id="2-create-a-linux-virtual-machine-in-termux" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#2-create-a-linux-virtual-machine-in-termux" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Download the &lt;a href="https://ubuntu.com/download/server/arm" target="_blank" rel="noreferrer"&gt;Ubuntu ARM&lt;/a&gt; ISO and put it in Termux&amp;rsquo;s home directory&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Confirm that KVM exists&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo ls /dev/kvm&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="3"&gt;
&lt;li&gt;Create a virtual disk&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;qemu-img create -f qcow2 ubuntu.qcow2 32G&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="4"&gt;
&lt;li&gt;Create files to store UEFI&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;truncate -s 64m varstore.img
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;truncate -s 64m efi.img
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dd &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$PREFIX&lt;/span&gt;/share/qemu/edk2-aarch64-code.fd &lt;span class="nv"&gt;of&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;efi.img &lt;span class="nv"&gt;conv&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;notrunc&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="5"&gt;
&lt;li&gt;Add a boot script&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;touch startubuntu.sh
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;chmod +x startubuntu.sh
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;vim startubuntu.sh&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="6"&gt;
&lt;li&gt;The contents are as follows&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;qemu-system-aarch64 -M virt &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-enable-kvm &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-drive &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;pflash,format&lt;span class="o"&gt;=&lt;/span&gt;raw,file&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;efi.img&amp;#34;&lt;/span&gt;,readonly &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-drive &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;pflash,format&lt;span class="o"&gt;=&lt;/span&gt;raw,file&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;varstore.img&amp;#34;&lt;/span&gt; &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-smp &lt;span class="nv"&gt;cpus&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-m &lt;span class="m"&gt;1024&lt;/span&gt; &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-cpu host &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-nographic &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-netdev user,id&lt;span class="o"&gt;=&lt;/span&gt;n1,hostfwd&lt;span class="o"&gt;=&lt;/span&gt;tcp::2222-:22 -device virtio-net,netdev&lt;span class="o"&gt;=&lt;/span&gt;n1 &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-drive &lt;span class="nv"&gt;file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ubuntu.qcow2 &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-boot d &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-vnc :0 &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-cdrom ubuntu-24.04.3-live-server-arm64.iso&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="7"&gt;
&lt;li&gt;Add &lt;code&gt;sudo&lt;/code&gt; when running it.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo ./startubuntu.sh&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;If everything goes smoothly, you can open &lt;code&gt;localhost:59000&lt;/code&gt; in AVNC and see the virtual machine display.&lt;/p&gt;
&lt;p&gt;The strange thing is that it can boot without enabling KVM, but once KVM is enabled it hits the &lt;code&gt;qemu-system-aarch64: Failed to put registers after init: Invalid argument&lt;/code&gt; error.&lt;/p&gt;
&lt;p&gt;If you switch to chroot and run KVM inside it, maybe the success rate will go up?&lt;/p&gt;

&lt;h2 class="relative group"&gt;References
 &lt;div id="references" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#references" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.reddit.com/r/termux/comments/169lzsf/running_a_pkvm_in_termux/" target="_blank" rel="noreferrer"&gt;running a pKVM in Termux? - Reddit&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.reddit.com/r/termux/comments/1fa6w9w/running_linux_vm_on_pixel_7/" target="_blank" rel="noreferrer"&gt; Running Linux VM on pixel 7 - Reddit&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Why I Like Using Virt Manager + QEMU/KVM, Starting From Baked Spaghetti</title><link>https://ivonblog.com/en-us/posts/the-path-of-learning-qemu-kvm/</link><pubDate>Mon, 08 Jul 2024 22:00:00 +0800</pubDate><author>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</author><guid>https://ivonblog.com/en-us/posts/the-path-of-learning-qemu-kvm/</guid><description>&lt;!-- Co-translated by ChatGPT --&gt;
&lt;p&gt;A side story not mentioned in &lt;a href="https://ivonblog.com/posts/en-us/linux-learning-history-2th-year/" target="_blank" rel="noreferrer"&gt;Linux Leraning History&lt;/a&gt;! The QEMU/KVM skill tree.&lt;/p&gt;
&lt;p&gt;As of now, common virtualization software on GNU/Linux systems includes:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;QEMU/KVM, managed with Virt Manager or GNOME Boxes&lt;/li&gt;
&lt;li&gt;Oracle VirtualBox&lt;/li&gt;
&lt;li&gt;VMware&lt;/li&gt;
&lt;li&gt;Xen&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Why do the articles in this site&amp;rsquo;s &amp;ldquo;Virtual Machines and Container Technologies&amp;rdquo; category almost all discuss QEMU/KVM as the virtual machine software? (At least up to now.) This has to start with my obsession with QEMU/KVM.&lt;/p&gt;
&lt;p&gt;I am not talented; my understanding of Linux virtualization is only like taking one ladle of water from the river.&lt;/p&gt;

&lt;h2 class="relative group"&gt;1. Baked Spaghetti and QEMU/KVM
 &lt;div id="1-baked-spaghetti-and-qemukvm" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#1-baked-spaghetti-and-qemukvm" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;The reason I have been enthusiastic about studying QEMU/KVM virtual machines to this day is that, at first, I wanted to migrate to Linux, but was worried about losing access to Windows functionality.&lt;/p&gt;
&lt;p&gt;Before 2022, I had not yet come into contact with the cult-like free software ideology, so naturally I could not let go of Windows. Even though I knew Wine existed, I still hoped to have a virtual machine that could quickly create a Windows environment, so that I could run software when necessary.&lt;/p&gt;
&lt;p&gt;(In hindsight: I did not expect that two years later I would go to the computer science department to learn C# programming. The virtual machine saved my life, letting me install Visual Studio and finish assignments.)&lt;/p&gt;
&lt;p&gt;I already had some experience operating virtual machines before this, but I did not really understand the principles behind them. I only felt that VirtualBox and VMware were intuitive and easy to use! Systems could be installed whoosh, just like that. QEMU/KVM was unknown territory to me.&lt;/p&gt;
&lt;p&gt;I vaguely understood that the greatest weak point of virtual machines was graphics processing capability, so starting in my sophomore year (2020), I began researching GPU passthrough technology.&lt;/p&gt;
&lt;p&gt;At the school cafeteria attached to the National Pingtung University dormitory, I ordered baked spaghetti, sat down, took out my phone, and read articles written by &amp;ldquo;For Possible Sounds&amp;rdquo;, &amp;ldquo;CT Wang&amp;rdquo;, &amp;ldquo;How to Play LOL on Linux&amp;rdquo;, &amp;ldquo;Bird Brother&amp;rdquo;, and others, beginning my study of how to do GPU passthrough.&lt;/p&gt;
&lt;p&gt;During the same period, I tried installing Hackintosh on bare metal. I read articles, went back to the dorm to test it, and actually succeeded! Ah, but I could not handle the audio card kext, so I gave up very quickly.&lt;/p&gt;
&lt;p&gt;The shop served the meal in a small bowl. The spaghetti was wrapped in aluminum foil, with a hot baked crust covering the top. When I pierced it with a fork and rolled up tomato noodles with stringy cheese and crust, the crispy, sweet-and-sour feeling in my mouth was truly delicious.&lt;/p&gt;
&lt;p&gt;Mamma mia, I simply could not understand what those online articles were writing. What IOMMU, VFIO, nouveau blacklist, what the heck!? Why does everyone introduce GPU passthrough like they are writing a thesis? While reading, I finished the noodles too, so I quit and went to sleep!&lt;/p&gt;
&lt;p&gt;Slowly, by 2022, I successfully tried GPU passthrough on Ubuntu for the first time. It was not some sudden enlightenment, but success through repeated trial and error. After all, that was a time when I did not even know how to use vim.&lt;/p&gt;</description></item></channel></rss>