[Libguestfs] [PATCH 2/7] examples: In create_disk example, don't call set_autosync.

Richard W.M. Jones rjones at redhat.com
Tue Jul 3 18:03:18 UTC 2012


From: "Richard W.M. Jones" <rjones at redhat.com>

This is now set by default in all supported versions of libguestfs.
It's just confusing if the examples refer to it.
---
 erlang/examples/create_disk.erl |    8 --------
 examples/create_disk.c          |    9 ---------
 java/examples/CreateDisk.java   |    8 --------
 ocaml/examples/create_disk.ml   |   11 +----------
 perl/examples/create_disk.pl    |    7 -------
 python/examples/create_disk.py  |    7 -------
 ruby/examples/create_disk.rb    |    7 -------
 7 files changed, 1 insertion(+), 56 deletions(-)

diff --git a/erlang/examples/create_disk.erl b/erlang/examples/create_disk.erl
index 231c398..a0c9044 100755
--- a/erlang/examples/create_disk.erl
+++ b/erlang/examples/create_disk.erl
@@ -16,10 +16,6 @@ main(_) ->
     % Set the trace flag so that we can see each libguestfs call.
     ok = guestfs:set_trace(G, true),
 
-    % Set the autosync flag so that the disk will be synchronized
-    % automatically when the libguestfs handle is closed.
-    ok = guestfs:set_autosync(G, true),
-
     % Attach the disk image to libguestfs.
     ok = guestfs:add_drive_opts(G, Output,
                                 [{format, "raw"}, {readonly, false}]),
@@ -55,10 +51,6 @@ main(_) ->
     % the disk image.
     ok = guestfs:upload(G, "/etc/resolv.conf", "/foo/resolv.conf"),
 
-    % Because 'autosync' was set (above) we can just close the handle
-    % and the disk contents will be synchronized.  You can also do
-    % this manually by calling guestfs:umount_all and guestfs:sync.
-    %
     % 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/examples/create_disk.c b/examples/create_disk.c
index bcad6d8..5380888 100644
--- a/examples/create_disk.c
+++ b/examples/create_disk.c
@@ -37,11 +37,6 @@ main (int argc, char *argv[])
   /* Set the trace flag so that we can see each libguestfs call. */
   guestfs_set_trace (g, 1);
 
