lxd icon indicating copy to clipboard operation
lxd copied to clipboard

LXD vga type console login blocks audio devices in host OS

Open selcem-artan opened this issue 1 year ago • 9 comments

Hello team,

I have a Ubuntu Desktop VM running named "esa-desktop" on LXD as below. When I launch a console via lxc console --type vga esa-desktop, it launches remote console successfully but also throws below errors and my PC built-in mic and speaker does not work anymore. Could you please help if audio transfer could be disabled?

$ lxc ls
+---------------+---------+------+------+-----------------+-----------+
|     NAME      |  STATE  | IPV4 | IPV6 |      TYPE       | SNAPSHOTS |

+---------------+---------+------+------+-----------------+-----------+
| esa-desktop   | STOPPED |      |      | VIRTUAL-MACHINE | 0         |
$ lxc console esa-desktop --type vga

(remote-viewer:1804033): GLib-GObject-WARNING **: 12:13:06.540: g_object_get_is_valid_property: object class 'GstAutoAudioSink' has no property named 'volume'

(remote-viewer:1804033): GLib-GObject-WARNING **: 12:13:06.567: g_object_get_is_valid_property: object class 'GstAutoAudioSrc' has no property named 'volume'
$ lxd version
5.21.1 LTS

selcem-artan avatar Apr 29 '24 12:04 selcem-artan

Here, testing with spicy (rather than remote-viewer) I have similar warnings:

$ lxc launch images:ubuntu/noble/desktop nd1 --vm -c limits.cpu=2 -c limits.memory=6GiB
$ lxc console -t vga nd1
GSpice-Message: 09:54:19.429: main channel: opened
port 0x589770488300 org.spice-space.webdav.0: opened
port 0x589770488300 org.spice-space.webdav.0: closed
/dev/shm/jack_db-0/__db.001: No such file or directory

(spicy:1214121): GLib-GObject-WARNING **: 09:54:41.215: g_object_get_is_valid_property: object class 'GstAutoAudioSink' has no property named 'volume'
/dev/shm/jack_db-0/__db.001: No such file or directory

(spicy:1214121): GLib-GObject-WARNING **: 09:54:41.221: g_object_get_is_valid_property: object class 'GstAutoAudioSrc' has no property named 'volume'

However, those warnings are consistent with the fact that the VM has no real audio device attached to it:

noble-vm-sound

That said, my host's sound is unaffected by having this VGA console opened.

simondeziel avatar Apr 29 '24 14:04 simondeziel

@selcem-artan, could you please indicate how you created that esa-desktop VM?

Also, it'd be useful if you could share the following details on your host machine (I've provided results for my host machine):

$ echo "$XDG_SESSION_TYPE"
wayland
$ cat /etc/os-release 
PRETTY_NAME="Ubuntu 22.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.4 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
$ uname -a
Linux sdeziel-lemur 6.5.0-28-generic #29~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Apr  4 14:39:20 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Thanks!

simondeziel avatar Apr 29 '24 14:04 simondeziel

@simondeziel is there a way to invoke the spice client without sound mode?

tomponline avatar Apr 29 '24 15:04 tomponline

@tomponline not that I could find when looking at both remote-viewer and spicy man pages.

simondeziel avatar Apr 29 '24 15:04 simondeziel

@selcem-artan also, once you have the VGA console running, could you check your host's sound configuration and see if there is are new output and input devices showing?

gnome-control-center sound will let you see the sound menu which should look like this:

gnome-sound-menu

If if you click on the Output Device and Input Device drop down lists, you should see which devices are currently actives and which are present.

simondeziel avatar Apr 29 '24 15:04 simondeziel

Hello Sİmon and Tom,

I am creating my VM using below; lxc launch images:ubuntu/22.04/desktop esa-desktop --vm -c limits.cpu=1 -c limits.memory=2GiB

I will check for sound setting as you showed

selcem-artan avatar Apr 30 '24 07:04 selcem-artan

I am sharing "Audio" settings from both my main OS (left), and Ubuntu Desktop VM (right). IN left one, no more selection is available

image

selcem-artan avatar Apr 30 '24 07:04 selcem-artan

@selcem-artan thanks, so far that doesn't seem to indicate a problem. Could you please share the other bits of information from your host, those from https://github.com/canonical/lxd/issues/13402#issuecomment-2082912230? Those will help us narrow down what it could be.

simondeziel avatar May 01 '24 01:05 simondeziel

So far, I've been unable to reproduce this issue locally while using the same guest OS. My local environment runs under Wayland (XDG_SESSION_TYPE=wayland).

simondeziel avatar May 01 '24 01:05 simondeziel

I'll close the issue as I'm unable to reproduce it. @selcem-artan please let us know if you are still experiencing it and share a bit more information about your local environment to help us reproduce and fix it. Thank you

simondeziel avatar Mar 25 '25 18:03 simondeziel

I have the same problem. After reading this, I realized it has to do with how the viewer process gets spawned.

As a workaround, I use xdg-open with the socket url, and replaced in "/snap/lxd/current/bin/remote-viewer" this line:

exec unshare -U -r chroot "/var/lib/snapd/hostfs/" "${CMD}" "$@"

with this:

    # Use xdg-open instead of launching the viewer in a new ns
    # must have a valid audio device, e.g.:
    # lxc config set VM_NAME raw.qemu -- "-device intel-hda -device hda-duplex -audio spice"
    xdg-open "$@"
    VIEWER=$(echo "/usr/bin/${CMD} $@" | sed 's/\+/\./g' )
    echo "waiting for viewer to close..."
    echo "VIEWER: $VIEWER"
    
    VIEWER_PID=$(pgrep -f "${VIEWER}")
    echo "VIEWER_PID: $VIEWER_PID"
    
    while [ -n "$VIEWER_PID" ]; do
        VIEWER_PID=$(pgrep -f "${VIEWER}")
        sleep 1s
    done
    
    echo "release socket"
    exit 0

To use the modified script, I mount it over the existing one in the lxd snap: sudo mount --bind ${HOME}/remote-viewer /snap/lxd/current/bin/remote-viewer

With this I have working sound (including mic) in the an ubuntu vm. The vm must have a valid audio device, e.g.: lxc config set VM_NAME raw.qemu -- "-device intel-hda -device hda-duplex -audio spice"

I have attached the complete file: remote-viewer

matthiasch avatar Apr 23 '25 05:04 matthiasch