Return to Level1Techs.com

[Guide] Painlessly adding audio support to a Looking Glass windows 10 machine using Scream!

Hello there fellow Looking Glass users!

As of a recent windows 10 update, all programs that utilize audio will hang when the output is set to an ICH6 or ICH9 device. AC97 drivers are quite old, and setup is quite tedious.

Today I present to you: Scream, primarily developed by duncanthrax. It provides an alternate way to send sound to the host, and is painless to set up.

Setup for scream is really simple, you already have the IVSHMEM drivers installed as part of Looking Glass setup, so you can skip this part in the official guide. (Link)

In this guide, an example for Pulseaudio is provided. But scream supports ALSA as well.

A link to the official tutorial I am basing this guide on is here! Below is a step-by step instruction for modifying your existing Looking Glass machine!

There’s some special sauce at the bottom that is not in the official guide, but i highly recommend doing. Scroll down to the “Linking Looking Glass with Scream for the perfect experience.” section.

Here’s how I upgraded my VM to use Scream v3.4

Configuring the windows VM.

  • Download the latest release from the GitHub repository.
    • Choose the non-source .zip file
  • Inside that file, there’s a directory called Install.
    move it into your Windows 10 virtual machine
  • Execute install.bat as administrator
  • Open registry editor and navigate to: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Scream\Options
    • If the Options key doesn’t exists, create it.
  • Create a DWORD value called UseIVSHMEM and set it to 2.
    image
    image
  • Shut down the VM, and use virsh edit <vm-name> and insert this snippet in the XML file.
    • Please notice that the size must match the number entered in the DWORD value as configured in windows.
    • If you get complaints like: “Attempted double use of PCI Address”, change the slot number to something else and try again.
   <shmem name='scream-ivshmem'>
      <model type='ivshmem-plain'/>
      <size unit='M'>2</size>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
    </shmem>
  • Configuring the windows machine is now complete.

Setting up the Linux host

The Linux host will use a ‘receiver’ to play sound. Instructions straight from the guide:

Linux/Pulseaudio: Not included in the installer package. Just type ‘make’ to build it. You might need to install build tools and Pulseaudio development packages.
Linux/ALSA: Originally contributed by ivan. Not included in the installer package. Just type ‘make’ to build it.You might need to install build tools and ALSA development packages.

  • Download the source code .zip for the same version of scream (In my case, v3.4)
  • Extract the following directory: Scream-X.X/Receivers/pulseaudio-ivshmem
  • Open a terminal inside the extracted directory containing a file named: Makefile
    • In the terminal, run: make
    • You might need some dependencies, for those, see the quote above.
  • You are left with a file called: scream-ivshmem-pulse. Move it to a location of your choosing. (I chose my Looking Glass folder.)

Testing functionality

  • Start the windows VM
  • Check if you have read-access to the /dev/shm/scream-ivshmem file.
  • Execute the following command in the directory you have moved the compiled program to: ./scream-ivshmem-pulse /dev/shm/scream-ivshmem
  • Play some test tunes in the windows VM. Make sure to set the audio output to scream.
  • You should hear sound at this point. If you don’t, something went wrong. (Maybe look at the official guide?)

Linking Looking Glass with Scream for the perfect experience.

We will use some bash magic to make sure Scream only runs for as long as Looking Glass is open. Therefore, we never run Looking Glass directly, but use bash to run it for us.
Create a file with a name of your choosing. This file will be used to start and stop Scream simultaniously with Looking Glass. Read the comments inside the snippet for further instructions.

#!/bin/bash

virsh start Windows_10_VM # Optional line, this will simply start the VM if it isn't running. You can delete this if you wish. Make sure to change the name to your VM name.
/path/to/looking-glass-client >/dev/null 2>&1 & # Starts Looking Glass, and ignores all output (We aren't watching anyways)
/path/to/scream-ivshmem-pulse /dev/shm/scream-ivshmem & # Starts Scream

