[PATCH 4/6] qemu: support ich9-intel-hda audio device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This resolves one of the issues in:

   https://bugzilla.redhat.com/show_bug.cgi?id=1003983

This device is identical to qemu's "intel-hda" device (known as "ich6"
in libvirt), but has a different PCI device ID (which matches the ID
of the hda audio built into the ich9 chipset, of course). It's not
supported int earlier versions of qemu, so it requires a capability
bit.
---
 docs/schemas/domaincommon.rng                         |  1 +
 src/conf/domain_conf.c                                |  6 ++++--
 src/conf/domain_conf.h                                |  1 +
 src/qemu/qemu_capabilities.c                          |  2 ++
 src/qemu/qemu_capabilities.h                          |  1 +
 src/qemu/qemu_command.c                               | 16 ++++++++++++++--
 tests/qemuxml2argvdata/qemuxml2argv-sound-device.args |  7 ++++++-
 tests/qemuxml2argvdata/qemuxml2argv-sound-device.xml  |  5 +++++
 tests/qemuxml2argvtest.c                              |  3 ++-
 9 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index fb6a26c..5c5301d 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2947,6 +2947,7 @@
           <value>pcspk</value>
           <value>ac97</value>
           <value>ich6</value>
+          <value>ich9</value>
         </choice>
       </attribute>
       <interleave>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 240f318..4110127 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -462,7 +462,8 @@ VIR_ENUM_IMPL(virDomainSoundModel, VIR_DOMAIN_SOUND_MODEL_LAST,
               "es1370",
               "pcspk",
               "ac97",
-              "ich6")
+              "ich6",
+              "ich9")
 
 VIR_ENUM_IMPL(virDomainMemDump, VIR_DOMAIN_MEM_DUMP_LAST,
               "default",
@@ -8451,7 +8452,8 @@ virDomainSoundDefParseXML(const xmlNodePtr node,
         goto error;
     }
 
-    if (def->model == VIR_DOMAIN_SOUND_MODEL_ICH6) {
+    if (def->model == VIR_DOMAIN_SOUND_MODEL_ICH6 ||
+        def->model == VIR_DOMAIN_SOUND_MODEL_ICH9) {
         int ncodecs;
         xmlNodePtr *codecNodes = NULL;
 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 5c33e08..f20a916 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1253,6 +1253,7 @@ enum virDomainSoundModel {
     VIR_DOMAIN_SOUND_MODEL_PCSPK,
     VIR_DOMAIN_SOUND_MODEL_AC97,
     VIR_DOMAIN_SOUND_MODEL_ICH6,
+    VIR_DOMAIN_SOUND_MODEL_ICH9,
 
     VIR_DOMAIN_SOUND_MODEL_LAST
 };
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index d830e2a..dc8f0be 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -241,6 +241,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
               "usb-storage", /* 155 */
               "usb-storage.removable",
               "virtio-mmio",
+              "ich9-intel-hda",
     );
 
 struct _virQEMUCaps {
@@ -1391,6 +1392,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
     { "i82801b11-bridge", QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE },
     { "usb-storage", QEMU_CAPS_DEVICE_USB_STORAGE },
     { "virtio-mmio", QEMU_CAPS_DEVICE_VIRTIO_MMIO },
+    { "ich9-intel-hda", QEMU_CAPS_DEVICE_ICH9_INTEL_HDA },
 };
 
 static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index f3c8fa8..f8dc728 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -196,6 +196,7 @@ enum virQEMUCapsFlags {
     QEMU_CAPS_DEVICE_USB_STORAGE = 155, /* -device usb-storage */
     QEMU_CAPS_USB_STORAGE_REMOVABLE = 156, /* usb-storage.removable */
     QEMU_CAPS_DEVICE_VIRTIO_MMIO = 157, /* -device virtio-mmio */
+    QEMU_CAPS_DEVICE_ICH9_INTEL_HDA = 158, /* -device ich9-intel-hda */
 
     QEMU_CAPS_LAST,                   /* this must always be the last item */
 };
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 3156cff..c8a5c8b 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1800,6 +1800,7 @@ qemuCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
     case VIR_DOMAIN_DEVICE_SOUND:
         switch (device->data.sound->model) {
         case VIR_DOMAIN_SOUND_MODEL_ICH6:
+        case VIR_DOMAIN_SOUND_MODEL_ICH9:
             flags = (QEMU_PCI_CONNECT_TYPE_PCI |
                      QEMU_PCI_CONNECT_TYPE_EITHER_IF_CONFIG);
             break;
@@ -5280,6 +5281,15 @@ qemuBuildSoundDevStr(virDomainDefPtr def,
     case VIR_DOMAIN_SOUND_MODEL_ICH6:
         model = "intel-hda";
         break;
+    case VIR_DOMAIN_SOUND_MODEL_ICH9:
+        model = "ich9-intel-hda";
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_ICH9_INTEL_HDA)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("The ich9-intel-hda audio controller "
+                             "is not supported in this QEMU binary"));
+            goto error;
+        }
+        break;
     }
 
     virBufferAsprintf(&buf, "%s,id=%s", model, sound->info.alias);
