Generated code for debug command.
authorRichard W.M. Jones <rjones@redhat.com>
Thu, 23 Apr 2009 13:39:31 +0000 (14:39 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Thu, 23 Apr 2009 13:39:31 +0000 (14:39 +0100)
22 files changed:
daemon/actions.h
daemon/stubs.c
fish/cmds.c
fish/completion.c
guestfish-actions.pod
guestfs-actions.pod
java/com/redhat/et/libguestfs/GuestFS.java
java/com_redhat_et_libguestfs_GuestFS.c
ocaml/guestfs.ml
ocaml/guestfs.mli
ocaml/guestfs_c_actions.c
perl/Guestfs.xs
perl/lib/Sys/Guestfs.pm
python/guestfs-py.c
python/guestfs.py
ruby/ext/guestfs/_guestfs.c
src/guestfs-actions.c
src/guestfs-actions.h
src/guestfs_protocol.c
src/guestfs_protocol.h
src/guestfs_protocol.x
tests.c

index 2cd7f3d..dafbca7 100644 (file)
@@ -96,3 +96,4 @@ extern int do_tgz_out (const char *directory);
 extern int do_mount_ro (const char *device, const char *mountpoint);
 extern int do_mount_options (const char *options, const char *device, const char *mountpoint);
 extern int do_mount_vfs (const char *options, const char *vfstype, const char *device, const char *mountpoint);
 extern int do_mount_ro (const char *device, const char *mountpoint);
 extern int do_mount_options (const char *options, const char *device, const char *mountpoint);
 extern int do_mount_vfs (const char *options, const char *vfstype, const char *device, const char *mountpoint);
+extern char *do_debug (const char *subcmd, char * const* const extraargs);
index e9d9f59..526a861 100644 (file)
@@ -1841,6 +1841,37 @@ done:
   xdr_free ((xdrproc_t) xdr_guestfs_mount_vfs_args, (char *) &args);
 }
 
   xdr_free ((xdrproc_t) xdr_guestfs_mount_vfs_args, (char *) &args);
 }
 
+static void debug_stub (XDR *xdr_in)
+{
+  char *r;
+  struct guestfs_debug_args args;
+  const char *subcmd;
+  char **extraargs;
+
+  memset (&args, 0, sizeof args);
+
+  if (!xdr_guestfs_debug_args (xdr_in, &args)) {
+    reply_with_error ("%s: daemon failed to decode procedure arguments", "debug");
+    return;
+  }
+  subcmd = args.subcmd;
+  args.extraargs.extraargs_val = realloc (args.extraargs.extraargs_val, sizeof (char *) * (args.extraargs.extraargs_len+1));
+  args.extraargs.extraargs_val[args.extraargs.extraargs_len] = NULL;
+  extraargs = args.extraargs.extraargs_val;
+
+  r = do_debug (subcmd, extraargs);
+  if (r == NULL)
+    /* do_debug has already called reply_with_error */
+    goto done;
+
+  struct guestfs_debug_ret ret;
+  ret.result = r;
+  reply ((xdrproc_t) &xdr_guestfs_debug_ret, (char *) &ret);
+  free (r);
+done:
+  xdr_free ((xdrproc_t) xdr_guestfs_debug_args, (char *) &args);
+}
+
 void dispatch_incoming_message (XDR *xdr_in)
 {
   switch (proc_nr) {
 void dispatch_incoming_message (XDR *xdr_in)
 {
   switch (proc_nr) {
@@ -2069,6 +2100,9 @@ void dispatch_incoming_message (XDR *xdr_in)
     case GUESTFS_PROC_MOUNT_VFS:
       mount_vfs_stub (xdr_in);
       break;
     case GUESTFS_PROC_MOUNT_VFS:
       mount_vfs_stub (xdr_in);
       break;
+    case GUESTFS_PROC_DEBUG:
+      debug_stub (xdr_in);
+      break;
     default:
       reply_with_error ("dispatch_incoming_message: unknown procedure number %d", proc_nr);
   }
     default:
       reply_with_error ("dispatch_incoming_message: unknown procedure number %d", proc_nr);
   }
index ff20c82..7b1386f 100644 (file)
@@ -63,6 +63,7 @@ void list_commands (void)
   printf ("%-20s %s\n", "command", "run a command from the guest filesystem");
   printf ("%-20s %s\n", "command-lines", "run a command, returning lines");
   printf ("%-20s %s\n", "config", "add qemu parameters");
   printf ("%-20s %s\n", "command", "run a command from the guest filesystem");
   printf ("%-20s %s\n", "command-lines", "run a command, returning lines");
   printf ("%-20s %s\n", "config", "add qemu parameters");
+  printf ("%-20s %s\n", "debug", "debugging and internals");
   printf ("%-20s %s\n", "download", "download a file to the local machine");
   printf ("%-20s %s\n", "exists", "test if file or directory exists");
   printf ("%-20s %s\n", "file", "determine file type");
   printf ("%-20s %s\n", "download", "download a file to the local machine");
   printf ("%-20s %s\n", "exists", "test if file or directory exists");
   printf ("%-20s %s\n", "file", "determine file type");
@@ -408,6 +409,9 @@ void display_command (const char *cmd)
   if (strcasecmp (cmd, "mount_vfs") == 0 || strcasecmp (cmd, "mount-vfs") == 0)
     pod2text ("mount-vfs - mount a guest disk with mount options and vfstype", " mount-vfs <options> <vfstype> <device> <mountpoint>\n\nThis is the same as the C<mount> command, but it\nallows you to set both the mount options and the vfstype\nas for the L<mount(8)> I<-o> and I<-t> flags.");
   else
   if (strcasecmp (cmd, "mount_vfs") == 0 || strcasecmp (cmd, "mount-vfs") == 0)
     pod2text ("mount-vfs - mount a guest disk with mount options and vfstype", " mount-vfs <options> <vfstype> <device> <mountpoint>\n\nThis is the same as the C<mount> command, but it\nallows you to set both the mount options and the vfstype\nas for the L<mount(8)> I<-o> and I<-t> flags.");
   else
+  if (strcasecmp (cmd, "debug") == 0)
+    pod2text ("debug - debugging and internals", " debug <subcmd> <extraargs>\n\nThe C<debug> command exposes some internals of\nC<guestfsd> (the guestfs daemon) that runs inside the\nqemu subprocess.\n\nThere is no comprehensive help for this command.  You have\nto look at the file C<daemon/debug.c> in the libguestfs source\nto find out what you can do.");
+  else
     display_builtin_command (cmd);
 }
 
     display_builtin_command (cmd);
 }
 
