summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard Jones <rjones@trick.home.annexia.org>2009-06-04 14:59:16 +0100
committerRichard Jones <rjones@trick.home.annexia.org>2009-06-04 15:06:27 +0100
commitb6adf09c4d2cc3f1d0285950c151b1fd7688ec67 (patch)
tree7ff59df24162a39824e65bf5e4fd0b4dafcad13a /src
parent2ef06eacc2be08b0268c98a4d157176aff9356e0 (diff)
downloadlibguestfs-b6adf09c4d2cc3f1d0285950c151b1fd7688ec67.tar.gz
libguestfs-b6adf09c4d2cc3f1d0285950c151b1fd7688ec67.tar.xz
libguestfs-b6adf09c4d2cc3f1d0285950c151b1fd7688ec67.zip
Generated code for the 'sleep' command.
Diffstat (limited to 'src')
-rw-r--r--src/guestfs-actions.c87
-rw-r--r--src/guestfs-actions.h1
-rw-r--r--src/guestfs_protocol.c10
-rw-r--r--src/guestfs_protocol.h10
-rw-r--r--src/guestfs_protocol.x5
5 files changed, 112 insertions, 1 deletions
diff --git a/src/guestfs-actions.c b/src/guestfs-actions.c
index dfca2048..955cfff8 100644
--- a/src/guestfs-actions.c
+++ b/src/guestfs-actions.c
@@ -9893,3 +9893,90 @@ int guestfs_e2fsck_f (guestfs_h *g,
return 0;
}
+struct sleep_ctx {
+ /* This flag is set by the callbacks, so we know we've done
+ * the callbacks as expected, and in the right sequence.
+ * 0 = not called, 1 = reply_cb called.
+ */
+ int cb_sequence;
+ struct guestfs_message_header hdr;
+ struct guestfs_message_error err;
+};
+
+static void sleep_reply_cb (guestfs_h *g, void *data, XDR *xdr)
+{
+ guestfs_main_loop *ml = guestfs_get_main_loop (g);
+ struct sleep_ctx *ctx = (struct sleep_ctx *) data;
+
+ /* This should definitely not happen. */
+ if (ctx->cb_sequence != 0) {
+ ctx->cb_sequence = 9999;
+ error (g, "%s: internal error: reply callback called twice", "guestfs_sleep");
+ return;
+ }
+
+ ml->main_loop_quit (ml, g);
+
+ if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
+ error (g, "%s: failed to parse reply header", "guestfs_sleep");
+ return;
+ }
+ if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
+ if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
+ error (g, "%s: failed to parse reply error", "guestfs_sleep");
+ return;
+ }
+ goto done;
+ }
+ done:
+ ctx->cb_sequence = 1;
+}
+
+int guestfs_sleep (guestfs_h *g,
+ int secs)
+{
+ struct guestfs_sleep_args args;
+ struct sleep_ctx ctx;
+ guestfs_main_loop *ml = guestfs_get_main_loop (g);
+ int serial;
+
+ if (check_state (g, "guestfs_sleep") == -1) return -1;
+ guestfs_set_busy (g);
+
+ memset (&ctx, 0, sizeof ctx);
+
+ args.secs = secs;
+ serial = guestfs__send_sync (g, GUESTFS_PROC_SLEEP,
+ (xdrproc_t) xdr_guestfs_sleep_args, (char *) &args);
+ if (serial == -1) {
+ guestfs_end_busy (g);
+ return -1;
+ }
+
+ guestfs__switch_to_receiving (g);
+ ctx.cb_sequence = 0;
+ guestfs_set_reply_callback (g, sleep_reply_cb, &ctx);
+ (void) ml->main_loop_run (ml, g);
+ guestfs_set_reply_callback (g, NULL, NULL);
+ if (ctx.cb_sequence != 1) {
+ error (g, "%s reply failed, see earlier error messages", "guestfs_sleep");
+ guestfs_end_busy (g);
+ return -1;
+ }
+
+ if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_SLEEP, serial) == -1) {
+ guestfs_end_busy (g);
+ return -1;
+ }
+
+ if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
+ error (g, "%s", ctx.err.error_message);
+ free (ctx.err.error_message);
+ guestfs_end_busy (g);
+ return -1;
+ }
+
+ guestfs_end_busy (g);
+ return 0;
+}
+
diff --git a/src/guestfs-actions.h b/src/guestfs-actions.h
index 2cd3bdba..1afb4f0b 100644
--- a/src/guestfs-actions.h
+++ b/src/guestfs-actions.h
@@ -179,3 +179,4 @@ extern int guestfs_lvresize (guestfs_h *handle, const char *device, int mbytes);
extern int guestfs_resize2fs (guestfs_h *handle, const char *device);
extern char **guestfs_find (guestfs_h *handle, const char *directory);
extern int guestfs_e2fsck_f (guestfs_h *handle, const char *device);
+extern int guestfs_sleep (guestfs_h *handle, int secs);
diff --git a/src/guestfs_protocol.c b/src/guestfs_protocol.c
index 2838d95c..df494203 100644
--- a/src/guestfs_protocol.c
+++ b/src/guestfs_protocol.c
@@ -1839,6 +1839,16 @@ xdr_guestfs_e2fsck_f_args (XDR *xdrs, guestfs_e2fsck_f_args *objp)
}
bool_t
+xdr_guestfs_sleep_args (XDR *xdrs, guestfs_sleep_args *objp)
+{
+ register int32_t *buf;
+
+ if (!xdr_int (xdrs, &objp->secs))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
xdr_guestfs_procedure (XDR *xdrs, guestfs_procedure *objp)
{
register int32_t *buf;
diff --git a/src/guestfs_protocol.h b/src/guestfs_protocol.h
index dd5da006..68f4ec62 100644
--- a/src/guestfs_protocol.h
+++ b/src/guestfs_protocol.h
@@ -930,6 +930,11 @@ struct guestfs_e2fsck_f_args {
};
typedef struct guestfs_e2fsck_f_args guestfs_e2fsck_f_args;
+struct guestfs_sleep_args {
+ int secs;
+};
+typedef struct guestfs_sleep_args guestfs_sleep_args;
+
enum guestfs_procedure {
GUESTFS_PROC_MOUNT = 1,
GUESTFS_PROC_SYNC = 2,
@@ -1039,7 +1044,8 @@ enum guestfs_procedure {
GUESTFS_PROC_RESIZE2FS = 106,
GUESTFS_PROC_FIND = 107,
GUESTFS_PROC_E2FSCK_F = 108,
- GUESTFS_PROC_NR_PROCS = 108 + 1,
+ GUESTFS_PROC_SLEEP = 109,
+ GUESTFS_PROC_NR_PROCS = 109 + 1,
};
typedef enum guestfs_procedure guestfs_procedure;
#define GUESTFS_MESSAGE_MAX 4194304
@@ -1237,6 +1243,7 @@ extern bool_t xdr_guestfs_resize2fs_args (XDR *, guestfs_resize2fs_args*);
extern bool_t xdr_guestfs_find_args (XDR *, guestfs_find_args*);
extern bool_t xdr_guestfs_find_ret (XDR *, guestfs_find_ret*);
extern bool_t xdr_guestfs_e2fsck_f_args (XDR *, guestfs_e2fsck_f_args*);
+extern bool_t xdr_guestfs_sleep_args (XDR *, guestfs_sleep_args*);
extern bool_t xdr_guestfs_procedure (XDR *, guestfs_procedure*);
extern bool_t xdr_guestfs_message_direction (XDR *, guestfs_message_direction*);
extern bool_t xdr_guestfs_message_status (XDR *, guestfs_message_status*);
@@ -1393,6 +1400,7 @@ extern bool_t xdr_guestfs_resize2fs_args ();
extern bool_t xdr_guestfs_find_args ();
extern bool_t xdr_guestfs_find_ret ();
extern bool_t xdr_guestfs_e2fsck_f_args ();
+extern bool_t xdr_guestfs_sleep_args ();
extern bool_t xdr_guestfs_procedure ();
extern bool_t xdr_guestfs_message_direction ();
extern bool_t xdr_guestfs_message_status ();
diff --git a/src/guestfs_protocol.x b/src/guestfs_protocol.x
index b2baab52..556ed60e 100644
--- a/src/guestfs_protocol.x
+++ b/src/guestfs_protocol.x
@@ -719,6 +719,10 @@ struct guestfs_e2fsck_f_args {
string device<>;
};
+struct guestfs_sleep_args {
+ int secs;
+};
+
enum guestfs_procedure {
GUESTFS_PROC_MOUNT = 1,
GUESTFS_PROC_SYNC = 2,
@@ -828,6 +832,7 @@ enum guestfs_procedure {
GUESTFS_PROC_RESIZE2FS = 106,
GUESTFS_PROC_FIND = 107,
GUESTFS_PROC_E2FSCK_F = 108,
+ GUESTFS_PROC_SLEEP = 109,
GUESTFS_PROC_NR_PROCS
};