Allow to map sound playback and recording devices to host devices
using the:
<soundDevice playback='/dev/playback_dev'
recording='recording_dev'/>
element under '<sound>'.
Signed-off-by: Roman Bogorodskiy <bogorodskiy(a)gmail.com>
---
src/bhyve/bhyve_command.c | 13 +++++++++++--
tests/bhyvexml2argvdata/bhyvexml2argv-sound.args | 2 +-
tests/bhyvexml2argvdata/bhyvexml2argv-sound.xml | 4 +++-
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-sound.xml | 1 +
4 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index 64af0b3598..62109f2db3 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -481,6 +481,8 @@ bhyveBuildSoundArgStr(const virDomainDef *def G_GNUC_UNUSED,
bhyveConnPtr driver,
virCommandPtr cmd)
{
+ g_auto(virBuffer) params = VIR_BUFFER_INITIALIZER;
+
if (!(bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_SOUND_HDA)) {
/* Currently, bhyve only supports "hda" sound devices, so
if it's not supported, sound devices are not supported at all */
@@ -497,9 +499,16 @@ bhyveBuildSoundArgStr(const virDomainDef *def G_GNUC_UNUSED,
}
virCommandAddArg(cmd, "-s");
- virCommandAddArgFormat(cmd, "%d:%d,hda,play=/dev/dsp0",
+
+ if (sound->playback)
+ virBufferAsprintf(¶ms, ",play=%s", sound->playback);
+ if (sound->recording)
+ virBufferAsprintf(¶ms, ",rec=%s", sound->recording);
+
+ virCommandAddArgFormat(cmd, "%d:%d,hda%s",
sound->info.addr.pci.slot,
- sound->info.addr.pci.function);
+ sound->info.addr.pci.function,
+ virBufferCurrentContent(¶ms));
return 0;
}
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-sound.args
b/tests/bhyvexml2argvdata/bhyvexml2argv-sound.args
index c242708ff1..05ff4965dd 100644
--- a/tests/bhyvexml2argvdata/bhyvexml2argv-sound.args
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-sound.args
@@ -7,4 +7,4 @@
-s 0:0,hostbridge \
-s 2:0,ahci,hd:/tmp/freebsd.img \
-s 3:0,virtio-net,faketapdev,mac=52:54:00:b9:94:02 \
--s 4:0,hda,play=/dev/dsp0 bhyve
+-s 4:0,hda,play=/dev/dsp0,rec=/dev/dsp0 bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-sound.xml
b/tests/bhyvexml2argvdata/bhyvexml2argv-sound.xml
index dd4f0491a2..db6ebc51e3 100644
--- a/tests/bhyvexml2argvdata/bhyvexml2argv-sound.xml
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-sound.xml
@@ -19,6 +19,8 @@
<source bridge="virbr0"/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x03' function='0x0'/>
</interface>
- <sound model='ich6'/>
+ <sound model='ich6'>
+ <soundDevice playback="/dev/dsp0"
recording="/dev/dsp0"/>
+ </sound>
</devices>
</domain>
diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-sound.xml
b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-sound.xml
index f5da7c23c8..9c0007c827 100644
--- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-sound.xml
+++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-sound.xml
@@ -30,6 +30,7 @@
<address type='pci' domain='0x0000' bus='0x00'
slot='0x03' function='0x0'/>
</interface>
<sound model='ich6'>
+ <soundDevice playback='/dev/dsp0' recording='/dev/dsp0'/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x04' function='0x0'/>
</sound>
</devices>
--
2.27.0