@@ -1983,6 +1987,25 @@ static int run_mount_vfs (const char *cmd, int argc, char *argv[])
   return r;
 }
 
   return r;
 }
 
+static int run_debug (const char *cmd, int argc, char *argv[])
+{
+  char *r;
+  const char *subcmd;
+  char **extraargs;
+  if (argc != 2) {
+    fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+    fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+    return -1;
+  }
+  subcmd = argv[0];
+  extraargs = parse_string_list (argv[1]);
+  r = guestfs_debug (g, subcmd, extraargs);
+  if (r == NULL) return -1;
+  printf ("%s\n", r);
+  free (r);
+  return 0;
+}
+
 int run_action (const char *cmd, int argc, char *argv[])
 {
   if (strcasecmp (cmd, "launch") == 0 || strcasecmp (cmd, "run") == 0)
 int run_action (const char *cmd, int argc, char *argv[])
 {
   if (strcasecmp (cmd, "launch") == 0 || strcasecmp (cmd, "run") == 0)
@@ -2264,6 +2287,9 @@ int run_action (const char *cmd, int argc, char *argv[])
   if (strcasecmp (cmd, "mount_vfs") == 0 || strcasecmp (cmd, "mount-vfs") == 0)
     return run_mount_vfs (cmd, argc, argv);
   else
   if (strcasecmp (cmd, "mount_vfs") == 0 || strcasecmp (cmd, "mount-vfs") == 0)
     return run_mount_vfs (cmd, argc, argv);
   else
+  if (strcasecmp (cmd, "debug") == 0)
+    return run_debug (cmd, argc, argv);
+  else
     {
       fprintf (stderr, "%s: unknown command\n", cmd);
       return -1;
     {
       fprintf (stderr, "%s: unknown command\n", cmd);
       return -1;
index 8c4f3ad..8e52981 100644 (file)
@@ -69,6 +69,7 @@ static const char *commands[] = {
   "command",
   "command-lines",
   "config",
   "command",
   "command-lines",
   "config",
+  "debug",
   "download",
   "exists",
   "file",
   "download",
   "exists",
   "file",
index 87ba018..a79e336 100644 (file)
@@ -403,6 +403,18 @@ The first character of C<param> string must be a C<-> (dash).
 
 C<value> can be NULL.
 
 
 C<value> can be NULL.
 
+=head2 debug
+
+ debug subcmd 'extraargs ...'
+
+The C<debug> command exposes some internals of
+C<guestfsd> (the guestfs daemon) that runs inside the
+qemu subprocess.
+
+There is no comprehensive help for this command.  You have
+to look at the file C<daemon/debug.c> in the libguestfs source
+to find out what you can do.
+
 =head2 download
 
  download remotefilename (filename|-)
 =head2 download
 
  download remotefilename (filename|-)
index dcc8b50..b945454 100644 (file)
@@ -522,6 +522,23 @@ C<value> can be NULL.
 
 This function returns 0 on success or -1 on error.
 
 
 This function returns 0 on success or -1 on error.
 
+=head2 guestfs_debug
+
+ char *guestfs_debug (guestfs_h *handle,
+               const char *subcmd,
+               char * const* const extraargs);
+
+The C<guestfs_debug> command exposes some internals of
+C<guestfsd> (the guestfs daemon) that runs inside the
+qemu subprocess.
+
+There is no comprehensive help for this command.  You have
+to look at the file C<daemon/debug.c> in the libguestfs source
+to find out what you can do.
+
+This function returns a string, or NULL on error.
+I<The caller must free the returned string after use>.
+
 =head2 guestfs_download
 
  int guestfs_download (guestfs_h *handle,
 =head2 guestfs_download
 
  int guestfs_download (guestfs_h *handle,
index bb6c8d7..f1cd508 100644 (file)
@@ -2186,4 +2186,27 @@ public class GuestFS {
   private native void _mount_vfs (long g, String options, String vfstype, String device, String mountpoint)
     throws LibGuestFSException;
 
   private native void _mount_vfs (long g, String options, String vfstype, String device, String mountpoint)
     throws LibGuestFSException;
 
+  /**
+   * debugging and internals
+   *
+   * The "g.debug" command exposes some internals of
+   * "guestfsd" (the guestfs daemon) that runs inside the
+   * qemu subprocess.
+   * 
+   * There is no comprehensive help for this command. You
+   * have to look at the file "daemon/debug.c" in the
+   * libguestfs source to find out what you can do.
+   * 
+   * @throws LibGuestFSException
+   */
+  public String debug (String subcmd, String[] extraargs)
+    throws LibGuestFSException
+  {
+    if (g == 0)
+      throw new LibGuestFSException ("debug: handle is closed");
+    return _debug (g, subcmd, extraargs);
+  }
+  private native String _debug (long g, String subcmd, String[] extraargs)
+    throws LibGuestFSException;
+
 }
 }
index 81435d9..4b96c26 100644 (file)
@@ -2230,3 +2230,39 @@ Java_com_redhat_et_libguestfs_GuestFS__1mount_1vfs
   }
 }
 
   }
 }
 
+JNIEXPORT jstring JNICALL
+Java_com_redhat_et_libguestfs_GuestFS__1debug
+  (JNIEnv *env, jobject obj, jlong jg, jstring jsubcmd, jobjectArray jextraargs)
+{
+  guestfs_h *g = (guestfs_h *) (long) jg;
+  jstring jr;
+  char *r;
+  const char *subcmd;
+  int extraargs_len;
+  const char **extraargs;
+  int i;
+
+  subcmd = (*env)->GetStringUTFChars (env, jsubcmd, NULL);
+  extraargs_len = (*env)->GetArrayLength (env, jextraargs);
+  extraargs = malloc (sizeof (char *) * (extraargs_len+1));
+  for (i = 0; i < extraargs_len; ++i) {
+    jobject o = (*env)->GetObjectArrayElement (env, jextraargs, i);
+    extraargs[i] = (*env)->GetStringUTFChars (env, o, NULL);
+  }
+  extraargs[extraargs_len] = NULL;
+  r = guestfs_debug (g, subcmd, extraargs);
+  (*env)->ReleaseStringUTFChars (env, jsubcmd, subcmd);
+  for (i = 0; i < extraargs_len; ++i) {
+    jobject o = (*env)->GetObjectArrayElement (env, jextraargs, i);
+    (*env)->ReleaseStringUTFChars (env, o, extraargs[i]);
+  }
+  free (extraargs);
+  if (r == NULL) {
+    throw_exception (env, guestfs_last_error (g));
+    return NULL;
+  }
+  jr = (*env)->NewStringUTF (env, r);
+  free (r);
+  return jr;
+}
+
index 96ec6e3..c3305e4 100644 (file)
@@ -211,3 +211,4 @@ external tgz_out : t -> string -> string -> unit = "ocaml_guestfs_tgz_out"
 external mount_ro : t -> string -> string -> unit = "ocaml_guestfs_mount_ro"
 external mount_options : t -> string -> string -> string -> unit = "ocaml_guestfs_mount_options"
 external mount_vfs : t -> string -> string -> string -> string -> unit = "ocaml_guestfs_mount_vfs"
 external mount_ro : t -> string -> string -> unit = "ocaml_guestfs_mount_ro"
 external mount_options : t -> string -> string -> string -> unit = "ocaml_guestfs_mount_options"
 external mount_vfs : t -> string -> string -> string -> string -> unit = "ocaml_guestfs_mount_vfs"
+external debug : t -> string -> string array -> string = "ocaml_guestfs_debug"
index a332f0b..846332c 100644 (file)
@@ -412,3 +412,6 @@ val mount_options : t -> string -> string -> string -> unit
 val mount_vfs : t -> string -> string -> string -> string -> unit
 (** mount a guest disk with mount options and vfstype *)
 
 val mount_vfs : t -> string -> string -> string -> string -> unit
 (** mount a guest disk with mount options and vfstype *)
 
+val debug : t -> string -> string array -> string
+(** debugging and internals *)
+
index acf8f92..c396a8a 100644 (file)
@@ -2608,3 +2608,29 @@ ocaml_guestfs_mount_vfs (value gv, value optionsv, value vfstypev, value devicev
   CAMLreturn (rv);
 }
 
   CAMLreturn (rv);
 }
 
+CAMLprim value
+ocaml_guestfs_debug (value gv, value subcmdv, value extraargsv)
+{
+  CAMLparam3 (gv, subcmdv, extraargsv);
+  CAMLlocal1 (rv);
+
+  guestfs_h *g = Guestfs_val (gv);
+  if (g == NULL)
+    caml_failwith ("debug: used handle after closing it");
+
+  const char *subcmd = String_val (subcmdv);
+  char **extraargs = ocaml_guestfs_strings_val (extraargsv);
+  char *r;
+
+  caml_enter_blocking_section ();
+  r = guestfs_debug (g, subcmd, extraargs);
+  caml_leave_blocking_section ();
+  ocaml_guestfs_free_strings (extraargs);
+  if (r == NULL)
+    ocaml_guestfs_raise_error (g, "debug");
+
+  rv = caml_copy_string (r);
+  free (r);
+  CAMLreturn (rv);
+}
+
index fe2c81c..be13fcd 100644 (file)
@@ -1468,3 +1468,20 @@ PREINIT:
       if (r == -1)
         croak ("mount_vfs: %s", guestfs_last_error (g));
 
       if (r == -1)
         croak ("mount_vfs: %s", guestfs_last_error (g));
 
+SV *
+debug (g, subcmd, extraargs)
+      guestfs_h *g;
+      char *subcmd;
+      char **extraargs;
+PREINIT:
+      char *result;
+   CODE:
+      result = guestfs_debug (g, subcmd, extraargs);
+      free (extraargs);
+      if (result == NULL)
+        croak ("debug: %s", guestfs_last_error (g));
+      RETVAL = newSVpv (result, 0);
+      free (result);
+ OUTPUT:
+      RETVAL
+
index ea82659..3d1493b 100644 (file)
@@ -432,6 +432,16 @@ The first character of C<param> string must be a C<-> (dash).
 
 C<value> can be NULL.
 
 
 C<value> can be NULL.
 
+=item $result = $h->debug ($subcmd, \@extraargs);
+
+The C<$h-E<gt>debug> command exposes some internals of
+C<guestfsd> (the guestfs daemon) that runs inside the
+qemu subprocess.
+
+There is no comprehensive help for this command.  You have
+to look at the file C<daemon/debug.c> in the libguestfs source
+to find out what you can do.
+
 =item $h->download ($remotefilename, $filename);
 
 Download file C<remotefilename> and save it as C<filename>
 =item $h->download ($remotefilename, $filename);
 
 Download file C<remotefilename> and save it as C<filename>
index 59f0b6e..0022b5b 100644 (file)
@@ -2795,6 +2795,36 @@ py_guestfs_mount_vfs (PyObject *self, PyObject *args)
   return py_r;
 }
 
   return py_r;
 }
 
