]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Faster response time to qemu startup errors
authorStefan Berger <stefanb@us.ibm.com>
Mon, 13 Jun 2011 19:59:58 +0000 (15:59 -0400)
committerStefan Berger <stefanb@us.ibm.com>
Mon, 13 Jun 2011 19:59:58 +0000 (15:59 -0400)
The below patch decreases the response time of libvirt to errors reported by Qemu upon startup by checking whether the qemu process is still alive while polling for the local socket to show up.

This patch also introduces a special handling of signal for the Win32 part of virKillProcess.

src/qemu/qemu_monitor.c
src/util/util.c

index 26bb814723a07fecbc3626c1ff52c6673e50460a..92c44bf3d6aae45cdd98e36ea4927a898ae909f6 100644 (file)
@@ -247,7 +247,7 @@ qemuMonitorUnwatch(void *monitor)
 }
 
 static int
-qemuMonitorOpenUnix(const char *monitor)
+qemuMonitorOpenUnix(const char *monitor, pid_t cpid)
 {
     struct sockaddr_un addr;
     int monfd;
@@ -274,7 +274,8 @@ qemuMonitorOpenUnix(const char *monitor)
         if (ret == 0)
             break;
 
-        if (errno == ENOENT || errno == ECONNREFUSED) {
+        if ((errno == ENOENT || errno == ECONNREFUSED) &&
+            virKillProcess(cpid, 0) == 0) {
             /* ENOENT       : Socket may not have shown up yet
              * ECONNREFUSED : Leftover socket hasn't been removed yet */
             continue;
@@ -691,7 +692,7 @@ qemuMonitorOpen(virDomainObjPtr vm,
     switch (config->type) {
     case VIR_DOMAIN_CHR_TYPE_UNIX:
         mon->hasSendFD = 1;
-        mon->fd = qemuMonitorOpenUnix(config->data.nix.path);
+        mon->fd = qemuMonitorOpenUnix(config->data.nix.path, vm->pid);
         break;
 
     case VIR_DOMAIN_CHR_TYPE_PTY:
index d00f065b565d24714a0760bd7c671c0148dc272d..df4dfacfed341a2e4e28efb897ae81fcc0c3d8c1 100644 (file)
@@ -2010,7 +2010,7 @@ int virKillProcess(pid_t pid, int sig)
          * TerminateProcess is more or less equiv to SIG_KILL, in that
          * a process can't trap / block it
          */
-        if (!TerminateProcess(proc, sig)) {
+        if (sig != 0 && !TerminateProcess(proc, sig)) {
             errno = ESRCH;
             return -1;
         }