summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2010-04-08 19:07:45 +0100
committerRichard Jones <rjones@redhat.com>2010-04-08 22:23:37 +0100
commitcd7a5b8ddfccf5641e52de7660fe50a093f7bb89 (patch)
treec1cc8531c5028720b4d84d46ed5c6c0cb7791853
parent772a8309611a8bf3fc0005c89d08c6e134ae3d23 (diff)
downloadlibguestfs-cd7a5b8ddfccf5641e52de7660fe50a093f7bb89.tar.gz
libguestfs-cd7a5b8ddfccf5641e52de7660fe50a093f7bb89.tar.xz
libguestfs-cd7a5b8ddfccf5641e52de7660fe50a093f7bb89.zip
If qemu dies during launch in "null vmchannel" mode, don't hang (RHBZ#579155).
Detect if qemu dies during launch by wait(2)-ing for it, and then getting EOF on the qemu pipe. This was broken in null vmchannel mode, causing a hang. (cherry picked from commit e35debd642bea240609775610b68145dab0a634b)
-rw-r--r--src/guestfs.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/guestfs.c b/src/guestfs.c
index d8c856a4..fe08cb56 100644
--- a/src/guestfs.c
+++ b/src/guestfs.c
@@ -2366,8 +2366,16 @@ accept_from_daemon (guestfs_h *g)
int sock = -1;
while (sock == -1) {
+ /* If the qemu process has died, clean up the zombie (RHBZ#579155).
+ * By partially polling in the select below we ensure that this
+ * function will be called eventually.
+ */
+ waitpid (g->pid, NULL, WNOHANG);
+
rset2 = rset;
- int r = select (max_fd+1, &rset2, NULL, NULL, NULL);
+
+ struct timeval tv = { .tv_sec = 1, .tv_usec = 0 };
+ int r = select (max_fd+1, &rset2, NULL, NULL, &tv);
if (r == -1) {
if (errno == EINTR || errno == EAGAIN)
continue;