From 1c29849e0bdc731c023cff00d2c2354a41fd2a92 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Tue, 9 Nov 2010 18:50:57 +0000 Subject: [PATCH] Add internal facility to checkpoint and roll back the command line. This internal interface can be used to ensure that certain operations are atomic. --- src/guestfs-internal.h | 2 ++ src/launch.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index 067251c..f8b3e94 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 e5bca56..48ddb8d 100644 --- a/src/launch.c +++ b/src/launch.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -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) { -- 1.8.3.1