wait -n # We wait for any of these processes to exit. (Like closing the Looking Glass window, in our case)
pkill -P $$ # We kill the remaining processes (In our case, scream)

Make sure the file is executable, and you should be good to go!

Thanks for making this, duncanthrax!

10 Likes

This is an excellent guide, thank you for your time documenting this. Perhaps this would be better though placed as a topic on the LG Wiki as a workaround until the Intel HDA issues are resolved.

https://looking-glass.hostfission.com/wiki

1 Like

I’d be honored to have this on the LG wiki!

I’m not sure how to create a new page on the wiki (and if I am allowed to). Would you mind copying this over there? I don’t need credits for writing this.

I would be happy to if I get a chance in the next few days. However if you feel so inlined you are able to create pages simply by visiting a non-existant page and creating it, for example:

https://looking-glass.hostfission.com/wiki/index.php?title=Using_Scream

Edit: Feel free to link to it in the appropriate place on the guides page:

https://looking-glass.hostfission.com/wiki/index.php?title=Guides

1 Like

I have created a page, and updated the guides list. I hope this helps!

3 Likes

So I’m attempting to set this up but when I go to run the VM I get an error message.

Error starting domain: internal error: qemu unexpectedly closed the monitor: 2020-02-21T19:06:17.795002Z qemu-system-x86_64: -object memory-backend-file,id=shmmem-shmem1,mem-path=/dev/shm/scream-lvshmem,size=2097152,share=yes: can’t open backing store /dev/shm/scream-ivshmem for guest RAM: Permission denied

I’m really not sure where to start troubleshooting. When setting up Looking Glass I had to manually create the /dev/shm/looking-glass folder. Your guide doesn’t specify that I need to for scream-ivshmem but it isn’t making it on it’s own.

You mean file.

It can’t because it doesn’t have permission to, it is trying to and failing, you need to make it on it’s behalf just like you did for LG.

Please note:

Note: While this setup is possible it is ill-advised, Scream does not benefit from using IVSHMEM in any way, if anything it increases CPU load and latency due to the polling nature of the implementation. Scream operates far better over a vfio-net device which is already a zero-copy data transfer via shared memory. If you however insist on continuing you’re on your own if you run into issues.

What the issue turned out to be was there needed to be an exception added to apparmor like I did with looking glass. It worked after that.

For about 30 seconds. Then the VM crashed and when restarting everything Looking Glass no longer wants to connect to the VM so it was nice while it worked but now I need to figure out what it broke.

Update: (Forgive my lack of correct terminology. I’m learning as I go.)
So the problem is after the crash, shutdown, and restart somehow internally looking-glass & scream-ivshmem got switched. When launching Looking Glass it attempts to run on the ivshmem shmem device which only has 2MB of capacity (space? size?). After a bunch of fiddling I was able to change the “slot” the device was in and it’s working how it was before.

We will see if it crashes again. I saw via the links they mentioned the possibility of BSODs due to…something I need to look it up again and what they said helps prevent them.

Please though I can’t stress this enough, Scream over IVSHMEM is higher latency and cpu usage then Scream over ethernet. It offers ZERO benefits as virto-pci-net is already a shared memory interface with the host.

You really are far better of putting your efforts into making SCREAM over lan work.

The support added to SCREAM for IVSHMEM has been a thorn in this project’s side since the day it was added, the developer had no understanding of how useless it would be to the project and did no profiling to determine if it was better/faster. If he/she had it would have been abandoned.

1 Like

If you can point me in the direction of how to do that I’m all for researching better solutions.

I’ve used virtio for NICs and Storage but never an audio device.

SCREAM was never built for VMs originally, it’s actual core mission is to send audio over the network, it’s default configuration does this already. Just follow their guides as per normal avoiding IVSHMEM detours.

See: https://github.com/duncanthrax/scream/blob/master/README.md

