From b113dc6b288ff2b75968e245a716dc7e1436aec1 Mon Sep 17 00:00:00 2001 From: Stefano Garzarella Date: Tue, 2 Jan 2024 16:16:09 +0100 Subject: [PATCH] sound: promote to main workspace The current implementation seems ready to be promoted to the main workspace since the device supports both playback and recording, and several audio backends. Also, test coverage is good and aligned with the coverage of crates in the main workspace. Signed-off-by: Stefano Garzarella --- Cargo.lock | 400 +++++++++++++++- Cargo.toml | 1 + README.md | 2 +- coverage_config_x86_64.json | 2 +- staging/Cargo.lock | 450 +----------------- staging/Cargo.toml | 1 - staging/coverage_config_x86_64.json | 2 +- .../CHANGELOG.md | 0 .../Cargo.toml | 0 .../LICENSE-APACHE | 0 .../LICENSE-BSD-3-Clause | 0 .../README.md | 0 .../rustfmt.toml | 0 .../src/audio_backends.rs | 0 .../src/audio_backends/alsa.rs | 0 .../src/audio_backends/alsa/test_utils.rs | 0 .../src/audio_backends/null.rs | 0 .../src/audio_backends/pipewire.rs | 0 .../src/audio_backends/pipewire/test_utils.rs | 0 .../src/device.rs | 0 .../src/lib.rs | 0 .../src/main.rs | 0 .../src/stream.rs | 0 .../src/virtio_sound.rs | 0 24 files changed, 415 insertions(+), 443 deletions(-) rename {staging/vhost-device-sound => vhost-device-sound}/CHANGELOG.md (100%) rename {staging/vhost-device-sound => vhost-device-sound}/Cargo.toml (100%) rename {staging/vhost-device-sound => vhost-device-sound}/LICENSE-APACHE (100%) rename {staging/vhost-device-sound => vhost-device-sound}/LICENSE-BSD-3-Clause (100%) rename {staging/vhost-device-sound => vhost-device-sound}/README.md (100%) rename {staging/vhost-device-sound => vhost-device-sound}/rustfmt.toml (100%) rename {staging/vhost-device-sound => vhost-device-sound}/src/audio_backends.rs (100%) rename {staging/vhost-device-sound => vhost-device-sound}/src/audio_backends/alsa.rs (100%) rename {staging/vhost-device-sound => vhost-device-sound}/src/audio_backends/alsa/test_utils.rs (100%) rename {staging/vhost-device-sound => vhost-device-sound}/src/audio_backends/null.rs (100%) rename {staging/vhost-device-sound => vhost-device-sound}/src/audio_backends/pipewire.rs (100%) rename {staging/vhost-device-sound => vhost-device-sound}/src/audio_backends/pipewire/test_utils.rs (100%) rename {staging/vhost-device-sound => vhost-device-sound}/src/device.rs (100%) rename {staging/vhost-device-sound => vhost-device-sound}/src/lib.rs (100%) rename {staging/vhost-device-sound => vhost-device-sound}/src/main.rs (100%) rename {staging/vhost-device-sound => vhost-device-sound}/src/stream.rs (100%) rename {staging/vhost-device-sound => vhost-device-sound}/src/virtio_sound.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 7ce91e7..4931e06 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,6 +11,28 @@ dependencies = [ "memchr", ] +[[package]] +name = "alsa" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce34de545ad29bcc00cb1b87a94c132256dcf83aa7eeb9674482568405a6ff0a" +dependencies = [ + "alsa-sys", + "bitflags 2.4.1", + "libc", + "nix 0.26.4", +] + +[[package]] +name = "alsa-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db8fee663d06c4e303404ef5f40488a53e062f89ba8bfed81f42325aafad1527" +dependencies = [ + "libc", + "pkg-config", +] + [[package]] name = "anstream" version = "0.6.5" @@ -59,6 +81,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "anyhow" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" + [[package]] name = "arc-swap" version = "1.6.0" @@ -110,6 +138,26 @@ dependencies = [ "which", ] +[[package]] +name = "bindgen" +version = "0.66.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" +dependencies = [ + "bitflags 2.4.1", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "peeking_take_while", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.46", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -158,6 +206,16 @@ dependencies = [ "nom", ] +[[package]] +name = "cfg-expr" +version = "0.15.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6100bc57b6209840798d95cb2775684849d332f7bd788db2a8c8caf7ef82a41a" +dependencies = [ + "smallvec", + "target-lexicon", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -235,6 +293,21 @@ dependencies = [ "yaml-rust", ] +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "cookie-factory" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "396de984970346b0d9e93d1415082923c679e5ae5c3ee3dcbd104f5610af126b" + [[package]] name = "either" version = "1.9.0" @@ -326,6 +399,101 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-executor" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.46", +] + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-timer" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + [[package]] name = "getrandom" version = "0.2.11" @@ -464,8 +632,8 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fea8c5d5997bdd7d972ef31d77bccc8d790f983e2bfe965b506980340f915df" dependencies = [ - "bindgen", - "system-deps", + "bindgen 0.63.0", + "system-deps 2.0.3", ] [[package]] @@ -478,6 +646,32 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "libspa" +version = "0.7.2" +source = "git+https://gitlab.freedesktop.org/pipewire/pipewire-rs.git?rev=5fe090b3ac8f6fed756c4871ac18f26edda3ac89#5fe090b3ac8f6fed756c4871ac18f26edda3ac89" +dependencies = [ + "bitflags 2.4.1", + "cc", + "convert_case", + "cookie-factory", + "libc", + "libspa-sys", + "nix 0.26.4", + "nom", + "system-deps 6.2.0", +] + +[[package]] +name = "libspa-sys" +version = "0.7.2" +source = "git+https://gitlab.freedesktop.org/pipewire/pipewire-rs.git?rev=5fe090b3ac8f6fed756c4871ac18f26edda3ac89#5fe090b3ac8f6fed756c4871ac18f26edda3ac89" +dependencies = [ + "bindgen 0.66.1", + "cc", + "system-deps 6.2.0", +] + [[package]] name = "linked-hash-map" version = "0.5.6" @@ -511,6 +705,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +dependencies = [ + "autocfg", +] + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -527,7 +730,20 @@ dependencies = [ "cc", "cfg-if", "libc", - "memoffset", + "memoffset 0.6.5", +] + +[[package]] +name = "nix" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", + "memoffset 0.7.1", + "pin-utils", ] [[package]] @@ -590,6 +806,44 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pipewire" +version = "0.7.2" +source = "git+https://gitlab.freedesktop.org/pipewire/pipewire-rs.git?rev=5fe090b3ac8f6fed756c4871ac18f26edda3ac89#5fe090b3ac8f6fed756c4871ac18f26edda3ac89" +dependencies = [ + "anyhow", + "bitflags 2.4.1", + "libc", + "libspa", + "libspa-sys", + "nix 0.26.4", + "once_cell", + "pipewire-sys", + "thiserror", +] + +[[package]] +name = "pipewire-sys" +version = "0.7.2" +source = "git+https://gitlab.freedesktop.org/pipewire/pipewire-rs.git?rev=5fe090b3ac8f6fed756c4871ac18f26edda3ac89#5fe090b3ac8f6fed756c4871ac18f26edda3ac89" +dependencies = [ + "bindgen 0.66.1", + "libspa-sys", + "system-deps 6.2.0", +] + [[package]] name = "pkg-config" version = "0.3.28" @@ -704,12 +958,56 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +[[package]] +name = "relative-path" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e898588f33fdd5b9420719948f9f2a32c922a246964576f71ba7f24f80610fbc" + +[[package]] +name = "rstest" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97eeab2f3c0a199bc4be135c36c924b6590b88c377d416494288c14f2db30199" +dependencies = [ + "futures", + "futures-timer", + "rstest_macros", + "rustc_version", +] + +[[package]] +name = "rstest_macros" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d428f8247852f894ee1be110b375111b586d4fa431f6c46e64ba5a0dcccbe605" +dependencies = [ + "cfg-if", + "glob", + "proc-macro2", + "quote", + "regex", + "relative-path", + "rustc_version", + "syn 2.0.46", + "unicode-ident", +] + [[package]] name = "rustc-hash" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + [[package]] name = "rustix" version = "0.38.28" @@ -729,6 +1027,12 @@ version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +[[package]] +name = "semver" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" + [[package]] name = "serde" version = "1.0.193" @@ -749,6 +1053,15 @@ dependencies = [ "syn 2.0.46", ] +[[package]] +name = "serde_spanned" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +dependencies = [ + "serde", +] + [[package]] name = "serde_yaml" version = "0.9.29" @@ -768,6 +1081,21 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" + [[package]] name = "strsim" version = "0.10.0" @@ -825,8 +1153,21 @@ dependencies = [ "strum", "strum_macros", "thiserror", - "toml", - "version-compare", + "toml 0.5.11", + "version-compare 0.0.11", +] + +[[package]] +name = "system-deps" +version = "6.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2d580ff6a20c55dfb86be5f9c238f67835d0e81cbdea8bf5680e0897320331" +dependencies = [ + "cfg-expr", + "heck 0.4.1", + "pkg-config", + "toml 0.8.2", + "version-compare 0.1.1", ] [[package]] @@ -835,6 +1176,12 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "target-lexicon" +version = "0.12.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c39fd04924ca3a864207c66fc2cd7d22d7c016007f9ce846cbb9326331930a" + [[package]] name = "tempfile" version = "3.9.0" @@ -886,11 +1233,26 @@ dependencies = [ "serde", ] +[[package]] +name = "toml" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + [[package]] name = "toml_datetime" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +dependencies = [ + "serde", +] [[package]] name = "toml_edit" @@ -899,6 +1261,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" dependencies = [ "indexmap", + "serde", + "serde_spanned", "toml_datetime", "winnow", ] @@ -933,6 +1297,12 @@ version = "0.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c18c859eead79d8b95d09e4678566e8d70105c4e7b251f707a03df32442661b" +[[package]] +name = "version-compare" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29" + [[package]] name = "vhost" version = "0.9.0" @@ -1064,6 +1434,26 @@ dependencies = [ "vmm-sys-util", ] +[[package]] +name = "vhost-device-sound" +version = "0.1.0" +dependencies = [ + "alsa", + "clap", + "env_logger", + "log", + "pipewire", + "rstest", + "tempfile", + "thiserror", + "vhost", + "vhost-user-backend", + "virtio-bindings", + "virtio-queue", + "vm-memory", + "vmm-sys-util", +] + [[package]] name = "vhost-device-template" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index ee40f4d..bf2d33e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,7 @@ members = [ "vhost-device-rng", "vhost-device-scsi", "vhost-device-scmi", + "vhost-device-sound", "vhost-device-template", "vhost-device-vsock", ] diff --git a/README.md b/README.md index cf3a0b0..245c665 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Here is the list of device backends that we support: - [RNG](https://github.com/rust-vmm/vhost-device/blob/main/vhost-device-rng/README.md) - [SCMI](https://github.com/rust-vmm/vhost-device/blob/main/vhost-device-scmi/README.md) - [SCSI](https://github.com/rust-vmm/vhost-device/blob/main/vhost-device-scsi/README.md) +- [Sound](https://github.com/rust-vmm/vhost-device/blob/main/vhost-device-sound/README.md) - [VSOCK](https://github.com/rust-vmm/vhost-device/blob/main/vhost-device-vsock/README.md) The vhost-device workspace also provides a @@ -44,7 +45,6 @@ More information may be found in its [README file](./staging/README.md). Here is the list of device backends in **staging**: -- [Sound](https://github.com/rust-vmm/vhost-device/blob/main/staging/vhost-device-sound/README.md) - [Video](https://github.com/rust-vmm/vhost-device/blob/main/staging/vhost-device-video/README.md)