Add 'get-pid' command.
authorRichard Jones <rjones@trick.home.annexia.org>
Mon, 6 Jul 2009 11:30:59 +0000 (12:30 +0100)
committerRichard Jones <rjones@trick.home.annexia.org>
Mon, 6 Jul 2009 11:30:59 +0000 (12:30 +0100)
This is used to get the PID of the qemu subprocess, mainly for
debugging and testing purposes.

src/generator.ml
src/guestfs.c

index e86fce1..d44b7a7 100755 (executable)
@@ -632,6 +632,15 @@ then this returns the compiled-in default value for memsize.
 For more information on the architecture of libguestfs,
 see L<guestfs(3)>.");
 
 For more information on the architecture of libguestfs,
 see L<guestfs(3)>.");
 
+  ("get_pid", (RInt "pid", []), -1, [FishAlias "pid"],
+   [],
+   "get PID of qemu subprocess",
+   "\
+Return the process ID of the qemu subprocess.  If there is no
+qemu subprocess, then this will return an error.
+
+This is an internal call used for debugging and testing.");
+
 ]
 
 (* daemon_functions are any functions which cause some action
 ]
 
 (* daemon_functions are any functions which cause some action
index 350d848..bbbd4ea 100644 (file)
@@ -667,6 +667,17 @@ guestfs_get_memsize (guestfs_h *g)
   return g->memsize;
 }
 
   return g->memsize;
 }
 
+int
+guestfs_get_pid (guestfs_h *g)
+{
+  if (g->pid > 0)
+    return g->pid;
+  else {
+    error (g, "get_pid: no qemu subprocess");
+    return -1;
+  }
+}
+
 /* Add a string to the current command line. */
 static void
 incr_cmdline_size (guestfs_h *g)
 /* Add a string to the current command line. */
 static void
 incr_cmdline_size (guestfs_h *g)