Manually kill gzip if restore fails before starting qemu

If a guest image is saved in compressed format, and the restore fails
in some way after the intermediate process used to uncompress the
image has been started, but before qemu has been started to hook up to
the uncompressor, libvirt will endlessly wait for the uncompressor to
finish, but it never will because it's still waiting to have something
hooked up to drain its output.

The solution is to close the pipes on both sides of the uncompressor,
then send a SIGTERM before calling waitpid on it (only if the restore
has failed, of course).
This commit is contained in:
Laine Stump 2011-01-24 11:58:15 -05:00
parent 3493f1bcec
commit c9c794b52b

View File

@ -5770,6 +5770,15 @@ qemudDomainSaveImageStartVM(virConnectPtr conn,
VIR_VM_OP_RESTORE);
if (intermediate_pid != -1) {
if (ret < 0) {
/* if there was an error setting up qemu, the intermediate process will
* wait forever to write to stdout, so we must manually kill it.
*/
VIR_FORCE_CLOSE(intermediatefd);
VIR_FORCE_CLOSE(fd);
kill(intermediate_pid, SIGTERM);
}
/* Wait for intermediate process to exit */
while (waitpid(intermediate_pid, &childstat, 0) == -1 &&
errno == EINTR) {