summaryrefslogtreecommitdiffstats
path: root/daemon/proto.c
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2010-12-01 10:30:44 +0000
committerRichard W.M. Jones <rjones@redhat.com>2010-12-01 13:34:28 +0000
commit3aa8182c3cc478bf723205f1a4dd84e160768448 (patch)
treedd4da33344a17fe4da7a997dd9d4d8aecbbb07da /daemon/proto.c
parentfdc8805362c6fc587bb7985c5290362ad3094f4e (diff)
downloadlibguestfs-3aa8182c3cc478bf723205f1a4dd84e160768448.tar.gz
libguestfs-3aa8182c3cc478bf723205f1a4dd84e160768448.tar.xz
libguestfs-3aa8182c3cc478bf723205f1a4dd84e160768448.zip
protocol: Upload progress messages and optional arguments.
Two unrelated changes to the protocol to support progress messages during uploads, and optional arguments. Note that this makes an incompatible change to the protocol, and this is reflected in the protocol version field (3 -> 4).
Diffstat (limited to 'daemon/proto.c')
-rw-r--r--daemon/proto.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/daemon/proto.c b/daemon/proto.c
index 63d1cc99..f3a3b26c 100644
--- a/daemon/proto.c
+++ b/daemon/proto.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
+#include <inttypes.h>
#include <unistd.h>
#include <errno.h>
#include <sys/param.h> /* defines MIN */
@@ -45,6 +46,23 @@
int proc_nr;
int serial;
+/* Hint for implementing progress messages for uploaded/incoming data.
+ * The caller sets this to a value > 0 if it knows or can estimate how
+ * much data will be sent (this is not always known, eg. for uploads
+ * coming from a pipe). If this is known then we can emit progress
+ * messages as we write the data.
+ */
+uint64_t progress_hint;
+
+/* Optional arguments bitmask. Caller sets this to indicate which
+ * optional arguments in the guestfs_<foo>_args structure are
+ * meaningful. Optional arguments not covered by the bitmask are set
+ * to arbitrary values and the daemon should ignore them. If the
+ * bitmask has bits set that the daemon doesn't understand, then the
+ * whole call is rejected early in processing.
+ */
+uint64_t optargs_bitmask;
+
/* Time at which we received the current request. */
static struct timeval start_t;
@@ -149,9 +167,19 @@ main_loop (int _sock)
reply_with_error ("unexpected message status (%d)", hdr.status);
goto cont;
}
+ /* This version of the daemon does not understand optional arguments
+ * at all. When we fix this, we will remove the next conditional.
+ */
+ if (hdr.optargs_bitmask != 0) {
+ reply_with_error ("optargs_bitmask != 0 (%" PRIu64 ")",
+ hdr.optargs_bitmask);
+ goto cont;
+ }
proc_nr = hdr.proc;
serial = hdr.serial;
+ progress_hint = hdr.progress_hint;
+ optargs_bitmask = hdr.optargs_bitmask;
/* Clear errors before we call the stub functions. This is just
* to ensure that we can accurately report errors in cases where