summaryrefslogtreecommitdiffstats
path: root/daemon/daemon.h
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2011-04-01 15:50:33 +0100
committerRichard W.M. Jones <rjones@redhat.com>2011-04-01 16:05:45 +0100
commit40f7323134e058c0920caa18c667ea99a4c8b3e8 (patch)
tree01876dc75ebac380ce75855ddfbb5e9b6cd26b88 /daemon/daemon.h
parent6e5f64089631622167e60df25ee009ef83df5170 (diff)
downloadlibguestfs-40f7323134e058c0920caa18c667ea99a4c8b3e8.tar.gz
libguestfs-40f7323134e058c0920caa18c667ea99a4c8b3e8.tar.xz
libguestfs-40f7323134e058c0920caa18c667ea99a4c8b3e8.zip
daemon: Introduce "pulse mode" progress events.
This introduces a new form of progress event, where we don't know how much of the operation has taken place, but we nevertheless want to send back some indication of activity. Some progress bar indicators directly support this, eg. GtkProgressBar where it is known as "pulse mode". A pulse mode progress message is a special backwards-compatible form of the ordinary progress message. No change is required in callers, unless they want to add support for pulse mode. The daemon sends: - zero or more progress messages with position = 0, total = 1 - a single final progress message with position = total = 1 Note that the final progress message may not be sent if the call fails and returns an error. This is consistent with the behaviour of ordinary progress messages. The daemon allows two types of implementation. Either you can just call notify_progress (0, 1); ...; notify_progress (1, 1) as usual. Or you can call the functions pulse_mode_start, pulse_mode_end and/or pulse_mode_cancel (see documentation in daemon/daemon.h). For this second form of call, the guarantee is very weak: it *just* says the daemon is still capable of doing something, and it doesn't imply that if there is a subprocess that it is doing anything. However this does make it very easy to add pulse mode progress messages to all sorts of existing calls that depend on long-running external commands. To do: add a third variant that monitors a subprocess and only sends back progress messages if it's doing something, where "doing something" might indicate it's using CPU time or it's printing output.
Diffstat (limited to 'daemon/daemon.h')
-rw-r--r--daemon/daemon.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 3a67758b..40a087de 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -174,6 +174,23 @@ extern void reply (xdrproc_t xdrp, char *ret);
*/
extern void notify_progress (uint64_t position, uint64_t total);
+/* Pulse mode progress messages.
+ *
+ * Call pulse_mode_start to start sending progress messages.
+ *
+ * Call pulse_mode_end along the ordinary exit path (ie. before a
+ * reply message is sent).
+ *
+ * Call pulse_mode_cancel along all error paths *before* any reply is
+ * sent. pulse_mode_cancel does not modify errno, so it is safe to
+ * call it before reply_with_perror.
+ *
+ * Pulse mode and ordinary notify_progress must not be mixed.
+ */
+extern void pulse_mode_start (void);
+extern void pulse_mode_end (void);
+extern void pulse_mode_cancel (void);
+
/* Helper for functions that need a root filesystem mounted.
* NB. Cannot be used for FileIn functions.
*/