AC_VERB_SET_CHANNEL_STREAMID masks st->stream and st->channel to 4 bits (& 0x0f), and hda_audio_post_load() uses st->stream directly to index a->running_real[st->output * 16 + st->stream].
vmstate_hda_audio_stream loads both fields as uint32_t. Mask them with 0x0f in a post_load callback on vmstate_hda_audio_stream before the parent hda_audio_post_load() runs. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/4774 Signed-off-by: lbyxiaolizi <[email protected]> --- hw/audio/hda-codec.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c index 173fe56..f452bae 100644 --- a/hw/audio/hda-codec.c +++ b/hw/audio/hda-codec.c @@ -761,9 +761,19 @@ static const VMStateDescription vmstate_hda_audio_stream_buf = { } }; +static int hda_audio_stream_post_load(void *opaque, int version_id) +{ + HDAAudioStream *st = opaque; + + st->stream &= 0x0f; + st->channel &= 0x0f; + return 0; +} + static const VMStateDescription vmstate_hda_audio_stream = { .name = "hda-audio-stream", .version_id = 1, + .post_load = hda_audio_stream_post_load, .fields = (const VMStateField[]) { VMSTATE_UINT32(stream, HDAAudioStream), VMSTATE_UINT32(channel, HDAAudioStream),
