[Libguestfs] [PATCH 1/3] daemon: Change command to abort() on resource problems.

Richard W.M. Jones rjones at redhat.com
Thu May 6 21:03:43 UTC 2010


-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v
-------------- next part --------------
>From fd62c985a26bfd0cac27735a47ce7fd7b068fdb4 Mon Sep 17 00:00:00 2001
From: Richard Jones <rjones at redhat.com>
Date: Thu, 6 May 2010 20:32:09 +0100
Subject: [PATCH 1/3] daemon: Change command to abort() on resource problems.

The comment in the code describes it thus:

  /* Note: abort is used in a few places along the error paths early
   * in this function.  This is because (a) cleaning up correctly is
   * very complex at these places and (b) abort is used when a
   * resource problems is indicated which would be due to much more
   * serious issues - eg. memory or file descriptor leaks.  We
   * wouldn't expect fork(2) or pipe(2) to fail in normal
   * circumstances.
   */
---
 daemon/guestfsd.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c
index 03a975a..be79300 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -1,5 +1,5 @@
 /* libguestfs - the guestfsd daemon
- * Copyright (C) 2009 Red Hat Inc.
+ * Copyright (C) 2009-2010 Red Hat Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -738,19 +738,24 @@ commandrvf (char **stdoutput, char **stderror, int flags,
     printf ("\n");
   }
 
+  /* Note: abort is used in a few places along the error paths early
+   * in this function.  This is because (a) cleaning up correctly is
+   * very complex at these places and (b) abort is used when a
+   * resource problems is indicated which would be due to much more
+   * serious issues - eg. memory or file descriptor leaks.  We
+   * wouldn't expect fork(2) or pipe(2) to fail in normal
+   * circumstances.
+   */
+
   if (pipe (so_fd) == -1 || pipe (se_fd) == -1) {
     perror ("pipe");
-    return -1;
+    abort ();
   }
 
   pid = fork ();
   if (pid == -1) {
     perror ("fork");
-    close (so_fd[0]);
-    close (so_fd[1]);
-    close (se_fd[0]);
-    close (se_fd[1]);
-    return -1;
+    abort ();
   }
 
   if (pid == 0) {		/* Child process. */
-- 
1.6.6.1



More information about the Libguestfs mailing list