rust-vmm / rust-vmm-container

Container with all dependencies required for running rust-vmm crates integration tests.
Apache License 2.0
65 stars 32 forks source link

Add vhost-device-sound dependencies #88

Closed epilys closed 10 months ago

epilys commented 11 months ago

Summary of the PR

vhost-device-sound has an ALSA audio backend that dynamically links to library libasound2 and also needs its development headers. The pipewire backend also needs a libpipewire version more recent than the packaged ubuntu one, so build it and install it manually.

Requirements

Before submitting your PR, please make sure you addressed the following requirements:

stefano-garzarella commented 11 months ago

Tested on main branch of https://github.com/rust-vmm/vhost-device, but it is still failing (pipewire libs):

   Compiling pipewire-sys v0.7.2 (https://gitlab.freedesktop.org/pipewire/pipewire-rs.git?rev=5fe090b3ac8f6fed756c4871ac18f26edda3ac89#5fe090b3)
error: failed to run custom build command for `libspa-sys v0.7.2 (https://gitlab.freedesktop.org/pipewire/pipewire-rs.git?rev=5fe090b3ac8f6fed756c4871ac18f26edda3ac89#5fe090b3)`

Caused by:
  process didn't exit successfully: `/crate/target/debug/build/libspa-sys-b36aced9b54adfb1/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=LIBPIPEWIRE_0.3_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  thread 'main' panicked at 'Cannot find libraries: PkgConfig(`PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" "pkg-config" "--libs" "--cflags" "libpipewire-0.3" "libpipewire-0.3 >= 0.3"` did not exit successfully: exit status: 1
  error: could not find system library 'libpipewire-0.3' required by the 'libspa-sys' crate

Can you add also that dependency in this PR?

epilys commented 11 months ago

@stefano-garzarella I couldn't because the pipewire bindings require a newer lib version. I had mentioned it on slack recently that the function signatures of the bindings did not match the system version.

However it works if you build without pipewire:

% docker run --volume $(pwd):/vhost-device \
         12507ff4c38d74964af12c7385e0bea6163a2a1cd8f9be8e1a1a6691456f7b09 \
         /bin/bash -c "cd /vhost-device/staging && cargo build --release --features alsa-backend --no-default-features"
<-snip->
Compiling vhost-device-sound v0.1.0 (/vhost-device/staging/vhost-device-sound)
    Finished release [optimized] target(s) in 11.15s
stefano-garzarella commented 11 months ago

@stefano-garzarella I couldn't because the pipewire bindings require a newer lib version. I had mentioned it on slack recently that the function signatures of the bindings did not match the system version.

Can we build them from source like for libgpiod?

However it works if you build without pipewire:

Yep, but I think we also want pipewire tested, don't we?

It worked before too if we disabled the alsa backend...

epilys commented 11 months ago

@stefano-garzarella yeah of course! I would just do it in a separate PR; I will add a commit to this PR for building it.

stefano-garzarella commented 11 months ago

@epilys thanks!

Separate commit should be fine, but I'd do in this PR. Every PR merged is a new rustvmm/dev version release, so I'd try to have everything we need for vhost-device-sound addressed here.

epilys commented 11 months ago

Pipewire build and build deps could probably be trimmed down with the appropriate meson_options.txt but I'll leave that for the future since it requires sitting down and figuring out what combination works.

epilys commented 11 months ago

By the way, for convenience, I tested it with:

docker run --volume $(pwd):/vhost-device \
         33f91f168f278b440fe6f2eb49eca63edb6d03ffe4901b5d1fe3fe54d029adfd \
         /bin/bash -c "cd /vhost-device/staging && cargo build --release --all-features"

Just replace the image name/SHA.

stefano-garzarella commented 11 months ago

@epilys great, now I'm able to build vhost-device-sound.

Pipewire build and build deps could probably be trimmed down with the appropriate meson_options.txt but I'll leave that for the future since it requires sitting down and figuring out what combination works.

yep, I agree. @dorindabassey might have some useful suggestions.