Ways to use pcspkr from VM

senthor

New Member
May 31, 2022
4
0
1
I have a small home server used to virtualize a few machines. It's headless and sits in my living room. Before virtualizing, I used to utilize the pcspkr via beep for simple communication; e.g. a lost network connection, or to signal a completed backup to a offline drive. Most of these things can be accomplished via more sophisticated messages, but I like the simplicity of plugging in a drive and waiting for a chime to signal the completed backup. There are no soundcards / other speaker attached to the machine.
So, I'm trying to use the pcspkr from my VM. My current idea involves ssh'ing from the VM to the host to run the 'beep'-command here. This results in some delay, however, as there's authentication to do each time a sound is played. As such, I've been toying with the idea to directly offer the pcspkr as a device to the VM according to the QEMU manual. I haven't had any success, yet, as I am unsure what to select as audio backend -- there's nothing on the machine so far.
Any help with this would be greatly appreciated, as would be other ideas to offer the functionality to the VM without the ssh-authentication indulged delays.
 
Last edited:
Hi,
the Proxmox VE UI only exposes spice and dummy driver for audio devices. But you should be able to configure the device by passing the CLI parameters directly to QEMU via the args property by using qm set <ID> --args '<options from the manual>'
 
Hi Fiona, and thanks for your reply! I should have clarified: I am using the args property in my vm.conf file. I am having issues finding the correct CLI parameters: -audiodev <backend>,id=<name> -machine pcspk-audiodev=<name>. Or is this a question I should ask the qemu-community?
 
Hi Fiona, and thanks for your reply! I should have clarified: I am using the args property in my vm.conf file. I am having issues finding the correct CLI parameters: -audiodev <backend>,id=<name> -machine pcspk-audiodev=<name>. Or is this a question I should ask the qemu-community?
You can certainly ask there too, as it's not specific to Proxmox VE. But it's not like you can't ask here! You need to replace <backend> and <name> with specific values. You can see the available backends with kvm -audiodev help, the name can be anything but has to be the same both times.
 
The options I get with kvm -audiodev help are:
Code:
none
alsa
dbus
oss
pa
spice
wav
As far as I can tell, all of these are full-fledged audio drivers, which require me to configure a real audio backend on the host. There seem to be drivers for routing sound to the PC Speaker (like snd-pcsp or snd-pcsp-dkms). However, these are not available via the default repos.

Just to be sure: I'm talking about sound coming from the motherboard speaker, for which the beep command issues a special character to a local tty, not producing any "real" sound using a sound card or actual driver.

Do I understand correctly: You propose routing all sound on the host via a pseudo-driver like snd-pcsp to the pcspkr and then creating a virtual sound device on the VM? This would result in:
Code:
VM beep command
-> VM tty
-> catch via virtual sound card and convert to sine wave
-> issue to host as sine wave
-> catch via snd_pcsp and convert to tty
-> issue to host tty

I was hoping for:
Code:
VM beep command
-> VM tty
-> issue to host  tty
 
The options I get with kvm -audiodev help are:
Code:
none
alsa
dbus
oss
pa
spice
wav
As far as I can tell, all of these are full-fledged audio drivers, which require me to configure a real audio backend on the host. There seem to be drivers for routing sound to the PC Speaker (like snd-pcsp or snd-pcsp-dkms). However, these are not available via the default repos.

Just to be sure: I'm talking about sound coming from the motherboard speaker, for which the beep command issues a special character to a local tty, not producing any "real" sound using a sound card or actual driver.
If the default audio backends don't support it, it will get trickier of course.

Do I understand correctly: You propose routing all sound on the host via a pseudo-driver like snd-pcsp to the pcspkr and then creating a virtual sound device on the VM? This would result in:
Code:
VM beep command
-> VM tty
-> catch via virtual sound card and convert to sine wave
-> issue to host as sine wave
-> catch via snd_pcsp and convert to tty
-> issue to host tty
No, I just tried to give you more references on your initial idea, but didn't realize you can't use another audio backend.

I was hoping for:
Code:
VM beep command
-> VM tty
-> issue to host  tty
You need something in between. The host tty is of course isolated from the VM and for good security reasons. Maybe you can use one of the default audio backends and configure it to trigger the host's speaker somehow? But no idea.
 
@senthor did you find a solution to your issue? im in the same boat as you, dont want to use the ssh to run beep command on the host.

Code:
Available audio drivers:
none
alsa
dbus
oss
pa
spice
wav
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!