diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2009-05-13 17:51:14 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2009-05-13 17:51:14 +0100 |
commit | e8ecc08f663b44f3d79517affe52f137858dfe00 (patch) | |
tree | 0bee77cb454884699d671f5b1ef264ba4fde5f9e /src | |
parent | 5b17af107f75a0d6f3a39b88b9c18714014eb7af (diff) | |
download | libguestfs-e8ecc08f663b44f3d79517affe52f137858dfe00.tar.gz libguestfs-e8ecc08f663b44f3d79517affe52f137858dfe00.tar.xz libguestfs-e8ecc08f663b44f3d79517affe52f137858dfe00.zip |
Add 'append', LIBGUESTFS_APPEND to set additional kernel options.
Diffstat (limited to 'src')
-rwxr-xr-x | src/generator.ml | 25 | ||||
-rw-r--r-- | src/guestfs-actions.h | 2 | ||||
-rw-r--r-- | src/guestfs.c | 23 |
3 files changed, 48 insertions, 2 deletions
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); |