Add 'append', LIBGUESTFS_APPEND to set additional kernel options.
authorRichard W.M. Jones <rjones@redhat.com>
Wed, 13 May 2009 16:51:14 +0000 (17:51 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Wed, 13 May 2009 16:51:14 +0000 (17:51 +0100)
21 files changed:
fish/cmds.c
fish/completion.c
guestfish-actions.pod
guestfish.pod
guestfs-actions.pod
guestfs.pod
haskell/Guestfs.hs
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/generator.ml
src/guestfs-actions.h
src/guestfs.c
tests.c

index 4c5b5fa..47c66da 100644 (file)
@@ -73,6 +73,7 @@ void list_commands (void)
   printf ("%-20s %s\n", "exists", "test if file or directory exists");
   printf ("%-20s %s\n", "file", "determine file type");
   printf ("%-20s %s\n", "fsck", "run the filesystem checker");
   printf ("%-20s %s\n", "exists", "test if file or directory exists");
   printf ("%-20s %s\n", "file", "determine file type");
   printf ("%-20s %s\n", "fsck", "run the filesystem checker");
+  printf ("%-20s %s\n", "get-append", "get the additional kernel options");
   printf ("%-20s %s\n", "get-autosync", "get autosync mode");
   printf ("%-20s %s\n", "get-e2label", "get the ext2/3/4 filesystem label");
   printf ("%-20s %s\n", "get-e2uuid", "get the ext2/3/4 filesystem UUID");
   printf ("%-20s %s\n", "get-autosync", "get autosync mode");
   printf ("%-20s %s\n", "get-e2label", "get the ext2/3/4 filesystem label");
   printf ("%-20s %s\n", "get-e2uuid", "get the ext2/3/4 filesystem UUID");
@@ -118,6 +119,7 @@ void list_commands (void)
   printf ("%-20s %s\n", "rm", "remove a file");
   printf ("%-20s %s\n", "rm-rf", "remove a file or directory recursively");
   printf ("%-20s %s\n", "rmdir", "remove a directory");
   printf ("%-20s %s\n", "rm", "remove a file");
   printf ("%-20s %s\n", "rm-rf", "remove a file or directory recursively");
   printf ("%-20s %s\n", "rmdir", "remove a directory");
+  printf ("%-20s %s\n", "set-append", "add options to kernel command line");
   printf ("%-20s %s\n", "set-autosync", "set autosync mode");
   printf ("%-20s %s\n", "set-e2label", "set the ext2/3/4 filesystem label");
   printf ("%-20s %s\n", "set-e2uuid", "set the ext2/3/4 filesystem UUID");
   printf ("%-20s %s\n", "set-autosync", "set autosync mode");
   printf ("%-20s %s\n", "set-e2label", "set the ext2/3/4 filesystem label");
   printf ("%-20s %s\n", "set-e2uuid", "set the ext2/3/4 filesystem UUID");
@@ -177,6 +179,12 @@ void display_command (const char *cmd)
   if (strcasecmp (cmd, "get_path") == 0 || strcasecmp (cmd, "get-path") == 0)
     pod2text ("get-path - get the search path", " get-path\n\nReturn the current search path.\n\nThis is always non-NULL.  If it wasn't set already, then this will\nreturn the default path.");
   else
   if (strcasecmp (cmd, "get_path") == 0 || strcasecmp (cmd, "get-path") == 0)
     pod2text ("get-path - get the search path", " get-path\n\nReturn the current search path.\n\nThis is always non-NULL.  If it wasn't set already, then this will\nreturn the default path.");
   else
+  if (strcasecmp (cmd, "set_append") == 0 || strcasecmp (cmd, "set-append") == 0 || strcasecmp (cmd, "append") == 0)
+    pod2text ("set-append - add options to kernel command line", " set-append <append>\n\nThis function is used to add additional options to the\nguest kernel command line.\n\nThe default is C<NULL> unless overridden by setting\nC<LIBGUESTFS_APPEND> environment variable.\n\nThe string C<append> is stashed in the libguestfs handle, so the caller\nmust make sure it remains valid for the lifetime of the handle.\n\nSetting C<append> to C<NULL> means I<no> additional options\nare passed (libguestfs always adds a few of its own).\n\nYou can use 'append' as an alias for this command.");
+  else
+  if (strcasecmp (cmd, "get_append") == 0 || strcasecmp (cmd, "get-append") == 0)
+    pod2text ("get-append - get the additional kernel options", " get-append\n\nReturn the additional kernel options which are added to the\nguest kernel command line.\n\nIf C<NULL> then no options are added.");
+  else
   if (strcasecmp (cmd, "set_autosync") == 0 || strcasecmp (cmd, "set-autosync") == 0 || strcasecmp (cmd, "autosync") == 0)
     pod2text ("set-autosync - set autosync mode", " set-autosync <autosync>\n\nIf C<autosync> is true, this enables autosync.  Libguestfs will make a\nbest effort attempt to run C<umount_all> followed by\nC<sync> when the handle is closed\n(also if the program exits without closing handles).\n\nThis is disabled by default (except in guestfish where it is\nenabled by default).\n\nYou can use 'autosync' as an alias for this command.");
   else
   if (strcasecmp (cmd, "set_autosync") == 0 || strcasecmp (cmd, "set-autosync") == 0 || strcasecmp (cmd, "autosync") == 0)
     pod2text ("set-autosync - set autosync mode", " set-autosync <autosync>\n\nIf C<autosync> is true, this enables autosync.  Libguestfs will make a\nbest effort attempt to run C<umount_all> followed by\nC<sync> when the handle is closed\n(also if the program exits without closing handles).\n\nThis is disabled by default (except in guestfish where it is\nenabled by default).\n\nYou can use 'autosync' as an alias for this command.");
   else
@@ -753,6 +761,34 @@ static int run_get_path (const char *cmd, int argc, char *argv[])
   return 0;
 }
 
   return 0;
 }
 
