After the QEMU monitor filehandle has been successfully initialized, we
then promptly close it ! It seems a 'return' statement accidentally got
removed somewhere during previously refactoring.

Second, the QEMU logfile does not have the close-on-exec flag set so the
logfile is leaked to child processes.

 qemu_driver.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)

Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 
Index: src/qemu_driver.c
===================================================================
RCS file: /data/cvs/libvirt/src/qemu_driver.c,v
retrieving revision 1.8
diff -u -p -r1.8 qemu_driver.c
--- src/qemu_driver.c   12 Jul 2007 15:09:01 -0000      1.8
+++ src/qemu_driver.c   19 Jul 2007 00:50:04 -0000
@@ -540,6 +540,11 @@ static int qemudOpenMonitor(virConnectPt
                                  buf, sizeof(buf),
                                  qemudCheckMonitorPrompt,
                                  "monitor");
+
+    /* Keep monitor open upon success */
+    if (ret == 0)
+        return ret;
+
  error:
     close(monfd);
     return ret;
@@ -701,6 +706,14 @@ static int qemudStartVMDaemon(virConnect
                          logfile, strerror(errno));
         return -1;
     }
+    if (qemudSetCloseExec(vm->logfile) < 0) {
+        qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+                         "Unable to set VM logfile close-on-exec flag %s",
+                         strerror(errno));
+        close(vm->logfile);
+        vm->logfile = -1;
+        return -1;
+    }
 
     if (qemudBuildCommandLine(conn, driver, vm, &argv) < 0) {
         close(vm->logfile);
--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to