summaryrefslogtreecommitdiffstats
path: root/fish
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-07-03 13:22:45 +0100
committerRichard W.M. Jones <rjones@redhat.com>2012-07-03 21:27:29 +0100
commitffbf1475f7ae7c462db289ad4834391469e72edd (patch)
tree5caa1b0f2ed83afd56495f9dabf8e81be5f680c7 /fish
parentbcc4ffb52b9f4b5db7861682905ec32844f4603b (diff)
downloadlibguestfs-ffbf1475f7ae7c462db289ad4834391469e72edd.tar.gz
libguestfs-ffbf1475f7ae7c462db289ad4834391469e72edd.tar.xz
libguestfs-ffbf1475f7ae7c462db289ad4834391469e72edd.zip
New API: guestfs_shutdown: Cleanly shutdown the backend.
The new API splits orderly close into a two-step process: if (guestfs_shutdown (g) == -1) { /* handle the error, eg. qemu error */ } guestfs_close (g); Note that the explicit shutdown step is only necessary in the case where you have made changes to the disk image and want to handle write errors. Read the documentation for further information. This change also: - deprecates guestfs_kill_subprocess - turns guestfs_kill_subprocess into the same as guestfs_shutdown - changes guestfish and other tools to call shutdown + close where necessary (not for read-only tools) - updates documentation - updates examples
Diffstat (limited to 'fish')
-rw-r--r--fish/fish.c3
-rw-r--r--fish/reopen.c3
-rwxr-xr-xfish/test-events.sh3
3 files changed, 9 insertions, 0 deletions
diff --git a/fish/fish.c b/fish/fish.c
index 80b33644..ded80ec2 100644
--- a/fish/fish.c
+++ b/fish/fish.c
@@ -553,6 +553,9 @@ main (int argc, char *argv[])
else
cmdline (argv, optind, argc);
+ if (guestfs_shutdown (g) == -1)
+ exit (EXIT_FAILURE);
+
guestfs_close (g);
out_after_handle_close:
diff --git a/fish/reopen.c b/fish/reopen.c
index 3fc9510b..6b3707e9 100644
--- a/fish/reopen.c
+++ b/fish/reopen.c
@@ -40,6 +40,9 @@ run_reopen (const char *cmd, size_t argc, char *argv[])
return -1;
}
+ if (guestfs_shutdown (g) == -1)
+ return -1;
+
/* Open the new handle first, so we can copy the settings from the
* old one to the new one, and also so if it fails we still have an
* open handle.
diff --git a/fish/test-events.sh b/fish/test-events.sh
index 76d3823f..b3684a83 100755
--- a/fish/test-events.sh
+++ b/fish/test-events.sh
@@ -53,6 +53,9 @@ if [ "$(cat test.out)" != '"ev1" (0): *: echo $EVENT $@
"ev1" (1): *: echo $EVENT $@
"ev2" (2): *: echo $EVENT $@
"ev2" (2): *: echo $EVENT $@
+enter shutdown
+trace shutdown
+trace shutdown = 0
enter get_autosync
trace get_autosync
trace get_autosync = 1