Skip to contentSkip to conversation

hw/audio: Remove legacy code related to '-soundhw hda'

PATCH In review Philippe Mathieu-Daudé 2 participants 7 messages Oct 21, 2025

lore
Share & tools
lore
#0 lore raw

cover hw/audio: Remove legacy code related to '-soundhw hda'

Few more patches following Marc-André cleanups, allowing to remove audio_register_model_with_cb().

Based-on: <[email protected]>

Philippe Mathieu-Daudé (3):
docs: Update mentions of removed '-soundhw' command line option hw/audio: Remove intel_hda_and_codec_init()
hw/audio: Remove unused audio_register_model_with_cb()

 docs/qdev-device-use.txt |  4 ++--
 include/hw/audio/model.h |  2 --
 hw/audio/intel-hda.c     | 23 -----------------------
 hw/audio/model.c         | 26 +++++++-------------------
 system/qdev-monitor.c    |  4 ++--
 5 files changed, 11 insertions(+), 48 deletions(-)
Signature · 1 line
2.51.0
#1 lore raw

PATCH 1/3 docs: Update mentions of removed '-soundhw' command line option

The -soundhw CLI was removed in commit 039a68373c4 ("introduce -audio as a replacement for -soundhw"). Remove outdated comments and update the document mentioning the old usage.

---
 docs/qdev-device-use.txt | 4 ++--
 system/qdev-monitor.c    | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
docs/qdev-device-use.txt +2 -2
index 043ae461140..fb420da2a9e 100644
@@ -311,9 +311,9 @@ constraints.
 
 Host and guest part of audio devices have always been separate.
 
-The old way to define guest audio devices is -soundhw C1,...
+The old way to define guest audio devices was -soundhw C1,...
 
-The new way is to define each guest audio device separately with
+The current way is to define each guest audio device separately with
 -device.
 
 Map from -soundhw sound card name to -device:
system/qdev-monitor.c +2 -2
index 4b732f579ad..5c95926aadd 100644
@@ -73,9 +73,9 @@ typedef struct QDevAlias
 
 /* Please keep this table sorted by typename. */
 static const QDevAlias qdev_alias_table[] = {
-    { "AC97", "ac97" }, /* -soundhw name */
+    { "AC97", "ac97" },
     { "e1000", "e1000-82540em" },
-    { "ES1370", "es1370" }, /* -soundhw name */
+    { "ES1370", "es1370" },
     { "ich9-ahci", "ahci" },
     { "lsi53c895a", "lsi" },
     { "virtio-9p-device", "virtio-9p", QEMU_ARCH_VIRTIO_MMIO },
Signature · 1 line
2.51.0
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] docs: Update mentions of removed '-soundhw' command line option

Hi

Quoted 6 lines · Philippe Mathieu-Daudé

The -soundhw CLI was removed in commit 039a68373c4 ("introduce -audio as a replacement for -soundhw"). Remove outdated comments and update the document mentioning the old usage.

I'll take it in my v2.

Quoted 41 lines
---
 docs/qdev-device-use.txt | 4 ++--
 system/qdev-monitor.c    | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
docs/qdev-device-use.txt +2 -2
index 043ae461140..fb420da2a9e 100644
@@ -311,9 +311,9 @@ constraints.
 
 Host and guest part of audio devices have always been separate.
 
-The old way to define guest audio devices is -soundhw C1,...
+The old way to define guest audio devices was -soundhw C1,...
 
-The new way is to define each guest audio device separately with
+The current way is to define each guest audio device separately with
 -device.
 
 Map from -soundhw sound card name to -device:
