Hello Ludovic,
I investigated a bit. I managed to get our code to cause a kernel
panic
upon failure (patch below). However I fail to turn that guest kernel
panic into a different QEMU exit code.
I tried to use the “pvpanic” paravirtualized device (the ‘pvpanic.ko’
module in the guest, and “-device pvpanic” on the QEMU command line),
but unfortunately that thing is almost undocumented and I can’t get it
to turn the panic into a non-zero exit code, nor do I know if it’s
possible.
Thoughts anyone?
I looked a little into it and I have found how to use pvpanic.
Unfortunately it's not as straight forward as getting a non-zero exit
code form qemu. When pvpanic is loaded in a VṂ, as you did with
“-device
pvpanic”, generate events[0] on the QMP interface when a crash happen
and qemu either shutdown or pause when using --no-shutdown[1].
(gnu build marionette) which use the “-monitor” interface could be
recycled to use “-qmp” a machine interface using JSON.
Following is log of a QMP session where the guest panicked[2]:
--8<---------------cut here---------------start------------->8---
{
"QMP": {
"version": {
"qemu": {
"micro": 0,
"minor": 2,
"major": 4
},
"package": ""
},
"capabilities": [
"oob"
]
}
}
{ "execute": "qmp_capabilities" }
{
"return": {
}
}
{
"timestamp": {
"seconds": 1584645026,
"microseconds": 936550
},
"event": "GUEST_PANICKED",
"data": {
"action": "pause"
}
}
{
"timestamp": {
"seconds": 1584645026,
"microseconds": 936675
},
"event": "GUEST_PANICKED",
"data": {
"action": "poweroff"
}
}
{
"timestamp": {
"seconds": 1584645026,
"microseconds": 936776
},
"event": "SHUTDOWN",
"data": {
"guest": true,
"reason": "guest-panic"
}
}
--8<---------------cut here---------------end--------------->8---
[0]:
https://github.com/qemu/qemu/blob/9ced5c7c20cb16dff0c2fa3242c3ee96b68cec2a/qapi/run-state.json#L339-L355
[1]:
https://github.com/qemu/qemu/blob/4dd6517e369828171290b65e11f6a45aeeed15af/softmmu/vl.c#L1423-L1427
[2]:
https://git.qemu.org/?p=qemu.git;a=blob_plain;f=docs/interop/qmp-intro.txt;hb=HEAD
Brice.