From: Richard Jones Date: Mon, 6 Jul 2009 11:30:59 +0000 (+0100) Subject: Add 'get-pid' command. X-Git-Tag: 1.0.56~8^2~7 X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=commitdiff_plain;h=7cbb86e4c8b6b8bca8606d219c5571549ceabba6 Add 'get-pid' command. This is used to get the PID of the qemu subprocess, mainly for debugging and testing purposes. --- diff --git a/src/generator.ml b/src/generator.ml index e86fce1..d44b7a7 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -632,6 +632,15 @@ then this returns the compiled-in default value for memsize. For more information on the architecture of libguestfs, see L."); + ("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 diff --git a/src/guestfs.c b/src/guestfs.c index 350d848..bbbd4ea 100644 --- a/src/guestfs.c +++ b/src/guestfs.c @@ -667,6 +667,17 @@ guestfs_get_memsize (guestfs_h *g) 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)