Monthly Archive for April, 2012

Send Magic SysRq to a KVM guest using virsh


When a linux computer is "hung" or "frozen" you can use a Magic SysRq key sequence to send various low level requests to the kernel in order to try to recover from or investigate the problem. This is extremely useful when troubleshooting server lockups, but until recently libvirt did not expose this functionality for KVM guests.

In v0.9.3 (and newer) of libvirt you can send a Magic SysRq sequence to a guest by utilizing the send-key subcommand provided by virsh. In other words, sending the 'h' Magic SysRq command is as simple as:

dustymabe@media: ~>virsh send-key guest1 KEY_LEFTALT KEY_SYSRQ KEY_H

After executing the command a help message will be printed to the console of the guest known as 'guest1'. Any other character can be sent as well by substituting KEY_H with KEY_X, where X is the character.

Happy Investigating!

Dusty

Terminal Screencast Revisit: Log output from a multiplexed terminal


Traditionally with script you have really only been able to log the output of a simple "single session" terminal window. However, if you capture the timing data from script you can actually log much more than that.

In a previous post I talked about how to save the timing data using script and then play it back using scriptreplay. If you use this technique and also use a a terminal multiplexer such as screen or tmux you can capture much more information in your screencast.

To see an example of this you can watch the video below where I use scriptreplay to play back an earlier recorded screencast.



Additionally, you can download the screencast.timing and screencast.log if you like.

Cheers, Dusty Mabe