+static int run_set_append (const char *cmd, int argc, char *argv[])
+{
+  int r;
+  const char *append;
+  if (argc != 1) {
+    fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+    fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+    return -1;
+  }
+  append = argv[0];
+  r = guestfs_set_append (g, append);
+  return r;
+}
+
+static int run_get_append (const char *cmd, int argc, char *argv[])
+{
+  const char *r;
+  if (argc != 0) {
+    fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+    fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+    return -1;
+  }
+  r = guestfs_get_append (g);
+  if (r == NULL) return -1;
+  printf ("%s\n", r);
+  return 0;
+}
+
 static int run_set_autosync (const char *cmd, int argc, char *argv[])
 {
   int r;
 static int run_set_autosync (const char *cmd, int argc, char *argv[])
 {
   int r;
@@ -2431,6 +2467,12 @@ int run_action (const char *cmd, int argc, char *argv[])
   if (strcasecmp (cmd, "get_path") == 0 || strcasecmp (cmd, "get-path") == 0)
     return run_get_path (cmd, argc, argv);
   else
   if (strcasecmp (cmd, "get_path") == 0 || strcasecmp (cmd, "get-path") == 0)
     return run_get_path (cmd, argc, argv);
   else
+  if (strcasecmp (cmd, "set_append") == 0 || strcasecmp (cmd, "set-append") == 0 || strcasecmp (cmd, "append") == 0)
+    return run_set_append (cmd, argc, argv);
+  else
+  if (strcasecmp (cmd, "get_append") == 0 || strcasecmp (cmd, "get-append") == 0)
+    return run_get_append (cmd, argc, argv);
+  else
   if (strcasecmp (cmd, "set_autosync") == 0 || strcasecmp (cmd, "set-autosync") == 0 || strcasecmp (cmd, "autosync") == 0)
     return run_set_autosync (cmd, argc, argv);
   else
   if (strcasecmp (cmd, "set_autosync") == 0 || strcasecmp (cmd, "set-autosync") == 0 || strcasecmp (cmd, "autosync") == 0)
     return run_set_autosync (cmd, argc, argv);
   else
index 9318288..4db2d5e 100644 (file)
@@ -37,6 +37,7 @@ static const char *const commands[] = {
   "add",
   "add-cdrom",
   "add-drive",
   "add",
   "add-cdrom",
   "add-drive",
+  "append",
   "aug-close",
   "aug-defnode",
   "aug-defvar",
   "aug-close",
   "aug-defnode",
   "aug-defvar",
@@ -79,6 +80,7 @@ static const char *const commands[] = {
   "exists",
   "file",
   "fsck",
   "exists",
   "file",
   "fsck",
+  "get-append",
   "get-autosync",
   "get-e2label",
   "get-e2uuid",
   "get-autosync",
   "get-e2label",
   "get-e2uuid",
@@ -127,6 +129,7 @@ static const char *const commands[] = {
   "rm-rf",
   "rmdir",
   "run",
   "rm-rf",
   "rmdir",
   "run",
+  "set-append",
   "set-autosync",
   "set-e2label",
   "set-e2uuid",
   "set-autosync",
   "set-e2label",
   "set-e2uuid",
index 7d46206..20c34a5 100644 (file)
@@ -546,6 +546,15 @@ Checking or repairing NTFS volumes is not supported
 
 This command is entirely equivalent to running C<fsck -a -t fstype device>.
 
 
 This command is entirely equivalent to running C<fsck -a -t fstype device>.
 
+=head2 get-append
+
+ get-append
+
+Return the additional kernel options which are added to the
+guest kernel command line.
+
+If C<NULL> then no options are added.
+
 =head2 get-autosync
 
  get-autosync
 =head2 get-autosync
 
  get-autosync
@@ -949,6 +958,22 @@ command.
 
 Remove the single directory C<path>.
 
 
 Remove the single directory C<path>.
 
+=head2 set-append | append
+
+ set-append append
+
+This function is used to add additional options to the
+guest kernel command line.
+
+The default is C<NULL> unless overridden by setting
+C<LIBGUESTFS_APPEND> environment variable.
+
+The string C<append> is stashed in the libguestfs handle, so the caller
+must make sure it remains valid for the lifetime of the handle.
+
+Setting C<append> to C<NULL> means I<no> additional options
+are passed (libguestfs always adds a few of its own).
+
 =head2 set-autosync | autosync
 
  set-autosync true|false
 =head2 set-autosync | autosync
 
  set-autosync true|false
index e7a4ffa..d44e3e3 100644 (file)
@@ -300,6 +300,10 @@ Set the default qemu binary that libguestfs uses.  If not set, then
 the qemu which was found at compile time by the configure script is
 used.
 
 the qemu which was found at compile time by the configure script is
 used.
 
+=item LIBGUESTFS_APPEND
+
+Pass additional options to the guest kernel.
+
 =item HOME
 
 If compiled with GNU readline support, then the command history
 =item HOME
 
 If compiled with GNU readline support, then the command history
index c187540..7de041c 100644 (file)
@@ -713,6 +713,18 @@ This command is entirely equivalent to running C<fsck -a -t fstype device>.
 
 On error this function returns -1.
 
 
 On error this function returns -1.
 
+=head2 guestfs_get_append
+
+ const char *guestfs_get_append (guestfs_h *handle);
+
+Return the additional kernel options which are added to the
+guest kernel command line.
+
+If C<NULL> then no options are added.
+
+This function returns a string, or NULL on error.
+The string is owned by the guest handle and must I<not> be freed.
+
 =head2 guestfs_get_autosync
 
  int guestfs_get_autosync (guestfs_h *handle);
 =head2 guestfs_get_autosync
 
  int guestfs_get_autosync (guestfs_h *handle);
@@ -1272,6 +1284,25 @@ Remove the single directory C<path>.
 
 This function returns 0 on success or -1 on error.
 
 
 This function returns 0 on success or -1 on error.
 
+=head2 guestfs_set_append
+
+ int guestfs_set_append (guestfs_h *handle,
+               const char *append);
+
+This function is used to add additional options to the
+guest kernel command line.
+
+The default is C<NULL> unless overridden by setting
+C<LIBGUESTFS_APPEND> environment variable.
+
+The string C<append> is stashed in the libguestfs handle, so the caller
+must make sure it remains valid for the lifetime of the handle.
+
+Setting C<append> to C<NULL> means I<no> additional options
+are passed (libguestfs always adds a few of its own).
+
+This function returns 0 on success or -1 on error.
+
 =head2 guestfs_set_autosync
 
  int guestfs_set_autosync (guestfs_h *handle,
 =head2 guestfs_set_autosync
 
  int guestfs_set_autosync (guestfs_h *handle,
index 06cc2b3..4dc5757 100644 (file)
@@ -678,6 +678,10 @@ used.
 
 See also L<QEMU WRAPPERS> above.
 
 
 See also L<QEMU WRAPPERS> above.
 
+=item LIBGUESTFS_APPEND
+
+Pass additional options to the guest kernel.
+
 =back
 
 =head1 SEE ALSO
 =back
 
 =head1 SEE ALSO
index aedf3b5..4721376 100644 (file)
@@ -32,6 +32,7 @@ module Guestfs (
   config,
   set_qemu,
   set_path,
   config,
   set_qemu,
   set_path,
+  set_append,
   set_busy,
   set_ready,
   end_busy,
   set_busy,
   set_ready,
   end_busy,
@@ -223,6 +224,18 @@ set_path h path = do
       fail err
     else return ()
 
       fail err
     else return ()
 
+foreign import ccall unsafe "guestfs_set_append" c_set_append
+  :: GuestfsP -> CString -> IO (CInt)
+
+set_append :: GuestfsH -> String -> IO ()
+set_append h append = do
+  r <- withCString append $ \append -> withForeignPtr h (\p -> c_set_append p append)
+  if (r == -1)
+    then do
+      err <- last_error h
+      fail err
+    else return ()
+
 foreign import ccall unsafe "guestfs_set_busy" c_set_busy
   :: GuestfsP -> IO (CInt)
 
 foreign import ccall unsafe "guestfs_set_busy" c_set_busy
   :: GuestfsP -> IO (CInt)
 
index 70efb8d..d0b3446 100644 (file)
@@ -316,6 +316,54 @@ public class GuestFS {
     throws LibGuestFSException;
 
   /**
     throws LibGuestFSException;
 
   /**
+   * add options to kernel command line
+   *
+   * This function is used to add additional options to the
+   * guest kernel command line.
+   * 
+   * The default is "NULL" unless overridden by setting
+   * "LIBGUESTFS_APPEND" environment variable.
+   * 
+   * The string "append" is stashed in the libguestfs handle,
+   * so the caller must make sure it remains valid for the
+   * lifetime of the handle.
+   * 
+   * Setting "append" to "NULL" means *no* additional options
+   * are passed (libguestfs always adds a few of its own).
+   * 
+   * @throws LibGuestFSException
+   */
+  public void set_append (String append)
+    throws LibGuestFSException
+  {
+    if (g == 0)
+      throw new LibGuestFSException ("set_append: handle is closed");
+    _set_append (g, append);
+  }
+  private native void _set_append (long g, String append)
+    throws LibGuestFSException;
+
+  /**
+   * get the additional kernel options
+   *
+   * Return the additional kernel options which are added to
+   * the guest kernel command line.
+   * 
+   * If "NULL" then no options are added.
+   * 
+   * @throws LibGuestFSException
+   */
+  public String get_append ()
+    throws LibGuestFSException
+  {
+    if (g == 0)
+      throw new LibGuestFSException ("get_append: handle is closed");
+    return _get_append (g);
+  }
+  private native String _get_append (long g)
+    throws LibGuestFSException;
+
+  /**
    * set autosync mode
    *
    * If "autosync" is true, this enables autosync. Libguestfs
    * set autosync mode
    *
    * If "autosync" is true, this enables autosync. Libguestfs
index 2ad4c6a..ce1f2db 100644 (file)
@@ -222,6 +222,38 @@ Java_com_redhat_et_libguestfs_GuestFS__1get_1path
 }
 
 JNIEXPORT void JNICALL
 }
 
 JNIEXPORT void JNICALL
+Java_com_redhat_et_libguestfs_GuestFS__1set_1append
+  (JNIEnv *env, jobject obj, jlong jg, jstring jappend)
+{
+  guestfs_h *g = (guestfs_h *) (long) jg;
+  int r;
+  const char *append;
+
+  append = (*env)->GetStringUTFChars (env, jappend, NULL);
+  r = guestfs_set_append (g, append);
+  (*env)->ReleaseStringUTFChars (env, jappend, append);
+  if (r == -1) {
+    throw_exception (env, guestfs_last_error (g));
+    return ;
+  }
+}
+
+JNIEXPORT jstring JNICALL
+Java_com_redhat_et_libguestfs_GuestFS__1get_1append
+  (JNIEnv *env, jobject obj, jlong jg)
+{
+  guestfs_h *g = (guestfs_h *) (long) jg;
+  const char *r;
+
+  r = guestfs_get_append (g);
+  if (r == NULL) {
+    throw_exception (env, guestfs_last_error (g));
+    return NULL;
+  }
+  return (*env)->NewStringUTF (env, r);
+}
+
+JNIEXPORT void JNICALL
 Java_com_redhat_et_libguestfs_GuestFS__1set_1autosync
   (JNIEnv *env, jobject obj, jlong jg, jboolean jautosync)
 {
 Java_com_redhat_et_libguestfs_GuestFS__1set_1autosync
   (JNIEnv *env, jobject obj, jlong jg, jboolean jautosync)
 {
index 39d2329..2544b16 100644 (file)
@@ -125,6 +125,8 @@ external set_qemu : t -> string -> unit = "ocaml_guestfs_set_qemu"
 external get_qemu : t -> string = "ocaml_guestfs_get_qemu"
 external set_path : t -> string -> unit = "ocaml_guestfs_set_path"
 external get_path : t -> string = "ocaml_guestfs_get_path"
 external get_qemu : t -> string = "ocaml_guestfs_get_qemu"
 external set_path : t -> string -> unit = "ocaml_guestfs_set_path"
 external get_path : t -> string = "ocaml_guestfs_get_path"
+external set_append : t -> string -> unit = "ocaml_guestfs_set_append"
+external get_append : t -> string = "ocaml_guestfs_get_append"
 external set_autosync : t -> bool -> unit = "ocaml_guestfs_set_autosync"
 external get_autosync : t -> bool = "ocaml_guestfs_get_autosync"
 external set_verbose : t -> bool -> unit = "ocaml_guestfs_set_verbose"
 external set_autosync : t -> bool -> unit = "ocaml_guestfs_set_autosync"
 external get_autosync : t -> bool = "ocaml_guestfs_get_autosync"
 external set_verbose : t -> bool -> unit = "ocaml_guestfs_set_verbose"
index 21e6eeb..870ffb6 100644 (file)
@@ -154,6 +154,12 @@ val set_path : t -> string -> unit
 val get_path : t -> string
 (** get the search path *)
 
 val get_path : t -> string
 (** get the search path *)
 
+val set_append : t -> string -> unit
+(** add options to kernel command line *)
+
+val get_append : t -> string
+(** get the additional kernel options *)
+
 val set_autosync : t -> bool -> unit
 (** set autosync mode *)
 
 val set_autosync : t -> bool -> unit
 (** set autosync mode *)
 
index fa352fc..22e6500 100644 (file)
@@ -556,6 +556,51 @@ ocaml_guestfs_get_path (value gv)
 }
 
 CAMLprim value
 }
 
 CAMLprim value
+ocaml_guestfs_set_append (value gv, value appendv)
+{
+  CAMLparam2 (gv, appendv);
+  CAMLlocal1 (rv);
+
+  guestfs_h *g = Guestfs_val (gv);
+  if (g == NULL)
+    caml_failwith ("set_append: used handle after closing it");
+
+  const char *append = String_val (appendv);
+  int r;
+
+  caml_enter_blocking_section ();
+  r = guestfs_set_append (g, append);
+  caml_leave_blocking_section ();
+  if (r == -1)
+    ocaml_guestfs_raise_error (g, "set_append");
+
+  rv = Val_unit;
+  CAMLreturn (rv);
+}
+
+CAMLprim value
+ocaml_guestfs_get_append (value gv)
+{
+  CAMLparam1 (gv);
+  CAMLlocal1 (rv);
+
+  guestfs_h *g = Guestfs_val (gv);
+  if (g == NULL)
+    caml_failwith ("get_append: used handle after closing it");
+
+  const char *r;
+
+  caml_enter_blocking_section ();
+  r = guestfs_get_append (g);
+  caml_leave_blocking_section ();
+  if (r == NULL)
+    ocaml_guestfs_raise_error (g, "get_append");
+
+  rv = caml_copy_string (r);
+  CAMLreturn (rv);
+}
+
+CAMLprim value
 ocaml_guestfs_set_autosync (value gv, value autosyncv)
 {
   CAMLparam2 (gv, autosyncv);
 ocaml_guestfs_set_autosync (value gv, value autosyncv)
 {
   CAMLparam2 (gv, autosyncv);
index 5ce5def..973f56e 100644 (file)
@@ -219,6 +219,30 @@ PREINIT:
       RETVAL
 
 void
       RETVAL
 
 void
+set_append (g, append)
+      guestfs_h *g;
+      char *append;
+PREINIT:
+      int r;
+ PPCODE:
+      r = guestfs_set_append (g, append);
+      if (r == -1)
+        croak ("set_append: %s", guestfs_last_error (g));
+
+SV *
+get_append (g)
+      guestfs_h *g;
+PREINIT:
+      const char *append;
+   CODE:
+      append = guestfs_get_append (g);
+      if (append == NULL)
+        croak ("get_append: %s", guestfs_last_error (g));
+      RETVAL = newSVpv (append, 0);
+ OUTPUT:
+      RETVAL
+
+void
 set_autosync (g, autosync)
       guestfs_h *g;
       int autosync;
 set_autosync (g, autosync)
       guestfs_h *g;
       int autosync;
index 001fa88..d803ce1 100644 (file)
@@ -561,6 +561,13 @@ Checking or repairing NTFS volumes is not supported
 
 This command is entirely equivalent to running C<fsck -a -t fstype device>.
 
 
 This command is entirely equivalent to running C<fsck -a -t fstype device>.
 
+=item $append = $h->get_append ();
+
+Return the additional kernel options which are added to the
+guest kernel command line.
+
+If C<NULL> then no options are added.
+
 =item $autosync = $h->get_autosync ();
 
 Get the autosync flag.
 =item $autosync = $h->get_autosync ();
 
 Get the autosync flag.
@@ -874,6 +881,20 @@ command.
 
 Remove the single directory C<path>.
 
 
 Remove the single directory C<path>.
 
+=item $h->set_append ($append);
+
+This function is used to add additional options to the
+guest kernel command line.
+
+The default is C<NULL> unless overridden by setting
+C<LIBGUESTFS_APPEND> environment variable.
+
+The string C<append> is stashed in the libguestfs handle, so the caller
+must make sure it remains valid for the lifetime of the handle.
+
+Setting C<append> to C<NULL> means I<no> additional options
+are passed (libguestfs always adds a few of its own).
+
 =item $h->set_autosync ($autosync);
 
 If C<autosync> is true, this enables autosync.  Libguestfs will make a
 =item $h->set_autosync ($autosync);
 
 If C<autosync> is true, this enables autosync.  Libguestfs will make a
index 11ea6a4..3a09afb 100644 (file)
@@ -633,6 +633,54 @@ py_guestfs_get_path (PyObject *self, PyObject *args)
 }
 
 static PyObject *
 }
 
 static PyObject *
+py_guestfs_set_append (PyObject *self, PyObject *args)
+{
+  PyObject *py_g;
+  guestfs_h *g;
+  PyObject *py_r;
+  int r;
+  const char *append;
+
+  if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_set_append",
+                         &py_g, &append))
+    return NULL;
+  g = get_handle (py_g);
+
+  r = guestfs_set_append (g, append);
+  if (r == -1) {
+    PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
+    return NULL;
+  }
+
+  Py_INCREF (Py_None);
+  py_r = Py_None;
+  return py_r;
+}
+
+static PyObject *
+py_guestfs_get_append (PyObject *self, PyObject *args)
+{
+  PyObject *py_g;
+  guestfs_h *g;
+  PyObject *py_r;
+  const char *r;
+
+  if (!PyArg_ParseTuple (args, (char *) "O:guestfs_get_append",
+                         &py_g))
+    return NULL;
+  g = get_handle (py_g);
+
+  r = guestfs_get_append (g);
+  if (r == NULL) {
+    PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
+    return NULL;
+  }
+
+  py_r = PyString_FromString (r);
+  return py_r;
+}
+
+static PyObject *
 py_guestfs_set_autosync (PyObject *self, PyObject *args)
 {
   PyObject *py_g;
 py_guestfs_set_autosync (PyObject *self, PyObject *args)
 {
   PyObject *py_g;
@@ -3367,6 +3415,8 @@ static PyMethodDef methods[] = {
   { (char *) "get_qemu", py_guestfs_get_qemu, METH_VARARGS, NULL },
   { (char *) "set_path", py_guestfs_set_path, METH_VARARGS, NULL },
   { (char *) "get_path", py_guestfs_get_path, METH_VARARGS, NULL },
   { (char *) "get_qemu", py_guestfs_get_qemu, METH_VARARGS, NULL },
   { (char *) "set_path", py_guestfs_set_path, METH_VARARGS, NULL },
   { (char *) "get_path", py_guestfs_get_path, METH_VARARGS, NULL },
+  { (char *) "set_append", py_guestfs_set_append, METH_VARARGS, NULL },
+  { (char *) "get_append", py_guestfs_get_append, METH_VARARGS, NULL },
   { (char *) "set_autosync", py_guestfs_set_autosync, METH_VARARGS, NULL },
   { (char *) "get_autosync", py_guestfs_get_autosync, METH_VARARGS, NULL },
   { (char *) "set_verbose", py_guestfs_set_verbose, METH_VARARGS, NULL },
   { (char *) "set_autosync", py_guestfs_set_autosync, METH_VARARGS, NULL },
   { (char *) "get_autosync", py_guestfs_get_autosync, METH_VARARGS, NULL },
   { (char *) "set_verbose", py_guestfs_set_verbose, METH_VARARGS, NULL },
index 37dc80f..324dea5 100644 (file)
@@ -192,6 +192,30 @@ class GuestFS:
         """
         return libguestfsmod.get_path (self._o)
 
         """
         return libguestfsmod.get_path (self._o)
 
+    def set_append (self, append):
+        u"""This function is used to add additional options to the
+        guest kernel command line.
+        
+        The default is "NULL" unless overridden by setting
+        "LIBGUESTFS_APPEND" environment variable.
+        
+        The string "append" is stashed in the libguestfs handle,
+        so the caller must make sure it remains valid for the
+        lifetime of the handle.
+        
+        Setting "append" to "NULL" means *no* additional options
+        are passed (libguestfs always adds a few of its own).
+        """
+        return libguestfsmod.set_append (self._o, append)
+
+    def get_append (self):
+        u"""Return the additional kernel options which are added to
+        the guest kernel command line.
+        
+        If "NULL" then no options are added.
+        """
+        return libguestfsmod.get_append (self._o)
+
     def set_autosync (self, autosync):
         u"""If "autosync" is true, this enables autosync. Libguestfs
         will make a best effort attempt to run "g.umount_all"
     def set_autosync (self, autosync):
         u"""If "autosync" is true, this enables autosync. Libguestfs
         will make a best effort attempt to run "g.umount_all"
index dd51ca5..0c20703 100644 (file)
@@ -262,6 +262,44 @@ static VALUE ruby_guestfs_get_path (VALUE gv)
   return rb_str_new2 (r);
 }
 
   return rb_str_new2 (r);
 }
 
+static VALUE ruby_guestfs_set_append (VALUE gv, VALUE appendv)
+{
+  guestfs_h *g;
+  Data_Get_Struct (gv, guestfs_h, g);
+  if (!g)
+    rb_raise (rb_eArgError, "%s: used handle after closing it", "set_append");
+
+  const char *append = StringValueCStr (appendv);
+  if (!append)
+    rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
+              "append", "set_append");
+
+  int r;
+
+  r = guestfs_set_append (g, append);
+  if (r == -1)
+    rb_raise (e_Error, "%s", guestfs_last_error (g));
+
+  return Qnil;
+}
+
+static VALUE ruby_guestfs_get_append (VALUE gv)
+{
+  guestfs_h *g;
+  Data_Get_Struct (gv, guestfs_h, g);
+  if (!g)
+    rb_raise (rb_eArgError, "%s: used handle after closing it", "get_append");
+
+
+  const char *r;
+
+  r = guestfs_get_append (g);
+  if (r == NULL)
+    rb_raise (e_Error, "%s", guestfs_last_error (g));
+
+  return rb_str_new2 (r);
+}
+
 static VALUE ruby_guestfs_set_autosync (VALUE gv, VALUE autosyncv)
 {
   guestfs_h *g;
 static VALUE ruby_guestfs_set_autosync (VALUE gv, VALUE autosyncv)
 {
   guestfs_h *g;
@@ -2877,6 +2915,10 @@ void Init__guestfs ()
         ruby_guestfs_set_path, 1);
   rb_define_method (c_guestfs, "get_path",
         ruby_guestfs_get_path, 0);
         ruby_guestfs_set_path, 1);
   rb_define_method (c_guestfs, "get_path",
         ruby_guestfs_get_path, 0);
+  rb_define_method (c_guestfs, "set_append",
+        ruby_guestfs_set_append, 1);
+  rb_define_method (c_guestfs, "get_append",
+        ruby_guestfs_get_append, 0);
   rb_define_method (c_guestfs, "set_autosync",
         ruby_guestfs_set_autosync, 1);
   rb_define_method (c_guestfs, "get_autosync",
   rb_define_method (c_guestfs, "set_autosync",
         ruby_guestfs_set_autosync, 1);
   rb_define_method (c_guestfs, "get_autosync",
index b3388f6..fdd4ae6 100755 (executable)
@@ -342,6 +342,31 @@ Return the current search path.
 This is always non-NULL.  If it wasn't set already, then this will
 return the default path.");
 
 This is always non-NULL.  If it wasn't set already, then this will
 return the default path.");
 
+  ("set_append", (RErr, [String "append"]), -1, [FishAlias "append"],
+   [],
+   "add options to kernel command line",
+   "\
+This function is used to add additional options to the
+guest kernel command line.
+
+The default is C<NULL> unless overridden by setting
+C<LIBGUESTFS_APPEND> environment variable.
+
+The string C<append> is stashed in the libguestfs handle, so the caller
+must make sure it remains valid for the lifetime of the handle.
+
+Setting C<append> to C<NULL> means I<no> additional options
+are passed (libguestfs always adds a few of its own).");
+
+  ("get_append", (RConstString "append", []), -1, [],
+   [],
+   "get the additional kernel options",
+   "\
+Return the additional kernel options which are added to the
+guest kernel command line.
+
+If C<NULL> then no options are added.");
+
   ("set_autosync", (RErr, [Bool "autosync"]), -1, [FishAlias "autosync"],
    [],
    "set autosync mode",
   ("set_autosync", (RErr, [Bool "autosync"]), -1, [FishAlias "autosync"],
    [],
    "set autosync mode",
index bad7271..92c1a93 100644 (file)
@@ -29,6 +29,8 @@ extern int guestfs_set_qemu (guestfs_h *handle, const char *qemu);
 extern const char *guestfs_get_qemu (guestfs_h *handle);
 extern int guestfs_set_path (guestfs_h *handle, const char *path);
 extern const char *guestfs_get_path (guestfs_h *handle);
 extern const char *guestfs_get_qemu (guestfs_h *handle);
 extern int guestfs_set_path (guestfs_h *handle, const char *path);
 extern const char *guestfs_get_path (guestfs_h *handle);
+extern int guestfs_set_append (guestfs_h *handle, const char *append);
+extern const char *guestfs_get_append (guestfs_h *handle);
 extern int guestfs_set_autosync (guestfs_h *handle, int autosync);
 extern int guestfs_get_autosync (guestfs_h *handle);
 extern int guestfs_set_verbose (guestfs_h *handle, int verbose);
 extern int guestfs_set_autosync (guestfs_h *handle, int autosync);
 extern int guestfs_get_autosync (guestfs_h *handle);
 extern int guestfs_set_verbose (guestfs_h *handle, int verbose);
index 43571af..646be77 100644 (file)
@@ -161,6 +161,8 @@ struct guestfs_h
   const char *path;
   const char *qemu;
 
   const char *path;
   const char *qemu;
 
+  const char *append;          /* Append to kernel command line. */
+
   char *last_error;
 
   /* Callbacks. */
   char *last_error;
 
   /* Callbacks. */
@@ -225,6 +227,9 @@ guestfs_create (void)
   str = getenv ("LIBGUESTFS_QEMU");
   g->qemu = str != NULL ? str : QEMU;
 
   str = getenv ("LIBGUESTFS_QEMU");
   g->qemu = str != NULL ? str : QEMU;
 
+  str = getenv ("LIBGUESTFS_APPEND");
+  g->append = str;
+
   g->main_loop = guestfs_get_default_main_loop ();
 
   /* Start with large serial numbers so they are easy to spot
   g->main_loop = guestfs_get_default_main_loop ();
 
   /* Start with large serial numbers so they are easy to spot
@@ -540,6 +545,19 @@ guestfs_get_qemu (guestfs_h *g)
   return g->qemu;
 }
 
   return g->qemu;
 }
 
+int
+guestfs_set_append (guestfs_h *g, const char *append)
+{
+  g->append = append;
+  return 0;
+}
+
+const char *
+guestfs_get_append (guestfs_h *g)
+{
+  return g->append;
+}
+
 /* 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)
@@ -764,9 +782,10 @@ guestfs_launch (guestfs_h *g)
 
     /* Linux kernel command line. */
     snprintf (append, sizeof append,
 
     /* Linux kernel command line. */
     snprintf (append, sizeof append,
-             "panic=1 console=ttyS0 guestfs=%s:%d%s",
+             "panic=1 console=ttyS0 guestfs=%s:%d%s%s%s",
              VMCHANNEL_ADDR, VMCHANNEL_PORT,
              VMCHANNEL_ADDR, VMCHANNEL_PORT,
-             g->verbose ? " guestfs_verbose=1" : "");
+             g->verbose ? " guestfs_verbose=1" : "",
+             g->append ? " " : "", g->append ? g->append : "");
 
     snprintf (memsize_str, sizeof memsize_str, "%d", memsize);
 
 
     snprintf (memsize_str, sizeof memsize_str, "%d", memsize);
 
diff --git a/tests.c b/tests.c
index f09c754..a61c492 100644 (file)
--- a/tests.c
+++ b/tests.c
@@ -72,6 +72,8 @@ static void no_test_warnings (void)
   fprintf (stderr, "warning: \"guestfs_get_qemu\" has no tests\n");
   fprintf (stderr, "warning: \"guestfs_set_path\" has no tests\n");
   fprintf (stderr, "warning: \"guestfs_get_path\" has no tests\n");
   fprintf (stderr, "warning: \"guestfs_get_qemu\" has no tests\n");
   fprintf (stderr, "warning: \"guestfs_set_path\" has no tests\n");
   fprintf (stderr, "warning: \"guestfs_get_path\" has no tests\n");
+  fprintf (stderr, "warning: \"guestfs_set_append\" has no tests\n");
+  fprintf (stderr, "warning: \"guestfs_get_append\" has no tests\n");
   fprintf (stderr, "warning: \"guestfs_set_autosync\" has no tests\n");
   fprintf (stderr, "warning: \"guestfs_get_autosync\" has no tests\n");
   fprintf (stderr, "warning: \"guestfs_set_verbose\" has no tests\n");
   fprintf (stderr, "warning: \"guestfs_set_autosync\" has no tests\n");
   fprintf (stderr, "warning: \"guestfs_get_autosync\" has no tests\n");
   fprintf (stderr, "warning: \"guestfs_set_verbose\" has no tests\n");