devices: virtio-balloon: change vq indexes based on features

The virtio specification for the traditional memory balloon device
contains some unclear wording related to virtqueue numbering. The
interpretation crosvm has been using does not match the interpretation
used by the Linux driver, nor the QEMU balloon device, so change crosvm
to match reality. In particular, this affects the page reporting feature
(--balllon-page-reporting), which did not work with the upstream Linux
virtio-balloon driver previously.

The specification assigns fixed numbers to each virtqueue (for example,
vq 2 is statsq, 3 is free_page_vq, and 4 is reporting_vq); however, the
spec also says that these feature-controlled virtqueues only "exist"
when the corresponding feature is "set". The different interpretations
are due to these words, whose meaning is not defined in the spec. crosvm
assumed that this meant that the vq indexes would remain fixed (and the
queues that didn't "exist" would simply be non-functional if the driver
attempted to modify any queue properties or enable the queue), whereas
QEMU and Linux interpreted this to mean that if a device does not
advertise the corresponding feature, that vq is totally removed from the
list and its vq index is reused for the next feature-dependent vq, and
so on for following vqs.

This change modifies crosvm to work like QEMU, so now the advertised
features (note: not the features acknowledged by the driver) control
whether a given queue "exists" or if it should be totally removed and
its index reused for other queues.

TEST: crosvm run --balloon-page-reporting

Change-Id: I76a29744028574ddc5aa31fbb97d0a2f8ece80f2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/6454902
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
1 file changed
tree: 0dcef3273d09715739810ad8cad0018259d15f49
  1. .cargo/
  2. .config/
  3. .devcontainer/
  4. .github/
  5. .vscode/
  6. aarch64/
  7. aarch64_sys_reg/
  8. acpi_tables/
  9. android_audio/
  10. arch/
  11. argh_helpers/
  12. audio_streams_conformance_test/
  13. audio_util/
  14. base/
  15. base_tokio/
  16. bit_field/
  17. broker_ipc/
  18. common/
  19. cros_async/
  20. cros_fdt/
  21. cros_tracing/
  22. cros_tracing_types/
  23. crosvm_cli/
  24. crosvm_control/
  25. crosvm_plugin/
  26. devices/
  27. disk/
  28. docs/
  29. e2e_tests/
  30. ext2/
  31. fuse/
  32. fuzz/
  33. gpu_display/
  34. hypervisor/
  35. infra/
  36. io_uring/
  37. jail/
  38. kernel_cmdline/
  39. kernel_loader/
  40. kvm/
  41. kvm_sys/
  42. libcras_stub/
  43. linux_input_sys/
  44. logo/
  45. media/
  46. metrics/
  47. metrics_events/
  48. net_sys/
  49. net_util/
  50. perfetto/
  51. power_monitor/
  52. prebuilts/
  53. proto_build_tools/
  54. protos/
  55. resources/
  56. riscv64/
  57. rutabaga_gfx/
  58. sandbox/
  59. serde_keyvalue/
  60. snapshot/
  61. src/
  62. swap/
  63. system_api/
  64. tests/
  65. third_party/
  66. tools/
  67. tube_transporter/
  68. usb_sys/
  69. usb_util/
  70. vendor/
  71. vfio_sys/
  72. vhost/
  73. virtio_sys/
  74. vm_control/
  75. vm_memory/
  76. win_audio/
  77. win_util/
  78. x86_64/
  79. .dockerignore
  80. .envrc
  81. .gitattributes
  82. .gitignore
  83. .gitmodules
  84. .rustfmt.toml
  85. ARCHITECTURE.md
  86. Cargo.lock
  87. Cargo.toml
  88. CONTRIBUTING.md
  89. DIR_METADATA
  90. LICENSE
  91. mypy.ini
  92. OWNERS
  93. OWNERS_COUNCIL
  94. PRESUBMIT.cfg
  95. pyproject.toml
  96. README.chromeos.md
  97. README.md
  98. rust-toolchain
README.md

crosvm - The ChromeOS Virtual Machine Monitor

crosvm is a virtual machine monitor (VMM) based on Linux’s KVM hypervisor, with a focus on simplicity, security, and speed. crosvm is intended to run Linux guests, originally as a security boundary for running native applications on the ChromeOS platform. Compared to QEMU, crosvm doesn’t emulate architectures or real hardware, instead concentrating on paravirtualized devices, such as the virtio standard.

crosvm is currently used to run Linux/Android guests on ChromeOS devices.

Logo