43fe83
From bc76fb17caf756582784cf9a0fbae2a0956ec3c5 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <bc76fb17caf756582784cf9a0fbae2a0956ec3c5.1380703761.git.jdenemar@redhat.com>
43fe83
From: Laine Stump <laine@laine.org>
43fe83
Date: Fri, 27 Sep 2013 05:19:43 -0600
43fe83
Subject: [PATCH] qemu: support ich9-intel-hda audio device
43fe83
43fe83
This resolves one of the issues in:
43fe83
43fe83
   https://bugzilla.redhat.com/show_bug.cgi?id=1003983
43fe83
43fe83
This device is identical to qemu's "intel-hda" device (known as "ich6"
43fe83
in libvirt), but has a different PCI device ID (which matches the ID
43fe83
of the hda audio built into the ich9 chipset, of course). It's not
43fe83
supported in earlier versions of qemu, so it requires a capability
43fe83
bit.
43fe83
43fe83
(cherry picked from commit b83d26f6c434f80c71a2a7a0823b1ec16b798ca3)
43fe83
43fe83
Conflicts:
43fe83
	src/qemu/qemu_capabilities.c
43fe83
	src/qemu/qemu_capabilities.h
43fe83
43fe83
        There were a few other capabilities added upstream that
43fe83
        haven't yet been added to the RHEL7 branch; these caused a
43fe83
        mismatch in the capabilities enum.
43fe83
43fe83
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
43fe83
---
43fe83
 docs/schemas/domaincommon.rng                         |  1 +
43fe83
 src/conf/domain_conf.c                                |  6 ++++--
43fe83
 src/conf/domain_conf.h                                |  1 +
43fe83
 src/qemu/qemu_capabilities.c                          |  2 ++
43fe83
 src/qemu/qemu_capabilities.h                          |  1 +
43fe83
 src/qemu/qemu_command.c                               | 16 ++++++++++++++--
43fe83
 tests/qemuxml2argvdata/qemuxml2argv-sound-device.args |  7 ++++++-
43fe83
 tests/qemuxml2argvdata/qemuxml2argv-sound-device.xml  |  5 +++++
43fe83
 tests/qemuxml2argvtest.c                              |  3 ++-
43fe83
 9 files changed, 36 insertions(+), 6 deletions(-)
43fe83
43fe83
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
43fe83
index dfcd61c..838f657 100644
43fe83
--- a/docs/schemas/domaincommon.rng
43fe83
+++ b/docs/schemas/domaincommon.rng
43fe83
@@ -2896,6 +2896,7 @@
43fe83
           <value>pcspk</value>
43fe83
           <value>ac97</value>
43fe83
           <value>ich6</value>
43fe83
+          <value>ich9</value>
43fe83
         </choice>
43fe83
       </attribute>
43fe83
       <interleave>
43fe83
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
43fe83
index c391eae..bca2151 100644
43fe83
--- a/src/conf/domain_conf.c
43fe83
+++ b/src/conf/domain_conf.c
43fe83
@@ -455,7 +455,8 @@ VIR_ENUM_IMPL(virDomainSoundModel, VIR_DOMAIN_SOUND_MODEL_LAST,
43fe83
               "es1370",
43fe83
               "pcspk",
43fe83
               "ac97",
43fe83
-              "ich6")
43fe83
+              "ich6",
43fe83
+              "ich9")
43fe83
 
