audio: fix VirtioSnd re-activation

Hitherto the activation could succeed only once since take() function on
Option "Takes the value out of the option, leaving a None in its place."
Above resulted with crosvm crash in guest suspend/resume scenario when
the activate was called more than once (for the second time snd_data
and stream_source_generators was None).

To overcome above issue use clone for snd_data. For
stream_source_generator the clone can't be
easily used due to missing Clone support for stream_source_generators
embed data types (e.g.
369 | struct AudioBuffer<'a> {
370 |     buffer: &'a mut [u8],
    |     ^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for
    `&mut [u8]`

and some other). Therefore for stream_source_generator move
create_stream_source_generators from new() to activate.

BUG=b:246728970
TEST=Perform multiple suspend/resume s2idle cycle for borealis VM and
make sure that 1) crosvm doesn't crash anymore 2) audio from borealis VM
is still working after VM suspend/resume cycles.

Change-Id: I8b27042e4cc0e5efb1d92756ac3b71a5a744f705
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3904649
Commit-Queue: Norman Bintang <normanbt@chromium.org>
Reviewed-by: Norman Bintang <normanbt@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
1 file changed
tree: df7655ed3c0d61b34b911a7b856f7c3d8af9c8d7
  1. .cargo/
  2. .devcontainer/
  3. .github/
  4. .vscode/
  5. aarch64/
  6. acpi_tables/
  7. anti_tamper/
  8. arch/
  9. argh_helpers/
  10. base/
  11. bit_field/
  12. broker_ipc/
  13. common/
  14. cros_async/
  15. crosvm-fuzz/
  16. crosvm_control/
  17. crosvm_plugin/
  18. devices/
  19. disk/
  20. docs/
  21. fuse/
  22. gpu_display/
  23. hypervisor/
  24. infra/
  25. integration_tests/
  26. io_uring/
  27. kernel_cmdline/
  28. kernel_loader/
  29. kvm/
  30. kvm_sys/
  31. libcras_stub/
  32. linux_input_sys/
  33. logo/
  34. media/
  35. metrics/
  36. net_sys/
  37. net_util/
  38. power_monitor/
  39. protos/
  40. qcow_utils/
  41. resources/
  42. rutabaga_gfx/
  43. seccomp/
  44. serde_keyvalue/
  45. src/
  46. system_api_stub/
  47. tests/
  48. third_party/
  49. tools/
  50. tpm2/
  51. tpm2-sys/
  52. tracing/
  53. tube_transporter/
  54. usb_sys/
  55. usb_util/
  56. vfio_sys/
  57. vhost/
  58. virtio_sys/
  59. vm_control/
  60. vm_memory/
  61. win_audio/
  62. win_util/
  63. x86_64/
  64. .dockerignore
  65. .gitignore
  66. .gitmodules
  67. .rustfmt.toml
  68. ARCHITECTURE.md
  69. build.rs
  70. Cargo.lock
  71. Cargo.toml
  72. CONTRIBUTING.md
  73. DIR_METADATA
  74. LICENSE
  75. mypy.ini
  76. OWNERS
  77. PRESUBMIT.cfg
  78. pyproject.toml
  79. README.chromeos.md
  80. README.md
  81. rust-toolchain
README.md

crosvm - The Chrome OS 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 Chrome OS 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 Chrome OS devices.

Logo