virt-resize: Document guest boot stops at "GRUB" (RHBZ#640961).
[libguestfs.git] / src / launch.c
index eaf3974..f9d8329 100644 (file)
@@ -61,9 +61,7 @@
 #include <arpa/inet.h>
 #include <netinet/in.h>
 
-#include "c-ctype.h"
 #include "glthread/lock.h"
-#include "ignore-value.h"
 
 #include "guestfs.h"
 #include "guestfs-internal.h"
@@ -251,10 +249,7 @@ guestfs__launch (guestfs_h *g)
 
   /* Make the temporary directory. */
   if (!g->tmpdir) {
-    const char *tmpdir = guestfs___tmpdir ();
-    char dir_template[strlen (tmpdir) + 32];
-    sprintf (dir_template, "%s/libguestfsXXXXXX", tmpdir);
-
+    TMP_TEMPLATE_ON_STACK (dir_template);
     g->tmpdir = safe_strdup (g, dir_template);
     if (mkdtemp (g->tmpdir) == NULL) {
       perrorf (g, _("%s: cannot create temporary directory"), dir_template);
@@ -513,6 +508,8 @@ guestfs__launch (guestfs_h *g)
   kernel = NULL;
   free (initrd);
   initrd = NULL;
+  free (appliance);
+  appliance = NULL;
 
   /* Fork the recovery process off which will kill qemu if the parent
    * process fails to do so (eg. if the parent segfaults).
@@ -649,8 +646,11 @@ guestfs__launch (guestfs_h *g)
   return -1;
 }
 
+/* Return the location of the tmpdir (eg. "/tmp") and allow users
+ * to override it at runtime using $TMPDIR.
+ */
 const char *
-guestfs___tmpdir (void)
+guestfs_tmpdir (void)
 {
   const char *tmpdir;