summaryrefslogtreecommitdiffstats
path: root/src/guestfs-actions.c
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-04-30 23:10:22 +0100
committerRichard Jones <rjones@redhat.com>2009-04-30 23:10:22 +0100
commite118c14b9552de311cbc1734e03a3226b484c1e8 (patch)
tree6e7952088d10df67004db83bfe2f370e2e4ffba2 /src/guestfs-actions.c
parentb55bf8158f0b7f6b1760b7b3b5f7c1274a149127 (diff)
downloadlibguestfs-e118c14b9552de311cbc1734e03a3226b484c1e8.tar.gz
libguestfs-e118c14b9552de311cbc1734e03a3226b484c1e8.tar.xz
libguestfs-e118c14b9552de311cbc1734e03a3226b484c1e8.zip
Generated code for grub-install command.
Diffstat (limited to 'src/guestfs-actions.c')
-rw-r--r--src/guestfs-actions.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/guestfs-actions.c b/src/guestfs-actions.c
index e2da1c3a..c20301b8 100644
--- a/src/guestfs-actions.c
+++ b/src/guestfs-actions.c
@@ -7728,3 +7728,91 @@ int guestfs_zero (guestfs_h *g,
return 0;
}
+struct grub_install_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 grub_install_reply_cb (guestfs_h *g, void *data, XDR *xdr)
+{
+ guestfs_main_loop *ml = guestfs_get_main_loop (g);
+ struct grub_install_ctx *ctx = (struct grub_install_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_grub_install");
+ return;
+ }
+
+ ml->main_loop_quit (ml, g);
+
+ if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
+ error (g, "%s: failed to parse reply header", "guestfs_grub_install");
+ 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_grub_install");
+ return;
+ }
+ goto done;
+ }
+ done:
+ ctx->cb_sequence = 1;
+}
+
+int guestfs_grub_install (guestfs_h *g,
+ const char *root,
+ const char *device)
+{
+ struct guestfs_grub_install_args args;
+ struct grub_install_ctx ctx;
+ guestfs_main_loop *ml = guestfs_get_main_loop (g);
+ int serial;
+
+ if (check_state (g, "guestfs_grub_install") == -1) return -1;
+ guestfs_set_busy (g);
+
+ memset (&ctx, 0, sizeof ctx);
+
+ args.root = (char *) root;
+ args.device = (char *) device;
+ serial = guestfs__send_sync (g, GUESTFS_PROC_GRUB_INSTALL,
+ (xdrproc_t) xdr_guestfs_grub_install_args, (char *) &args);
+ if (serial == -1) {
+ guestfs_set_ready (g);
+ return -1;
+ }
+
+ guestfs__switch_to_receiving (g);
+ ctx.cb_sequence = 0;
+ guestfs_set_reply_callback (g, grub_install_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_grub_install");
+ guestfs_set_ready (g);
+ return -1;
+ }
+
+ if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_GRUB_INSTALL, serial) == -1) {
+ guestfs_set_ready (g);
+ return -1;
+ }
+
+ if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
+ error (g, "%s", ctx.err.error_message);
+ guestfs_set_ready (g);
+ return -1;
+ }
+
+ guestfs_set_ready (g);
+ return 0;
+}
+