summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--daemon/sync.c17
-rw-r--r--generator/generator_actions.ml16
-rw-r--r--src/MAX_PROC_NR2
-rw-r--r--src/guestfs.c6
4 files changed, 33 insertions, 8 deletions
diff --git a/daemon/sync.c b/daemon/sync.c
index b848ab54..25c7de89 100644
--- a/daemon/sync.c
+++ b/daemon/sync.c
@@ -43,6 +43,23 @@ do_sync (void)
return 0;
}
+/* Older versions of libguestfs used to issue separate 'umount_all'
+ * and 'sync' commands just before closing the handle. Since
+ * libguestfs 1.9.7 the library issues this 'internal_autosync'
+ * internal operation instead, allowing more control in the daemon.
+ */
+int
+do_internal_autosync (void)
+{
+ int r;
+
+ r = do_umount_all ();
+
+ sync_disks ();
+
+ return r;
+}
+
/* This is a replacement for sync(2) which is called from
* this file and from other places in the daemon. It works
* on Windows too.
diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml
index 77f13580..0ae87902 100644
--- a/generator/generator_actions.ml
+++ b/generator/generator_actions.ml
@@ -282,8 +282,8 @@ If C<NULL> then no options are added.");
"set autosync mode",
"\
If C<autosync> is true, this enables autosync. Libguestfs will make a
-best effort attempt to run C<guestfs_umount_all> followed by
-C<guestfs_sync> when the handle is closed
+best effort attempt to make filesystems consistent and synchronized
+when the handle is closed
(also if the program exits without closing handles).
This is enabled by default (since libguestfs 1.5.24, previously it was
@@ -3842,7 +3842,7 @@ pathnames, as in the example code above.
For more details see L<https://bugzilla.redhat.com/show_bug.cgi?id=599503>
Autosync [see C<guestfs_set_autosync>, this is set by default on
-handles] means that C<guestfs_umount_all> is called when the handle
+handles] can cause C<guestfs_umount_all> to be called when the handle
is closed which can also trigger these issues.");
("rmmountpoint", (RErr, [String "exemptpath"], []), 149, [],
@@ -5776,6 +5776,16 @@ C<guestfs_tune2fs_l> and read the C<Block size> and C<Block count>
values. These two numbers, multiplied together, give the
resulting size of the minimal filesystem in bytes.");
+ ("internal_autosync", (RErr, [], []), 282, [NotInFish; NotInDocs],
+ [],
+ "internal autosync operation",
+ "\
+This command performs the autosync operation just before the
+handle is closed. You should not call this command directly.
+Instead, use the autosync flag (C<guestfs_set_autosync>) to
+control whether or not this operation is performed when the
+handle is closed.");
+
]
let all_functions = non_daemon_functions @ daemon_functions
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 1473a88f..e01062f1 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-281
+282
diff --git a/src/guestfs.c b/src/guestfs.c
index 488b6586..79fc5bfa 100644
--- a/src/guestfs.c
+++ b/src/guestfs.c
@@ -189,10 +189,8 @@ guestfs_close (guestfs_h *g)
guestfs___free_inspect_info (g);
/* Try to sync if autosync flag is set. */
- if (g->autosync && g->state == READY) {
- guestfs_umount_all (g);
- guestfs_sync (g);
- }
+ if (g->autosync && g->state == READY)
+ guestfs_internal_autosync (g);
/* Remove any handlers that might be called back before we kill the
* subprocess.