Most active commenters

    ←back to thread

    QEMU 10.1.0

    (wiki.qemu.org)
    302 points dmitrijbelikov | 11 comments | | HN request time: 0.434s | source | bottom
    Show context
    dijit ◴[] No.45038037[source]
    QEMU is truly excellent software, from the perspective of a person who very rarely needs to emulate another architecture. It "just works" and has wonderful integrations with basically everything I could want.. sometimes it feels like magic: even if the commandline UX is a bit weird in places.

    I've always wondered though how it works with KVM: I know KVM is a virtualisation accelerator that enables passing through native code to the CPU somehow; but it feels like QEMU/KVM basically runs the internet now. Almost the entire modern cloud is built on QEMU and KVM as a hypervisor (right?) but I feel like I'm missing a lot about how it's working.

    I also wonder if this steals huge amounts of resources away from emulation, or does it end up helping out. Because to say the modern internet is largely running on QEMU is likely a massive understatement.

    replies(8): >>45038105 #>>45038111 #>>45038113 #>>45038185 #>>45038444 #>>45038616 #>>45038965 #>>45038990 #
    1. monocasa ◴[] No.45038185[source]
    KVM is basically three components.

    * An abstraction over second level page tables to map some of a host user process as what the guest thinks of as physical memory.

    * An abstraction to jump into the context that uses those page tables, and traps back out in the case of anything that the hardware would normally handle, but the hypervisor wants to handle manually instead.

    * A collection of mechanisms to handle some of those traps in kernel space to avoid having to context switch back out to the host user process if the kind of trap is common enough, both in the sense of the trap itself happens often enough to show up on perf graphs, as well as the abstraction being exercised is relatively standard (think interrupt controllers and timers).

    Let me know if you have any other questions.

    replies(3): >>45038711 #>>45042005 #>>45042709 #
    2. eddd-ddde ◴[] No.45038711[source]
    Where could someone get started in terms of reading material to learn more about this in depth?
    replies(3): >>45039162 #>>45041157 #>>45043593 #
    3. dysoco ◴[] No.45039162[source]
    I would assume sooner or later you're going to end up in the Intel Developer manuals or the equivalent for whatever architecture you are interested in. The Intel ones are very complete at least.
    replies(2): >>45039342 #>>45042538 #
    4. znpy ◴[] No.45039342{3}[source]
    > I would assume sooner or later you're going to end up in the Intel Developer manuals or the equivalent for whatever architecture you are interested in. The Intel ones are very complete at least.

    I can vouch for this. I'm no virtualization expert but I did stumble upon some intel developers manuals (truthfully, i fell into the rabbit hole) and just skimming it made everything make much more sense.

    For example: https://www.intel.com/content/dam/www/public/us/en/documents... - "CHAPTER 23 INTRODUCTION TO VIRTUAL MACHINE EXTENSIONS"

    The link above explains how the VMX extension work on intel processors. Any software doing hardware-assisted virtualization (so no binary translation, no full-system-emulation) will likely be using those instructions.

    5. yjftsjthsd-h ◴[] No.45041157[source]
    From a different direction, I'd suggest https://www.devever.net/~hl/kvm
    6. privatelypublic ◴[] No.45042005[source]
    I thought part of vt-d/vt-x made the "virtual tables" actual tables.

    Eg- the memory the VM can access is controlled by the MMU of the CPU (below ring0/kernel). Resulting in the only VM escapes being the Shim(s) for talking with the host (network, memory balloon, graphics).

    replies(1): >>45043670 #
    7. jlokier ◴[] No.45042538{3}[source]
    The AMD Processor Programming Reference manuals are also good for this, if you like complete and detailed. They complement the Intel manuals. Much the material is duplicate because the processors are so similar, but written in a different way.
    8. accelbred ◴[] No.45042709[source]
    How does nested KVM work? Are all the page tables handled by the top level? Do the traps have to propagate up?
    replies(1): >>45043681 #
    9. billywhizz ◴[] No.45043593[source]
    if you want to look at existing implementations on top of kvm then these might be useful - rust-vmm is a core library for AWS' firecracker vmm.

    https://github.com/rust-vmm/kvm https://github.com/kvmtool/kvmtool https://github.com/sysprog21/kvm-host

    10. bonzini ◴[] No.45043670[source]
    Yes, there are virtualization-specific page tables that convert guest physical to host physical addresses. KVM still haw to take host userspace's virtual addresses, convert them to host physical addresses, and make sure that the virtualization-specific page tables stay in sync with the kernel's usual page tables (which convery host virtual addresses to host physical)
    11. bonzini ◴[] No.45043681[source]
    Yes, the top level uses write protection of guest memory to combine the two levels of translation into one.