xen-org/xen-api — pull request #1318 by andyhhp (2013-06-18 18:13:52+00:00)
Title: Fix logic at the conclusion of Xenguest for domain creation and migration

Fix logic at the conclusion of Xenguest for domain creation and migration.

As part of the control protocol, Xenguest is expected to write the string

"result: \n"

to the a pipe back into xenops. forkexecutioner has already executed a
waitpid() on the xenguest process, waiting for it to exit.

Unfortunately, as soon as xenops receives the result string, it decides to
SIGTERM the xenguest process.

This begins a race condition. If xenguest finishes executing and exits
cleanly (which it will do, given the result string) in a timely fashion, fe
will record success and the domain creation/migration will be all good.

If however xenguest gets killed with the SIGTERM before it has exited cleanly
(such as actually having valgrind wrapped around xenguest, and the recipient
of the SIGTERM), fe will record a failure at which point xenops will clean up
the domain, despite it having actually been created/migrated successfully.

This could likely explain some spurious failures seen in high-load situation
but not reliably enough to investigate.

Signed-off-by: Andrew Cooper