]> xenbits.xensource.com Git - libvirt.git/commitdiff
src/qemu_driver.c: Handle errors from fork(2) and pipe(2)
authorRichard W.M. Jones <rjones@redhat.com>
Tue, 8 Apr 2008 12:27:53 +0000 (12:27 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Tue, 8 Apr 2008 12:27:53 +0000 (12:27 +0000)
          system calls when creating qemu subprocess.

ChangeLog
src/qemu_driver.c

index c4b6c00b39cc19646ac8ca4a2e758a49f6f7d719..aab12313c53b6353f4cba6cdab60f1fc81fb1c24 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Apr  8 13:24:00 BST 2008 Richard W.M. Jones <rjones@redhat.com>
+
+       * src/qemu_driver.c: Handle errors from fork(2) and pipe(2)
+         system calls when creating qemu subprocess.
+
 Tue Apr  8 11:50:42 CEST 2008 Daniel Veillard <daniel@veillard.com>
 
        * po/sr.po po/sr@Latn.po po/sr@latin.po: fix/update serbian
index 3c6a18dd46e2ad0a130a4cf5898edb6d43775654..87b58db6b47b8ea9324c02485fafc9cbef65ac31 100644 (file)
@@ -603,7 +603,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
                               struct qemud_driver *driver,
                               struct qemud_vm *vm) {
     char **argv = NULL, **tmp;
-    int i;
+    int i, ret;
     char logfile[PATH_MAX];
 
     if (qemudIsActiveVM(vm)) {
@@ -681,8 +681,9 @@ static int qemudStartVMDaemon(virConnectPtr conn,
         qemudLog(QEMUD_WARN, _("Unable to write argv to logfile %d: %s"),
                  errno, strerror(errno));
 
-    if (virExecNonBlock(conn, argv, &vm->pid,
-                        vm->stdin, &vm->stdout, &vm->stderr) == 0) {
+    ret = virExecNonBlock(conn, argv, &vm->pid,
+                          vm->stdin, &vm->stdout, &vm->stderr);
+    if (ret == 0) {
         vm->id = driver->nextvmid++;
         vm->state = vm->migrateFrom[0] ? VIR_DOMAIN_PAUSED : VIR_DOMAIN_RUNNING;
 
@@ -704,28 +705,30 @@ static int qemudStartVMDaemon(virConnectPtr conn,
         vm->ntapfds = 0;
     }
 
-    if (virEventAddHandle(vm->stdout,
-                          POLLIN | POLLERR | POLLHUP,
-                          qemudDispatchVMEvent,
-                          driver) < 0) {
-        qemudShutdownVMDaemon(conn, driver, vm);
-        return -1;
-    }
+    if (ret == 0) {
+        if (virEventAddHandle(vm->stdout,
+                              POLLIN | POLLERR | POLLHUP,
+                              qemudDispatchVMEvent,
+                              driver) < 0) {
+            qemudShutdownVMDaemon(conn, driver, vm);
+            return -1;
+        }
 
-    if (virEventAddHandle(vm->stderr,
-                          POLLIN | POLLERR | POLLHUP,
-                          qemudDispatchVMEvent,
-                          driver) < 0) {
-        qemudShutdownVMDaemon(conn, driver, vm);
-        return -1;
-    }
+        if (virEventAddHandle(vm->stderr,
+                              POLLIN | POLLERR | POLLHUP,
+                              qemudDispatchVMEvent,
+                              driver) < 0) {
+            qemudShutdownVMDaemon(conn, driver, vm);
+            return -1;
+        }
 
-    if (qemudWaitForMonitor(conn, driver, vm) < 0) {
-        qemudShutdownVMDaemon(conn, driver, vm);
-        return -1;
+        if (qemudWaitForMonitor(conn, driver, vm) < 0) {
+            qemudShutdownVMDaemon(conn, driver, vm);
+            return -1;
+        }
     }
 
-    return 0;
+    return ret;
 }
 
 static int qemudVMData(struct qemud_driver *driver ATTRIBUTE_UNUSED,