I will look into this. Do you have any experience with this setup yourself in-case I get hung-up on something?

Personally no, I use QEMUs inbuilt audio emulation as it’s more efficient and doesn’t require any custom configuration in the guest. The better way to go here would be to complain to RedHat/QEMU to fix the Intel HDA virtual sound device as it’s VERY broken.

The only option outside of SCREAM is the AC97 device but no Windows 10 x64 signed drivers exist for it and you will have to run Windows in Test Sign Mode, however, I believe the same holds true for SCREAM anyway.

It shouldn’t be hard though, if your VM has networking support working, you’re 90% done already. Just install the scream device and configure the appropriate receiver (Alsa/PulseAudio) on your host.

1 Like

For the tutorial I’ve written on how to setup QEMU & Looking Glass this is one of the few components I haven’t really covered. If I can make it work it will be a better alternative to passing through a USB audio device.

1 Like

Awesome, if you are so inclined we would really welcome a Scream over LAN tutorial for the LG wiki also :slight_smile:

See: https://looking-glass.hostfission.com/wiki/Guides

2 Likes

That was a stressful 2 hours. As best I can tell it is now working w/out IVSHMEM. Found a guide that explained it all in 3 mins and after some tinkering around is now being broadcasted through the VirtIO bridge I created for the VM and my Linux host is receiving off that bridge.

Hopefully this is what you meant by virtio-pci-net

Only problem I see is this setup will require that the bridge (which is also the hosts source of internet) be assigned a static IP. That’s not a huge issue but I wonder if there’s an easier way.

I’ll tinker with some of the settings a bit and see of there’s any issues. If not I can add this to my tutorial. Once the write-up is done I wouldn’t mind making a copy for your WiKi. Though I’ve never posted to a WiKi before…

Edit: Do believe I found a workaround for the static IP issue. There’s a change it’ll broadcast out all available networks which may be undesirable though.

2 Likes

How universal do these instructions need to be? I can write up specifically the LAN segment as the existing Scream Guide already outlines how to install it on Windows but strictly the LAN setup is extremely simple. it’s just:

  1. Download Scream from Git (one command)
  2. Build Scream using make (one command)
  3. Launch scream-pulse (one command)

What’s not extremely simple are the prerequisites.

  • You need to remove your host network adapters configuration
  • You need to replace it with a bridge
  • You need to add that bridge to the VM
  • You need to install the virtio driver in Windows

After all of that scream will work over the virtio network with a command as simple as ./scream-pulse -i bridge0

The problem here is the extra steps if I explain them in detail will only work for Debian distributions such as Ubuntu, Mint, PopOS, etc.

I can’t provide these instructions for RHEL, OpenSUSE, Arch, etc. They’ll have to figure out how to make a bridge and assign it to the VM on their own. Or if you know how and can fill in those segments.

2 Likes

Perfect, yes, avoid duplication.

Ah, I understand, no, you don’t need to go this far, it would suffice to say that the VM needs to be using bridged networking.

@gnif is correct, IVSHMEM provides no benefit when using scream. I am using it because it’s easy to set up, and allows me to isolate the guest network from the host.

IVSHMEM allows me to have no possible route to the host’s ethernet device. This is especially useful for virtual machines which run untrusted code, eg: Whonix Workstation.

@Windows7ge I’m looking forward to your guide! Once it’s finished, we can put a disclaimer on the current IVSHMEM guide to link to yours instead.

1 Like

Believe me Scream over LAN is EXTREMELY simple to setup and run. It might be more complicated if you want 5.1 or 7.1 surround (which I have not researched) but for Stereo audio the program is plug’n’play.

Really not much to look forward to but I’ll post what instruction I can give. Now the VFIO QEMU/KVM w/ Looking Glass tutorial as a whole I’ve uploaded and am updating/expanding, that’s something to want to look at if you’re curious but it sounds like you’ve already done this yourself.