--- wikisrc/users/kamil/qemu.mdwn 2018/05/27 09:32:14 1.1 +++ wikisrc/users/kamil/qemu.mdwn 2019/02/13 05:56:28 1.8 @@ -63,7 +63,7 @@ docs | build documentation guest-agent | build the QEMU Guest Agent | unknown, probably broken guest-agent-msi| build guest agent Windows MSI installation package | unknown, probably broken pie | Position Independent Executables | should work -modules | modules support | unknown, should work +modules | QEMU modules support (not kernel modules) | unknown, should work debug-tcg | TCG debugging (default is disabled) | should work debug-info | debugging information | should work sparse | sparse checker | should work @@ -91,7 +91,7 @@ membarrier | membarrier system call fdt | fdt device tree | unknown, should work bluez | bluez stack connectivity | unknown kvm | KVM acceleration support | N/A , Linux specific kernel APIs required in userland -hax | HAX acceleration support | not ported, Windows/Darwin specific as of today +hax | HAX acceleration support | mostly works hvf | Hypervisor.framework acceleration support | not ported, Darwin specific whpx | Windows Hypervisor Platform acceleration support | N/A rdma | Enable RDMA-based migration and PVRDMA support | unknown, probably not supported @@ -141,19 +141,19 @@ capstone | capstone disassembler s > HQEMU is a retargetable and multi-threaded dynamic binary translator on multicores. It integrates QEMU and LLVM as its building blocks. The translator in the enhanced QEMU acts as a fast translator with low translation overhead. The optimization-intensive LLVM optimizer running on separate threads dynamically improves code for higher performance. With the hybrid QEMU+LLVM approach, HQEMU can achieve low translation overhead and good translated code quality. > HQEMU supports process-level emulation and full-system virtualization. It provides translation modes of running the QEMU translator and LLVM optimizer in one process, or running the LLVM optimizer as a stand-alone optimization server (version 0.13.0). -http://itanium.iis.sinica.edu.tw/hqemu/ +[http://itanium.iis.sinica.edu.tw/hqemu/](http://itanium.iis.sinica.edu.tw/hqemu/) 2. DPDK > DPDK is a set of libraries and drivers for fast packet processing. -https://dpdk.org/ +[https://dpdk.org/](https://dpdk.org/) 3. The ultimate CPU emulator > Unicorn is a lightweight multi-platform, multi-architecture CPU emulator framework. -https://www.unicorn-engine.org/ +[https://www.unicorn-engine.org/](https://www.unicorn-engine.org/) ## Prioritized tasks @@ -163,47 +163,56 @@ https://www.unicorn-engine.org/ 3. Develop NetBSD USER emulation, attempt to either share the code with FreeBSD (bsd-user, old broken, downstream patches) or with Linux (linux-user, recent, actively maintained). Preferred approach is to share as much code with linux-user as possible, regardless of the state of bsd-user. -4. Develop HAXM backend support for the NetBSD kernel. +## HAXM -## HAXM hardware assisted virtualization +> HAXM is a cross-platform hardware-assisted virtualization engine (hypervisor), widely used as an accelerator for Android Emulator and QEMU. It has always supported running on Windows and macOS, and has been ported to other host operating systems as well, such as Linux and NetBSD. -Features: +> HAXM runs as a kernel-mode driver on the host operating system, and provides a KVM-like interface to user space, thereby enabling applications like QEMU to utilize the hardware virtualization capabilities built into modern Intel CPUs, namely Intel Virtualization Technology. - - Open Source - - HAXM is an Intel hardware assisted virtualization. - - HAXM supports up to 8 active VMs. - - HAXM supports up to 16 active VCPUs per VM. - - ioctl(2) based API with statically created devices (/dev/HAX, /dev/haxm_vm/vmXX, /dev/haxm_vm/haxm_vmXX_vcpuYY) -HAXM porting for NetBSD rationale: +More information on the porting process is available on The NetBSD blog: - - Relatively low cost (compared to alternatives) to get it aboard to the NetBSD kernel. - - Relatively non-intrusive (compared to alternatives like bhyve and KVM) - - Scratch but non-functional port for NetBSD is ready. - - Active (paid developers) upstream to maintain this - - Clean separation between kernel specific and independent parts (there are at least 2 backends: Darwin and Windows) - - QEMU frontend already exists, API is ioctl(2) based - - Good license (BSD-3-clause) for the kernel driver - - Tailored down for desktop users, initially prepared for Android developers +[http://blog.netbsd.org/tnf/entry/the_hardware_assisted_virtualization_challenge](http://blog.netbsd.org/tnf/entry/the_hardware_assisted_virtualization_challenge) -HAXM shortcomings: +A tutorial (outdated) by an early user of the support: - - No AMD support - - Required relatively recent Intel CPU - - Not as flexible as KVM-like solutions for embedded or server usage - - Not necessarily ready (not tested) to run every OS in existence, there are known failures to execute some versions of the Linux kernel +[http://polprog.net/blog/netbsd-hax/](http://polprog.net/blog/netbsd-hax/) -Current HAXM/NetBSD status: +NetBSD/amd64 is the only supported host of the package, but it shouldn't be difficult to expand it to Darwin, Windows and Linux if there would be users and maintainers for these OSes. - - The module builds and loads into the kernel (triggering a panic) - - Revisit the UVM APIs to ship all the needed features of sharing memory between user and kernel that is used by HAXM +NetBSD as host version 8.0 and HEAD (8.99.3x) tested. The minimal version that could work in theory is 6.x, but everything prior 8.0 is untested. -``` -https://github.com/krytarowski/haxm/tree/netbsd-1 +There is no longer need to keep a patched host kernel. -$ cd netbsd && make -``` +There is need to keep at least a copy of syssrc in /usr/src(/sys). -https://www.qemu.org/2017/11/22/haxm-usage-windows/ -https://software.intel.com/en-us/articles/intel-hardware-accelerated-execution-manager-intel-haxm -https://github.com/intel/haxm +Guests known to work: + + * NetBSD/amd64 8.99.3x (other variations untested) + * Windows 7 32-bit + * FreeBSD 12 32-bit + * Linux (noapic boot) + * Minix3 i386 + * Plan9 (i386?) + * FREEDOS + +Other OSes are either broken or untested. + +Usage: + +1. Install emulators/haxm from pkgsrc +2. Install emulators/qemu 3.1.0nb5 or newer from pkgsrc +3. Use auxiliary scripts for HAXM (superuser privileges needed) +4. Append HAXM option to qemu (qemu --accel hax) + +Auxiliary scripts in the HAXM package: + + * haxm-mknod # creates /dev entries + * haxm-modload # insert the HAXM kernel module + * haxm-modunload # remove the HAXM module from kernel + +Optionally grant access to the HAXM device nodes to user(s): + + * /dev/HAX + * /dev/hax_vm/vm{00-07} + * /dev/hax_vm{00-07}/vcpu{00-16}