In QEMU, the card itself is a PCI device, but it requires
-device hda-output in order to actually get sound to the host. AIUI this
is just HDA configuration and does not require stable addressing, so
is not presently represented in the XML.
Additionally, qemu supports audio input with '-device hda-duplex', however
that provides guests access to the host's microphone, so probably isn't
what we want by default.
---
docs/formatdomain.html.in | 5 +++--
docs/schemas/domain.rng | 1 +
src/conf/domain_conf.c | 3 ++-
src/conf/domain_conf.h | 1 +
src/qemu/qemu_command.c | 14 +++++++++++++-
.../qemuxml2argv-sound-device.args | 2 +-
.../qemuxml2argvdata/qemuxml2argv-sound-device.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-sound.args | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-sound.xml | 1 +
9 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index e9fcea1..8c43b74 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1663,8 +1663,9 @@ qemu-kvm -net nic,model=? /dev/null
The <code>sound</code> element has one mandatory attribute,
<code>model</code>, which specifies what real sound device is
emulated.
Valid values are specific to the underlying hypervisor, though typical
- choices are 'es1370', 'sb16', and 'ac97'
- (<span class="since">'ac97' only since
0.6.0</span>)
+ choices are 'es1370', 'sb16', 'ac97', and 'hda'
+ (<span class="since">
+ 'ac97' only since 0.6.0, 'hda' only since 0.8.8</span>)
</dd>
</dl>
diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index a524e4b..491a5a5 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -1489,6 +1489,7 @@
<value>es1370</value>
<value>pcspk</value>
<value>ac97</value>
+ <value>hda</value>
</choice>
</attribute>
<optional>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c857a89..992435d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -225,7 +225,8 @@ VIR_ENUM_IMPL(virDomainSoundModel, VIR_DOMAIN_SOUND_MODEL_LAST,
"sb16",
"es1370",
"pcspk",
- "ac97")
+ "ac97",
+ "hda")
VIR_ENUM_IMPL(virDomainMemballoonModel, VIR_DOMAIN_MEMBALLOON_MODEL_LAST,
"virtio",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index a459a22..d5ff9f3 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -458,6 +458,7 @@ enum virDomainSoundModel {
VIR_DOMAIN_SOUND_MODEL_ES1370,
VIR_DOMAIN_SOUND_MODEL_PCSPK,
VIR_DOMAIN_SOUND_MODEL_AC97,
+ VIR_DOMAIN_SOUND_MODEL_HDA,
VIR_DOMAIN_SOUND_MODEL_LAST
};
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 7dd8e03..2030455 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1726,11 +1726,13 @@ qemuBuildSoundDevStr(virDomainSoundDefPtr sound)
goto error;
}
- /* Hack for 2 wierdly unusal devices name in QEMU */
+ /* Hack for wierdly unusal devices name in QEMU */
if (STREQ(model, "es1370"))
model = "ES1370";
else if (STREQ(model, "ac97"))
model = "AC97";
+ else if (STREQ(model, "hda"))
+ model = "intel-hda";
virBufferVSprintf(&buf, "%s", model);
virBufferVSprintf(&buf, ",id=%s", sound->info.alias);
@@ -3750,6 +3752,14 @@ qemuBuildCommandLine(virConnectPtr conn,
goto error;
virCommandAddArg(cmd, str);
+
+ if (sound->model == VIR_DOMAIN_SOUND_MODEL_HDA) {
+ /* This is just an HDA codec, so doesn't require
+ * stable addressing AIUI */
+ virCommandAddArgList(cmd,
+ "-device", "hda-output",
NULL);
+ }
+
VIR_FREE(str);
}
}
@@ -5529,6 +5539,8 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps,
type = VIR_DOMAIN_SOUND_MODEL_ES1370;
} else if (STRPREFIX(start, "ac97")) {
type = VIR_DOMAIN_SOUND_MODEL_AC97;
+ } else if (STRPREFIX(start, "hda")) {
+ type = VIR_DOMAIN_SOUND_MODEL_HDA;
}
if (type != -1) {
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args
b/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args
index 6b2e697..6cd4b4a 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args
@@ -1 +1 @@
-LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214
-smp 1 -nographic -nodefconfig -nodefaults -monitor unix:/tmp/test-monitor,server,nowait
-no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -usb -soundhw pcspk -device
ES1370,id=sound1,bus=pci.0,addr=0x2 -device sb16,id=sound2 -device
AC97,id=sound3,bus=pci.0,addr=0x3 -device
virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214
-smp 1 -nographic -nodefconfig -nodefaults -monitor unix:/tmp/test-monitor,server,nowait
-no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -usb -soundhw pcspk -device
ES1370,id=sound1,bus=pci.0,addr=0x2 -device sb16,id=sound2 -device
AC97,id=sound3,bus=pci.0,addr=0x3 -device intel-hda,id=sound4,bus=pci.0,addr=0x4 -device
hda-output -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-sound-device.xml
b/tests/qemuxml2argvdata/qemuxml2argv-sound-device.xml
index c725346..f48c61e 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-sound-device.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-sound-device.xml
@@ -22,6 +22,7 @@
<sound model='es1370'/>
<sound model='sb16'/>
<sound model='ac97'/>
+ <sound model='hda'/>
<memballoon model='virtio'/>
</devices>
</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-sound.args
b/tests/qemuxml2argvdata/qemuxml2argv-sound.args
index 8cb2da2..0db62c3 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-sound.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-sound.args
@@ -1 +1 @@
-LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214
-smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -soundhw
pcspk,es1370,sb16,ac97
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214
-smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -soundhw
pcspk,es1370,sb16,ac97,hda
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-sound.xml
b/tests/qemuxml2argvdata/qemuxml2argv-sound.xml
index d34e0b3..c713d05 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-sound.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-sound.xml
@@ -24,6 +24,7 @@
<sound model='es1370'/>
<sound model='sb16'/>
<sound model='ac97'/>
+ <sound model='hda'/>
<memballoon model='virtio'/>
</devices>
</domain>
--
1.7.3.3