summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2009-05-13 17:51:14 +0100
committerRichard W.M. Jones <rjones@redhat.com>2009-05-13 17:51:14 +0100
commite8ecc08f663b44f3d79517affe52f137858dfe00 (patch)
tree0bee77cb454884699d671f5b1ef264ba4fde5f9e
parent5b17af107f75a0d6f3a39b88b9c18714014eb7af (diff)
downloadlibguestfs-e8ecc08f663b44f3d79517affe52f137858dfe00.tar.gz
libguestfs-e8ecc08f663b44f3d79517affe52f137858dfe00.tar.xz
libguestfs-e8ecc08f663b44f3d79517affe52f137858dfe00.zip
Add 'append', LIBGUESTFS_APPEND to set additional kernel options.
-rw-r--r--fish/cmds.c42
-rw-r--r--fish/completion.c3
-rw-r--r--guestfish-actions.pod25
-rw-r--r--guestfish.pod4
-rw-r--r--guestfs-actions.pod31
-rw-r--r--guestfs.pod4
-rw-r--r--haskell/Guestfs.hs13
-rw-r--r--java/com/redhat/et/libguestfs/GuestFS.java48
-rw-r--r--java/com_redhat_et_libguestfs_GuestFS.c32
-rw-r--r--ocaml/guestfs.ml2
-rw-r--r--ocaml/guestfs.mli6
-rw-r--r--ocaml/guestfs_c_actions.c45
-rw-r--r--perl/Guestfs.xs24
-rw-r--r--perl/lib/Sys/Guestfs.pm21
-rw-r--r--python/guestfs-py.c50
-rw-r--r--python/guestfs.py24
-rw-r--r--ruby/ext/guestfs/_guestfs.c42
-rwxr-xr-xsrc/generator.ml25
-rw-r--r--src/guestfs-actions.h2
-rw-r--r--src/guestfs.c23
-rw-r--r--tests.c2
21 files changed, 466 insertions, 2 deletions
diff --git a/fish/cmds.c b/fish/cmds.c
index 4c5b5fa0..47c66da3 100644
--- a/fish/cmds.c
+++ b/fish/cmds.c
@@ -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", "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");
@@ -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", "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");
@@ -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, "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
@@ -753,6 +761,34 @@ static int run_get_path (const char *cmd, int argc, char *argv[])
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;
@@ -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, "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
diff --git a/fish/completion.c b/fish/completion.c
index 93182886..4db2d5ef 100644
--- a/fish/completion.c
+++ b/fish/completion.c
@@ -37,6 +37,7 @@ static const char *const commands[] = {
"add",
"add-cdrom",
"add-drive",
+ "append",
"aug-close",
"aug-defnode",
"aug-defvar",
@@ -79,6 +80,7 @@ static const char *const commands[] = {
"exists",
"file",
"fsck",
+ "get-append",
"get-autosync",
"get-e2label",
"get-e2uuid",
@@ -127,6 +129,7 @@ static const char *const commands[] = {
"rm-rf",
"rmdir",
"run",
+ "set-append",
"set-autosync",
"set-e2label",
"set-e2uuid",
diff --git a/guestfish-actions.pod b/guestfish-actions.pod
index 7d46206b..20c34a59 100644
--- a/guestfish-actions.pod
+++ b/guestfish-actions.pod
@@ -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>.
+=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
@@ -949,6 +958,22 @@ command.
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
diff --git a/guestfish.pod b/guestfish.pod
index e7a4ffa6..d44e3e3f 100644
--- a/guestfish.pod
+++ b/guestfish.pod
@@ -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.
+=item LIBGUESTFS_APPEND
+
+Pass additional options to the guest kernel.
+
=item HOME
If compiled with GNU readline support, then the command history
diff --git a/guestfs-actions.pod b/guestfs-actions.pod
index c1875400..7de041c9 100644
--- a/guestfs-actions.pod
+++ b/guestfs-actions.pod
@@ -713,6 +713,18 @@ This command is entirely equivalent to running C<fsck -a -t fstype device>.
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);
@@ -1272,6 +1284,25 @@ Remove the single directory C<path>.
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,
diff --git a/guestfs.pod b/guestfs.pod
index 06cc2b3a..4dc5757d 100644
--- a/guestfs.pod
+++ b/guestfs.pod
@@ -678,6 +678,10 @@ used.
See also L<QEMU WRAPPERS> above.
+=item LIBGUESTFS_APPEND
+
+Pass additional options to the guest kernel.
+
=back
=head1 SEE ALSO
diff --git a/haskell/Guestfs.hs b/haskell/Guestfs.hs
index aedf3b53..47213768 100644
--- a/haskell/Guestfs.hs
+++ b/haskell/Guestfs.hs
@@ -32,6 +32,7 @@ module Guestfs (
config,
set_qemu,
set_path,
+ set_append,
set_busy,
set_ready,
end_busy,
@@ -223,6 +224,18 @@ set_path h path = do
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)
diff --git a/java/com/redhat/et/libguestfs/GuestFS.java b/java/com/redhat/et/libguestfs/GuestFS.java
index 70efb8d0..d0b34465 100644
--- a/java/com/redhat/et/libguestfs/GuestFS.java
+++ b/java/com/redhat/et/libguestfs/GuestFS.java
@@ -316,6 +316,54 @@ public class GuestFS {
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
diff --git a/java/com_redhat_et_libguestfs_GuestFS.c b/java/com_redhat_et_libguestfs_GuestFS.c
index 2ad4c6ab..ce1f2dbf 100644
--- a/java/com_redhat_et_libguestfs_GuestFS.c
+++ b/java/com_redhat_et_libguestfs_GuestFS.c
@@ -222,6 +222,38 @@ Java_com_redhat_et_libguestfs_GuestFS__1get_1path
}
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)
{
diff --git a/ocaml/guestfs.ml b/ocaml/guestfs.ml
index 39d23293..2544b16b 100644
--- a/ocaml/guestfs.ml
+++ b/ocaml/guestfs.ml
@@ -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 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"
diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli
index 21e6eeb5..870ffb69 100644
--- a/ocaml/guestfs.mli
+++ b/ocaml/guestfs.mli
@@ -154,6 +154,12 @@ val set_path : t -> string -> unit
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 *)
diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c
index fa352fcc..22e65008 100644
--- a/ocaml/guestfs_c_actions.c
+++ b/ocaml/guestfs_c_actions.c
@@ -556,6 +556,51 @@ ocaml_guestfs_get_path (value gv)
}
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);
diff --git a/perl/Guestfs.xs b/perl/Guestfs.xs
index 5ce5def1..973f56e5 100644
--- a/perl/Guestfs.xs
+++ b/perl/Guestfs.xs
@@ -219,6 +219,30 @@ PREINIT:
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;
diff --git a/perl/lib/Sys/Guestfs.pm b/perl/lib/Sys/Guestfs.pm
index 001fa880..d803ce11 100644
--- a/perl/lib/Sys/Guestfs.pm
+++ b/perl/lib/Sys/Guestfs.pm
@@ -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>.
+=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.
@@ -874,6 +881,20 @@ command.
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
diff --git a/python/guestfs-py.c b/python/guestfs-py.c
index 11ea6a45..3a09afb3 100644
--- a/python/guestfs-py.c
+++ b/python/guestfs-py.c
@@ -633,6 +633,54 @@ py_guestfs_get_path (PyObject *self, PyObject *args)
}
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;
@@ -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 *) "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 },
diff --git a/python/guestfs.py b/python/guestfs.py
index 37dc80f7..324dea56 100644
--- a/python/guestfs.py
+++ b/python/guestfs.py
@@ -192,6 +192,30 @@ class GuestFS:
"""
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"
diff --git a/ruby/ext/guestfs/_guestfs.c b/ruby/ext/guestfs/_guestfs.c
index dd51ca5c..0c20703d 100644
--- a/ruby/ext/guestfs/_guestfs.c
+++ b/ruby/ext/guestfs/_guestfs.c
@@ -262,6 +262,44 @@ static VALUE ruby_guestfs_get_path (VALUE gv)
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;
@@ -2877,6 +2915,10 @@ void Init__guestfs ()
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",
diff --git a/src/generator.ml b/src/generator.ml
index b3388f6e..fdd4ae63 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -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.");
+ ("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",
diff --git a/src/guestfs-actions.h b/src/guestfs-actions.h
index bad72718..92c1a932 100644
--- a/src/guestfs-actions.h
+++ b/src/guestfs-actions.h
@@ -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 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);
diff --git a/src/guestfs.c b/src/guestfs.c
index 43571af7..646be772 100644
--- a/src/guestfs.c
+++ b/src/guestfs.c
@@ -161,6 +161,8 @@ struct guestfs_h
const char *path;
const char *qemu;
+ const char *append; /* Append to kernel command line. */
+
char *last_error;
/* Callbacks. */
@@ -225,6 +227,9 @@ guestfs_create (void)
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
@@ -540,6 +545,19 @@ guestfs_get_qemu (guestfs_h *g)
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)
@@ -764,9 +782,10 @@ guestfs_launch (guestfs_h *g)
/* 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,
- g->verbose ? " guestfs_verbose=1" : "");
+ g->verbose ? " guestfs_verbose=1" : "",
+ g->append ? " " : "", g->append ? g->append : "");
snprintf (memsize_str, sizeof memsize_str, "%d", memsize);
diff --git a/tests.c b/tests.c
index f09c7545..a61c4924 100644
--- 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_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");