43fe83
 VIR_ENUM_IMPL(virDomainMemDump, VIR_DOMAIN_MEM_DUMP_LAST,
43fe83
               "default",
43fe83
@@ -8397,7 +8398,8 @@ virDomainSoundDefParseXML(const xmlNodePtr node,
43fe83
         goto error;
43fe83
     }
43fe83
 
43fe83
-    if (def->model == VIR_DOMAIN_SOUND_MODEL_ICH6) {
43fe83
+    if (def->model == VIR_DOMAIN_SOUND_MODEL_ICH6 ||
43fe83
+        def->model == VIR_DOMAIN_SOUND_MODEL_ICH9) {
43fe83
         int ncodecs;
43fe83
         xmlNodePtr *codecNodes = NULL;
43fe83
 
43fe83
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
43fe83
index b9e9600..5d2cb83 100644
43fe83
--- a/src/conf/domain_conf.h
43fe83
+++ b/src/conf/domain_conf.h
43fe83
@@ -1237,6 +1237,7 @@ enum virDomainSoundModel {
43fe83
     VIR_DOMAIN_SOUND_MODEL_PCSPK,
43fe83
     VIR_DOMAIN_SOUND_MODEL_AC97,
43fe83
     VIR_DOMAIN_SOUND_MODEL_ICH6,
43fe83
+    VIR_DOMAIN_SOUND_MODEL_ICH9,
43fe83
 
43fe83
     VIR_DOMAIN_SOUND_MODEL_LAST
43fe83
 };
43fe83
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
43fe83
index 47cc07a..9b1d9f5 100644
43fe83
--- a/src/qemu/qemu_capabilities.c
43fe83
+++ b/src/qemu/qemu_capabilities.c
43fe83
@@ -235,6 +235,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
43fe83
               "vnc-share-policy", /* 150 */
43fe83
               "device-del-event",
43fe83
               "dmi-to-pci-bridge",
43fe83
+              "ich9-intel-hda",
43fe83
     );
43fe83
 
43fe83
 struct _virQEMUCaps {
43fe83
@@ -1383,6 +1384,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
43fe83
     { "vfio-pci", QEMU_CAPS_DEVICE_VFIO_PCI },
43fe83
     { "scsi-generic", QEMU_CAPS_DEVICE_SCSI_GENERIC },
43fe83
     { "i82801b11-bridge", QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE },
43fe83
+    { "ich9-intel-hda", QEMU_CAPS_DEVICE_ICH9_INTEL_HDA },
43fe83
 };
43fe83
 
43fe83
 static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = {
43fe83
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
43fe83
index 074e55d..c992dcb 100644
43fe83
--- a/src/qemu/qemu_capabilities.h
43fe83
+++ b/src/qemu/qemu_capabilities.h
43fe83
@@ -191,6 +191,7 @@ enum virQEMUCapsFlags {
43fe83
     QEMU_CAPS_VNC_SHARE_POLICY   = 150, /* set display sharing policy */
43fe83
     QEMU_CAPS_DEVICE_DEL_EVENT   = 151, /* DEVICE_DELETED event */
43fe83
     QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE  = 152, /* -device i82801b11-bridge */
43fe83
+    QEMU_CAPS_DEVICE_ICH9_INTEL_HDA = 153, /* -device ich9-intel-hda */
43fe83
 
43fe83
     QEMU_CAPS_LAST,                   /* this must always be the last item */
43fe83
 };
43fe83
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
43fe83
index 8b03470..2de7678 100644
43fe83
--- a/src/qemu/qemu_command.c
43fe83
+++ b/src/qemu/qemu_command.c
43fe83
@@ -1758,6 +1758,7 @@ qemuCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
43fe83
     case VIR_DOMAIN_DEVICE_SOUND:
43fe83
         switch (device->data.sound->model) {
43fe83
         case VIR_DOMAIN_SOUND_MODEL_ICH6:
43fe83
+        case VIR_DOMAIN_SOUND_MODEL_ICH9:
43fe83
             flags = (QEMU_PCI_CONNECT_TYPE_PCI |
43fe83
                      QEMU_PCI_CONNECT_TYPE_EITHER_IF_CONFIG);
43fe83
             break;
43fe83
@@ -5142,6 +5143,15 @@ qemuBuildSoundDevStr(virDomainDefPtr def,
43fe83
     case VIR_DOMAIN_SOUND_MODEL_ICH6:
43fe83
         model = "intel-hda";
43fe83
         break;
43fe83
+    case VIR_DOMAIN_SOUND_MODEL_ICH9:
43fe83
+        model = "ich9-intel-hda";
43fe83
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_ICH9_INTEL_HDA)) {
43fe83
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
43fe83
+                           _("The ich9-intel-hda audio controller "
43fe83
+                             "is not supported in this QEMU binary"));
43fe83
+            goto error;
43fe83
+        }
43fe83
+        break;
43fe83
     }
43fe83
 
43fe83
     virBufferAsprintf(&buf, "%s,id=%s", model, sound->info.alias);
43fe83
@@ -8866,7 +8876,8 @@ qemuBuildCommandLine(virConnectPtr conn,
43fe83
 
43fe83
                     virCommandAddArg(cmd, str);
43fe83
 
43fe83
-                    if (sound->model == VIR_DOMAIN_SOUND_MODEL_ICH6) {
43fe83
+                    if (sound->model == VIR_DOMAIN_SOUND_MODEL_ICH6 ||
43fe83
+                        sound->model == VIR_DOMAIN_SOUND_MODEL_ICH9) {
43fe83
                         char *codecstr = NULL;
43fe83
 
43fe83
                         for (j = 0; j < sound->ncodecs; j++) {
43fe83
@@ -8912,7 +8923,8 @@ qemuBuildCommandLine(virConnectPtr conn,
43fe83
                     goto error;
43fe83
                 }
43fe83
 
43fe83
-                if (sound->model == VIR_DOMAIN_SOUND_MODEL_ICH6) {
43fe83
+                if (sound->model == VIR_DOMAIN_SOUND_MODEL_ICH6 ||
43fe83
+                    sound->model == VIR_DOMAIN_SOUND_MODEL_ICH9) {
43fe83
                     VIR_FREE(modstr);
43fe83
                     virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
43fe83
                                    _("this QEMU binary lacks hda support"));
43fe83
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args b/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args
43fe83
index 7c5f05c..997e458 100644
43fe83
--- a/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args
43fe83
+++ b/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args
43fe83
@@ -8,4 +8,9 @@ id=sound4-codec0,bus=sound4.0,cad=0 \
43fe83
 -device intel-hda,id=sound5,bus=pci.0,addr=0x6 \
43fe83
 -device hda-micro,id=sound5-codec0,bus=sound5.0,cad=0 \
43fe83
 -device hda-duplex,id=sound5-codec1,bus=sound5.0,cad=1 \
43fe83
--device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x7
43fe83
+-device ich9-intel-hda,id=sound6,bus=pci.0,addr=0x7 -device hda-duplex,\
43fe83
+id=sound6-codec0,bus=sound6.0,cad=0 \
43fe83
+-device ich9-intel-hda,id=sound7,bus=pci.0,addr=0x8 \
43fe83
+-device hda-micro,id=sound7-codec0,bus=sound7.0,cad=0 \
43fe83
+-device hda-duplex,id=sound7-codec1,bus=sound7.0,cad=1 \
43fe83
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x9
43fe83
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-sound-device.xml b/tests/qemuxml2argvdata/qemuxml2argv-sound-device.xml
43fe83
index 7bf9ff9..8ce718e 100644
43fe83
--- a/tests/qemuxml2argvdata/qemuxml2argv-sound-device.xml
43fe83
+++ b/tests/qemuxml2argvdata/qemuxml2argv-sound-device.xml
43fe83
@@ -31,6 +31,11 @@
43fe83
       <codec type='micro'/>
43fe83
       <codec type='duplex'/>
43fe83
     </sound>
43fe83
+    <sound model='ich9'/>
43fe83
+    <sound model='ich9'>
43fe83
+      <codec type='micro'/>
43fe83
+      <codec type='duplex'/>
43fe83
+    </sound>
43fe83
     <memballoon model='virtio'/>
43fe83
   </devices>
43fe83
 </domain>
43fe83
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
43fe83
index aa43145..23ea2ee 100644
43fe83
--- a/tests/qemuxml2argvtest.c
43fe83
+++ b/tests/qemuxml2argvtest.c
43fe83
@@ -841,7 +841,8 @@ mymain(void)
43fe83
     DO_TEST("sound", NONE);
43fe83
     DO_TEST("sound-device",
43fe83
             QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
43fe83
-            QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_HDA_MICRO);
43fe83
+            QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_HDA_MICRO,
43fe83
+            QEMU_CAPS_DEVICE_ICH9_INTEL_HDA);
43fe83
     DO_TEST("fs9p",
43fe83
             QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_FSDEV,
43fe83
             QEMU_CAPS_FSDEV_WRITEOUT);
43fe83
-- 
43fe83
1.8.3.2
43fe83