+static PyObject *
+py_guestfs_debug (PyObject *self, PyObject *args)
+{
+  PyObject *py_g;
+  guestfs_h *g;
+  PyObject *py_r;
+  char *r;
+  const char *subcmd;
+  PyObject *py_extraargs;
+  const char **extraargs;
+
+  if (!PyArg_ParseTuple (args, (char *) "OsO:guestfs_debug",
+                         &py_g, &subcmd, &py_extraargs))
+    return NULL;
+  g = get_handle (py_g);
+  extraargs = get_string_list (py_extraargs);
+  if (!extraargs) return NULL;
+
+  r = guestfs_debug (g, subcmd, extraargs);
+  free (extraargs);
+  if (r == NULL) {
+    PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
+    return NULL;
+  }
+
+  py_r = PyString_FromString (r);
+  free (r);
+  return py_r;
+}
+
 static PyMethodDef methods[] = {
   { (char *) "create", py_guestfs_create, METH_VARARGS, NULL },
   { (char *) "close", py_guestfs_close, METH_VARARGS, NULL },
 static PyMethodDef methods[] = {
   { (char *) "create", py_guestfs_create, METH_VARARGS, NULL },
   { (char *) "close", py_guestfs_close, METH_VARARGS, NULL },
@@ -2894,6 +2924,7 @@ static PyMethodDef methods[] = {
   { (char *) "mount_ro", py_guestfs_mount_ro, METH_VARARGS, NULL },
   { (char *) "mount_options", py_guestfs_mount_options, METH_VARARGS, NULL },
   { (char *) "mount_vfs", py_guestfs_mount_vfs, METH_VARARGS, NULL },
   { (char *) "mount_ro", py_guestfs_mount_ro, METH_VARARGS, NULL },
   { (char *) "mount_options", py_guestfs_mount_options, METH_VARARGS, NULL },
   { (char *) "mount_vfs", py_guestfs_mount_vfs, METH_VARARGS, NULL },
+  { (char *) "debug", py_guestfs_debug, METH_VARARGS, NULL },
   { NULL, NULL, 0, NULL }
 };
 
   { NULL, NULL, 0, NULL }
 };
 
index 7515aa7..b2c3e49 100644 (file)
@@ -1075,3 +1075,14 @@ class GuestFS:
         """
         return libguestfsmod.mount_vfs (self._o, options, vfstype, device, mountpoint)
 
         """
         return libguestfsmod.mount_vfs (self._o, options, vfstype, device, mountpoint)
 
+    def debug (self, subcmd, extraargs):
+        u"""The "g.debug" command exposes some internals of
+        "guestfsd" (the guestfs daemon) that runs inside the
+        qemu subprocess.
+        
+        There is no comprehensive help for this command. You
+        have to look at the file "daemon/debug.c" in the
+        libguestfs source to find out what you can do.
+        """
+        return libguestfsmod.debug (self._o, subcmd, extraargs)
+
index 89eb6af..07b0228 100644 (file)
@@ -2318,6 +2318,39 @@ static VALUE ruby_guestfs_mount_vfs (VALUE gv, VALUE optionsv, VALUE vfstypev, V
   return Qnil;
 }
 
   return Qnil;
 }
 
