mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
bhyve: allow to specify host sound device
Allow to map sound playback and recording devices to host devices using "<audio type='oss'/>" OSS audio backend. Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
9375bc7373
commit
26a13ec469
@ -478,9 +478,12 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def,
|
|||||||
static int
|
static int
|
||||||
bhyveBuildSoundArgStr(const virDomainDef *def G_GNUC_UNUSED,
|
bhyveBuildSoundArgStr(const virDomainDef *def G_GNUC_UNUSED,
|
||||||
virDomainSoundDefPtr sound,
|
virDomainSoundDefPtr sound,
|
||||||
|
virDomainAudioDefPtr audio,
|
||||||
bhyveConnPtr driver,
|
bhyveConnPtr driver,
|
||||||
virCommandPtr cmd)
|
virCommandPtr cmd)
|
||||||
{
|
{
|
||||||
|
g_auto(virBuffer) params = VIR_BUFFER_INITIALIZER;
|
||||||
|
|
||||||
if (!(bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_SOUND_HDA)) {
|
if (!(bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_SOUND_HDA)) {
|
||||||
/* Currently, bhyve only supports "hda" sound devices, so
|
/* Currently, bhyve only supports "hda" sound devices, so
|
||||||
if it's not supported, sound devices are not supported at all */
|
if it's not supported, sound devices are not supported at all */
|
||||||
@ -497,9 +500,33 @@ bhyveBuildSoundArgStr(const virDomainDef *def G_GNUC_UNUSED,
|
|||||||
}
|
}
|
||||||
|
|
||||||
virCommandAddArg(cmd, "-s");
|
virCommandAddArg(cmd, "-s");
|
||||||
virCommandAddArgFormat(cmd, "%d:%d,hda,play=/dev/dsp0",
|
|
||||||
|
if (audio) {
|
||||||
|
switch ((virDomainAudioType) audio->type) {
|
||||||
|
case VIR_DOMAIN_AUDIO_TYPE_OSS:
|
||||||
|
if (audio->backend.oss.inputDev)
|
||||||
|
virBufferAsprintf(¶ms, ",play=%s",
|
||||||
|
audio->backend.oss.inputDev);
|
||||||
|
|
||||||
|
if (audio->backend.oss.outputDev)
|
||||||
|
virBufferAsprintf(¶ms, ",rec=%s",
|
||||||
|
audio->backend.oss.outputDev);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_AUDIO_TYPE_LAST:
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("unsupported audio backend '%s'"),
|
||||||
|
virDomainAudioTypeTypeToString(audio->type));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virCommandAddArgFormat(cmd, "%d:%d,hda%s",
|
||||||
sound->info.addr.pci.slot,
|
sound->info.addr.pci.slot,
|
||||||
sound->info.addr.pci.function);
|
sound->info.addr.pci.function,
|
||||||
|
virBufferCurrentContent(¶ms));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -648,7 +675,9 @@ virBhyveProcessBuildBhyveCmd(bhyveConnPtr driver, virDomainDefPtr def,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < def->nsounds; i++) {
|
for (i = 0; i < def->nsounds; i++) {
|
||||||
if (bhyveBuildSoundArgStr(def, def->sounds[i], driver, cmd) < 0)
|
if (bhyveBuildSoundArgStr(def, def->sounds[i],
|
||||||
|
virDomainDefFindAudioForSound(def, def->sounds[i]),
|
||||||
|
driver, cmd) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31493,6 +31493,19 @@ virDomainDefFindDevice(virDomainDefPtr def,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virDomainAudioDefPtr
|
||||||
|
virDomainDefFindAudioForSound(virDomainDefPtr def,
|
||||||
|
virDomainSoundDefPtr sound)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; i < def->naudios; i++)
|
||||||
|
if (def->audios[i]->id == sound->audioId)
|
||||||
|
return def->audios[i];
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
virDomainObjGetMetadata(virDomainObjPtr vm,
|
virDomainObjGetMetadata(virDomainObjPtr vm,
|
||||||
int type,
|
int type,
|
||||||
|
@ -3712,6 +3712,10 @@ int virDomainDefFindDevice(virDomainDefPtr def,
|
|||||||
virDomainDeviceDefPtr dev,
|
virDomainDeviceDefPtr dev,
|
||||||
bool reportError);
|
bool reportError);
|
||||||
|
|
||||||
|
virDomainAudioDefPtr
|
||||||
|
virDomainDefFindAudioForSound(virDomainDefPtr def,
|
||||||
|
virDomainSoundDefPtr sound);
|
||||||
|
|
||||||
const char *virDomainChrSourceDefGetPath(virDomainChrSourceDefPtr chr);
|
const char *virDomainChrSourceDefGetPath(virDomainChrSourceDefPtr chr);
|
||||||
|
|
||||||
void virDomainChrSourceDefClear(virDomainChrSourceDefPtr def);
|
void virDomainChrSourceDefClear(virDomainChrSourceDefPtr def);
|
||||||
|
@ -298,6 +298,7 @@ virDomainDefCheckABIStability;
|
|||||||
virDomainDefCheckABIStabilityFlags;
|
virDomainDefCheckABIStabilityFlags;
|
||||||
virDomainDefCompatibleDevice;
|
virDomainDefCompatibleDevice;
|
||||||
virDomainDefCopy;
|
virDomainDefCopy;
|
||||||
|
virDomainDefFindAudioForSound;
|
||||||
virDomainDefFindDevice;
|
virDomainDefFindDevice;
|
||||||
virDomainDefFormat;
|
virDomainDefFormat;
|
||||||
virDomainDefFormatConvertXMLFlags;
|
virDomainDefFormatConvertXMLFlags;
|
||||||
|
@ -7,4 +7,4 @@
|
|||||||
-s 0:0,hostbridge \
|
-s 0:0,hostbridge \
|
||||||
-s 2:0,ahci,hd:/tmp/freebsd.img \
|
-s 2:0,ahci,hd:/tmp/freebsd.img \
|
||||||
-s 3:0,virtio-net,faketapdev,mac=52:54:00:b9:94:02 \
|
-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
|
||||||
|
@ -19,6 +19,12 @@
|
|||||||
<source bridge="virbr0"/>
|
<source bridge="virbr0"/>
|
||||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
|
||||||
</interface>
|
</interface>
|
||||||
<sound model='ich7'/>
|
<sound model='ich7'>
|
||||||
|
<audio id="1"/>
|
||||||
|
</sound>
|
||||||
|
<audio type="oss" id="1">
|
||||||
|
<input dev="/dev/dsp0"/>
|
||||||
|
<output dev="/dev/dsp0"/>
|
||||||
|
</audio>
|
||||||
</devices>
|
</devices>
|
||||||
</domain>
|
</domain>
|
||||||
|
@ -30,7 +30,12 @@
|
|||||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
|
||||||
</interface>
|
</interface>
|
||||||
<sound model='ich7'>
|
<sound model='ich7'>
|
||||||
|
<audio id='1'/>
|
||||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
|
||||||
</sound>
|
</sound>
|
||||||
|
<audio id='1' type='oss'>
|
||||||
|
<input dev='/dev/dsp0'/>
|
||||||
|
<output dev='/dev/dsp0'/>
|
||||||
|
</audio>
|
||||||
</devices>
|
</devices>
|
||||||
</domain>
|
</domain>
|
||||||
|
Loading…
Reference in New Issue
Block a user