@@ -9065,7 +9075,8 @@ qemuBuildCommandLine(virConnectPtr conn,
 
                     virCommandAddArg(cmd, str);
 
-                    if (sound->model == VIR_DOMAIN_SOUND_MODEL_ICH6) {
+                    if (sound->model == VIR_DOMAIN_SOUND_MODEL_ICH6 ||
+                        sound->model == VIR_DOMAIN_SOUND_MODEL_ICH9) {
                         char *codecstr = NULL;
 
                         for (j = 0; j < sound->ncodecs; j++) {
@@ -9111,7 +9122,8 @@ qemuBuildCommandLine(virConnectPtr conn,
                     goto error;
                 }
 
-                if (sound->model == VIR_DOMAIN_SOUND_MODEL_ICH6) {
+                if (sound->model == VIR_DOMAIN_SOUND_MODEL_ICH6 ||
+                    sound->model == VIR_DOMAIN_SOUND_MODEL_ICH9) {
                     VIR_FREE(modstr);
                     virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                                    _("this QEMU binary lacks hda support"));
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args b/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args
index d358453..1511389 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args
@@ -9,4 +9,9 @@ id=sound4-codec0,bus=sound4.0,cad=0 \
 -device intel-hda,id=sound5,bus=pci.0,addr=0x6 \
 -device hda-micro,id=sound5-codec0,bus=sound5.0,cad=0 \
 -device hda-duplex,id=sound5-codec1,bus=sound5.0,cad=1 \
--device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x7
+-device ich9-intel-hda,id=sound6,bus=pci.0,addr=0x7 -device hda-duplex,\
+id=sound6-codec0,bus=sound6.0,cad=0 \
+-device ich9-intel-hda,id=sound7,bus=pci.0,addr=0x8 \
+-device hda-micro,id=sound7-codec0,bus=sound7.0,cad=0 \
+-device hda-duplex,id=sound7-codec1,bus=sound7.0,cad=1 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x9
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-sound-device.xml b/tests/qemuxml2argvdata/qemuxml2argv-sound-device.xml
index 7bf9ff9..8ce718e 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-sound-device.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-sound-device.xml
@@ -31,6 +31,11 @@
       <codec type='micro'/>
       <codec type='duplex'/>
     </sound>
+    <sound model='ich9'/>
+    <sound model='ich9'>
+      <codec type='micro'/>
+      <codec type='duplex'/>
+    </sound>
     <memballoon model='virtio'/>
   </devices>
 </domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index ec4a6e5..0b808a4 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -855,7 +855,8 @@ mymain(void)
     DO_TEST("sound", NONE);
     DO_TEST("sound-device",
             QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
-            QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_HDA_MICRO);
+            QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_HDA_MICRO,
+            QEMU_CAPS_DEVICE_ICH9_INTEL_HDA);
     DO_TEST("fs9p",
             QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_FSDEV,
             QEMU_CAPS_FSDEV_WRITEOUT);
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]