[Libvir] PATCH: Support <on_reboot>poweroff</on_reboot> in QEMU/KVM

Currently in the QEMU driver we don't support any of the customizable shutdown operation behaviour elements in the XML. ie <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> This was principally because we don't particularly have a good way to actually implement some of them. Well, QEMU 0.9.0 added a -no-reboot flag which could be used to force a 'reboot' inside the guest to behaviour like a shutdown. So we can now support at least the <on_reboot> element with 'destroy' or 'restart' behaviours. This turns out to be critical for provisioning guests, because the initial install uses a different VM configs, from later runtime, eg boot from ISO, vs boot from Disk. The attached patch adds support for accepting <on_reboot> when defining new domain configs. When dumping XML we will also add <on_poweroff> and <on_crash> elements to at least indicate what our behaviour is, though the user can't customize them. In doing this patch I had to change the way we read data from QEMU. We were over the 4096 buffer size, and also in some cases we were getting a short read which meant we lost the end of the help message. We now have a buffer of 8k (max QEMU help is 5k currently), and read in a loop until EOF or 8k is hit. Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

Daniel P. Berrange wrote:
In doing this patch I had to change the way we read data from QEMU. We were over the 4096 buffer size, and also in some cases we were getting a short read which meant we lost the end of the help message. We now have a buffer of 8k (max QEMU help is 5k currently), and read in a loop until EOF or 8k is hit.
Grrrr, I knew we should have moved to the XDR-based QEMU daemon earlier. Anyway, rest of the patch looks fine to me, from what little I know about how qemu works. Rich. -- Emerging Technologies, Red Hat http://et.redhat.com/~rjones/ 64 Baker Street, London, W1U 7DF Mobile: +44 7866 314 421 Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Directors: Michael Cunningham (USA), Charlie Peters (USA) and David Owens (Ireland)
participants (2)
-
Daniel P. Berrange
-
Richard W.M. Jones