mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-23 05:58:04 +00:00
qemu: add pvpanic device to get GUEST_PANICKED event
Listening to the events channel from QEMU and a guest panic event issued, then we can get the event and do some work for the special event. Fixes: #152 Signed-off-by: bin liu <bin@hyper.sh>
This commit is contained in:
parent
546cc55ea4
commit
d7836877e9
18
qemu/qemu.go
18
qemu/qemu.go
@ -1118,6 +1118,24 @@ func (blkdev BlockDevice) deviceName(config *Config) string {
|
|||||||
return string(blkdev.Driver)
|
return string(blkdev.Driver)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PVPanicDevice represents a qemu pvpanic device.
|
||||||
|
type PVPanicDevice struct {
|
||||||
|
NoShutdown bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// Valid always returns true for pvpanic device
|
||||||
|
func (dev PVPanicDevice) Valid() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// QemuParams returns the qemu parameters built out of this serial device.
|
||||||
|
func (dev PVPanicDevice) QemuParams(config *Config) []string {
|
||||||
|
if dev.NoShutdown {
|
||||||
|
return []string{"-device", "pvpanic", "-no-shutdown"}
|
||||||
|
}
|
||||||
|
return []string{"-device", "pvpanic"}
|
||||||
|
}
|
||||||
|
|
||||||
// VhostUserDevice represents a qemu vhost-user device meant to be passed
|
// VhostUserDevice represents a qemu vhost-user device meant to be passed
|
||||||
// in to the guest
|
// in to the guest
|
||||||
type VhostUserDevice struct {
|
type VhostUserDevice struct {
|
||||||
|
@ -1203,3 +1203,18 @@ func TestAppendFwcfg(t *testing.T) {
|
|||||||
}
|
}
|
||||||
testAppend(fwcfg, fwcfgString, t)
|
testAppend(fwcfg, fwcfgString, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAppendPVPanicDevice(t *testing.T) {
|
||||||
|
testCases := []struct {
|
||||||
|
dev Device
|
||||||
|
out string
|
||||||
|
}{
|
||||||
|
{nil, ""},
|
||||||
|
{PVPanicDevice{}, "-device pvpanic"},
|
||||||
|
{PVPanicDevice{NoShutdown: true}, "-device pvpanic -no-shutdown"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range testCases {
|
||||||
|
testAppend(tc.dev, tc.out, t)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user