device-emulation.rst 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. .. _device-emulation:
  2. Device Emulation
  3. ----------------
  4. QEMU supports the emulation of a large number of devices from
  5. peripherals such network cards and USB devices to integrated systems
  6. on a chip (SoCs). Configuration of these is often a source of
  7. confusion so it helps to have an understanding of some of the terms
  8. used to describes devices within QEMU.
  9. Common Terms
  10. ~~~~~~~~~~~~
  11. Device Front End
  12. ================
  13. A device front end is how a device is presented to the guest. The type
  14. of device presented should match the hardware that the guest operating
  15. system is expecting to see. All devices can be specified with the
  16. ``--device`` command line option. Running QEMU with the command line
  17. options ``--device help`` will list all devices it is aware of. Using
  18. the command line ``--device foo,help`` will list the additional
  19. configuration options available for that device.
  20. A front end is often paired with a back end, which describes how the
  21. host's resources are used in the emulation.
  22. Device Buses
  23. ============
  24. Most devices will exist on a BUS of some sort. Depending on the
  25. machine model you choose (``-M foo``) a number of buses will have been
  26. automatically created. In most cases the BUS a device is attached to
  27. can be inferred, for example PCI devices are generally automatically
  28. allocated to the next free address of first PCI bus found. However in
  29. complicated configurations you can explicitly specify what bus
  30. (``bus=ID``) a device is attached to along with its address
  31. (``addr=N``).
  32. Some devices, for example a PCI SCSI host controller, will add an
  33. additional buses to the system that other devices can be attached to.
  34. A hypothetical chain of devices might look like:
  35. --device foo,bus=pci.0,addr=0,id=foo
  36. --device bar,bus=foo.0,addr=1,id=baz
  37. which would be a bar device (with the ID of baz) which is attached to
  38. the first foo bus (foo.0) at address 1. The foo device which provides
  39. that bus is itself is attached to the first PCI bus (pci.0).
  40. Device Back End
  41. ===============
  42. The back end describes how the data from the emulated device will be
  43. processed by QEMU. The configuration of the back end is usually
  44. specific to the class of device being emulated. For example serial
  45. devices will be backed by a ``--chardev`` which can redirect the data
  46. to a file or socket or some other system. Storage devices are handled
  47. by ``--blockdev`` which will specify how blocks are handled, for
  48. example being stored in a qcow2 file or accessing a raw host disk
  49. partition. Back ends can sometimes be stacked to implement features
  50. like snapshots.
  51. While the choice of back end is generally transparent to the guest,
  52. there are cases where features will not be reported to the guest if
  53. the back end is unable to support it.
  54. Device Pass Through
  55. ===================
  56. Device pass through is where the device is actually given access to
  57. the underlying hardware. This can be as simple as exposing a single
  58. USB device on the host system to the guest or dedicating a video card
  59. in a PCI slot to the exclusive use of the guest.
  60. Emulated Devices
  61. ~~~~~~~~~~~~~~~~
  62. .. toctree::
  63. :maxdepth: 1
  64. devices/can.rst
  65. devices/ccid.rst
  66. devices/cxl.rst
  67. devices/ivshmem.rst
  68. devices/ivshmem-flat.rst
  69. devices/keyboard.rst
  70. devices/net.rst
  71. devices/nvme.rst
  72. devices/usb.rst
  73. devices/vhost-user.rst
  74. devices/virtio-gpu.rst
  75. devices/virtio-pmem.rst
  76. devices/virtio-snd.rst
  77. devices/vhost-user-input.rst
  78. devices/vhost-user-rng.rst
  79. devices/canokey.rst
  80. devices/usb-u2f.rst
  81. devices/igb.rst