Annotation of wikisrc/users/kamil/qemu.mdwn, revision 1.6

1.1       kamil       1: QEMU for NetBSD
                      2: 
                      3: # Current status
                      4: 
                      5: Summary of the current status of QEMU hosted on a NetBSD host.
                      6: 
                      7: ## What works?
                      8: 
                      9: Quick summary:
                     10: 
                     11:  - The NetBSD target builds and works out of the box with elementary features.
                     12: 
                     13:  - There is a pkgsrc package that ships a recent version.
                     14: 
                     15:  - QEMU should work with all currently supported NetBSD versions starting from 6.x.
                     16: 
                     17:  - QEMU as of today is not PaX MPROTECT safe.
                     18: 
                     19:  - All tests in the check target pass.
                     20: 
                     21:  - NetBSD is a maintained platform.
                     22: 
                     23: ## Standard features matrix
                     24: 
                     25: Elementary features for NetBSD are probably well supported.
                     26: 
                     27: Name                  | Description                                        | NetBSD status
                     28: ----------------------|----------------------------------------------------|--------------
                     29: python                | Python programming language                        | should work
                     30: smbd                  | Samba                                              | net/samba, untested
                     31: git                   | GIT VCS                                            | should work
                     32: debug                 |                                                    | should work
                     33: sanitizers            | ASan, UBSan, ASan headers                          | should work
                     34: sanitizers Fibers     | Asan headers with fibers                           | Futue GCC/Clang should work
                     35: stack-protector       | Stack protector                                    | works
                     36: audio oss             | OSS audio backend                                  | should work
                     37: audio sdl             | SDL audio backend                                  | should work
                     38: coroutine ucontext    |                                                    | should work
                     39: coroutine sigaltstack |                                                    | should work
                     40: coroutine windows     |                                                    | N/A, Windows specific
                     41: slirp                 | User networking                                    | works                     
                     42: tcg-interpreter       | Tiny Code Generator                                | should work
                     43: malloc-trim           | GNU malloc(3) optimization                         | N/A, Linux specific
                     44: gcov                  | Test Coverage Program                              | should work
                     45: gprof                 | GNU profiling                                      | should work
                     46: profiler              |                                                    | should work
                     47: 
                     48: 
                     49: ## Optional feature matrix
                     50: 
                     51: Additional features support various extensions,
                     52: most of them are a matter of using the emulator with a 3rd party and are OS independent.
                     53: 
                     54: Part of features require OS specific extensions.
                     55: 
                     56: Name           | Description                                        | NetBSD status
                     57: ---------------|----------------------------------------------------|--------------
                     58: system         | all system emulation targets                       | works
                     59: user           | supported user emulation targets                   | broken
                     60: linux-user     | all linux usermode emulation targets               | N/A
                     61: bsd-user       | all BSD usermode emulation targets                 | broken (FreeBSD ships local patches)
                     62: docs           | build documentation                                | should work
                     63: guest-agent    | build the QEMU Guest Agent                         | unknown, probably broken
                     64: guest-agent-msi| build guest agent Windows MSI installation package | unknown, probably broken
                     65: pie            | Position Independent Executables                   | should work
