virtme-ng: return 255 on panic in script mode instead of hanging #70
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If we trigger a kernel panic when running in script mode the guest would just hangs indefinitely.
Test case:
$ vng -vr -- "echo c > /proc/sysrq-trigger"
This can be a bit problematic in a CI scenario, since the indefinite hang can block all the next tests or actions.
A possible solution is to use the
timeout
command withvng
, but we may also want to distinguish actual timeout conditions from kernel panics.For this reason always boot the guest with "panic=-1" when running in script mode; this, together with qemu
-no-reboot
will trigger an immediate exit, that can be detected by vng and report the special exit code 255.This allows to explicitly catch kernel panic conditions, by checking if the return code of vng is 255.
Example:
$ vng -vr -- "echo c > /proc/sysrq-trigger" 2>/tmp/kernel.log
$ [ $? == 255 ] && grep "Kernel panic" /tmp/kernel.log
[ 3.260927] Kernel panic - not syncing: sysrq triggered crash
NOTE: we don't want to change the behavior with interactive mode. In that case it is fine to hang indefinitely by default, because we may want to attach a debugger, or trigger a memory dump, etc. So this change should only affect script mode for now.
Link: linux-netdev/nipa#11