qmp: add dump-guest-memory support

By adding `dump-guest-memory` command, user can get kernel
memory dump when guest panic occurred.

Fixes: #152

Signed-off-by: bin liu <bin@hyper.sh>
This commit is contained in:
bin liu
2020-10-19 17:09:12 +08:00
parent d7836877e9
commit b8cd705901
2 changed files with 31 additions and 1 deletions

View File

@@ -1794,3 +1794,22 @@ func TestExecQomGet(t *testing.T) {
q.Shutdown()
<-disconnectedCh
}
// Checks dump-guest-memory
func TestExecuteDumpGuestMemory(t *testing.T) {
connectedCh := make(chan *QMPVersion)
disconnectedCh := make(chan struct{})
buf := newQMPTestCommandBuffer(t)
buf.AddCommand("dump-guest-memory", nil, "return", nil)
cfg := QMPConfig{Logger: qmpTestLogger{}}
q := startQMPLoop(buf, cfg, connectedCh, disconnectedCh)
checkVersion(t, connectedCh)
err := q.ExecuteDumpGuestMemory(context.Background(), "file:/tmp/dump.xxx.yyy", false, "elf")
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
q.Shutdown()
<-disconnectedCh
}