]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Manually kill gzip if restore fails before starting qemu
authorLaine Stump <laine@laine.org>
Mon, 24 Jan 2011 16:58:15 +0000 (11:58 -0500)
committerLaine Stump <laine@laine.org>
Wed, 26 Jan 2011 15:13:43 +0000 (10:13 -0500)
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).

src/qemu/qemu_driver.c

index b6a5cd68a80f9f2c37e4218b75d7c8366c326ad0..23e0db0b053bd5437e0e96b4a3e77599880d56c6 100644 (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) {