1.3       kamil      66: modules        | QEMU modules support (not kernel modules)          | unknown, should work
1.1       kamil      67: debug-tcg      | TCG debugging (default is disabled)                | should work
                     68: debug-info     | debugging information                              | should work
                     69: sparse         | sparse checker                                     | should work
                     70: gnutls         | GNUTLS cryptography support                        | should work
                     71: nettle         | nettle cryptography support                        | should work
                     72: gcrypt         | libgcrypt cryptography support                     | should work
                     73: sdl            | SDL UI                                             | should work
                     74: --with-sdlabi  |   select preferred SDL ABI 1.2 or 2.0              | should work, not imporant
                     75: gtk            | gtk UI                                             | should work
                     76: --with-gtkabi  |   select preferred GTK ABI 2.0 or 3.0              | should work, not important
                     77: vte            | vte support for the gtk UI                         | should work
                     78: curses         | curses UI                                          | works with native NetBSD 8.0 curses(3) 
                     79: vnc            | VNC UI support                                     | should work
                     80: vnc-sasl       | SASL encryption for VNC server                     | should work
                     81: vnc-jpeg       | JPEG lossy compression for VNC server              | should work
                     82: vnc-png        | PNG compression for VNC server                     | should work
                     83: cocoa          | Cocoa UI (Mac OS X only)                           | N/A, Darwin specific
                     84: virtfs         | VirtFS                                             | probably broken
                     85: mpath          | Multipath persistent reservation passthrough       | unknown, problably not supported
                     86: xen            | xen backend driver support                         | unknown
                     87: xen-pci-passthrough |   PCI passthrough support for Xen             | unknown, probably not supported
                     88: brlapi         | BrlAPI (Braile)                                    | unknown, should work
                     89: curl           | curl connectivity                                  | should work
                     90: membarrier     | membarrier system call (for Linux 4.14+ or Windows)| not supported
                     91: fdt            | fdt device tree                                    | unknown, should work
                     92: bluez          | bluez stack connectivity                           | unknown
                     93: kvm            | KVM acceleration support                           | N/A , Linux specific kernel APIs required in userland
1.5       kamil      94: hax            | HAX acceleration support                           | mostly works
1.1       kamil      95: hvf            | Hypervisor.framework acceleration support          | not ported, Darwin specific
                     96: whpx           | Windows Hypervisor Platform acceleration support   | N/A
                     97: rdma           | Enable RDMA-based migration and PVRDMA support     | unknown, probably not supported
                     98: vde            | support for vde network                            | probably not supported and Linux specific as of today
                     99: netmap         | support for netmap network                         | not supported (FreeBSD specific?)
                    100: linux-aio      | Linux AIO support                                  | not supported, Linux specific
                    101: cap-ng         | libcap-ng support                                  | not supported, Linux specific
                    102: attr           | attr and xattr support                             | N/A, Linux specific ?
                    103: vhost-net      | vhost-net acceleration support                     | not supported
                    104: vhost-crypto   | vhost-crypto acceleration support                  | not supported
                    105: spice          | spice                                              | unknown, probably not supported
                    106: rbd            | rados block device (rbd)                           | unknown
                    107: libiscsi       | iscsi support                                      | unknown
                    108: libnfs         | nfs support                                        | unknown
                    109: smartcard      | smartcard support (libcacard)                      | unknown
                    110: libusb         | libusb (for usb passthrough)                       | unknown
                    111: live-block-migration |  Block migration in the main migration stream| unknown
                    112: usb-redir      | usb network redirection support                    | unknown
                    113: lzo            | support of lzo compression library                 | should work
                    114: snappy         | support of snappy compression library              | should work
                    115: bzip2          | support of bzip2 compression library               | should work
                    116: seccomp        | seccomp support                                    | Linux specific (?)
                    117: coroutine-pool | coroutine freelist (better performance)            | unknown
                    118: glusterfs      | GlusterFS backend                                  | unknown
                    119: tpm            | TPM support                                        | unknown
                    120: libssh2        | ssh block device support                           | should work
                    121: numa           | libnuma support                                    | not ported
                    122: libxml2        | for Parallels image format                         | should work
                    123: tcmalloc       | tcmalloc support                                   | should work
                    124: jemalloc       | jemalloc support                                   | works
                    125: replication    | replication support                                | not ported, N/A ?, Linux specific
                    126: vhost-vsock    | virtio sockets device support                      | not ported
                    127: opengl         | opengl support                                     | unknown
                    128: virglrenderer  | virgl rendering support                            | unknown
                    129: xfsctl         | xfsctl support                                     | N/A / not ported
                    130: qom-cast-debug | cast debugging support                             | unknown
                    131: tools          | build qemu-io, qemu-nbd and qemu-image tools       | works (userland nbd only)
                    132: vxhs           | Veritas HyperScale vDisk backend support           | N/A ?
                    133: crypto-afalg   | Linux AF_ALG crypto backend driver                 | N/A / not ported
                    134: vhost-user     | vhost-user support                                 | not ported
                    135: capstone       | capstone disassembler support                      | should work
                    136: 
                    137: ## External features
                    138: 
                    139: 1. HQEMU
                    140: 
                    141: > 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.
                    142: > 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).
                    143: 
