summaryrefslogtreecommitdiffstats
path: root/ocaml
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 /ocaml
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 'ocaml')
-rw-r--r--ocaml/examples/create_disk.ml6
-rw-r--r--ocaml/t/guestfs_010_basic.ml1
-rw-r--r--ocaml/t/guestfs_070_threads.ml3
-rw-r--r--ocaml/t/guestfs_500_parallel_mount_local.ml1
4 files changed, 9 insertions, 2 deletions
diff --git a/ocaml/examples/create_disk.ml b/ocaml/examples/create_disk.ml
index 75dbdc35..4437b1c8 100644
--- a/ocaml/examples/create_disk.ml
+++ b/ocaml/examples/create_disk.ml
@@ -57,6 +57,12 @@ let () =
*)
g#upload "/etc/resolv.conf" "/foo/resolv.conf";
+ (* Because we wrote to the disk and we want to detect write
+ * errors, call g#shutdown. You don't need to do this:
+ * g#close will do it implicitly.
+ *)
+ g#shutdown ();
+
(* Note also that handles are automatically closed if they are
* reaped by the garbage collector. You only need to call close
* if you want to close the handle right away.
diff --git a/ocaml/t/guestfs_010_basic.ml b/ocaml/t/guestfs_010_basic.ml
index b6750a1a..bb96737b 100644
--- a/ocaml/t/guestfs_010_basic.ml
+++ b/ocaml/t/guestfs_010_basic.ml
@@ -61,5 +61,6 @@ let () =
"q", 'r' ] then
failwith "Guestfs.readdir returned incorrect result";
+ g#shutdown ();
g#close ();
unlink "test.img"
diff --git a/ocaml/t/guestfs_070_threads.ml b/ocaml/t/guestfs_070_threads.ml
index 8b22f938..419f853e 100644
--- a/ocaml/t/guestfs_070_threads.ml
+++ b/ocaml/t/guestfs_070_threads.ml
@@ -65,8 +65,7 @@ let () =
let s = String.copy "/test" in
Guestfs.touch g s;
- Guestfs.umount_all g;
- Guestfs.sync g;
+ Guestfs.shutdown g;
Guestfs.close g;
unlink "test.img";
Gc.compact ();
diff --git a/ocaml/t/guestfs_500_parallel_mount_local.ml b/ocaml/t/guestfs_500_parallel_mount_local.ml
index 5a432f00..a26ff9d6 100644
--- a/ocaml/t/guestfs_500_parallel_mount_local.ml
+++ b/ocaml/t/guestfs_500_parallel_mount_local.ml
@@ -145,6 +145,7 @@ and start_thread (filename, mp) =
in
loop ();
+ g#shutdown ();
g#close ()
(* This is run in a child program. *)