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

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
                     94: hax            | HAX acceleration support                           | not ported, Windows/Darwin specific as of today
                     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.
                    165: 
                    166: 4. Develop HAXM backend support for the NetBSD kernel.
                    167: 
                    168: ## HAXM hardware assisted virtualization
                    169: 
                    170: Features:
                    171: 
                    172:  - Open Source
                    173:  - HAXM is an Intel hardware assisted virtualization.
                    174:  - HAXM supports up to 8 active VMs.
                    175:  - HAXM supports up to 16 active VCPUs per VM.
                    176:  - ioctl(2) based API with statically created devices (/dev/HAX, /dev/haxm_vm/vmXX, /dev/haxm_vm/haxm_vmXX_vcpuYY)
                    177: 
                    178: HAXM porting for NetBSD rationale:
                    179: 
                    180:  - Relatively low cost (compared to alternatives) to get it aboard to the NetBSD kernel.
                    181:  - Relatively non-intrusive (compared to alternatives like bhyve and KVM)
                    182:  - Scratch but non-functional port for NetBSD is ready.
                    183:  - Active (paid developers) upstream to maintain this
                    184:  - Clean separation between kernel specific and independent parts (there are at least 2 backends: Darwin and Windows)
                    185:  - QEMU frontend already exists, API is ioctl(2) based
                    186:  - Good license (BSD-3-clause) for the kernel driver
                    187:  - Tailored down for desktop users, initially prepared for Android developers
                    188: 
                    189: HAXM shortcomings:
                    190: 
                    191:  - No AMD support
                    192:  - Required relatively recent Intel CPU
                    193:  - Not as flexible as KVM-like solutions for embedded or server usage
                    194:  - Not necessarily ready (not tested) to run every OS in existence, there are known failures to execute some versions of the Linux kernel
                    195: 
                    196: Current HAXM/NetBSD status:
                    197: 
                    198:  - The module builds and loads into the kernel (triggering a panic)
                    199:  - Revisit the UVM APIs to ship all the needed features of sharing memory between user and kernel that is used by HAXM
                    200: 
1.2       kamil     201: > https://github.com/krytarowski/haxm/tree/netbsd-1
                    202: > 
                    203: > $ cd netbsd && make
1.1       kamil     204: 
1.2       kamil     205: External links:
1.1       kamil     206: 
1.2       kamil     207: [https://www.qemu.org/2017/11/22/haxm-usage-windows/](https://www.qemu.org/2017/11/22/haxm-usage-windows/)
                    208: 
                    209: [https://software.intel.com/en-us/articles/intel-hardware-accelerated-execution-manager-intel-haxm](https://software.intel.com/en-us/articles/intel-hardware-accelerated-execution-manager-intel-haxm)
                    210: 
                    211: [https://github.com/intel/haxm](https://github.com/intel/haxm)

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