-  /* Set the autosync flag so that the disk will be synchronized
-   * automatically when the libguestfs handle is closed.
-   */
-  guestfs_set_autosync (g, 1);
-
   /* Add the disk image to libguestfs. */
   if (guestfs_add_drive_opts (g, "disk.img",
         GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw", /* raw format */
@@ -104,10 +99,6 @@ main (int argc, char *argv[])
   if (guestfs_upload (g, "/etc/resolv.conf", "/foo/resolv.conf") == -1)
     exit (EXIT_FAILURE);
 
-  /* Because 'autosync' was set (above) we can just close the handle
-   * and the disk contents will be synchronized.  You can also do
-   * this manually by calling guestfs_umount_all and guestfs_sync.
-   */
   guestfs_close (g);
 
   /* Free up the lists. */
diff --git a/java/examples/CreateDisk.java b/java/examples/CreateDisk.java
index 4742b5a..41f8739 100644
--- a/java/examples/CreateDisk.java
+++ b/java/examples/CreateDisk.java
@@ -22,10 +22,6 @@ public class CreateDisk
             // Set the trace flag so that we can see each libguestfs call.
             g.set_trace (true);
 
-            // Set the autosync flag so that the disk will be synchronized
-            // automatically when the libguestfs handle is closed.
-            g.set_autosync (true);
-
             // Attach the disk image to libguestfs.
             Map<String, Object> optargs = new HashMap<String, Object>() {
                 {
@@ -70,10 +66,6 @@ public class CreateDisk
             // the disk image.
             g.upload ("/etc/resolv.conf", "/foo/resolv.conf");
 
-            // Because 'autosync' was set (above) we can just close the handle
-            // and the disk contents will be synchronized.  You can also do
-            // this manually by calling g#umount_all and g#sync.
-            //
             // 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/examples/create_disk.ml b/ocaml/examples/create_disk.ml
index 0f9f941..75dbdc3 100644
--- a/ocaml/examples/create_disk.ml
+++ b/ocaml/examples/create_disk.ml
@@ -16,11 +16,6 @@ let () =
   (* Set the trace flag so that we can see each libguestfs call. *)
   g#set_trace true;
 
-  (* Set the autosync flag so that the disk will be synchronized
-   * automatically when the libguestfs handle is closed.
-   *)
-  g#set_autosync true;
-
   (* Attach the disk image to libguestfs. *)
   g#add_drive_opts ~format:"raw" ~readonly:false output;
 
@@ -62,11 +57,7 @@ let () =
    *)
   g#upload "/etc/resolv.conf" "/foo/resolv.conf";
 
-  (* Because 'autosync' was set (above) we can just close the handle
-   * and the disk contents will be synchronized.  You can also do
-   * this manually by calling g#umount_all and g#sync.
-   *
-   * Note also that handles are automatically closed if they are
+  (* 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/perl/examples/create_disk.pl b/perl/examples/create_disk.pl
index 5a81663..49538a5 100755
--- a/perl/examples/create_disk.pl
+++ b/perl/examples/create_disk.pl
@@ -17,10 +17,6 @@ close FILE or die "$output: $!";
 # Set the trace flag so that we can see each libguestfs call.
 $g->set_trace (1);
 
-# Set the autosync flag so that the disk will be synchronized
-# automatically when the libguestfs handle is closed.
-$g->set_autosync (1);
-
 # Attach the disk image to libguestfs.
 $g->add_drive_opts ($output, format => "raw", readonly => 0);
 
@@ -61,7 +57,4 @@ $g->mkdir ("/foo");
 # the disk image.
 $g->upload ("/etc/resolv.conf", "/foo/resolv.conf");
 
-# Because 'autosync' was set (above) we can just exit here
-# and the disk contents will be synchronized.  You can also do
-# this manually by calling $g->umount_all and $g->sync.
 exit 0
diff --git a/python/examples/create_disk.py b/python/examples/create_disk.py
index c80fc6d..bf47c91 100644
--- a/python/examples/create_disk.py
+++ b/python/examples/create_disk.py
@@ -15,10 +15,6 @@ f.close ()
 # Set the trace flag so that we can see each libguestfs call.
 g.set_trace (1)
 
-# Set the autosync flag so that the disk will be synchronized
-# automatically when the libguestfs handle is closed.
-g.set_autosync (1)
-
 # Attach the disk image to libguestfs.
 g.add_drive_opts (output, format = "raw", readonly = 0)
 
@@ -55,7 +51,4 @@ g.mkdir ("/foo")
 # the disk image.
 g.upload ("/etc/resolv.conf", "/foo/resolv.conf")
 
-# Because 'autosync' was set (above) we can just close the handle
-# and the disk contents will be synchronized.  You can also do
-# this manually by calling g.umount_all and g.sync.
 g.close ()
diff --git a/ruby/examples/create_disk.rb b/ruby/examples/create_disk.rb
index 16871cb..4e42cf6 100644
--- a/ruby/examples/create_disk.rb
+++ b/ruby/examples/create_disk.rb
@@ -14,10 +14,6 @@ File.open(output, "w") {
 # Set the trace flag so that we can see each libguestfs call.
 g.set_trace(1)
 
-# Set the autosync flag so that the disk will be synchronized
-# automatically when the libguestfs handle is closed.
-g.set_autosync(1)
-
 # Attach the disk image to libguestfs.
 g.add_drive_opts(output, :format => "raw")
 
@@ -58,7 +54,4 @@ g.mkdir("/foo")
 # the disk image.
 g.upload("/etc/resolv.conf", "/foo/resolv.conf")
 
-# Because 'autosync' was set (above) we can just close the handle
-# and the disk contents will be synchronized.  You can also do
-# this manually by calling g#umount_all and g#sync.
 g.close()
-- 
1.7.10.4




More information about the Libguestfs mailing list