diff options
| author | Alexey Kardashevskiy <aik@linux.ibm.com> | 2021-02-16 15:15:47 +1100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2021-10-22 08:18:58 +0200 |
| commit | e1ee7e413ff064f6cd5867cc80970efcc6c333a7 (patch) | |
| tree | 81187a4421ce85872387e04d40334761745d3f58 /vm | |
| parent | 55f90bc6164340898299a59bec0f8599be49a13e (diff) | |
vm/qemu: handle QMP events
QEMU occasionally sends events in the same stream used for QMP commands
so from time time the received packet is not a QMP reponse but a QMP event
which breaks the parser. For example, events are send when a machine state
changed.
This adds basic support for event. For now we skip them and wait until
the expected QMP command response arrives.
Signed-off-by: Alexey Kardashevskiy <aik@linux.ibm.com>
Diffstat (limited to 'vm')
| -rw-r--r-- | vm/qemu/qmp.go | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/vm/qemu/qmp.go b/vm/qemu/qmp.go index dba151f37..e7e3b69e2 100644 --- a/vm/qemu/qmp.go +++ b/vm/qemu/qmp.go @@ -7,6 +7,8 @@ import ( "encoding/json" "fmt" "net" + + "github.com/google/syzkaller/pkg/log" ) type qmpVersion struct { @@ -40,6 +42,13 @@ type qmpResponse struct { Desc string } Return interface{} + + Event string + Data map[string]interface{} + Timestamp struct { + Seconds int64 + Microseconds int64 + } } func (inst *instance) qmpConnCheck() error { @@ -74,10 +83,14 @@ func (inst *instance) qmpConnCheck() error { } func (inst *instance) qmpRecv() (*qmpResponse, error) { - qmp := new(qmpResponse) - err := inst.monDec.Decode(qmp) - - return qmp, err + for { + qmp := new(qmpResponse) + err := inst.monDec.Decode(qmp) + if err != nil || qmp.Event == "" { + return qmp, err + } + log.Logf(1, "event: %v", qmp) + } } func (inst *instance) doQmp(cmd *qmpCommand) (*qmpResponse, error) { |