1.2       kamil     144: [http://itanium.iis.sinica.edu.tw/hqemu/](http://itanium.iis.sinica.edu.tw/hqemu/)
1.1       kamil     145: 
                    146: 2. DPDK
                    147: 
                    148: > DPDK is a set of libraries and drivers for fast packet processing.
                    149: 
1.2       kamil     150: [https://dpdk.org/](https://dpdk.org/)
1.1       kamil     151: 
                    152: 3. The ultimate CPU emulator
                    153: 
                    154: > Unicorn is a lightweight multi-platform, multi-architecture CPU emulator framework. 
                    155: 
1.2       kamil     156: [https://www.unicorn-engine.org/](https://www.unicorn-engine.org/)
1.1       kamil     157: 
                    158: ## Prioritized tasks
                    159: 
                    160: 1. Upstream remaining local pkgsrc patches, mostly (old?) NetBSD and SmartOS related ones.
                    161: 
                    162: 2. Make QEMU PaX MPROTECT safe.
                    163: 
                    164: 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.
1.5       kamil     165: 
                    166: ## HAXM
                    167: 
                    168: > 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.
                    169: 
                    170: > 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.
                    171: 
                    172: 
                    173: More information on the porting process is available on The NetBSD blog:
                    174: 
1.6     ! kamil     175: [http://blog.netbsd.org/tnf/entry/the_hardware_assisted_virtualization_challenge](http://blog.netbsd.org/tnf/entry/the_hardware_assisted_virtualization_challenge)
1.5       kamil     176: 
                    177: A tutorial (outdated) by an early user of the support:
                    178: 
1.6     ! kamil     179: [http://polprog.net/blog/netbsd-hax/](http://polprog.net/blog/netbsd-hax/)
1.5       kamil     180: 
                    181: 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.
                    182: 
                    183: 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.
                    184: 
                    185: There is no longer need to keep a patched host kernel.
                    186: 
                    187: There is need to keep at least a copy syssrc in /usr/src(/sys).
                    188: 
                    189: Guests known to work:
                    190: 
1.6     ! kamil     191:  * NetBSD/amd64 8.99.3x (other variations untested)
        !           192:  * Windows 7 32-bit
        !           193:  * FreeBSD 12 32-bit
        !           194:  * Linux (noapic boot)
        !           195:  * Minix3 i386
        !           196:  * Plan9 (i386?)
        !           197:  * FREEDOS
1.5       kamil     198: 
                    199: Other OSes are either broken or untested.
                    200: 
                    201: Usage:
                    202: 
                    203: 1. Install emulators/haxm from pkgsrc
                    204: 2. Install emulators/qemu 3.1.0nb5 or newer from pkgsrc
                    205: 3. Use auxiliary scripts for HAXM (superuser privileges needed):
                    206: 
1.6     ! kamil     207:  * haxm-mknod     # creates /dev entries
        !           208:  * haxm-modload   # insert the HAXM kernel module
        !           209:  * haxm-modunload # remove the HAXM module from kernel
1.5       kamil     210: 
                    211: Optionally grant access to the HAXM device nodes to user(s):
                    212: 
1.6     ! kamil     213:  * /dev/HAX
        !           214:  * /dev/hax_vm/*
        !           215:  * /dev/hax_vm*/*
1.5       kamil     216: 
                    217: 4. Append HAXM option to qemu
                    218: 
                    219: qemu --accel hax

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb