Skip to content

Commit

Permalink
incusd/instance/qmp: Handle QMP occasionally returning multiple respo…
Browse files Browse the repository at this point in the history
…nses

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
  • Loading branch information
stgraber committed Sep 4, 2024
1 parent d173a4b commit e46c8e3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/server/instance/drivers/qmp/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ func (m *Monitor) RunJSON(request []byte, resp any) error {
return err
}

// Handle weird QEMU QMP bug.
responses := strings.Split(string(out), "\r\n")
if len(responses) > 1 {
resp = responses[len(responses)-1]
}

// Decode the response if needed.
if resp != nil {
err = json.Unmarshal(out, &resp)
Expand Down

0 comments on commit e46c8e3

Please sign in to comment.