audio/spice: convert to QOM lifecycle methods
Migrate the SPICE audio backend from the legacy driver init/fini callbacks to proper QOM realize method. The spice_audio_init() function is replaced with spice_audio_realize(), which validates that SPICE is enabled before delegating to the parent class realize method. The empty spice_audio_fini() is removed as no cleanup is needed. Reviewed-by: Mark Cave-Ayland <mark.caveayland@nutanix.com> Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Marc-André Lureau committed
Jan 16, 2026 at 11:47 UTC
7e4f621fa5fad49916032c81512b76856580aaf7
1 file changed
+17
-17
audio/spiceaudio.c
+17
-17
@@ -33,16 +33,33 @@
33
#define TYPE_AUDIO_SPICE "audio-spice"
34
OBJECT_DECLARE_SIMPLE_TYPE(AudioSpice, AUDIO_SPICE)
35
36
+static AudioBackendClass *audio_spice_parent_class;
37
+
38
struct AudioSpice {
39
AudioMixengBackend parent_obj;
40
};
41
42
static struct audio_driver spice_audio_driver;
43
44
+static bool spice_audio_realize(AudioBackend *abe, Audiodev *dev, Error **errp)
45
+{
46
+ if (!using_spice) {
47
+ error_setg(errp, "Cannot use spice audio without -spice");
48
+ qapi_free_Audiodev(dev);
49
+ return false;
50
+ }
51
+
52
+ return audio_spice_parent_class->realize(abe, dev, errp);
53
+}
54
+
55
static void audio_spice_class_init(ObjectClass *klass, const void *data)
56
{
57
+ AudioBackendClass *b = AUDIO_BACKEND_CLASS(klass);
58
AudioMixengBackendClass *k = AUDIO_MIXENG_BACKEND_CLASS(klass);
59
60
+ audio_spice_parent_class = AUDIO_BACKEND_CLASS(object_class_get_parent(klass));
61
+
62
+ b->realize = spice_audio_realize;
63
k->driver = &spice_audio_driver;
64
}
65
@@ -89,21 +106,6 @@ static const SpiceRecordInterface record_sif = {
106
.base.minor_version = SPICE_INTERFACE_RECORD_MINOR,
107
};
108
92
-static void *spice_audio_init(Audiodev *dev, Error **errp)
93
-{
94
- if (!using_spice) {
95
- error_setg(errp, "Cannot use spice audio without -spice");
96
- return NULL;
97
- }
98
-
99
- return &spice_audio_init;
100
-}
101
-
102
-static void spice_audio_fini (void *opaque)
103
-{
104
- /* nothing */
105
-}
106
-
109
/* playback */
110
111
static int line_out_init(HWVoiceOut *hw, struct audsettings *as,
@@ -333,8 +335,6 @@ static struct audio_pcm_ops audio_callbacks = {
335
336
static struct audio_driver spice_audio_driver = {
337
.name = "spice",
336
- .init = spice_audio_init,
337
- .fini = spice_audio_fini,
338
.pcm_ops = &audio_callbacks,
339
.max_voices_out = 1,
340
.max_voices_in = 1,