On 29/10/25 22:42, Philippe Mathieu-Daudé wrote:
On 29/10/25 20:00, Marc-André Lureau wrote:
Hi

On Wed, Oct 29, 2025 at 5:51 PM Philippe Mathieu-Daudé
<[email protected]> wrote:

On 27/10/25 16:10, [email protected] wrote:
From: Marc-André Lureau <[email protected]>

Proper lifecycle management with QOM state.

Signed-off-by: Marc-André Lureau <[email protected]>
---
   audio/audio.c | 7 ++++++-
   1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/audio/audio.c b/audio/audio.c
index 4c3c3fd52f..853930bb48 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1614,6 +1614,8 @@ static void audio_vm_change_state_handler (void *opaque, bool running,
       audio_reset_timer (s);
   }

+static const VMStateDescription vmstate_audio;
+
   static void audio_state_init(Object *obj)
   {
       AudioState *s = AUDIO_STATE(obj);
@@ -1625,6 +1627,8 @@ static void audio_state_init(Object *obj)

       s->vmse = qemu_add_vm_change_state_handler(audio_vm_change_state_handler, s);
       assert(s->vmse != NULL);
+
+    vmstate_register_any(NULL, &vmstate_audio, s);

Please avoid legacy APIs:

/**
   * vmstate_register_any() - legacy function to register state
   * serialisation description and let the function choose the id
   *
   * New code shouldn't be using this function as QOM-ified devices have
   * dc->vmsd to store the serialisation description.
   *
   * Returns: 0 on success, -1 on failure
   */


qdev/Device have vmsd, but not plain Object (or legacy code without object).

Hmm right. Cc'ing Peter & Fabiano.

Not blocking, so:

Reply via email to