diff options
author | Richard Jones <rjones@redhat.com> | 2010-11-09 18:50:57 +0000 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2010-11-10 10:52:12 +0000 |
commit | 1c29849e0bdc731c023cff00d2c2354a41fd2a92 (patch) | |
tree | fd2ab2d342a725ec37fe1c6345fb33412384fc5b /src | |
parent | a0b4caa0821b759de01361b7019c9c9c9607027d (diff) | |
download | libguestfs-1c29849e0bdc731c023cff00d2c2354a41fd2a92.tar.gz libguestfs-1c29849e0bdc731c023cff00d2c2354a41fd2a92.tar.xz libguestfs-1c29849e0bdc731c023cff00d2c2354a41fd2a92.zip |
Add internal facility to checkpoint and roll back the command line.
This internal interface can be used to ensure that certain
operations are atomic.
Diffstat (limited to 'src')
-rw-r--r-- | src/guestfs-internal.h | 2 | ||||
-rw-r--r-- | src/launch.c | 20 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index 067251c2..f8b3e94d 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -234,6 +234,8 @@ extern int guestfs___match2 (guestfs_h *g, const char *str, const pcre *re, char #endif extern int guestfs___feature_available (guestfs_h *g, const char *feature); extern void guestfs___free_string_list (char **); +extern int guestfs___checkpoint_cmdline (guestfs_h *g); +extern void guestfs___rollback_cmdline (guestfs_h *g, int pos); #define error(g,...) guestfs_error_errno((g),0,__VA_ARGS__) #define perrorf guestfs_perrorf diff --git a/src/launch.c b/src/launch.c index e5bca56e..48ddb8df 100644 --- a/src/launch.c +++ b/src/launch.c @@ -34,6 +34,7 @@ #include <sys/select.h> #include <dirent.h> #include <signal.h> +#include <assert.h> #include <rpc/types.h> #include <rpc/xdr.h> @@ -101,6 +102,25 @@ add_cmdline (guestfs_h *g, const char *str) } int +guestfs___checkpoint_cmdline (guestfs_h *g) +{ + return g->cmdline_size; +} + +void +guestfs___rollback_cmdline (guestfs_h *g, int pos) +{ + int i; + + assert (g->cmdline_size >= pos); + + for (i = g->cmdline_size - 1; i >= pos; --i) + free (g->cmdline[i]); + + g->cmdline_size = pos; +} + +int guestfs__config (guestfs_h *g, const char *qemu_param, const char *qemu_value) { |