Ensure atomic creation of a cached appliance
[libguestfs.git] / src / guestfs.c
index 2f5063c..df13d51 100644 (file)
@@ -33,7 +33,6 @@
 #include <sys/stat.h>
 #include <sys/select.h>
 #include <dirent.h>
-#include <signal.h>
 #include <assert.h>
 
 #include <rpc/types.h>
 #include <arpa/inet.h>
 #include <netinet/in.h>
 
+#include "c-ctype.h"
 #include "glthread/lock.h"
 #include "hash.h"
 #include "hash-pjw.h"
-#include "ignore-value.h"
 
 #include "guestfs.h"
 #include "guestfs-internal.h"
@@ -101,6 +100,7 @@ guestfs_create (void)
   g->error_cb_data = NULL;
 
   g->recovery_proc = 1;
+  g->autosync = 1;
 
   str = getenv ("LIBGUESTFS_DEBUG");
   g->verbose = str != NULL && STREQ (str, "1");
@@ -733,3 +733,31 @@ guestfs_get_private (guestfs_h *g, const char *key)
   else
     return NULL;
 }
+
+/* When tracing, be careful how we print BufferIn parameters which
+ * usually contain large amounts of binary data (RHBZ#646822).
+ */
+void
+guestfs___print_BufferIn (FILE *out, const char *buf, size_t buf_size)
+{
+  size_t i;
+  size_t orig_size = buf_size;
+
+  if (buf_size > 256)
+    buf_size = 256;
+
+  fputc ('"', out);
+
+  for (i = 0; i < buf_size; ++i) {
+    if (c_isprint (buf[i]))
+      fputc (buf[i], out);
+    else
+      fprintf (out, "\\x%02x", (unsigned char) buf[i]);
+  }
+
+  fputc ('"', out);
+
+  if (orig_size > buf_size)
+    fprintf (out,
+             _("<truncated, original size %zu bytes>"), orig_size);
+}