+static VALUE ruby_guestfs_debug (VALUE gv, VALUE subcmdv, VALUE extraargsv)
+{
+  guestfs_h *g;
+  Data_Get_Struct (gv, guestfs_h, g);
+  if (!g)
+    rb_raise (rb_eArgError, "%s: used handle after closing it", "debug");
+
+  const char *subcmd = StringValueCStr (subcmdv);
+  if (!subcmd)
+    rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
+              "subcmd", "debug");
+  char **extraargs;  {
+    int i, len;
+    len = RARRAY_LEN (extraargsv);
+    extraargs = malloc (sizeof (char *) * (len+1));
+    for (i = 0; i < len; ++i) {
+      VALUE v = rb_ary_entry (extraargsv, i);
+      extraargs[i] = StringValueCStr (v);
+    }
+  }
+
+  char *r;
+
+  r = guestfs_debug (g, subcmd, extraargs);
+  free (extraargs);
+  if (r == NULL)
+    rb_raise (e_Error, "%s", guestfs_last_error (g));
+
+  VALUE rv = rb_str_new2 (r);
+  free (r);
+  return rv;
+}
+
 /* Initialize the module. */
 void Init__guestfs ()
 {
 /* Initialize the module. */
 void Init__guestfs ()
 {
@@ -2520,4 +2553,6 @@ void Init__guestfs ()
         ruby_guestfs_mount_options, 3);
   rb_define_method (c_guestfs, "mount_vfs",
         ruby_guestfs_mount_vfs, 4);
         ruby_guestfs_mount_options, 3);
   rb_define_method (c_guestfs, "mount_vfs",
         ruby_guestfs_mount_vfs, 4);