system/qdev-monitor.c +2 -3
index 4b732f579ad..5c95926aadd 100644
@@ -73,9 +73,9 @@ typedef struct QDevAlias
 
 /* Please keep this table sorted by typename. */
 static const QDevAlias qdev_alias_table[] = {
-    { "AC97", "ac97" }, /* -soundhw name */
+    { "AC97", "ac97" },
     { "e1000", "e1000-82540em" },
-    { "ES1370", "es1370" }, /* -soundhw name */
+    { "ES1370", "es1370" },
     { "ich9-ahci", "ahci" },
     { "lsi53c895a", "lsi" },
     { "virtio-9p-device", "virtio-9p", QEMU_ARCH_VIRTIO_MMIO },
--

2.51.0

#3 lore raw

PATCH 2/3 hw/audio: Remove intel_hda_and_codec_init()

In reply to Philippe Mathieu-Daudé

-soundhw hda was removed in commit 039a68373c4 ("introduce -audio as a replacement for -soundhw").

---
 hw/audio/intel-hda.c | 23 -----------------------
 1 file changed, 23 deletions(-)
hw/audio/intel-hda.c +0 -23
index 0d35afa4ab4..83bb7e597db 100644
@@ -1301,28 +1301,6 @@ static const TypeInfo hda_codec_device_type_info = {
     .class_init = hda_codec_device_class_init,
 };
 
-/*
- * create intel hda controller with codec attached to it,
- * so '-soundhw hda' works.
- */
-static int intel_hda_and_codec_init(const char *audiodev)
-{
-    g_autoptr(QDict) props = qdict_new();
-    DeviceState *intel_hda, *codec;
-    BusState *hdabus;
-
-    qdict_put_str(props, "driver", "intel-hda");
-    intel_hda = qdev_device_add_from_qdict(props, false, &error_fatal);
-    hdabus = QLIST_FIRST(&intel_hda->child_bus);
-
-    codec = qdev_new("hda-duplex");
-    qdev_prop_set_string(codec, "audiodev", audiodev);
-    qdev_realize_and_unref(codec, hdabus, &error_fatal);
-    object_unref(intel_hda);
-
-    return 0;
-}
-
 static void intel_hda_register_types(void)
 {
     type_register_static(&hda_codec_bus_info);
@@ -1330,7 +1308,6 @@ static void intel_hda_register_types(void)
     type_register_static(&intel_hda_info_ich6);
     type_register_static(&intel_hda_info_ich9);
     type_register_static(&hda_codec_device_type_info);
-    audio_register_model_with_cb("hda", "Intel HD Audio", intel_hda_and_codec_init);
 }
 
 type_init(intel_hda_register_types)
Signature · 1 line
2.51.0
#4 lore raw

Re: [PATCH 2/3] hw/audio: Remove intel_hda_and_codec_init()

Hi

Quoted 4 lines · Philippe Mathieu-Daudé

-soundhw hda was removed in commit 039a68373c4 ("introduce -audio as a replacement for -soundhw").

Sorry, that "hda" (= intel-hda + hda-duplex) short form is used by -audio.

Quoted 51 lines
---
 hw/audio/intel-hda.c | 23 -----------------------
 1 file changed, 23 deletions(-)
hw/audio/intel-hda.c +0 -23
index 0d35afa4ab4..83bb7e597db 100644
@@ -1301,28 +1301,6 @@ static const TypeInfo hda_codec_device_type_info = {
     .class_init = hda_codec_device_class_init,
 };
 
-/*
- * create intel hda controller with codec attached to it,
- * so '-soundhw hda' works.
- */
-static int intel_hda_and_codec_init(const char *audiodev)
-{
-    g_autoptr(QDict) props = qdict_new();
-    DeviceState *intel_hda, *codec;
-    BusState *hdabus;
-
-    qdict_put_str(props, "driver", "intel-hda");
-    intel_hda = qdev_device_add_from_qdict(props, false, &error_fatal);
-    hdabus = QLIST_FIRST(&intel_hda->child_bus);
-
-    codec = qdev_new("hda-duplex");
-    qdev_prop_set_string(codec, "audiodev", audiodev);
-    qdev_realize_and_unref(codec, hdabus, &error_fatal);
-    object_unref(intel_hda);
-
-    return 0;
-}
-
 static void intel_hda_register_types(void)
 {
     type_register_static(&hda_codec_bus_info);
@@ -1330,7 +1308,6 @@ static void intel_hda_register_types(void)
     type_register_static(&intel_hda_info_ich6);
     type_register_static(&intel_hda_info_ich9);
     type_register_static(&hda_codec_device_type_info);
-    audio_register_model_with_cb("hda", "Intel HD Audio",
 intel_hda_and_codec_init);
 }
 

type_init(intel_hda_register_types)
--
2.51.0

#5 lore raw

Re: [PATCH 2/3] hw/audio: Remove intel_hda_and_codec_init()

Quoted 9 lines · Marc-André Lureau

Hi

On Tue, Oct 21, 2025 at 5:18 PM Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:

-soundhw hda was removed in commit 039a68373c4 ("introduce -audio as a replacement for -soundhw").

Sorry, that "hda" (= intel-hda + hda-duplex) short form is used by -audio.

Yes, it was deprecated for 2 releases but we missed to remove it in commit 039a68373c4:

-- >8 --

hw/audio/intel-hda.c +2 -3
index bc77e3d8c9d..f38117057b9 100644
@@ -1311,17 +1311,16 @@ static const TypeInfo hda_codec_device_type_info = {
  * create intel hda controller with codec attached to it,
  * so '-soundhw hda' works.
  */
-static int intel_hda_and_codec_init(PCIBus *bus)
+static int intel_hda_and_codec_init(PCIBus *bus, const char *audiodev)
 {
     DeviceState *controller;
     BusState *hdabus;
     DeviceState *codec;
 
-    warn_report("'-soundhw hda' is deprecated, "
-                "please use '-device intel-hda -device hda-duplex' instead");
     controller = DEVICE(pci_create_simple(bus, -1, "intel-hda"));
     hdabus = QLIST_FIRST(&controller->child_bus);
     codec = qdev_new("hda-duplex");
+    qdev_prop_set_string(codec, "audiodev", audiodev);
     qdev_realize_and_unref(codec, hdabus, &error_fatal);
     return 0;
 }

---

Users should be now using "-device intel-hda -device hda-duplex" instead of "-audio hda".

#6 lore raw

PATCH 3/3 hw/audio: Remove unused audio_register_model_with_cb()

In reply to Philippe Mathieu-Daudé

We remove the last use of audio_register_model_with_cb(), remove it as not needed anymore, simplifying audio_model_init().

---
 include/hw/audio/model.h |  2 --
 hw/audio/model.c         | 26 +++++++-------------------
 2 files changed, 7 insertions(+), 21 deletions(-)
include/hw/audio/model.h +0 -2
index ebe456c22ff..b812c9211a0 100644
@@ -1,8 +1,6 @@
 #ifndef HW_AUDIO_MODEL_H
 #define HW_AUDIO_MODEL_H
 
-void audio_register_model_with_cb(const char *name, const char *descr,
-                                  int (*init_audio_model)(const char *audiodev));
 void audio_register_model(const char *name, const char *descr,
                           const char *typename);
 
hw/audio/model.c +7 -19
index 924a41e0ac9..d1e00b4eaa4 100644
@@ -34,22 +34,11 @@ struct audio_model {
     const char *name;
     const char *descr;
     const char *typename;
-    int (*init)(const char *audiodev);
 };
 
 static struct audio_model audio_models[9];
 static int audio_models_count;
 
-void audio_register_model_with_cb(const char *name, const char *descr,
-                                  int (*init_audio_model)(const char *audiodev))
-{
-    assert(audio_models_count < ARRAY_SIZE(audio_models) - 1);
-    audio_models[audio_models_count].name = name;
-    audio_models[audio_models_count].descr = descr;
-    audio_models[audio_models_count].init = init_audio_model;
-    audio_models_count++;
-}
-
 void audio_register_model(const char *name, const char *descr,
                           const char *typename)
 {
@@ -105,17 +94,16 @@ void audio_set_model(const char *name, const char *audiodev)
 void audio_model_init(void)
 {
     struct audio_model *c = selected;
+    DeviceState *dev;
+    BusState *bus;
 
     if (!c) {
         return;
     }
 
-    if (c->typename) {
-        DeviceState *dev = qdev_new(c->typename);
-        BusState *bus = qdev_find_default_bus(DEVICE_GET_CLASS(dev), &error_fatal);
-        qdev_prop_set_string(dev, "audiodev", audiodev_id);
-        qdev_realize_and_unref(dev, bus, &error_fatal);
-    } else {
-        c->init(audiodev_id);
-    }
+    g_assert(c->typename);
+    dev = qdev_new(c->typename);
+    bus = qdev_find_default_bus(DEVICE_GET_CLASS(dev), &error_fatal);
+    qdev_prop_set_string(dev, "audiodev", audiodev_id);
+    qdev_realize_and_unref(dev, bus, &error_fatal);
 }
Signature · 1 line
2.51.0