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", "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");
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
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;
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
"add",
"add-cdrom",
"add-drive",
+ "append",
"aug-close",
"aug-defnode",
"aug-defvar",
"exists",
"file",
"fsck",
+ "get-append",
"get-autosync",
"get-e2label",
"get-e2uuid",
"rm-rf",
"rmdir",
"run",
+ "set-append",
"set-autosync",
"set-e2label",
"set-e2uuid",
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
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
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
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);
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,
See also L<QEMU WRAPPERS> above.
+=item LIBGUESTFS_APPEND
+
+Pass additional options to the guest kernel.
+
=back
=head1 SEE ALSO
config,
set_qemu,
set_path,
+ set_append,
set_busy,
set_ready,
end_busy,
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)
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
}
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)
{
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"
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 *)
}
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);
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;
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.
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
}
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;
{ (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 },
"""
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"
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;
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",
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",
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);
const char *path;
const char *qemu;
+ const char *append; /* Append to kernel command line. */
+
char *last_error;
/* Callbacks. */
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
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)
/* 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);
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");