+  rb_define_method (c_guestfs, "debug",
+        ruby_guestfs_debug, 2);
 }
 }
index ae8afcf..e143c27 100644 (file)
@@ -6389,3 +6389,91 @@ int guestfs_mount_vfs (guestfs_h *g,
   return 0;
 }
 
   return 0;
 }
 
+struct debug_ctx {
+  /* This flag is set by the callbacks, so we know we've done
+   * the callbacks as expected, and in the right sequence.
+   * 0 = not called, 1 = send called,
+   * 1001 = reply called.
+   */
+  int cb_sequence;
+  struct guestfs_message_header hdr;
+  struct guestfs_message_error err;
+  struct guestfs_debug_ret ret;
+};
+
+static void debug_reply_cb (guestfs_h *g, void *data, XDR *xdr)
+{
+  guestfs_main_loop *ml = guestfs_get_main_loop (g);
+  struct debug_ctx *ctx = (struct debug_ctx *) data;
+
+  ml->main_loop_quit (ml, g);
+
+  if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
+    error (g, "%s: failed to parse reply header", "guestfs_debug");
+    return;
+  }
+  if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
+    if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
+      error (g, "%s: failed to parse reply error", "guestfs_debug");
+      return;
+    }
+    goto done;
+  }
+  if (!xdr_guestfs_debug_ret (xdr, &ctx->ret)) {
+    error (g, "%s: failed to parse reply", "guestfs_debug");
+    return;
+  }
+ done:
+  ctx->cb_sequence = 1001;
+}
+
+char *guestfs_debug (guestfs_h *g,
+               const char *subcmd,
+               char * const* const extraargs)
+{
+  struct guestfs_debug_args args;
+  struct debug_ctx ctx;
+  guestfs_main_loop *ml = guestfs_get_main_loop (g);
+  int serial;
+
+  if (check_state (g, "guestfs_debug") == -1) return NULL;
+  guestfs_set_busy (g);
+
+  memset (&ctx, 0, sizeof ctx);
+
+  args.subcmd = (char *) subcmd;
+  args.extraargs.extraargs_val = (char **) extraargs;
+  for (args.extraargs.extraargs_len = 0; extraargs[args.extraargs.extraargs_len]; args.extraargs.extraargs_len++) ;
+  serial = guestfs__send_sync (g, GUESTFS_PROC_DEBUG,
+        (xdrproc_t) xdr_guestfs_debug_args, (char *) &args);
+  if (serial == -1) {
+    guestfs_set_ready (g);
+    return NULL;
+  }
+
+  guestfs__switch_to_receiving (g);
+  ctx.cb_sequence = 0;
+  guestfs_set_reply_callback (g, debug_reply_cb, &ctx);
+  (void) ml->main_loop_run (ml, g);
+  guestfs_set_reply_callback (g, NULL, NULL);
+  if (ctx.cb_sequence != 1001) {
+    error (g, "%s reply failed, see earlier error messages", "guestfs_debug");
+    guestfs_set_ready (g);
+    return NULL;
+  }
+
+  if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_DEBUG, serial) == -1) {
+    guestfs_set_ready (g);
+    return NULL;
+  }
+
+  if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
+    error (g, "%s", ctx.err.error_message);
+    guestfs_set_ready (g);
+    return NULL;
+  }
+
+  guestfs_set_ready (g);
+  return ctx.ret.result; /* caller will free */
+}
+
index 756b678..5190528 100644 (file)
@@ -115,3 +115,4 @@ extern int guestfs_tgz_out (guestfs_h *handle, const char *directory, const char
 extern int guestfs_mount_ro (guestfs_h *handle, const char *device, const char *mountpoint);
 extern int guestfs_mount_options (guestfs_h *handle, const char *options, const char *device, const char *mountpoint);
 extern int guestfs_mount_vfs (guestfs_h *handle, const char *options, const char *vfstype, const char *device, const char *mountpoint);
 extern int guestfs_mount_ro (guestfs_h *handle, const char *device, const char *mountpoint);
 extern int guestfs_mount_options (guestfs_h *handle, const char *options, const char *device, const char *mountpoint);
 extern int guestfs_mount_vfs (guestfs_h *handle, const char *options, const char *vfstype, const char *device, const char *mountpoint);
+extern char *guestfs_debug (guestfs_h *handle, const char *subcmd, char * const* const extraargs);
index 65eb5fc..5bde2b9 100644 (file)
@@ -1311,6 +1311,29 @@ xdr_guestfs_mount_vfs_args (XDR *xdrs, guestfs_mount_vfs_args *objp)
 }
 
 bool_t
 }
 
 bool_t
