Add 'checksum' command.
[libguestfs.git] / daemon / guestfsd.c
index c701f19..2553ea2 100644 (file)
@@ -41,6 +41,8 @@ static void usage (void);
 #define VMCHANNEL_PORT "6666"
 #define VMCHANNEL_ADDR "10.0.2.4"
 
+int verbose = 0;
+
 int
 main (int argc, char *argv[])
 {
@@ -63,7 +65,7 @@ main (int argc, char *argv[])
   struct addrinfo *res, *rr;
   struct addrinfo hints;
   XDR xdr;
-  unsigned len;
+  uint32_t len;
 
   for (;;) {
     c = getopt_long (argc, argv, options, long_options, NULL);
@@ -108,6 +110,14 @@ main (int argc, char *argv[])
     fclose (fp);
     buf[n] = '\0';
 
+    /* Set the verbose flag.  Not quite right because this will only
+     * set the flag if host and port aren't set on the command line.
+     * Don't worry about this for now. (XXX)
+     */
+    verbose = strstr (buf, "guestfs_verbose=1") != NULL;
+    if (verbose)
+      printf ("verbose daemon enabled\n");
+
     p = strstr (buf, "guestfs=");
 
     if (p) {
@@ -163,7 +173,7 @@ main (int argc, char *argv[])
   /* Send the magic length message which indicates that
    * userspace is up inside the guest.
    */
-  len = 0xf5f55ff5;
+  len = GUESTFS_LAUNCH_FLAG;
   xdrmem_create (&xdr, buf, sizeof buf, XDR_ENCODE);
   if (!xdr_uint32_t (&xdr, &len)) {
     fprintf (stderr, "xdr_uint32_t failed\n");
@@ -359,10 +369,12 @@ commandv (char **stdoutput, char **stderror, char * const* const argv)
   if (stdoutput) *stdoutput = NULL;
   if (stderror) *stderror = NULL;
 
-  printf ("%s", argv[0]);
-  for (i = 1; argv[i] != NULL; ++i)
-    printf (" %s", argv[i]);
-  printf ("\n");
+  if (verbose) {
+    printf ("%s", argv[0]);
+    for (i = 1; argv[i] != NULL; ++i)
+      printf (" %s", argv[i]);
+    printf ("\n");
+  }
 
   if (pipe (so_fd) == -1 || pipe (se_fd) == -1) {
     perror ("pipe");