+xdr_guestfs_debug_args (XDR *xdrs, guestfs_debug_args *objp)
+{
+       register int32_t *buf;
+
+        if (!xdr_string (xdrs, &objp->subcmd, ~0))
+                return FALSE;
+        if (!xdr_array (xdrs, (char **)&objp->extraargs.extraargs_val, (u_int *) &objp->extraargs.extraargs_len, ~0,
+               sizeof (str), (xdrproc_t) xdr_str))
+                return FALSE;
+       return TRUE;
+}
+
+bool_t
+xdr_guestfs_debug_ret (XDR *xdrs, guestfs_debug_ret *objp)
+{
+       register int32_t *buf;
+
+        if (!xdr_string (xdrs, &objp->result, ~0))
+                return FALSE;
+       return TRUE;
+}
+
+bool_t
 xdr_guestfs_procedure (XDR *xdrs, guestfs_procedure *objp)
 {
        register int32_t *buf;
 xdr_guestfs_procedure (XDR *xdrs, guestfs_procedure *objp)
 {
        register int32_t *buf;
index 8803b3d..2a8d919 100644 (file)
@@ -678,6 +678,20 @@ struct guestfs_mount_vfs_args {
 };
 typedef struct guestfs_mount_vfs_args guestfs_mount_vfs_args;
 
 };
 typedef struct guestfs_mount_vfs_args guestfs_mount_vfs_args;
 
+struct guestfs_debug_args {
+       char *subcmd;
+       struct {
+               u_int extraargs_len;
+               str *extraargs_val;
+       } extraargs;
+};
+typedef struct guestfs_debug_args guestfs_debug_args;
+
+struct guestfs_debug_ret {
+       char *result;
+};
+typedef struct guestfs_debug_ret guestfs_debug_ret;
+
 enum guestfs_procedure {
        GUESTFS_PROC_MOUNT = 1,
        GUESTFS_PROC_SYNC = 2,
 enum guestfs_procedure {
        GUESTFS_PROC_MOUNT = 1,
        GUESTFS_PROC_SYNC = 2,
@@ -754,7 +768,8 @@ enum guestfs_procedure {
        GUESTFS_PROC_MOUNT_RO = 73,
        GUESTFS_PROC_MOUNT_OPTIONS = 74,
        GUESTFS_PROC_MOUNT_VFS = 75,
        GUESTFS_PROC_MOUNT_RO = 73,
        GUESTFS_PROC_MOUNT_OPTIONS = 74,
        GUESTFS_PROC_MOUNT_VFS = 75,
-       GUESTFS_PROC_NR_PROCS = 75 + 1,
+       GUESTFS_PROC_DEBUG = 76,
+       GUESTFS_PROC_NR_PROCS = 76 + 1,
 };
 typedef enum guestfs_procedure guestfs_procedure;
 #define GUESTFS_MESSAGE_MAX 4194304
 };
 typedef enum guestfs_procedure guestfs_procedure;
 #define GUESTFS_MESSAGE_MAX 4194304
@@ -908,6 +923,8 @@ extern  bool_t xdr_guestfs_tgz_out_args (XDR *, guestfs_tgz_out_args*);
 extern  bool_t xdr_guestfs_mount_ro_args (XDR *, guestfs_mount_ro_args*);
 extern  bool_t xdr_guestfs_mount_options_args (XDR *, guestfs_mount_options_args*);
 extern  bool_t xdr_guestfs_mount_vfs_args (XDR *, guestfs_mount_vfs_args*);
 extern  bool_t xdr_guestfs_mount_ro_args (XDR *, guestfs_mount_ro_args*);
 extern  bool_t xdr_guestfs_mount_options_args (XDR *, guestfs_mount_options_args*);
 extern  bool_t xdr_guestfs_mount_vfs_args (XDR *, guestfs_mount_vfs_args*);
+extern  bool_t xdr_guestfs_debug_args (XDR *, guestfs_debug_args*);
+extern  bool_t xdr_guestfs_debug_ret (XDR *, guestfs_debug_ret*);
 extern  bool_t xdr_guestfs_procedure (XDR *, guestfs_procedure*);
 extern  bool_t xdr_guestfs_message_direction (XDR *, guestfs_message_direction*);
 extern  bool_t xdr_guestfs_message_status (XDR *, guestfs_message_status*);
 extern  bool_t xdr_guestfs_procedure (XDR *, guestfs_procedure*);
 extern  bool_t xdr_guestfs_message_direction (XDR *, guestfs_message_direction*);
 extern  bool_t xdr_guestfs_message_status (XDR *, guestfs_message_status*);
@@ -1020,6 +1037,8 @@ extern bool_t xdr_guestfs_tgz_out_args ();
 extern bool_t xdr_guestfs_mount_ro_args ();
 extern bool_t xdr_guestfs_mount_options_args ();
 extern bool_t xdr_guestfs_mount_vfs_args ();
 extern bool_t xdr_guestfs_mount_ro_args ();
 extern bool_t xdr_guestfs_mount_options_args ();
 extern bool_t xdr_guestfs_mount_vfs_args ();
+extern bool_t xdr_guestfs_debug_args ();
+extern bool_t xdr_guestfs_debug_ret ();
 extern bool_t xdr_guestfs_procedure ();
 extern bool_t xdr_guestfs_message_direction ();
 extern bool_t xdr_guestfs_message_status ();
 extern bool_t xdr_guestfs_procedure ();
 extern bool_t xdr_guestfs_message_direction ();
 extern bool_t xdr_guestfs_message_status ();
index 3cf4df3..7f0793f 100644 (file)
@@ -526,6 +526,15 @@ struct guestfs_mount_vfs_args {
   string mountpoint<>;
 };
 
   string mountpoint<>;
 };
 
+struct guestfs_debug_args {
+  string subcmd<>;
+  str extraargs<>;
+};
+
+struct guestfs_debug_ret {
+  string result<>;
+};
+
 enum guestfs_procedure {
   GUESTFS_PROC_MOUNT = 1,
   GUESTFS_PROC_SYNC = 2,
 enum guestfs_procedure {
   GUESTFS_PROC_MOUNT = 1,
   GUESTFS_PROC_SYNC = 2,
@@ -602,6 +611,7 @@ enum guestfs_procedure {
   GUESTFS_PROC_MOUNT_RO = 73,
   GUESTFS_PROC_MOUNT_OPTIONS = 74,
   GUESTFS_PROC_MOUNT_VFS = 75,
   GUESTFS_PROC_MOUNT_RO = 73,
   GUESTFS_PROC_MOUNT_OPTIONS = 74,
   GUESTFS_PROC_MOUNT_VFS = 75,
+  GUESTFS_PROC_DEBUG = 76,
   GUESTFS_PROC_NR_PROCS
 };
 
   GUESTFS_PROC_NR_PROCS
 };
 
diff --git a/tests.c b/tests.c
index 9c102cd..be32e66 100644 (file)
--- a/tests.c
+++ b/tests.c
@@ -107,6 +107,7 @@ static void no_test_warnings (void)
   fprintf (stderr, "warning: \"guestfs_tgz_out\" has no tests\n");
   fprintf (stderr, "warning: \"guestfs_mount_options\" has no tests\n");
   fprintf (stderr, "warning: \"guestfs_mount_vfs\" has no tests\n");
   fprintf (stderr, "warning: \"guestfs_tgz_out\" has no tests\n");
   fprintf (stderr, "warning: \"guestfs_mount_options\" has no tests\n");
   fprintf (stderr, "warning: \"guestfs_mount_vfs\" has no tests\n");
+  fprintf (stderr, "warning: \"guestfs_debug\" has no tests\n");
 }
 
 static int test_mount_ro_0 (void)
 }
 
 static int test_mount_ro_0 (void)