1 /* libguestfs generated file
2 * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
3 * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
5 * Copyright (C) 2009 Red Hat Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 #include "guestfs_protocol.h"
28 #define error guestfs_error
29 #define perrorf guestfs_perrorf
30 #define safe_malloc guestfs_safe_malloc
31 #define safe_realloc guestfs_safe_realloc
32 #define safe_strdup guestfs_safe_strdup
33 #define safe_memdup guestfs_safe_memdup
35 /* Check the return message from a call for validity. */
37 check_reply_header (guestfs_h *g,
38 const struct guestfs_message_header *hdr,
39 int proc_nr, int serial)
41 if (hdr->prog != GUESTFS_PROGRAM) {
42 error (g, "wrong program (%d/%d)", hdr->prog, GUESTFS_PROGRAM);
45 if (hdr->vers != GUESTFS_PROTOCOL_VERSION) {
46 error (g, "wrong protocol version (%d/%d)",
47 hdr->vers, GUESTFS_PROTOCOL_VERSION);
50 if (hdr->direction != GUESTFS_DIRECTION_REPLY) {
51 error (g, "unexpected message direction (%d/%d)",
52 hdr->direction, GUESTFS_DIRECTION_REPLY);
55 if (hdr->proc != proc_nr) {
56 error (g, "unexpected procedure number (%d/%d)", hdr->proc, proc_nr);
59 if (hdr->serial != serial) {
60 error (g, "unexpected serial (%d/%d)", hdr->serial, serial);
67 /* Check we are in the right state to run a high-level action. */
69 check_state (guestfs_h *g, const char *caller)
71 if (!guestfs_is_ready (g)) {
72 if (guestfs_is_config (g))
73 error (g, "%s: call launch() before using this function",
75 else if (guestfs_is_launching (g))
76 error (g, "%s: call wait_ready() before using this function",
79 error (g, "%s called from the wrong state, %d != READY",
80 caller, guestfs_get_state (g));
87 /* This flag is set by the callbacks, so we know we've done
88 * the callbacks as expected, and in the right sequence.
89 * 0 = not called, 1 = reply_cb called.
92 struct guestfs_message_header hdr;
93 struct guestfs_message_error err;
96 static void mount_reply_cb (guestfs_h *g, void *data, XDR *xdr)
98 guestfs_main_loop *ml = guestfs_get_main_loop (g);
99 struct mount_ctx *ctx = (struct mount_ctx *) data;
101 /* This should definitely not happen. */
102 if (ctx->cb_sequence != 0) {
103 ctx->cb_sequence = 9999;
104 error (g, "%s: internal error: reply callback called twice", "guestfs_mount");
108 ml->main_loop_quit (ml, g);
110 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
111 error (g, "%s: failed to parse reply header", "guestfs_mount");
114 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
115 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
116 error (g, "%s: failed to parse reply error", "guestfs_mount");
122 ctx->cb_sequence = 1;
125 int guestfs_mount (guestfs_h *g,
127 const char *mountpoint)
129 struct guestfs_mount_args args;
130 struct mount_ctx ctx;
131 guestfs_main_loop *ml = guestfs_get_main_loop (g);
134 if (check_state (g, "guestfs_mount") == -1) return -1;
135 guestfs_set_busy (g);
137 memset (&ctx, 0, sizeof ctx);
139 args.device = (char *) device;
140 args.mountpoint = (char *) mountpoint;
141 serial = guestfs__send_sync (g, GUESTFS_PROC_MOUNT,
142 (xdrproc_t) xdr_guestfs_mount_args, (char *) &args);
144 guestfs_set_ready (g);
148 guestfs__switch_to_receiving (g);
150 guestfs_set_reply_callback (g, mount_reply_cb, &ctx);
151 (void) ml->main_loop_run (ml, g);
152 guestfs_set_reply_callback (g, NULL, NULL);
153 if (ctx.cb_sequence != 1) {
154 error (g, "%s reply failed, see earlier error messages", "guestfs_mount");
155 guestfs_set_ready (g);
159 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MOUNT, serial) == -1) {
160 guestfs_set_ready (g);
164 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
165 error (g, "%s", ctx.err.error_message);
166 guestfs_set_ready (g);
170 guestfs_set_ready (g);
175 /* This flag is set by the callbacks, so we know we've done
176 * the callbacks as expected, and in the right sequence.
177 * 0 = not called, 1 = reply_cb called.
180 struct guestfs_message_header hdr;
181 struct guestfs_message_error err;
184 static void sync_reply_cb (guestfs_h *g, void *data, XDR *xdr)
186 guestfs_main_loop *ml = guestfs_get_main_loop (g);
187 struct sync_ctx *ctx = (struct sync_ctx *) data;
189 /* This should definitely not happen. */
190 if (ctx->cb_sequence != 0) {
191 ctx->cb_sequence = 9999;
192 error (g, "%s: internal error: reply callback called twice", "guestfs_sync");
196 ml->main_loop_quit (ml, g);
198 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
199 error (g, "%s: failed to parse reply header", "guestfs_sync");
202 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
203 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
204 error (g, "%s: failed to parse reply error", "guestfs_sync");
210 ctx->cb_sequence = 1;
213 int guestfs_sync (guestfs_h *g)
216 guestfs_main_loop *ml = guestfs_get_main_loop (g);
219 if (check_state (g, "guestfs_sync") == -1) return -1;
220 guestfs_set_busy (g);
222 memset (&ctx, 0, sizeof ctx);
224 serial = guestfs__send_sync (g, GUESTFS_PROC_SYNC, NULL, NULL);
226 guestfs_set_ready (g);
230 guestfs__switch_to_receiving (g);
232 guestfs_set_reply_callback (g, sync_reply_cb, &ctx);
233 (void) ml->main_loop_run (ml, g);
234 guestfs_set_reply_callback (g, NULL, NULL);
235 if (ctx.cb_sequence != 1) {
236 error (g, "%s reply failed, see earlier error messages", "guestfs_sync");
237 guestfs_set_ready (g);
241 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_SYNC, serial) == -1) {
242 guestfs_set_ready (g);
246 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
247 error (g, "%s", ctx.err.error_message);
248 guestfs_set_ready (g);
252 guestfs_set_ready (g);
257 /* This flag is set by the callbacks, so we know we've done
258 * the callbacks as expected, and in the right sequence.
259 * 0 = not called, 1 = reply_cb called.
262 struct guestfs_message_header hdr;
263 struct guestfs_message_error err;
266 static void touch_reply_cb (guestfs_h *g, void *data, XDR *xdr)
268 guestfs_main_loop *ml = guestfs_get_main_loop (g);
269 struct touch_ctx *ctx = (struct touch_ctx *) data;
271 /* This should definitely not happen. */
272 if (ctx->cb_sequence != 0) {
273 ctx->cb_sequence = 9999;
274 error (g, "%s: internal error: reply callback called twice", "guestfs_touch");
278 ml->main_loop_quit (ml, g);
280 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
281 error (g, "%s: failed to parse reply header", "guestfs_touch");
284 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
285 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
286 error (g, "%s: failed to parse reply error", "guestfs_touch");
292 ctx->cb_sequence = 1;
295 int guestfs_touch (guestfs_h *g,
298 struct guestfs_touch_args args;
299 struct touch_ctx ctx;
300 guestfs_main_loop *ml = guestfs_get_main_loop (g);
303 if (check_state (g, "guestfs_touch") == -1) return -1;
304 guestfs_set_busy (g);
306 memset (&ctx, 0, sizeof ctx);
308 args.path = (char *) path;
309 serial = guestfs__send_sync (g, GUESTFS_PROC_TOUCH,
310 (xdrproc_t) xdr_guestfs_touch_args, (char *) &args);
312 guestfs_set_ready (g);
316 guestfs__switch_to_receiving (g);
318 guestfs_set_reply_callback (g, touch_reply_cb, &ctx);
319 (void) ml->main_loop_run (ml, g);
320 guestfs_set_reply_callback (g, NULL, NULL);
321 if (ctx.cb_sequence != 1) {
322 error (g, "%s reply failed, see earlier error messages", "guestfs_touch");
323 guestfs_set_ready (g);
327 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_TOUCH, serial) == -1) {
328 guestfs_set_ready (g);
332 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
333 error (g, "%s", ctx.err.error_message);
334 guestfs_set_ready (g);
338 guestfs_set_ready (g);
343 /* This flag is set by the callbacks, so we know we've done
344 * the callbacks as expected, and in the right sequence.
345 * 0 = not called, 1 = reply_cb called.
348 struct guestfs_message_header hdr;
349 struct guestfs_message_error err;
350 struct guestfs_cat_ret ret;
353 static void cat_reply_cb (guestfs_h *g, void *data, XDR *xdr)
355 guestfs_main_loop *ml = guestfs_get_main_loop (g);
356 struct cat_ctx *ctx = (struct cat_ctx *) data;
358 /* This should definitely not happen. */
359 if (ctx->cb_sequence != 0) {
360 ctx->cb_sequence = 9999;
361 error (g, "%s: internal error: reply callback called twice", "guestfs_cat");
365 ml->main_loop_quit (ml, g);
367 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
368 error (g, "%s: failed to parse reply header", "guestfs_cat");
371 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
372 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
373 error (g, "%s: failed to parse reply error", "guestfs_cat");
378 if (!xdr_guestfs_cat_ret (xdr, &ctx->ret)) {
379 error (g, "%s: failed to parse reply", "guestfs_cat");
383 ctx->cb_sequence = 1;
386 char *guestfs_cat (guestfs_h *g,
389 struct guestfs_cat_args args;
391 guestfs_main_loop *ml = guestfs_get_main_loop (g);
394 if (check_state (g, "guestfs_cat") == -1) return NULL;
395 guestfs_set_busy (g);
397 memset (&ctx, 0, sizeof ctx);
399 args.path = (char *) path;
400 serial = guestfs__send_sync (g, GUESTFS_PROC_CAT,
401 (xdrproc_t) xdr_guestfs_cat_args, (char *) &args);
403 guestfs_set_ready (g);
407 guestfs__switch_to_receiving (g);
409 guestfs_set_reply_callback (g, cat_reply_cb, &ctx);
410 (void) ml->main_loop_run (ml, g);
411 guestfs_set_reply_callback (g, NULL, NULL);
412 if (ctx.cb_sequence != 1) {
413 error (g, "%s reply failed, see earlier error messages", "guestfs_cat");
414 guestfs_set_ready (g);
418 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_CAT, serial) == -1) {
419 guestfs_set_ready (g);
423 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
424 error (g, "%s", ctx.err.error_message);
425 guestfs_set_ready (g);
429 guestfs_set_ready (g);
430 return ctx.ret.content; /* caller will free */
434 /* This flag is set by the callbacks, so we know we've done
435 * the callbacks as expected, and in the right sequence.
436 * 0 = not called, 1 = reply_cb called.
439 struct guestfs_message_header hdr;
440 struct guestfs_message_error err;
441 struct guestfs_ll_ret ret;
444 static void ll_reply_cb (guestfs_h *g, void *data, XDR *xdr)
446 guestfs_main_loop *ml = guestfs_get_main_loop (g);
447 struct ll_ctx *ctx = (struct ll_ctx *) data;
449 /* This should definitely not happen. */
450 if (ctx->cb_sequence != 0) {
451 ctx->cb_sequence = 9999;
452 error (g, "%s: internal error: reply callback called twice", "guestfs_ll");
456 ml->main_loop_quit (ml, g);
458 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
459 error (g, "%s: failed to parse reply header", "guestfs_ll");
462 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
463 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
464 error (g, "%s: failed to parse reply error", "guestfs_ll");
469 if (!xdr_guestfs_ll_ret (xdr, &ctx->ret)) {
470 error (g, "%s: failed to parse reply", "guestfs_ll");
474 ctx->cb_sequence = 1;
477 char *guestfs_ll (guestfs_h *g,
478 const char *directory)
480 struct guestfs_ll_args args;
482 guestfs_main_loop *ml = guestfs_get_main_loop (g);
485 if (check_state (g, "guestfs_ll") == -1) return NULL;
486 guestfs_set_busy (g);
488 memset (&ctx, 0, sizeof ctx);
490 args.directory = (char *) directory;
491 serial = guestfs__send_sync (g, GUESTFS_PROC_LL,
492 (xdrproc_t) xdr_guestfs_ll_args, (char *) &args);
494 guestfs_set_ready (g);
498 guestfs__switch_to_receiving (g);
500 guestfs_set_reply_callback (g, ll_reply_cb, &ctx);
501 (void) ml->main_loop_run (ml, g);
502 guestfs_set_reply_callback (g, NULL, NULL);
503 if (ctx.cb_sequence != 1) {
504 error (g, "%s reply failed, see earlier error messages", "guestfs_ll");
505 guestfs_set_ready (g);
509 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_LL, serial) == -1) {
510 guestfs_set_ready (g);
514 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
515 error (g, "%s", ctx.err.error_message);
516 guestfs_set_ready (g);
520 guestfs_set_ready (g);
521 return ctx.ret.listing; /* caller will free */
525 /* This flag is set by the callbacks, so we know we've done
526 * the callbacks as expected, and in the right sequence.
527 * 0 = not called, 1 = reply_cb called.
530 struct guestfs_message_header hdr;
531 struct guestfs_message_error err;
532 struct guestfs_ls_ret ret;
535 static void ls_reply_cb (guestfs_h *g, void *data, XDR *xdr)
537 guestfs_main_loop *ml = guestfs_get_main_loop (g);
538 struct ls_ctx *ctx = (struct ls_ctx *) data;
540 /* This should definitely not happen. */
541 if (ctx->cb_sequence != 0) {
542 ctx->cb_sequence = 9999;
543 error (g, "%s: internal error: reply callback called twice", "guestfs_ls");
547 ml->main_loop_quit (ml, g);
549 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
550 error (g, "%s: failed to parse reply header", "guestfs_ls");
553 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
554 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
555 error (g, "%s: failed to parse reply error", "guestfs_ls");
560 if (!xdr_guestfs_ls_ret (xdr, &ctx->ret)) {
561 error (g, "%s: failed to parse reply", "guestfs_ls");
565 ctx->cb_sequence = 1;
568 char **guestfs_ls (guestfs_h *g,
569 const char *directory)
571 struct guestfs_ls_args args;
573 guestfs_main_loop *ml = guestfs_get_main_loop (g);
576 if (check_state (g, "guestfs_ls") == -1) return NULL;
577 guestfs_set_busy (g);
579 memset (&ctx, 0, sizeof ctx);
581 args.directory = (char *) directory;
582 serial = guestfs__send_sync (g, GUESTFS_PROC_LS,
583 (xdrproc_t) xdr_guestfs_ls_args, (char *) &args);
585 guestfs_set_ready (g);
589 guestfs__switch_to_receiving (g);
591 guestfs_set_reply_callback (g, ls_reply_cb, &ctx);
592 (void) ml->main_loop_run (ml, g);
593 guestfs_set_reply_callback (g, NULL, NULL);
594 if (ctx.cb_sequence != 1) {
595 error (g, "%s reply failed, see earlier error messages", "guestfs_ls");
596 guestfs_set_ready (g);
600 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_LS, serial) == -1) {
601 guestfs_set_ready (g);
605 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
606 error (g, "%s", ctx.err.error_message);
607 guestfs_set_ready (g);
611 guestfs_set_ready (g);
612 /* caller will free this, but we need to add a NULL entry */
613 ctx.ret.listing.listing_val =
614 safe_realloc (g, ctx.ret.listing.listing_val,
615 sizeof (char *) * (ctx.ret.listing.listing_len + 1));
616 ctx.ret.listing.listing_val[ctx.ret.listing.listing_len] = NULL;
617 return ctx.ret.listing.listing_val;
620 struct list_devices_ctx {
621 /* This flag is set by the callbacks, so we know we've done
622 * the callbacks as expected, and in the right sequence.
623 * 0 = not called, 1 = reply_cb called.
626 struct guestfs_message_header hdr;
627 struct guestfs_message_error err;
628 struct guestfs_list_devices_ret ret;
631 static void list_devices_reply_cb (guestfs_h *g, void *data, XDR *xdr)
633 guestfs_main_loop *ml = guestfs_get_main_loop (g);
634 struct list_devices_ctx *ctx = (struct list_devices_ctx *) data;
636 /* This should definitely not happen. */
637 if (ctx->cb_sequence != 0) {
638 ctx->cb_sequence = 9999;
639 error (g, "%s: internal error: reply callback called twice", "guestfs_list_devices");
643 ml->main_loop_quit (ml, g);
645 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
646 error (g, "%s: failed to parse reply header", "guestfs_list_devices");
649 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
650 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
651 error (g, "%s: failed to parse reply error", "guestfs_list_devices");
656 if (!xdr_guestfs_list_devices_ret (xdr, &ctx->ret)) {
657 error (g, "%s: failed to parse reply", "guestfs_list_devices");
661 ctx->cb_sequence = 1;
664 char **guestfs_list_devices (guestfs_h *g)
666 struct list_devices_ctx ctx;
667 guestfs_main_loop *ml = guestfs_get_main_loop (g);
670 if (check_state (g, "guestfs_list_devices") == -1) return NULL;
671 guestfs_set_busy (g);
673 memset (&ctx, 0, sizeof ctx);
675 serial = guestfs__send_sync (g, GUESTFS_PROC_LIST_DEVICES, NULL, NULL);
677 guestfs_set_ready (g);
681 guestfs__switch_to_receiving (g);
683 guestfs_set_reply_callback (g, list_devices_reply_cb, &ctx);
684 (void) ml->main_loop_run (ml, g);
685 guestfs_set_reply_callback (g, NULL, NULL);
686 if (ctx.cb_sequence != 1) {
687 error (g, "%s reply failed, see earlier error messages", "guestfs_list_devices");
688 guestfs_set_ready (g);
692 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_LIST_DEVICES, serial) == -1) {
693 guestfs_set_ready (g);
697 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
698 error (g, "%s", ctx.err.error_message);
699 guestfs_set_ready (g);
703 guestfs_set_ready (g);
704 /* caller will free this, but we need to add a NULL entry */
705 ctx.ret.devices.devices_val =
706 safe_realloc (g, ctx.ret.devices.devices_val,
707 sizeof (char *) * (ctx.ret.devices.devices_len + 1));
708 ctx.ret.devices.devices_val[ctx.ret.devices.devices_len] = NULL;
709 return ctx.ret.devices.devices_val;
712 struct list_partitions_ctx {
713 /* This flag is set by the callbacks, so we know we've done
714 * the callbacks as expected, and in the right sequence.
715 * 0 = not called, 1 = reply_cb called.
718 struct guestfs_message_header hdr;
719 struct guestfs_message_error err;
720 struct guestfs_list_partitions_ret ret;
723 static void list_partitions_reply_cb (guestfs_h *g, void *data, XDR *xdr)
725 guestfs_main_loop *ml = guestfs_get_main_loop (g);
726 struct list_partitions_ctx *ctx = (struct list_partitions_ctx *) data;
728 /* This should definitely not happen. */
729 if (ctx->cb_sequence != 0) {
730 ctx->cb_sequence = 9999;
731 error (g, "%s: internal error: reply callback called twice", "guestfs_list_partitions");
735 ml->main_loop_quit (ml, g);
737 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
738 error (g, "%s: failed to parse reply header", "guestfs_list_partitions");
741 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
742 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
743 error (g, "%s: failed to parse reply error", "guestfs_list_partitions");
748 if (!xdr_guestfs_list_partitions_ret (xdr, &ctx->ret)) {
749 error (g, "%s: failed to parse reply", "guestfs_list_partitions");
753 ctx->cb_sequence = 1;
756 char **guestfs_list_partitions (guestfs_h *g)
758 struct list_partitions_ctx ctx;
759 guestfs_main_loop *ml = guestfs_get_main_loop (g);
762 if (check_state (g, "guestfs_list_partitions") == -1) return NULL;
763 guestfs_set_busy (g);
765 memset (&ctx, 0, sizeof ctx);
767 serial = guestfs__send_sync (g, GUESTFS_PROC_LIST_PARTITIONS, NULL, NULL);
769 guestfs_set_ready (g);
773 guestfs__switch_to_receiving (g);
775 guestfs_set_reply_callback (g, list_partitions_reply_cb, &ctx);
776 (void) ml->main_loop_run (ml, g);
777 guestfs_set_reply_callback (g, NULL, NULL);
778 if (ctx.cb_sequence != 1) {
779 error (g, "%s reply failed, see earlier error messages", "guestfs_list_partitions");
780 guestfs_set_ready (g);
784 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_LIST_PARTITIONS, serial) == -1) {
785 guestfs_set_ready (g);
789 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
790 error (g, "%s", ctx.err.error_message);
791 guestfs_set_ready (g);
795 guestfs_set_ready (g);
796 /* caller will free this, but we need to add a NULL entry */
797 ctx.ret.partitions.partitions_val =
798 safe_realloc (g, ctx.ret.partitions.partitions_val,
799 sizeof (char *) * (ctx.ret.partitions.partitions_len + 1));
800 ctx.ret.partitions.partitions_val[ctx.ret.partitions.partitions_len] = NULL;
801 return ctx.ret.partitions.partitions_val;
805 /* This flag is set by the callbacks, so we know we've done
806 * the callbacks as expected, and in the right sequence.
807 * 0 = not called, 1 = reply_cb called.
810 struct guestfs_message_header hdr;
811 struct guestfs_message_error err;
812 struct guestfs_pvs_ret ret;
815 static void pvs_reply_cb (guestfs_h *g, void *data, XDR *xdr)
817 guestfs_main_loop *ml = guestfs_get_main_loop (g);
818 struct pvs_ctx *ctx = (struct pvs_ctx *) data;
820 /* This should definitely not happen. */
821 if (ctx->cb_sequence != 0) {
822 ctx->cb_sequence = 9999;
823 error (g, "%s: internal error: reply callback called twice", "guestfs_pvs");
827 ml->main_loop_quit (ml, g);
829 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
830 error (g, "%s: failed to parse reply header", "guestfs_pvs");
833 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
834 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
835 error (g, "%s: failed to parse reply error", "guestfs_pvs");
840 if (!xdr_guestfs_pvs_ret (xdr, &ctx->ret)) {
841 error (g, "%s: failed to parse reply", "guestfs_pvs");
845 ctx->cb_sequence = 1;
848 char **guestfs_pvs (guestfs_h *g)
851 guestfs_main_loop *ml = guestfs_get_main_loop (g);
854 if (check_state (g, "guestfs_pvs") == -1) return NULL;
855 guestfs_set_busy (g);
857 memset (&ctx, 0, sizeof ctx);
859 serial = guestfs__send_sync (g, GUESTFS_PROC_PVS, NULL, NULL);
861 guestfs_set_ready (g);
865 guestfs__switch_to_receiving (g);
867 guestfs_set_reply_callback (g, pvs_reply_cb, &ctx);
868 (void) ml->main_loop_run (ml, g);
869 guestfs_set_reply_callback (g, NULL, NULL);
870 if (ctx.cb_sequence != 1) {
871 error (g, "%s reply failed, see earlier error messages", "guestfs_pvs");
872 guestfs_set_ready (g);
876 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_PVS, serial) == -1) {
877 guestfs_set_ready (g);
881 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
882 error (g, "%s", ctx.err.error_message);
883 guestfs_set_ready (g);
887 guestfs_set_ready (g);
888 /* caller will free this, but we need to add a NULL entry */
889 ctx.ret.physvols.physvols_val =
890 safe_realloc (g, ctx.ret.physvols.physvols_val,
891 sizeof (char *) * (ctx.ret.physvols.physvols_len + 1));
892 ctx.ret.physvols.physvols_val[ctx.ret.physvols.physvols_len] = NULL;
893 return ctx.ret.physvols.physvols_val;
897 /* This flag is set by the callbacks, so we know we've done
898 * the callbacks as expected, and in the right sequence.
899 * 0 = not called, 1 = reply_cb called.
902 struct guestfs_message_header hdr;
903 struct guestfs_message_error err;
904 struct guestfs_vgs_ret ret;
907 static void vgs_reply_cb (guestfs_h *g, void *data, XDR *xdr)
909 guestfs_main_loop *ml = guestfs_get_main_loop (g);
910 struct vgs_ctx *ctx = (struct vgs_ctx *) data;
912 /* This should definitely not happen. */
913 if (ctx->cb_sequence != 0) {
914 ctx->cb_sequence = 9999;
915 error (g, "%s: internal error: reply callback called twice", "guestfs_vgs");
919 ml->main_loop_quit (ml, g);
921 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
922 error (g, "%s: failed to parse reply header", "guestfs_vgs");
925 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
926 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
927 error (g, "%s: failed to parse reply error", "guestfs_vgs");
932 if (!xdr_guestfs_vgs_ret (xdr, &ctx->ret)) {
933 error (g, "%s: failed to parse reply", "guestfs_vgs");
937 ctx->cb_sequence = 1;
940 char **guestfs_vgs (guestfs_h *g)
943 guestfs_main_loop *ml = guestfs_get_main_loop (g);
946 if (check_state (g, "guestfs_vgs") == -1) return NULL;
947 guestfs_set_busy (g);
949 memset (&ctx, 0, sizeof ctx);
951 serial = guestfs__send_sync (g, GUESTFS_PROC_VGS, NULL, NULL);
953 guestfs_set_ready (g);
957 guestfs__switch_to_receiving (g);
959 guestfs_set_reply_callback (g, vgs_reply_cb, &ctx);
960 (void) ml->main_loop_run (ml, g);
961 guestfs_set_reply_callback (g, NULL, NULL);
962 if (ctx.cb_sequence != 1) {
963 error (g, "%s reply failed, see earlier error messages", "guestfs_vgs");
964 guestfs_set_ready (g);
968 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_VGS, serial) == -1) {
969 guestfs_set_ready (g);
973 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
974 error (g, "%s", ctx.err.error_message);
975 guestfs_set_ready (g);
979 guestfs_set_ready (g);
980 /* caller will free this, but we need to add a NULL entry */
981 ctx.ret.volgroups.volgroups_val =
982 safe_realloc (g, ctx.ret.volgroups.volgroups_val,
983 sizeof (char *) * (ctx.ret.volgroups.volgroups_len + 1));
984 ctx.ret.volgroups.volgroups_val[ctx.ret.volgroups.volgroups_len] = NULL;
985 return ctx.ret.volgroups.volgroups_val;
989 /* This flag is set by the callbacks, so we know we've done
990 * the callbacks as expected, and in the right sequence.
991 * 0 = not called, 1 = reply_cb called.
994 struct guestfs_message_header hdr;
995 struct guestfs_message_error err;
996 struct guestfs_lvs_ret ret;
999 static void lvs_reply_cb (guestfs_h *g, void *data, XDR *xdr)
1001 guestfs_main_loop *ml = guestfs_get_main_loop (g);
1002 struct lvs_ctx *ctx = (struct lvs_ctx *) data;
1004 /* This should definitely not happen. */
1005 if (ctx->cb_sequence != 0) {
1006 ctx->cb_sequence = 9999;
1007 error (g, "%s: internal error: reply callback called twice", "guestfs_lvs");
1011 ml->main_loop_quit (ml, g);
1013 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
1014 error (g, "%s: failed to parse reply header", "guestfs_lvs");
1017 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
1018 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
1019 error (g, "%s: failed to parse reply error", "guestfs_lvs");
1024 if (!xdr_guestfs_lvs_ret (xdr, &ctx->ret)) {
1025 error (g, "%s: failed to parse reply", "guestfs_lvs");
1029 ctx->cb_sequence = 1;
1032 char **guestfs_lvs (guestfs_h *g)
1035 guestfs_main_loop *ml = guestfs_get_main_loop (g);
1038 if (check_state (g, "guestfs_lvs") == -1) return NULL;
1039 guestfs_set_busy (g);
1041 memset (&ctx, 0, sizeof ctx);
1043 serial = guestfs__send_sync (g, GUESTFS_PROC_LVS, NULL, NULL);
1045 guestfs_set_ready (g);
1049 guestfs__switch_to_receiving (g);
1050 ctx.cb_sequence = 0;
1051 guestfs_set_reply_callback (g, lvs_reply_cb, &ctx);
1052 (void) ml->main_loop_run (ml, g);
1053 guestfs_set_reply_callback (g, NULL, NULL);
1054 if (ctx.cb_sequence != 1) {
1055 error (g, "%s reply failed, see earlier error messages", "guestfs_lvs");
1056 guestfs_set_ready (g);
1060 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_LVS, serial) == -1) {
1061 guestfs_set_ready (g);
1065 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
1066 error (g, "%s", ctx.err.error_message);
1067 guestfs_set_ready (g);
1071 guestfs_set_ready (g);
1072 /* caller will free this, but we need to add a NULL entry */
1073 ctx.ret.logvols.logvols_val =
1074 safe_realloc (g, ctx.ret.logvols.logvols_val,
1075 sizeof (char *) * (ctx.ret.logvols.logvols_len + 1));
1076 ctx.ret.logvols.logvols_val[ctx.ret.logvols.logvols_len] = NULL;
1077 return ctx.ret.logvols.logvols_val;
1080 struct pvs_full_ctx {
1081 /* This flag is set by the callbacks, so we know we've done
1082 * the callbacks as expected, and in the right sequence.
1083 * 0 = not called, 1 = reply_cb called.
1086 struct guestfs_message_header hdr;
1087 struct guestfs_message_error err;
1088 struct guestfs_pvs_full_ret ret;
1091 static void pvs_full_reply_cb (guestfs_h *g, void *data, XDR *xdr)
1093 guestfs_main_loop *ml = guestfs_get_main_loop (g);
1094 struct pvs_full_ctx *ctx = (struct pvs_full_ctx *) data;
1096 /* This should definitely not happen. */
1097 if (ctx->cb_sequence != 0) {
1098 ctx->cb_sequence = 9999;
1099 error (g, "%s: internal error: reply callback called twice", "guestfs_pvs_full");
1103 ml->main_loop_quit (ml, g);
1105 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
1106 error (g, "%s: failed to parse reply header", "guestfs_pvs_full");
1109 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
1110 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
1111 error (g, "%s: failed to parse reply error", "guestfs_pvs_full");
1116 if (!xdr_guestfs_pvs_full_ret (xdr, &ctx->ret)) {
1117 error (g, "%s: failed to parse reply", "guestfs_pvs_full");
1121 ctx->cb_sequence = 1;
1124 struct guestfs_lvm_pv_list *guestfs_pvs_full (guestfs_h *g)
1126 struct pvs_full_ctx ctx;
1127 guestfs_main_loop *ml = guestfs_get_main_loop (g);
1130 if (check_state (g, "guestfs_pvs_full") == -1) return NULL;
1131 guestfs_set_busy (g);
1133 memset (&ctx, 0, sizeof ctx);
1135 serial = guestfs__send_sync (g, GUESTFS_PROC_PVS_FULL, NULL, NULL);
1137 guestfs_set_ready (g);
1141 guestfs__switch_to_receiving (g);
1142 ctx.cb_sequence = 0;
1143 guestfs_set_reply_callback (g, pvs_full_reply_cb, &ctx);
1144 (void) ml->main_loop_run (ml, g);
1145 guestfs_set_reply_callback (g, NULL, NULL);
1146 if (ctx.cb_sequence != 1) {
1147 error (g, "%s reply failed, see earlier error messages", "guestfs_pvs_full");
1148 guestfs_set_ready (g);
1152 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_PVS_FULL, serial) == -1) {
1153 guestfs_set_ready (g);
1157 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
1158 error (g, "%s", ctx.err.error_message);
1159 guestfs_set_ready (g);
1163 guestfs_set_ready (g);
1164 /* caller will free this */
1165 return safe_memdup (g, &ctx.ret.physvols, sizeof (ctx.ret.physvols));
1168 struct vgs_full_ctx {
1169 /* This flag is set by the callbacks, so we know we've done
1170 * the callbacks as expected, and in the right sequence.
1171 * 0 = not called, 1 = reply_cb called.
1174 struct guestfs_message_header hdr;
1175 struct guestfs_message_error err;
1176 struct guestfs_vgs_full_ret ret;
1179 static void vgs_full_reply_cb (guestfs_h *g, void *data, XDR *xdr)
1181 guestfs_main_loop *ml = guestfs_get_main_loop (g);
1182 struct vgs_full_ctx *ctx = (struct vgs_full_ctx *) data;
1184 /* This should definitely not happen. */
1185 if (ctx->cb_sequence != 0) {
1186 ctx->cb_sequence = 9999;
1187 error (g, "%s: internal error: reply callback called twice", "guestfs_vgs_full");
1191 ml->main_loop_quit (ml, g);
1193 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
1194 error (g, "%s: failed to parse reply header", "guestfs_vgs_full");
1197 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
1198 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
1199 error (g, "%s: failed to parse reply error", "guestfs_vgs_full");
1204 if (!xdr_guestfs_vgs_full_ret (xdr, &ctx->ret)) {
1205 error (g, "%s: failed to parse reply", "guestfs_vgs_full");
1209 ctx->cb_sequence = 1;
1212 struct guestfs_lvm_vg_list *guestfs_vgs_full (guestfs_h *g)
1214 struct vgs_full_ctx ctx;
1215 guestfs_main_loop *ml = guestfs_get_main_loop (g);
1218 if (check_state (g, "guestfs_vgs_full") == -1) return NULL;
1219 guestfs_set_busy (g);
1221 memset (&ctx, 0, sizeof ctx);
1223 serial = guestfs__send_sync (g, GUESTFS_PROC_VGS_FULL, NULL, NULL);
1225 guestfs_set_ready (g);
1229 guestfs__switch_to_receiving (g);
1230 ctx.cb_sequence = 0;
1231 guestfs_set_reply_callback (g, vgs_full_reply_cb, &ctx);
1232 (void) ml->main_loop_run (ml, g);
1233 guestfs_set_reply_callback (g, NULL, NULL);
1234 if (ctx.cb_sequence != 1) {
1235 error (g, "%s reply failed, see earlier error messages", "guestfs_vgs_full");
1236 guestfs_set_ready (g);
1240 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_VGS_FULL, serial) == -1) {
1241 guestfs_set_ready (g);
1245 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
1246 error (g, "%s", ctx.err.error_message);
1247 guestfs_set_ready (g);
1251 guestfs_set_ready (g);
1252 /* caller will free this */
1253 return safe_memdup (g, &ctx.ret.volgroups, sizeof (ctx.ret.volgroups));
1256 struct lvs_full_ctx {
1257 /* This flag is set by the callbacks, so we know we've done
1258 * the callbacks as expected, and in the right sequence.
1259 * 0 = not called, 1 = reply_cb called.
1262 struct guestfs_message_header hdr;
1263 struct guestfs_message_error err;
1264 struct guestfs_lvs_full_ret ret;
1267 static void lvs_full_reply_cb (guestfs_h *g, void *data, XDR *xdr)
1269 guestfs_main_loop *ml = guestfs_get_main_loop (g);
1270 struct lvs_full_ctx *ctx = (struct lvs_full_ctx *) data;
1272 /* This should definitely not happen. */
1273 if (ctx->cb_sequence != 0) {
1274 ctx->cb_sequence = 9999;
1275 error (g, "%s: internal error: reply callback called twice", "guestfs_lvs_full");
1279 ml->main_loop_quit (ml, g);
1281 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
1282 error (g, "%s: failed to parse reply header", "guestfs_lvs_full");
1285 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
1286 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
1287 error (g, "%s: failed to parse reply error", "guestfs_lvs_full");
1292 if (!xdr_guestfs_lvs_full_ret (xdr, &ctx->ret)) {
1293 error (g, "%s: failed to parse reply", "guestfs_lvs_full");
1297 ctx->cb_sequence = 1;
1300 struct guestfs_lvm_lv_list *guestfs_lvs_full (guestfs_h *g)
1302 struct lvs_full_ctx ctx;
1303 guestfs_main_loop *ml = guestfs_get_main_loop (g);
1306 if (check_state (g, "guestfs_lvs_full") == -1) return NULL;
1307 guestfs_set_busy (g);
1309 memset (&ctx, 0, sizeof ctx);
1311 serial = guestfs__send_sync (g, GUESTFS_PROC_LVS_FULL, NULL, NULL);
1313 guestfs_set_ready (g);
1317 guestfs__switch_to_receiving (g);
1318 ctx.cb_sequence = 0;
1319 guestfs_set_reply_callback (g, lvs_full_reply_cb, &ctx);
1320 (void) ml->main_loop_run (ml, g);
1321 guestfs_set_reply_callback (g, NULL, NULL);
1322 if (ctx.cb_sequence != 1) {
1323 error (g, "%s reply failed, see earlier error messages", "guestfs_lvs_full");
1324 guestfs_set_ready (g);
1328 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_LVS_FULL, serial) == -1) {
1329 guestfs_set_ready (g);
1333 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
1334 error (g, "%s", ctx.err.error_message);
1335 guestfs_set_ready (g);
1339 guestfs_set_ready (g);
1340 /* caller will free this */
1341 return safe_memdup (g, &ctx.ret.logvols, sizeof (ctx.ret.logvols));
1344 struct read_lines_ctx {
1345 /* This flag is set by the callbacks, so we know we've done
1346 * the callbacks as expected, and in the right sequence.
1347 * 0 = not called, 1 = reply_cb called.
1350 struct guestfs_message_header hdr;
1351 struct guestfs_message_error err;
1352 struct guestfs_read_lines_ret ret;
1355 static void read_lines_reply_cb (guestfs_h *g, void *data, XDR *xdr)
1357 guestfs_main_loop *ml = guestfs_get_main_loop (g);
1358 struct read_lines_ctx *ctx = (struct read_lines_ctx *) data;
1360 /* This should definitely not happen. */
1361 if (ctx->cb_sequence != 0) {
1362 ctx->cb_sequence = 9999;
1363 error (g, "%s: internal error: reply callback called twice", "guestfs_read_lines");
1367 ml->main_loop_quit (ml, g);
1369 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
1370 error (g, "%s: failed to parse reply header", "guestfs_read_lines");
1373 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
1374 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
1375 error (g, "%s: failed to parse reply error", "guestfs_read_lines");
1380 if (!xdr_guestfs_read_lines_ret (xdr, &ctx->ret)) {
1381 error (g, "%s: failed to parse reply", "guestfs_read_lines");
1385 ctx->cb_sequence = 1;
1388 char **guestfs_read_lines (guestfs_h *g,
1391 struct guestfs_read_lines_args args;
1392 struct read_lines_ctx ctx;
1393 guestfs_main_loop *ml = guestfs_get_main_loop (g);
1396 if (check_state (g, "guestfs_read_lines") == -1) return NULL;
1397 guestfs_set_busy (g);
1399 memset (&ctx, 0, sizeof ctx);
1401 args.path = (char *) path;
1402 serial = guestfs__send_sync (g, GUESTFS_PROC_READ_LINES,
1403 (xdrproc_t) xdr_guestfs_read_lines_args, (char *) &args);
1405 guestfs_set_ready (g);
1409 guestfs__switch_to_receiving (g);
1410 ctx.cb_sequence = 0;
1411 guestfs_set_reply_callback (g, read_lines_reply_cb, &ctx);
1412 (void) ml->main_loop_run (ml, g);
1413 guestfs_set_reply_callback (g, NULL, NULL);
1414 if (ctx.cb_sequence != 1) {
1415 error (g, "%s reply failed, see earlier error messages", "guestfs_read_lines");
1416 guestfs_set_ready (g);
1420 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_READ_LINES, serial) == -1) {
1421 guestfs_set_ready (g);
1425 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
1426 error (g, "%s", ctx.err.error_message);
1427 guestfs_set_ready (g);
1431 guestfs_set_ready (g);
1432 /* caller will free this, but we need to add a NULL entry */
1433 ctx.ret.lines.lines_val =
1434 safe_realloc (g, ctx.ret.lines.lines_val,
1435 sizeof (char *) * (ctx.ret.lines.lines_len + 1));
1436 ctx.ret.lines.lines_val[ctx.ret.lines.lines_len] = NULL;
1437 return ctx.ret.lines.lines_val;
1440 struct aug_init_ctx {
1441 /* This flag is set by the callbacks, so we know we've done
1442 * the callbacks as expected, and in the right sequence.
1443 * 0 = not called, 1 = reply_cb called.
1446 struct guestfs_message_header hdr;
1447 struct guestfs_message_error err;
1450 static void aug_init_reply_cb (guestfs_h *g, void *data, XDR *xdr)
1452 guestfs_main_loop *ml = guestfs_get_main_loop (g);
1453 struct aug_init_ctx *ctx = (struct aug_init_ctx *) data;
1455 /* This should definitely not happen. */
1456 if (ctx->cb_sequence != 0) {
1457 ctx->cb_sequence = 9999;
1458 error (g, "%s: internal error: reply callback called twice", "guestfs_aug_init");
1462 ml->main_loop_quit (ml, g);
1464 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
1465 error (g, "%s: failed to parse reply header", "guestfs_aug_init");
1468 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
1469 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
1470 error (g, "%s: failed to parse reply error", "guestfs_aug_init");
1476 ctx->cb_sequence = 1;
1479 int guestfs_aug_init (guestfs_h *g,
1483 struct guestfs_aug_init_args args;
1484 struct aug_init_ctx ctx;
1485 guestfs_main_loop *ml = guestfs_get_main_loop (g);
1488 if (check_state (g, "guestfs_aug_init") == -1) return -1;
1489 guestfs_set_busy (g);
1491 memset (&ctx, 0, sizeof ctx);
1493 args.root = (char *) root;
1495 serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_INIT,
1496 (xdrproc_t) xdr_guestfs_aug_init_args, (char *) &args);
1498 guestfs_set_ready (g);
1502 guestfs__switch_to_receiving (g);
1503 ctx.cb_sequence = 0;
1504 guestfs_set_reply_callback (g, aug_init_reply_cb, &ctx);
1505 (void) ml->main_loop_run (ml, g);
1506 guestfs_set_reply_callback (g, NULL, NULL);
1507 if (ctx.cb_sequence != 1) {
1508 error (g, "%s reply failed, see earlier error messages", "guestfs_aug_init");
1509 guestfs_set_ready (g);
1513 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_INIT, serial) == -1) {
1514 guestfs_set_ready (g);
1518 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
1519 error (g, "%s", ctx.err.error_message);
1520 guestfs_set_ready (g);
1524 guestfs_set_ready (g);
1528 struct aug_close_ctx {
1529 /* This flag is set by the callbacks, so we know we've done
1530 * the callbacks as expected, and in the right sequence.
1531 * 0 = not called, 1 = reply_cb called.
1534 struct guestfs_message_header hdr;
1535 struct guestfs_message_error err;
1538 static void aug_close_reply_cb (guestfs_h *g, void *data, XDR *xdr)
1540 guestfs_main_loop *ml = guestfs_get_main_loop (g);
1541 struct aug_close_ctx *ctx = (struct aug_close_ctx *) data;
1543 /* This should definitely not happen. */
1544 if (ctx->cb_sequence != 0) {
1545 ctx->cb_sequence = 9999;
1546 error (g, "%s: internal error: reply callback called twice", "guestfs_aug_close");
1550 ml->main_loop_quit (ml, g);
1552 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
1553 error (g, "%s: failed to parse reply header", "guestfs_aug_close");
1556 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
1557 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
1558 error (g, "%s: failed to parse reply error", "guestfs_aug_close");
1564 ctx->cb_sequence = 1;
1567 int guestfs_aug_close (guestfs_h *g)
1569 struct aug_close_ctx ctx;
1570 guestfs_main_loop *ml = guestfs_get_main_loop (g);
1573 if (check_state (g, "guestfs_aug_close") == -1) return -1;
1574 guestfs_set_busy (g);
1576 memset (&ctx, 0, sizeof ctx);
1578 serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_CLOSE, NULL, NULL);
1580 guestfs_set_ready (g);
1584 guestfs__switch_to_receiving (g);
1585 ctx.cb_sequence = 0;
1586 guestfs_set_reply_callback (g, aug_close_reply_cb, &ctx);
1587 (void) ml->main_loop_run (ml, g);
1588 guestfs_set_reply_callback (g, NULL, NULL);
1589 if (ctx.cb_sequence != 1) {
1590 error (g, "%s reply failed, see earlier error messages", "guestfs_aug_close");
1591 guestfs_set_ready (g);
1595 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_CLOSE, serial) == -1) {
1596 guestfs_set_ready (g);
1600 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
1601 error (g, "%s", ctx.err.error_message);
1602 guestfs_set_ready (g);
1606 guestfs_set_ready (g);
1610 struct aug_defvar_ctx {
1611 /* This flag is set by the callbacks, so we know we've done
1612 * the callbacks as expected, and in the right sequence.
1613 * 0 = not called, 1 = reply_cb called.
1616 struct guestfs_message_header hdr;
1617 struct guestfs_message_error err;
1618 struct guestfs_aug_defvar_ret ret;
1621 static void aug_defvar_reply_cb (guestfs_h *g, void *data, XDR *xdr)
1623 guestfs_main_loop *ml = guestfs_get_main_loop (g);
1624 struct aug_defvar_ctx *ctx = (struct aug_defvar_ctx *) data;
1626 /* This should definitely not happen. */
1627 if (ctx->cb_sequence != 0) {
1628 ctx->cb_sequence = 9999;
1629 error (g, "%s: internal error: reply callback called twice", "guestfs_aug_defvar");
1633 ml->main_loop_quit (ml, g);
1635 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
1636 error (g, "%s: failed to parse reply header", "guestfs_aug_defvar");
1639 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
1640 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
1641 error (g, "%s: failed to parse reply error", "guestfs_aug_defvar");
1646 if (!xdr_guestfs_aug_defvar_ret (xdr, &ctx->ret)) {
1647 error (g, "%s: failed to parse reply", "guestfs_aug_defvar");
1651 ctx->cb_sequence = 1;
1654 int guestfs_aug_defvar (guestfs_h *g,
1658 struct guestfs_aug_defvar_args args;
1659 struct aug_defvar_ctx ctx;
1660 guestfs_main_loop *ml = guestfs_get_main_loop (g);
1663 if (check_state (g, "guestfs_aug_defvar") == -1) return -1;
1664 guestfs_set_busy (g);
1666 memset (&ctx, 0, sizeof ctx);
1668 args.name = (char *) name;
1669 args.expr = expr ? (char **) &expr : NULL;
1670 serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_DEFVAR,
1671 (xdrproc_t) xdr_guestfs_aug_defvar_args, (char *) &args);
1673 guestfs_set_ready (g);
1677 guestfs__switch_to_receiving (g);
1678 ctx.cb_sequence = 0;
1679 guestfs_set_reply_callback (g, aug_defvar_reply_cb, &ctx);
1680 (void) ml->main_loop_run (ml, g);
1681 guestfs_set_reply_callback (g, NULL, NULL);
1682 if (ctx.cb_sequence != 1) {
1683 error (g, "%s reply failed, see earlier error messages", "guestfs_aug_defvar");
1684 guestfs_set_ready (g);
1688 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_DEFVAR, serial) == -1) {
1689 guestfs_set_ready (g);
1693 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
1694 error (g, "%s", ctx.err.error_message);
1695 guestfs_set_ready (g);
1699 guestfs_set_ready (g);
1700 return ctx.ret.nrnodes;
1703 struct aug_defnode_ctx {
1704 /* This flag is set by the callbacks, so we know we've done
1705 * the callbacks as expected, and in the right sequence.
1706 * 0 = not called, 1 = reply_cb called.
1709 struct guestfs_message_header hdr;
1710 struct guestfs_message_error err;
1711 struct guestfs_aug_defnode_ret ret;
1714 static void aug_defnode_reply_cb (guestfs_h *g, void *data, XDR *xdr)
1716 guestfs_main_loop *ml = guestfs_get_main_loop (g);
1717 struct aug_defnode_ctx *ctx = (struct aug_defnode_ctx *) data;
1719 /* This should definitely not happen. */
1720 if (ctx->cb_sequence != 0) {
1721 ctx->cb_sequence = 9999;
1722 error (g, "%s: internal error: reply callback called twice", "guestfs_aug_defnode");
1726 ml->main_loop_quit (ml, g);
1728 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
1729 error (g, "%s: failed to parse reply header", "guestfs_aug_defnode");
1732 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
1733 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
1734 error (g, "%s: failed to parse reply error", "guestfs_aug_defnode");
1739 if (!xdr_guestfs_aug_defnode_ret (xdr, &ctx->ret)) {
1740 error (g, "%s: failed to parse reply", "guestfs_aug_defnode");
1744 ctx->cb_sequence = 1;
1747 struct guestfs_int_bool *guestfs_aug_defnode (guestfs_h *g,
1752 struct guestfs_aug_defnode_args args;
1753 struct aug_defnode_ctx ctx;
1754 guestfs_main_loop *ml = guestfs_get_main_loop (g);
1757 if (check_state (g, "guestfs_aug_defnode") == -1) return NULL;
1758 guestfs_set_busy (g);
1760 memset (&ctx, 0, sizeof ctx);
1762 args.name = (char *) name;
1763 args.expr = (char *) expr;
1764 args.val = (char *) val;
1765 serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_DEFNODE,
1766 (xdrproc_t) xdr_guestfs_aug_defnode_args, (char *) &args);
1768 guestfs_set_ready (g);
1772 guestfs__switch_to_receiving (g);
1773 ctx.cb_sequence = 0;
1774 guestfs_set_reply_callback (g, aug_defnode_reply_cb, &ctx);
1775 (void) ml->main_loop_run (ml, g);
1776 guestfs_set_reply_callback (g, NULL, NULL);
1777 if (ctx.cb_sequence != 1) {
1778 error (g, "%s reply failed, see earlier error messages", "guestfs_aug_defnode");
1779 guestfs_set_ready (g);
1783 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_DEFNODE, serial) == -1) {
1784 guestfs_set_ready (g);
1788 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
1789 error (g, "%s", ctx.err.error_message);
1790 guestfs_set_ready (g);
1794 guestfs_set_ready (g);
1795 /* caller with free this */
1796 return safe_memdup (g, &ctx.ret, sizeof (ctx.ret));
1799 struct aug_get_ctx {
1800 /* This flag is set by the callbacks, so we know we've done
1801 * the callbacks as expected, and in the right sequence.
1802 * 0 = not called, 1 = reply_cb called.
1805 struct guestfs_message_header hdr;
1806 struct guestfs_message_error err;
1807 struct guestfs_aug_get_ret ret;
1810 static void aug_get_reply_cb (guestfs_h *g, void *data, XDR *xdr)
1812 guestfs_main_loop *ml = guestfs_get_main_loop (g);
1813 struct aug_get_ctx *ctx = (struct aug_get_ctx *) data;
1815 /* This should definitely not happen. */
1816 if (ctx->cb_sequence != 0) {
1817 ctx->cb_sequence = 9999;
1818 error (g, "%s: internal error: reply callback called twice", "guestfs_aug_get");
1822 ml->main_loop_quit (ml, g);
1824 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
1825 error (g, "%s: failed to parse reply header", "guestfs_aug_get");
1828 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
1829 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
1830 error (g, "%s: failed to parse reply error", "guestfs_aug_get");
1835 if (!xdr_guestfs_aug_get_ret (xdr, &ctx->ret)) {
1836 error (g, "%s: failed to parse reply", "guestfs_aug_get");
1840 ctx->cb_sequence = 1;
1843 char *guestfs_aug_get (guestfs_h *g,
1846 struct guestfs_aug_get_args args;
1847 struct aug_get_ctx ctx;
1848 guestfs_main_loop *ml = guestfs_get_main_loop (g);
1851 if (check_state (g, "guestfs_aug_get") == -1) return NULL;
1852 guestfs_set_busy (g);
1854 memset (&ctx, 0, sizeof ctx);
1856 args.path = (char *) path;
1857 serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_GET,
1858 (xdrproc_t) xdr_guestfs_aug_get_args, (char *) &args);
1860 guestfs_set_ready (g);
1864 guestfs__switch_to_receiving (g);
1865 ctx.cb_sequence = 0;
1866 guestfs_set_reply_callback (g, aug_get_reply_cb, &ctx);
1867 (void) ml->main_loop_run (ml, g);
1868 guestfs_set_reply_callback (g, NULL, NULL);
1869 if (ctx.cb_sequence != 1) {
1870 error (g, "%s reply failed, see earlier error messages", "guestfs_aug_get");
1871 guestfs_set_ready (g);
1875 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_GET, serial) == -1) {
1876 guestfs_set_ready (g);
1880 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
1881 error (g, "%s", ctx.err.error_message);
1882 guestfs_set_ready (g);
1886 guestfs_set_ready (g);
1887 return ctx.ret.val; /* caller will free */
1890 struct aug_set_ctx {
1891 /* This flag is set by the callbacks, so we know we've done
1892 * the callbacks as expected, and in the right sequence.
1893 * 0 = not called, 1 = reply_cb called.
1896 struct guestfs_message_header hdr;
1897 struct guestfs_message_error err;
1900 static void aug_set_reply_cb (guestfs_h *g, void *data, XDR *xdr)
1902 guestfs_main_loop *ml = guestfs_get_main_loop (g);
1903 struct aug_set_ctx *ctx = (struct aug_set_ctx *) data;
1905 /* This should definitely not happen. */
1906 if (ctx->cb_sequence != 0) {
1907 ctx->cb_sequence = 9999;
1908 error (g, "%s: internal error: reply callback called twice", "guestfs_aug_set");
1912 ml->main_loop_quit (ml, g);
1914 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
1915 error (g, "%s: failed to parse reply header", "guestfs_aug_set");
1918 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
1919 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
1920 error (g, "%s: failed to parse reply error", "guestfs_aug_set");
1926 ctx->cb_sequence = 1;
1929 int guestfs_aug_set (guestfs_h *g,
1933 struct guestfs_aug_set_args args;
1934 struct aug_set_ctx ctx;
1935 guestfs_main_loop *ml = guestfs_get_main_loop (g);
1938 if (check_state (g, "guestfs_aug_set") == -1) return -1;
1939 guestfs_set_busy (g);
1941 memset (&ctx, 0, sizeof ctx);
1943 args.path = (char *) path;
1944 args.val = (char *) val;
1945 serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_SET,
1946 (xdrproc_t) xdr_guestfs_aug_set_args, (char *) &args);
1948 guestfs_set_ready (g);
1952 guestfs__switch_to_receiving (g);
1953 ctx.cb_sequence = 0;
1954 guestfs_set_reply_callback (g, aug_set_reply_cb, &ctx);
1955 (void) ml->main_loop_run (ml, g);
1956 guestfs_set_reply_callback (g, NULL, NULL);
1957 if (ctx.cb_sequence != 1) {
1958 error (g, "%s reply failed, see earlier error messages", "guestfs_aug_set");
1959 guestfs_set_ready (g);
1963 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_SET, serial) == -1) {
1964 guestfs_set_ready (g);
1968 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
1969 error (g, "%s", ctx.err.error_message);
1970 guestfs_set_ready (g);
1974 guestfs_set_ready (g);
1978 struct aug_insert_ctx {
1979 /* This flag is set by the callbacks, so we know we've done
1980 * the callbacks as expected, and in the right sequence.
1981 * 0 = not called, 1 = reply_cb called.
1984 struct guestfs_message_header hdr;
1985 struct guestfs_message_error err;
1988 static void aug_insert_reply_cb (guestfs_h *g, void *data, XDR *xdr)
1990 guestfs_main_loop *ml = guestfs_get_main_loop (g);
1991 struct aug_insert_ctx *ctx = (struct aug_insert_ctx *) data;
1993 /* This should definitely not happen. */
1994 if (ctx->cb_sequence != 0) {
1995 ctx->cb_sequence = 9999;
1996 error (g, "%s: internal error: reply callback called twice", "guestfs_aug_insert");
2000 ml->main_loop_quit (ml, g);
2002 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
2003 error (g, "%s: failed to parse reply header", "guestfs_aug_insert");
2006 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
2007 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
2008 error (g, "%s: failed to parse reply error", "guestfs_aug_insert");
2014 ctx->cb_sequence = 1;
2017 int guestfs_aug_insert (guestfs_h *g,
2022 struct guestfs_aug_insert_args args;
2023 struct aug_insert_ctx ctx;
2024 guestfs_main_loop *ml = guestfs_get_main_loop (g);
2027 if (check_state (g, "guestfs_aug_insert") == -1) return -1;
2028 guestfs_set_busy (g);
2030 memset (&ctx, 0, sizeof ctx);
2032 args.path = (char *) path;
2033 args.label = (char *) label;
2034 args.before = before;
2035 serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_INSERT,
2036 (xdrproc_t) xdr_guestfs_aug_insert_args, (char *) &args);
2038 guestfs_set_ready (g);
2042 guestfs__switch_to_receiving (g);
2043 ctx.cb_sequence = 0;
2044 guestfs_set_reply_callback (g, aug_insert_reply_cb, &ctx);
2045 (void) ml->main_loop_run (ml, g);
2046 guestfs_set_reply_callback (g, NULL, NULL);
2047 if (ctx.cb_sequence != 1) {
2048 error (g, "%s reply failed, see earlier error messages", "guestfs_aug_insert");
2049 guestfs_set_ready (g);
2053 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_INSERT, serial) == -1) {
2054 guestfs_set_ready (g);
2058 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
2059 error (g, "%s", ctx.err.error_message);
2060 guestfs_set_ready (g);
2064 guestfs_set_ready (g);
2069 /* This flag is set by the callbacks, so we know we've done
2070 * the callbacks as expected, and in the right sequence.
2071 * 0 = not called, 1 = reply_cb called.
2074 struct guestfs_message_header hdr;
2075 struct guestfs_message_error err;
2076 struct guestfs_aug_rm_ret ret;
2079 static void aug_rm_reply_cb (guestfs_h *g, void *data, XDR *xdr)
2081 guestfs_main_loop *ml = guestfs_get_main_loop (g);
2082 struct aug_rm_ctx *ctx = (struct aug_rm_ctx *) data;
2084 /* This should definitely not happen. */
2085 if (ctx->cb_sequence != 0) {
2086 ctx->cb_sequence = 9999;
2087 error (g, "%s: internal error: reply callback called twice", "guestfs_aug_rm");
2091 ml->main_loop_quit (ml, g);
2093 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
2094 error (g, "%s: failed to parse reply header", "guestfs_aug_rm");
2097 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
2098 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
2099 error (g, "%s: failed to parse reply error", "guestfs_aug_rm");
2104 if (!xdr_guestfs_aug_rm_ret (xdr, &ctx->ret)) {
2105 error (g, "%s: failed to parse reply", "guestfs_aug_rm");
2109 ctx->cb_sequence = 1;
2112 int guestfs_aug_rm (guestfs_h *g,
2115 struct guestfs_aug_rm_args args;
2116 struct aug_rm_ctx ctx;
2117 guestfs_main_loop *ml = guestfs_get_main_loop (g);
2120 if (check_state (g, "guestfs_aug_rm") == -1) return -1;
2121 guestfs_set_busy (g);
2123 memset (&ctx, 0, sizeof ctx);
2125 args.path = (char *) path;
2126 serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_RM,
2127 (xdrproc_t) xdr_guestfs_aug_rm_args, (char *) &args);
2129 guestfs_set_ready (g);
2133 guestfs__switch_to_receiving (g);
2134 ctx.cb_sequence = 0;
2135 guestfs_set_reply_callback (g, aug_rm_reply_cb, &ctx);
2136 (void) ml->main_loop_run (ml, g);
2137 guestfs_set_reply_callback (g, NULL, NULL);
2138 if (ctx.cb_sequence != 1) {
2139 error (g, "%s reply failed, see earlier error messages", "guestfs_aug_rm");
2140 guestfs_set_ready (g);
2144 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_RM, serial) == -1) {
2145 guestfs_set_ready (g);
2149 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
2150 error (g, "%s", ctx.err.error_message);
2151 guestfs_set_ready (g);
2155 guestfs_set_ready (g);
2156 return ctx.ret.nrnodes;
2160 /* This flag is set by the callbacks, so we know we've done
2161 * the callbacks as expected, and in the right sequence.
2162 * 0 = not called, 1 = reply_cb called.
2165 struct guestfs_message_header hdr;
2166 struct guestfs_message_error err;
2169 static void aug_mv_reply_cb (guestfs_h *g, void *data, XDR *xdr)
2171 guestfs_main_loop *ml = guestfs_get_main_loop (g);
2172 struct aug_mv_ctx *ctx = (struct aug_mv_ctx *) data;
2174 /* This should definitely not happen. */
2175 if (ctx->cb_sequence != 0) {
2176 ctx->cb_sequence = 9999;
2177 error (g, "%s: internal error: reply callback called twice", "guestfs_aug_mv");
2181 ml->main_loop_quit (ml, g);
2183 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
2184 error (g, "%s: failed to parse reply header", "guestfs_aug_mv");
2187 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
2188 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
2189 error (g, "%s: failed to parse reply error", "guestfs_aug_mv");
2195 ctx->cb_sequence = 1;
2198 int guestfs_aug_mv (guestfs_h *g,
2202 struct guestfs_aug_mv_args args;
2203 struct aug_mv_ctx ctx;
2204 guestfs_main_loop *ml = guestfs_get_main_loop (g);
2207 if (check_state (g, "guestfs_aug_mv") == -1) return -1;
2208 guestfs_set_busy (g);
2210 memset (&ctx, 0, sizeof ctx);
2212 args.src = (char *) src;
2213 args.dest = (char *) dest;
2214 serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_MV,
2215 (xdrproc_t) xdr_guestfs_aug_mv_args, (char *) &args);
2217 guestfs_set_ready (g);
2221 guestfs__switch_to_receiving (g);
2222 ctx.cb_sequence = 0;
2223 guestfs_set_reply_callback (g, aug_mv_reply_cb, &ctx);
2224 (void) ml->main_loop_run (ml, g);
2225 guestfs_set_reply_callback (g, NULL, NULL);
2226 if (ctx.cb_sequence != 1) {
2227 error (g, "%s reply failed, see earlier error messages", "guestfs_aug_mv");
2228 guestfs_set_ready (g);
2232 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_MV, serial) == -1) {
2233 guestfs_set_ready (g);
2237 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
2238 error (g, "%s", ctx.err.error_message);
2239 guestfs_set_ready (g);
2243 guestfs_set_ready (g);
2247 struct aug_match_ctx {
2248 /* This flag is set by the callbacks, so we know we've done
2249 * the callbacks as expected, and in the right sequence.
2250 * 0 = not called, 1 = reply_cb called.
2253 struct guestfs_message_header hdr;
2254 struct guestfs_message_error err;
2255 struct guestfs_aug_match_ret ret;
2258 static void aug_match_reply_cb (guestfs_h *g, void *data, XDR *xdr)
2260 guestfs_main_loop *ml = guestfs_get_main_loop (g);
2261 struct aug_match_ctx *ctx = (struct aug_match_ctx *) data;
2263 /* This should definitely not happen. */
2264 if (ctx->cb_sequence != 0) {
2265 ctx->cb_sequence = 9999;
2266 error (g, "%s: internal error: reply callback called twice", "guestfs_aug_match");
2270 ml->main_loop_quit (ml, g);
2272 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
2273 error (g, "%s: failed to parse reply header", "guestfs_aug_match");
2276 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
2277 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
2278 error (g, "%s: failed to parse reply error", "guestfs_aug_match");
2283 if (!xdr_guestfs_aug_match_ret (xdr, &ctx->ret)) {
2284 error (g, "%s: failed to parse reply", "guestfs_aug_match");
2288 ctx->cb_sequence = 1;
2291 char **guestfs_aug_match (guestfs_h *g,
2294 struct guestfs_aug_match_args args;
2295 struct aug_match_ctx ctx;
2296 guestfs_main_loop *ml = guestfs_get_main_loop (g);
2299 if (check_state (g, "guestfs_aug_match") == -1) return NULL;
2300 guestfs_set_busy (g);
2302 memset (&ctx, 0, sizeof ctx);
2304 args.path = (char *) path;
2305 serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_MATCH,
2306 (xdrproc_t) xdr_guestfs_aug_match_args, (char *) &args);
2308 guestfs_set_ready (g);
2312 guestfs__switch_to_receiving (g);
2313 ctx.cb_sequence = 0;
2314 guestfs_set_reply_callback (g, aug_match_reply_cb, &ctx);
2315 (void) ml->main_loop_run (ml, g);
2316 guestfs_set_reply_callback (g, NULL, NULL);
2317 if (ctx.cb_sequence != 1) {
2318 error (g, "%s reply failed, see earlier error messages", "guestfs_aug_match");
2319 guestfs_set_ready (g);
2323 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_MATCH, serial) == -1) {
2324 guestfs_set_ready (g);
2328 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
2329 error (g, "%s", ctx.err.error_message);
2330 guestfs_set_ready (g);
2334 guestfs_set_ready (g);
2335 /* caller will free this, but we need to add a NULL entry */
2336 ctx.ret.matches.matches_val =
2337 safe_realloc (g, ctx.ret.matches.matches_val,
2338 sizeof (char *) * (ctx.ret.matches.matches_len + 1));
2339 ctx.ret.matches.matches_val[ctx.ret.matches.matches_len] = NULL;
2340 return ctx.ret.matches.matches_val;
2343 struct aug_save_ctx {
2344 /* This flag is set by the callbacks, so we know we've done
2345 * the callbacks as expected, and in the right sequence.
2346 * 0 = not called, 1 = reply_cb called.
2349 struct guestfs_message_header hdr;
2350 struct guestfs_message_error err;
2353 static void aug_save_reply_cb (guestfs_h *g, void *data, XDR *xdr)
2355 guestfs_main_loop *ml = guestfs_get_main_loop (g);
2356 struct aug_save_ctx *ctx = (struct aug_save_ctx *) data;
2358 /* This should definitely not happen. */
2359 if (ctx->cb_sequence != 0) {
2360 ctx->cb_sequence = 9999;
2361 error (g, "%s: internal error: reply callback called twice", "guestfs_aug_save");
2365 ml->main_loop_quit (ml, g);
2367 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
2368 error (g, "%s: failed to parse reply header", "guestfs_aug_save");
2371 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
2372 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
2373 error (g, "%s: failed to parse reply error", "guestfs_aug_save");
2379 ctx->cb_sequence = 1;
2382 int guestfs_aug_save (guestfs_h *g)
2384 struct aug_save_ctx ctx;
2385 guestfs_main_loop *ml = guestfs_get_main_loop (g);
2388 if (check_state (g, "guestfs_aug_save") == -1) return -1;
2389 guestfs_set_busy (g);
2391 memset (&ctx, 0, sizeof ctx);
2393 serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_SAVE, NULL, NULL);
2395 guestfs_set_ready (g);
2399 guestfs__switch_to_receiving (g);
2400 ctx.cb_sequence = 0;
2401 guestfs_set_reply_callback (g, aug_save_reply_cb, &ctx);
2402 (void) ml->main_loop_run (ml, g);
2403 guestfs_set_reply_callback (g, NULL, NULL);
2404 if (ctx.cb_sequence != 1) {
2405 error (g, "%s reply failed, see earlier error messages", "guestfs_aug_save");
2406 guestfs_set_ready (g);
2410 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_SAVE, serial) == -1) {
2411 guestfs_set_ready (g);
2415 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
2416 error (g, "%s", ctx.err.error_message);
2417 guestfs_set_ready (g);
2421 guestfs_set_ready (g);
2425 struct aug_load_ctx {
2426 /* This flag is set by the callbacks, so we know we've done
2427 * the callbacks as expected, and in the right sequence.
2428 * 0 = not called, 1 = reply_cb called.
2431 struct guestfs_message_header hdr;
2432 struct guestfs_message_error err;
2435 static void aug_load_reply_cb (guestfs_h *g, void *data, XDR *xdr)
2437 guestfs_main_loop *ml = guestfs_get_main_loop (g);
2438 struct aug_load_ctx *ctx = (struct aug_load_ctx *) data;
2440 /* This should definitely not happen. */
2441 if (ctx->cb_sequence != 0) {
2442 ctx->cb_sequence = 9999;
2443 error (g, "%s: internal error: reply callback called twice", "guestfs_aug_load");
2447 ml->main_loop_quit (ml, g);
2449 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
2450 error (g, "%s: failed to parse reply header", "guestfs_aug_load");
2453 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
2454 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
2455 error (g, "%s: failed to parse reply error", "guestfs_aug_load");
2461 ctx->cb_sequence = 1;
2464 int guestfs_aug_load (guestfs_h *g)
2466 struct aug_load_ctx ctx;
2467 guestfs_main_loop *ml = guestfs_get_main_loop (g);
2470 if (check_state (g, "guestfs_aug_load") == -1) return -1;
2471 guestfs_set_busy (g);
2473 memset (&ctx, 0, sizeof ctx);
2475 serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_LOAD, NULL, NULL);
2477 guestfs_set_ready (g);
2481 guestfs__switch_to_receiving (g);
2482 ctx.cb_sequence = 0;
2483 guestfs_set_reply_callback (g, aug_load_reply_cb, &ctx);
2484 (void) ml->main_loop_run (ml, g);
2485 guestfs_set_reply_callback (g, NULL, NULL);
2486 if (ctx.cb_sequence != 1) {
2487 error (g, "%s reply failed, see earlier error messages", "guestfs_aug_load");
2488 guestfs_set_ready (g);
2492 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_LOAD, serial) == -1) {
2493 guestfs_set_ready (g);
2497 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
2498 error (g, "%s", ctx.err.error_message);
2499 guestfs_set_ready (g);
2503 guestfs_set_ready (g);
2508 /* This flag is set by the callbacks, so we know we've done
2509 * the callbacks as expected, and in the right sequence.
2510 * 0 = not called, 1 = reply_cb called.
2513 struct guestfs_message_header hdr;
2514 struct guestfs_message_error err;
2515 struct guestfs_aug_ls_ret ret;
2518 static void aug_ls_reply_cb (guestfs_h *g, void *data, XDR *xdr)
2520 guestfs_main_loop *ml = guestfs_get_main_loop (g);
2521 struct aug_ls_ctx *ctx = (struct aug_ls_ctx *) data;
2523 /* This should definitely not happen. */
2524 if (ctx->cb_sequence != 0) {
2525 ctx->cb_sequence = 9999;
2526 error (g, "%s: internal error: reply callback called twice", "guestfs_aug_ls");
2530 ml->main_loop_quit (ml, g);
2532 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
2533 error (g, "%s: failed to parse reply header", "guestfs_aug_ls");
2536 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
2537 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
2538 error (g, "%s: failed to parse reply error", "guestfs_aug_ls");
2543 if (!xdr_guestfs_aug_ls_ret (xdr, &ctx->ret)) {
2544 error (g, "%s: failed to parse reply", "guestfs_aug_ls");
2548 ctx->cb_sequence = 1;
2551 char **guestfs_aug_ls (guestfs_h *g,
2554 struct guestfs_aug_ls_args args;
2555 struct aug_ls_ctx ctx;
2556 guestfs_main_loop *ml = guestfs_get_main_loop (g);
2559 if (check_state (g, "guestfs_aug_ls") == -1) return NULL;
2560 guestfs_set_busy (g);
2562 memset (&ctx, 0, sizeof ctx);
2564 args.path = (char *) path;
2565 serial = guestfs__send_sync (g, GUESTFS_PROC_AUG_LS,
2566 (xdrproc_t) xdr_guestfs_aug_ls_args, (char *) &args);
2568 guestfs_set_ready (g);
2572 guestfs__switch_to_receiving (g);
2573 ctx.cb_sequence = 0;
2574 guestfs_set_reply_callback (g, aug_ls_reply_cb, &ctx);
2575 (void) ml->main_loop_run (ml, g);
2576 guestfs_set_reply_callback (g, NULL, NULL);
2577 if (ctx.cb_sequence != 1) {
2578 error (g, "%s reply failed, see earlier error messages", "guestfs_aug_ls");
2579 guestfs_set_ready (g);
2583 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_AUG_LS, serial) == -1) {
2584 guestfs_set_ready (g);
2588 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
2589 error (g, "%s", ctx.err.error_message);
2590 guestfs_set_ready (g);
2594 guestfs_set_ready (g);
2595 /* caller will free this, but we need to add a NULL entry */
2596 ctx.ret.matches.matches_val =
2597 safe_realloc (g, ctx.ret.matches.matches_val,
2598 sizeof (char *) * (ctx.ret.matches.matches_len + 1));
2599 ctx.ret.matches.matches_val[ctx.ret.matches.matches_len] = NULL;
2600 return ctx.ret.matches.matches_val;
2604 /* This flag is set by the callbacks, so we know we've done
2605 * the callbacks as expected, and in the right sequence.
2606 * 0 = not called, 1 = reply_cb called.
2609 struct guestfs_message_header hdr;
2610 struct guestfs_message_error err;
2613 static void rm_reply_cb (guestfs_h *g, void *data, XDR *xdr)
2615 guestfs_main_loop *ml = guestfs_get_main_loop (g);
2616 struct rm_ctx *ctx = (struct rm_ctx *) data;
2618 /* This should definitely not happen. */
2619 if (ctx->cb_sequence != 0) {
2620 ctx->cb_sequence = 9999;
2621 error (g, "%s: internal error: reply callback called twice", "guestfs_rm");
2625 ml->main_loop_quit (ml, g);
2627 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
2628 error (g, "%s: failed to parse reply header", "guestfs_rm");
2631 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
2632 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
2633 error (g, "%s: failed to parse reply error", "guestfs_rm");
2639 ctx->cb_sequence = 1;
2642 int guestfs_rm (guestfs_h *g,
2645 struct guestfs_rm_args args;
2647 guestfs_main_loop *ml = guestfs_get_main_loop (g);
2650 if (check_state (g, "guestfs_rm") == -1) return -1;
2651 guestfs_set_busy (g);
2653 memset (&ctx, 0, sizeof ctx);
2655 args.path = (char *) path;
2656 serial = guestfs__send_sync (g, GUESTFS_PROC_RM,
2657 (xdrproc_t) xdr_guestfs_rm_args, (char *) &args);
2659 guestfs_set_ready (g);
2663 guestfs__switch_to_receiving (g);
2664 ctx.cb_sequence = 0;
2665 guestfs_set_reply_callback (g, rm_reply_cb, &ctx);
2666 (void) ml->main_loop_run (ml, g);
2667 guestfs_set_reply_callback (g, NULL, NULL);
2668 if (ctx.cb_sequence != 1) {
2669 error (g, "%s reply failed, see earlier error messages", "guestfs_rm");
2670 guestfs_set_ready (g);
2674 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_RM, serial) == -1) {
2675 guestfs_set_ready (g);
2679 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
2680 error (g, "%s", ctx.err.error_message);
2681 guestfs_set_ready (g);
2685 guestfs_set_ready (g);
2690 /* This flag is set by the callbacks, so we know we've done
2691 * the callbacks as expected, and in the right sequence.
2692 * 0 = not called, 1 = reply_cb called.
2695 struct guestfs_message_header hdr;
2696 struct guestfs_message_error err;
2699 static void rmdir_reply_cb (guestfs_h *g, void *data, XDR *xdr)
2701 guestfs_main_loop *ml = guestfs_get_main_loop (g);
2702 struct rmdir_ctx *ctx = (struct rmdir_ctx *) data;
2704 /* This should definitely not happen. */
2705 if (ctx->cb_sequence != 0) {
2706 ctx->cb_sequence = 9999;
2707 error (g, "%s: internal error: reply callback called twice", "guestfs_rmdir");
2711 ml->main_loop_quit (ml, g);
2713 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
2714 error (g, "%s: failed to parse reply header", "guestfs_rmdir");
2717 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
2718 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
2719 error (g, "%s: failed to parse reply error", "guestfs_rmdir");
2725 ctx->cb_sequence = 1;
2728 int guestfs_rmdir (guestfs_h *g,
2731 struct guestfs_rmdir_args args;
2732 struct rmdir_ctx ctx;
2733 guestfs_main_loop *ml = guestfs_get_main_loop (g);
2736 if (check_state (g, "guestfs_rmdir") == -1) return -1;
2737 guestfs_set_busy (g);
2739 memset (&ctx, 0, sizeof ctx);
2741 args.path = (char *) path;
2742 serial = guestfs__send_sync (g, GUESTFS_PROC_RMDIR,
2743 (xdrproc_t) xdr_guestfs_rmdir_args, (char *) &args);
2745 guestfs_set_ready (g);
2749 guestfs__switch_to_receiving (g);
2750 ctx.cb_sequence = 0;
2751 guestfs_set_reply_callback (g, rmdir_reply_cb, &ctx);
2752 (void) ml->main_loop_run (ml, g);
2753 guestfs_set_reply_callback (g, NULL, NULL);
2754 if (ctx.cb_sequence != 1) {
2755 error (g, "%s reply failed, see earlier error messages", "guestfs_rmdir");
2756 guestfs_set_ready (g);
2760 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_RMDIR, serial) == -1) {
2761 guestfs_set_ready (g);
2765 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
2766 error (g, "%s", ctx.err.error_message);
2767 guestfs_set_ready (g);
2771 guestfs_set_ready (g);
2776 /* This flag is set by the callbacks, so we know we've done
2777 * the callbacks as expected, and in the right sequence.
2778 * 0 = not called, 1 = reply_cb called.
2781 struct guestfs_message_header hdr;
2782 struct guestfs_message_error err;
2785 static void rm_rf_reply_cb (guestfs_h *g, void *data, XDR *xdr)
2787 guestfs_main_loop *ml = guestfs_get_main_loop (g);
2788 struct rm_rf_ctx *ctx = (struct rm_rf_ctx *) data;
2790 /* This should definitely not happen. */
2791 if (ctx->cb_sequence != 0) {
2792 ctx->cb_sequence = 9999;
2793 error (g, "%s: internal error: reply callback called twice", "guestfs_rm_rf");
2797 ml->main_loop_quit (ml, g);
2799 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
2800 error (g, "%s: failed to parse reply header", "guestfs_rm_rf");
2803 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
2804 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
2805 error (g, "%s: failed to parse reply error", "guestfs_rm_rf");
2811 ctx->cb_sequence = 1;
2814 int guestfs_rm_rf (guestfs_h *g,
2817 struct guestfs_rm_rf_args args;
2818 struct rm_rf_ctx ctx;
2819 guestfs_main_loop *ml = guestfs_get_main_loop (g);
2822 if (check_state (g, "guestfs_rm_rf") == -1) return -1;
2823 guestfs_set_busy (g);
2825 memset (&ctx, 0, sizeof ctx);
2827 args.path = (char *) path;
2828 serial = guestfs__send_sync (g, GUESTFS_PROC_RM_RF,
2829 (xdrproc_t) xdr_guestfs_rm_rf_args, (char *) &args);
2831 guestfs_set_ready (g);
2835 guestfs__switch_to_receiving (g);
2836 ctx.cb_sequence = 0;
2837 guestfs_set_reply_callback (g, rm_rf_reply_cb, &ctx);
2838 (void) ml->main_loop_run (ml, g);
2839 guestfs_set_reply_callback (g, NULL, NULL);
2840 if (ctx.cb_sequence != 1) {
2841 error (g, "%s reply failed, see earlier error messages", "guestfs_rm_rf");
2842 guestfs_set_ready (g);
2846 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_RM_RF, serial) == -1) {
2847 guestfs_set_ready (g);
2851 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
2852 error (g, "%s", ctx.err.error_message);
2853 guestfs_set_ready (g);
2857 guestfs_set_ready (g);
2862 /* This flag is set by the callbacks, so we know we've done
2863 * the callbacks as expected, and in the right sequence.
2864 * 0 = not called, 1 = reply_cb called.
2867 struct guestfs_message_header hdr;
2868 struct guestfs_message_error err;
2871 static void mkdir_reply_cb (guestfs_h *g, void *data, XDR *xdr)
2873 guestfs_main_loop *ml = guestfs_get_main_loop (g);
2874 struct mkdir_ctx *ctx = (struct mkdir_ctx *) data;
2876 /* This should definitely not happen. */
2877 if (ctx->cb_sequence != 0) {
2878 ctx->cb_sequence = 9999;
2879 error (g, "%s: internal error: reply callback called twice", "guestfs_mkdir");
2883 ml->main_loop_quit (ml, g);
2885 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
2886 error (g, "%s: failed to parse reply header", "guestfs_mkdir");
2889 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
2890 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
2891 error (g, "%s: failed to parse reply error", "guestfs_mkdir");
2897 ctx->cb_sequence = 1;
2900 int guestfs_mkdir (guestfs_h *g,
2903 struct guestfs_mkdir_args args;
2904 struct mkdir_ctx ctx;
2905 guestfs_main_loop *ml = guestfs_get_main_loop (g);
2908 if (check_state (g, "guestfs_mkdir") == -1) return -1;
2909 guestfs_set_busy (g);
2911 memset (&ctx, 0, sizeof ctx);
2913 args.path = (char *) path;
2914 serial = guestfs__send_sync (g, GUESTFS_PROC_MKDIR,
2915 (xdrproc_t) xdr_guestfs_mkdir_args, (char *) &args);
2917 guestfs_set_ready (g);
2921 guestfs__switch_to_receiving (g);
2922 ctx.cb_sequence = 0;
2923 guestfs_set_reply_callback (g, mkdir_reply_cb, &ctx);
2924 (void) ml->main_loop_run (ml, g);
2925 guestfs_set_reply_callback (g, NULL, NULL);
2926 if (ctx.cb_sequence != 1) {
2927 error (g, "%s reply failed, see earlier error messages", "guestfs_mkdir");
2928 guestfs_set_ready (g);
2932 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MKDIR, serial) == -1) {
2933 guestfs_set_ready (g);
2937 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
2938 error (g, "%s", ctx.err.error_message);
2939 guestfs_set_ready (g);
2943 guestfs_set_ready (g);
2947 struct mkdir_p_ctx {
2948 /* This flag is set by the callbacks, so we know we've done
2949 * the callbacks as expected, and in the right sequence.
2950 * 0 = not called, 1 = reply_cb called.
2953 struct guestfs_message_header hdr;
2954 struct guestfs_message_error err;
2957 static void mkdir_p_reply_cb (guestfs_h *g, void *data, XDR *xdr)
2959 guestfs_main_loop *ml = guestfs_get_main_loop (g);
2960 struct mkdir_p_ctx *ctx = (struct mkdir_p_ctx *) data;
2962 /* This should definitely not happen. */
2963 if (ctx->cb_sequence != 0) {
2964 ctx->cb_sequence = 9999;
2965 error (g, "%s: internal error: reply callback called twice", "guestfs_mkdir_p");
2969 ml->main_loop_quit (ml, g);
2971 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
2972 error (g, "%s: failed to parse reply header", "guestfs_mkdir_p");
2975 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
2976 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
2977 error (g, "%s: failed to parse reply error", "guestfs_mkdir_p");
2983 ctx->cb_sequence = 1;
2986 int guestfs_mkdir_p (guestfs_h *g,
2989 struct guestfs_mkdir_p_args args;
2990 struct mkdir_p_ctx ctx;
2991 guestfs_main_loop *ml = guestfs_get_main_loop (g);
2994 if (check_state (g, "guestfs_mkdir_p") == -1) return -1;
2995 guestfs_set_busy (g);
2997 memset (&ctx, 0, sizeof ctx);
2999 args.path = (char *) path;
3000 serial = guestfs__send_sync (g, GUESTFS_PROC_MKDIR_P,
3001 (xdrproc_t) xdr_guestfs_mkdir_p_args, (char *) &args);
3003 guestfs_set_ready (g);
3007 guestfs__switch_to_receiving (g);
3008 ctx.cb_sequence = 0;
3009 guestfs_set_reply_callback (g, mkdir_p_reply_cb, &ctx);
3010 (void) ml->main_loop_run (ml, g);
3011 guestfs_set_reply_callback (g, NULL, NULL);
3012 if (ctx.cb_sequence != 1) {
3013 error (g, "%s reply failed, see earlier error messages", "guestfs_mkdir_p");
3014 guestfs_set_ready (g);
3018 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MKDIR_P, serial) == -1) {
3019 guestfs_set_ready (g);
3023 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
3024 error (g, "%s", ctx.err.error_message);
3025 guestfs_set_ready (g);
3029 guestfs_set_ready (g);
3034 /* This flag is set by the callbacks, so we know we've done
3035 * the callbacks as expected, and in the right sequence.
3036 * 0 = not called, 1 = reply_cb called.
3039 struct guestfs_message_header hdr;
3040 struct guestfs_message_error err;
3043 static void chmod_reply_cb (guestfs_h *g, void *data, XDR *xdr)
3045 guestfs_main_loop *ml = guestfs_get_main_loop (g);
3046 struct chmod_ctx *ctx = (struct chmod_ctx *) data;
3048 /* This should definitely not happen. */
3049 if (ctx->cb_sequence != 0) {
3050 ctx->cb_sequence = 9999;
3051 error (g, "%s: internal error: reply callback called twice", "guestfs_chmod");
3055 ml->main_loop_quit (ml, g);
3057 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
3058 error (g, "%s: failed to parse reply header", "guestfs_chmod");
3061 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
3062 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
3063 error (g, "%s: failed to parse reply error", "guestfs_chmod");
3069 ctx->cb_sequence = 1;
3072 int guestfs_chmod (guestfs_h *g,
3076 struct guestfs_chmod_args args;
3077 struct chmod_ctx ctx;
3078 guestfs_main_loop *ml = guestfs_get_main_loop (g);
3081 if (check_state (g, "guestfs_chmod") == -1) return -1;
3082 guestfs_set_busy (g);
3084 memset (&ctx, 0, sizeof ctx);
3087 args.path = (char *) path;
3088 serial = guestfs__send_sync (g, GUESTFS_PROC_CHMOD,
3089 (xdrproc_t) xdr_guestfs_chmod_args, (char *) &args);
3091 guestfs_set_ready (g);
3095 guestfs__switch_to_receiving (g);
3096 ctx.cb_sequence = 0;
3097 guestfs_set_reply_callback (g, chmod_reply_cb, &ctx);
3098 (void) ml->main_loop_run (ml, g);
3099 guestfs_set_reply_callback (g, NULL, NULL);
3100 if (ctx.cb_sequence != 1) {
3101 error (g, "%s reply failed, see earlier error messages", "guestfs_chmod");
3102 guestfs_set_ready (g);
3106 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_CHMOD, serial) == -1) {
3107 guestfs_set_ready (g);
3111 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
3112 error (g, "%s", ctx.err.error_message);
3113 guestfs_set_ready (g);
3117 guestfs_set_ready (g);
3122 /* This flag is set by the callbacks, so we know we've done
3123 * the callbacks as expected, and in the right sequence.
3124 * 0 = not called, 1 = reply_cb called.
3127 struct guestfs_message_header hdr;
3128 struct guestfs_message_error err;
3131 static void chown_reply_cb (guestfs_h *g, void *data, XDR *xdr)
3133 guestfs_main_loop *ml = guestfs_get_main_loop (g);
3134 struct chown_ctx *ctx = (struct chown_ctx *) data;
3136 /* This should definitely not happen. */
3137 if (ctx->cb_sequence != 0) {
3138 ctx->cb_sequence = 9999;
3139 error (g, "%s: internal error: reply callback called twice", "guestfs_chown");
3143 ml->main_loop_quit (ml, g);
3145 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
3146 error (g, "%s: failed to parse reply header", "guestfs_chown");
3149 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
3150 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
3151 error (g, "%s: failed to parse reply error", "guestfs_chown");
3157 ctx->cb_sequence = 1;
3160 int guestfs_chown (guestfs_h *g,
3165 struct guestfs_chown_args args;
3166 struct chown_ctx ctx;
3167 guestfs_main_loop *ml = guestfs_get_main_loop (g);
3170 if (check_state (g, "guestfs_chown") == -1) return -1;
3171 guestfs_set_busy (g);
3173 memset (&ctx, 0, sizeof ctx);
3177 args.path = (char *) path;
3178 serial = guestfs__send_sync (g, GUESTFS_PROC_CHOWN,
3179 (xdrproc_t) xdr_guestfs_chown_args, (char *) &args);
3181 guestfs_set_ready (g);
3185 guestfs__switch_to_receiving (g);
3186 ctx.cb_sequence = 0;
3187 guestfs_set_reply_callback (g, chown_reply_cb, &ctx);
3188 (void) ml->main_loop_run (ml, g);
3189 guestfs_set_reply_callback (g, NULL, NULL);
3190 if (ctx.cb_sequence != 1) {
3191 error (g, "%s reply failed, see earlier error messages", "guestfs_chown");
3192 guestfs_set_ready (g);
3196 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_CHOWN, serial) == -1) {
3197 guestfs_set_ready (g);
3201 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
3202 error (g, "%s", ctx.err.error_message);
3203 guestfs_set_ready (g);
3207 guestfs_set_ready (g);
3212 /* This flag is set by the callbacks, so we know we've done
3213 * the callbacks as expected, and in the right sequence.
3214 * 0 = not called, 1 = reply_cb called.
3217 struct guestfs_message_header hdr;
3218 struct guestfs_message_error err;
3219 struct guestfs_exists_ret ret;
3222 static void exists_reply_cb (guestfs_h *g, void *data, XDR *xdr)
3224 guestfs_main_loop *ml = guestfs_get_main_loop (g);
3225 struct exists_ctx *ctx = (struct exists_ctx *) data;
3227 /* This should definitely not happen. */
3228 if (ctx->cb_sequence != 0) {
3229 ctx->cb_sequence = 9999;
3230 error (g, "%s: internal error: reply callback called twice", "guestfs_exists");
3234 ml->main_loop_quit (ml, g);
3236 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
3237 error (g, "%s: failed to parse reply header", "guestfs_exists");
3240 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
3241 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
3242 error (g, "%s: failed to parse reply error", "guestfs_exists");
3247 if (!xdr_guestfs_exists_ret (xdr, &ctx->ret)) {
3248 error (g, "%s: failed to parse reply", "guestfs_exists");
3252 ctx->cb_sequence = 1;
3255 int guestfs_exists (guestfs_h *g,
3258 struct guestfs_exists_args args;
3259 struct exists_ctx ctx;
3260 guestfs_main_loop *ml = guestfs_get_main_loop (g);
3263 if (check_state (g, "guestfs_exists") == -1) return -1;
3264 guestfs_set_busy (g);
3266 memset (&ctx, 0, sizeof ctx);
3268 args.path = (char *) path;
3269 serial = guestfs__send_sync (g, GUESTFS_PROC_EXISTS,
3270 (xdrproc_t) xdr_guestfs_exists_args, (char *) &args);
3272 guestfs_set_ready (g);
3276 guestfs__switch_to_receiving (g);
3277 ctx.cb_sequence = 0;
3278 guestfs_set_reply_callback (g, exists_reply_cb, &ctx);
3279 (void) ml->main_loop_run (ml, g);
3280 guestfs_set_reply_callback (g, NULL, NULL);
3281 if (ctx.cb_sequence != 1) {
3282 error (g, "%s reply failed, see earlier error messages", "guestfs_exists");
3283 guestfs_set_ready (g);
3287 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_EXISTS, serial) == -1) {
3288 guestfs_set_ready (g);
3292 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
3293 error (g, "%s", ctx.err.error_message);
3294 guestfs_set_ready (g);
3298 guestfs_set_ready (g);
3299 return ctx.ret.existsflag;
3302 struct is_file_ctx {
3303 /* This flag is set by the callbacks, so we know we've done
3304 * the callbacks as expected, and in the right sequence.
3305 * 0 = not called, 1 = reply_cb called.
3308 struct guestfs_message_header hdr;
3309 struct guestfs_message_error err;
3310 struct guestfs_is_file_ret ret;
3313 static void is_file_reply_cb (guestfs_h *g, void *data, XDR *xdr)
3315 guestfs_main_loop *ml = guestfs_get_main_loop (g);
3316 struct is_file_ctx *ctx = (struct is_file_ctx *) data;
3318 /* This should definitely not happen. */
3319 if (ctx->cb_sequence != 0) {
3320 ctx->cb_sequence = 9999;
3321 error (g, "%s: internal error: reply callback called twice", "guestfs_is_file");
3325 ml->main_loop_quit (ml, g);
3327 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
3328 error (g, "%s: failed to parse reply header", "guestfs_is_file");
3331 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
3332 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
3333 error (g, "%s: failed to parse reply error", "guestfs_is_file");
3338 if (!xdr_guestfs_is_file_ret (xdr, &ctx->ret)) {
3339 error (g, "%s: failed to parse reply", "guestfs_is_file");
3343 ctx->cb_sequence = 1;
3346 int guestfs_is_file (guestfs_h *g,
3349 struct guestfs_is_file_args args;
3350 struct is_file_ctx ctx;
3351 guestfs_main_loop *ml = guestfs_get_main_loop (g);
3354 if (check_state (g, "guestfs_is_file") == -1) return -1;
3355 guestfs_set_busy (g);
3357 memset (&ctx, 0, sizeof ctx);
3359 args.path = (char *) path;
3360 serial = guestfs__send_sync (g, GUESTFS_PROC_IS_FILE,
3361 (xdrproc_t) xdr_guestfs_is_file_args, (char *) &args);
3363 guestfs_set_ready (g);
3367 guestfs__switch_to_receiving (g);
3368 ctx.cb_sequence = 0;
3369 guestfs_set_reply_callback (g, is_file_reply_cb, &ctx);
3370 (void) ml->main_loop_run (ml, g);
3371 guestfs_set_reply_callback (g, NULL, NULL);
3372 if (ctx.cb_sequence != 1) {
3373 error (g, "%s reply failed, see earlier error messages", "guestfs_is_file");
3374 guestfs_set_ready (g);
3378 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_IS_FILE, serial) == -1) {
3379 guestfs_set_ready (g);
3383 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
3384 error (g, "%s", ctx.err.error_message);
3385 guestfs_set_ready (g);
3389 guestfs_set_ready (g);
3390 return ctx.ret.fileflag;
3394 /* This flag is set by the callbacks, so we know we've done
3395 * the callbacks as expected, and in the right sequence.
3396 * 0 = not called, 1 = reply_cb called.
3399 struct guestfs_message_header hdr;
3400 struct guestfs_message_error err;
3401 struct guestfs_is_dir_ret ret;
3404 static void is_dir_reply_cb (guestfs_h *g, void *data, XDR *xdr)
3406 guestfs_main_loop *ml = guestfs_get_main_loop (g);
3407 struct is_dir_ctx *ctx = (struct is_dir_ctx *) data;
3409 /* This should definitely not happen. */
3410 if (ctx->cb_sequence != 0) {
3411 ctx->cb_sequence = 9999;
3412 error (g, "%s: internal error: reply callback called twice", "guestfs_is_dir");
3416 ml->main_loop_quit (ml, g);
3418 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
3419 error (g, "%s: failed to parse reply header", "guestfs_is_dir");
3422 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
3423 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
3424 error (g, "%s: failed to parse reply error", "guestfs_is_dir");
3429 if (!xdr_guestfs_is_dir_ret (xdr, &ctx->ret)) {
3430 error (g, "%s: failed to parse reply", "guestfs_is_dir");
3434 ctx->cb_sequence = 1;
3437 int guestfs_is_dir (guestfs_h *g,
3440 struct guestfs_is_dir_args args;
3441 struct is_dir_ctx ctx;
3442 guestfs_main_loop *ml = guestfs_get_main_loop (g);
3445 if (check_state (g, "guestfs_is_dir") == -1) return -1;
3446 guestfs_set_busy (g);
3448 memset (&ctx, 0, sizeof ctx);
3450 args.path = (char *) path;
3451 serial = guestfs__send_sync (g, GUESTFS_PROC_IS_DIR,
3452 (xdrproc_t) xdr_guestfs_is_dir_args, (char *) &args);
3454 guestfs_set_ready (g);
3458 guestfs__switch_to_receiving (g);
3459 ctx.cb_sequence = 0;
3460 guestfs_set_reply_callback (g, is_dir_reply_cb, &ctx);
3461 (void) ml->main_loop_run (ml, g);
3462 guestfs_set_reply_callback (g, NULL, NULL);
3463 if (ctx.cb_sequence != 1) {
3464 error (g, "%s reply failed, see earlier error messages", "guestfs_is_dir");
3465 guestfs_set_ready (g);
3469 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_IS_DIR, serial) == -1) {
3470 guestfs_set_ready (g);
3474 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
3475 error (g, "%s", ctx.err.error_message);
3476 guestfs_set_ready (g);
3480 guestfs_set_ready (g);
3481 return ctx.ret.dirflag;
3484 struct pvcreate_ctx {
3485 /* This flag is set by the callbacks, so we know we've done
3486 * the callbacks as expected, and in the right sequence.
3487 * 0 = not called, 1 = reply_cb called.
3490 struct guestfs_message_header hdr;
3491 struct guestfs_message_error err;
3494 static void pvcreate_reply_cb (guestfs_h *g, void *data, XDR *xdr)
3496 guestfs_main_loop *ml = guestfs_get_main_loop (g);
3497 struct pvcreate_ctx *ctx = (struct pvcreate_ctx *) data;
3499 /* This should definitely not happen. */
3500 if (ctx->cb_sequence != 0) {
3501 ctx->cb_sequence = 9999;
3502 error (g, "%s: internal error: reply callback called twice", "guestfs_pvcreate");
3506 ml->main_loop_quit (ml, g);
3508 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
3509 error (g, "%s: failed to parse reply header", "guestfs_pvcreate");
3512 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
3513 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
3514 error (g, "%s: failed to parse reply error", "guestfs_pvcreate");
3520 ctx->cb_sequence = 1;
3523 int guestfs_pvcreate (guestfs_h *g,
3526 struct guestfs_pvcreate_args args;
3527 struct pvcreate_ctx ctx;
3528 guestfs_main_loop *ml = guestfs_get_main_loop (g);
3531 if (check_state (g, "guestfs_pvcreate") == -1) return -1;
3532 guestfs_set_busy (g);
3534 memset (&ctx, 0, sizeof ctx);
3536 args.device = (char *) device;
3537 serial = guestfs__send_sync (g, GUESTFS_PROC_PVCREATE,
3538 (xdrproc_t) xdr_guestfs_pvcreate_args, (char *) &args);
3540 guestfs_set_ready (g);
3544 guestfs__switch_to_receiving (g);
3545 ctx.cb_sequence = 0;
3546 guestfs_set_reply_callback (g, pvcreate_reply_cb, &ctx);
3547 (void) ml->main_loop_run (ml, g);
3548 guestfs_set_reply_callback (g, NULL, NULL);
3549 if (ctx.cb_sequence != 1) {
3550 error (g, "%s reply failed, see earlier error messages", "guestfs_pvcreate");
3551 guestfs_set_ready (g);
3555 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_PVCREATE, serial) == -1) {
3556 guestfs_set_ready (g);
3560 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
3561 error (g, "%s", ctx.err.error_message);
3562 guestfs_set_ready (g);
3566 guestfs_set_ready (g);
3570 struct vgcreate_ctx {
3571 /* This flag is set by the callbacks, so we know we've done
3572 * the callbacks as expected, and in the right sequence.
3573 * 0 = not called, 1 = reply_cb called.
3576 struct guestfs_message_header hdr;
3577 struct guestfs_message_error err;
3580 static void vgcreate_reply_cb (guestfs_h *g, void *data, XDR *xdr)
3582 guestfs_main_loop *ml = guestfs_get_main_loop (g);
3583 struct vgcreate_ctx *ctx = (struct vgcreate_ctx *) data;
3585 /* This should definitely not happen. */
3586 if (ctx->cb_sequence != 0) {
3587 ctx->cb_sequence = 9999;
3588 error (g, "%s: internal error: reply callback called twice", "guestfs_vgcreate");
3592 ml->main_loop_quit (ml, g);
3594 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
3595 error (g, "%s: failed to parse reply header", "guestfs_vgcreate");
3598 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
3599 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
3600 error (g, "%s: failed to parse reply error", "guestfs_vgcreate");
3606 ctx->cb_sequence = 1;
3609 int guestfs_vgcreate (guestfs_h *g,
3610 const char *volgroup,
3611 char * const* const physvols)
3613 struct guestfs_vgcreate_args args;
3614 struct vgcreate_ctx ctx;
3615 guestfs_main_loop *ml = guestfs_get_main_loop (g);
3618 if (check_state (g, "guestfs_vgcreate") == -1) return -1;
3619 guestfs_set_busy (g);
3621 memset (&ctx, 0, sizeof ctx);
3623 args.volgroup = (char *) volgroup;
3624 args.physvols.physvols_val = (char **) physvols;
3625 for (args.physvols.physvols_len = 0; physvols[args.physvols.physvols_len]; args.physvols.physvols_len++) ;
3626 serial = guestfs__send_sync (g, GUESTFS_PROC_VGCREATE,
3627 (xdrproc_t) xdr_guestfs_vgcreate_args, (char *) &args);
3629 guestfs_set_ready (g);
3633 guestfs__switch_to_receiving (g);
3634 ctx.cb_sequence = 0;
3635 guestfs_set_reply_callback (g, vgcreate_reply_cb, &ctx);
3636 (void) ml->main_loop_run (ml, g);
3637 guestfs_set_reply_callback (g, NULL, NULL);
3638 if (ctx.cb_sequence != 1) {
3639 error (g, "%s reply failed, see earlier error messages", "guestfs_vgcreate");
3640 guestfs_set_ready (g);
3644 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_VGCREATE, serial) == -1) {
3645 guestfs_set_ready (g);
3649 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
3650 error (g, "%s", ctx.err.error_message);
3651 guestfs_set_ready (g);
3655 guestfs_set_ready (g);
3659 struct lvcreate_ctx {
3660 /* This flag is set by the callbacks, so we know we've done
3661 * the callbacks as expected, and in the right sequence.
3662 * 0 = not called, 1 = reply_cb called.
3665 struct guestfs_message_header hdr;
3666 struct guestfs_message_error err;
3669 static void lvcreate_reply_cb (guestfs_h *g, void *data, XDR *xdr)
3671 guestfs_main_loop *ml = guestfs_get_main_loop (g);
3672 struct lvcreate_ctx *ctx = (struct lvcreate_ctx *) data;
3674 /* This should definitely not happen. */
3675 if (ctx->cb_sequence != 0) {
3676 ctx->cb_sequence = 9999;
3677 error (g, "%s: internal error: reply callback called twice", "guestfs_lvcreate");
3681 ml->main_loop_quit (ml, g);
3683 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
3684 error (g, "%s: failed to parse reply header", "guestfs_lvcreate");
3687 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
3688 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
3689 error (g, "%s: failed to parse reply error", "guestfs_lvcreate");
3695 ctx->cb_sequence = 1;
3698 int guestfs_lvcreate (guestfs_h *g,
3700 const char *volgroup,
3703 struct guestfs_lvcreate_args args;
3704 struct lvcreate_ctx ctx;
3705 guestfs_main_loop *ml = guestfs_get_main_loop (g);
3708 if (check_state (g, "guestfs_lvcreate") == -1) return -1;
3709 guestfs_set_busy (g);
3711 memset (&ctx, 0, sizeof ctx);
3713 args.logvol = (char *) logvol;
3714 args.volgroup = (char *) volgroup;
3715 args.mbytes = mbytes;
3716 serial = guestfs__send_sync (g, GUESTFS_PROC_LVCREATE,
3717 (xdrproc_t) xdr_guestfs_lvcreate_args, (char *) &args);
3719 guestfs_set_ready (g);
3723 guestfs__switch_to_receiving (g);
3724 ctx.cb_sequence = 0;
3725 guestfs_set_reply_callback (g, lvcreate_reply_cb, &ctx);
3726 (void) ml->main_loop_run (ml, g);
3727 guestfs_set_reply_callback (g, NULL, NULL);
3728 if (ctx.cb_sequence != 1) {
3729 error (g, "%s reply failed, see earlier error messages", "guestfs_lvcreate");
3730 guestfs_set_ready (g);
3734 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_LVCREATE, serial) == -1) {
3735 guestfs_set_ready (g);
3739 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
3740 error (g, "%s", ctx.err.error_message);
3741 guestfs_set_ready (g);
3745 guestfs_set_ready (g);
3750 /* This flag is set by the callbacks, so we know we've done
3751 * the callbacks as expected, and in the right sequence.
3752 * 0 = not called, 1 = reply_cb called.
3755 struct guestfs_message_header hdr;
3756 struct guestfs_message_error err;
3759 static void mkfs_reply_cb (guestfs_h *g, void *data, XDR *xdr)
3761 guestfs_main_loop *ml = guestfs_get_main_loop (g);
3762 struct mkfs_ctx *ctx = (struct mkfs_ctx *) data;
3764 /* This should definitely not happen. */
3765 if (ctx->cb_sequence != 0) {
3766 ctx->cb_sequence = 9999;
3767 error (g, "%s: internal error: reply callback called twice", "guestfs_mkfs");
3771 ml->main_loop_quit (ml, g);
3773 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
3774 error (g, "%s: failed to parse reply header", "guestfs_mkfs");
3777 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
3778 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
3779 error (g, "%s: failed to parse reply error", "guestfs_mkfs");
3785 ctx->cb_sequence = 1;
3788 int guestfs_mkfs (guestfs_h *g,
3792 struct guestfs_mkfs_args args;
3793 struct mkfs_ctx ctx;
3794 guestfs_main_loop *ml = guestfs_get_main_loop (g);
3797 if (check_state (g, "guestfs_mkfs") == -1) return -1;
3798 guestfs_set_busy (g);
3800 memset (&ctx, 0, sizeof ctx);
3802 args.fstype = (char *) fstype;
3803 args.device = (char *) device;
3804 serial = guestfs__send_sync (g, GUESTFS_PROC_MKFS,
3805 (xdrproc_t) xdr_guestfs_mkfs_args, (char *) &args);
3807 guestfs_set_ready (g);
3811 guestfs__switch_to_receiving (g);
3812 ctx.cb_sequence = 0;
3813 guestfs_set_reply_callback (g, mkfs_reply_cb, &ctx);
3814 (void) ml->main_loop_run (ml, g);
3815 guestfs_set_reply_callback (g, NULL, NULL);
3816 if (ctx.cb_sequence != 1) {
3817 error (g, "%s reply failed, see earlier error messages", "guestfs_mkfs");
3818 guestfs_set_ready (g);
3822 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MKFS, serial) == -1) {
3823 guestfs_set_ready (g);
3827 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
3828 error (g, "%s", ctx.err.error_message);
3829 guestfs_set_ready (g);
3833 guestfs_set_ready (g);
3838 /* This flag is set by the callbacks, so we know we've done
3839 * the callbacks as expected, and in the right sequence.
3840 * 0 = not called, 1 = reply_cb called.
3843 struct guestfs_message_header hdr;
3844 struct guestfs_message_error err;
3847 static void sfdisk_reply_cb (guestfs_h *g, void *data, XDR *xdr)
3849 guestfs_main_loop *ml = guestfs_get_main_loop (g);
3850 struct sfdisk_ctx *ctx = (struct sfdisk_ctx *) data;
3852 /* This should definitely not happen. */
3853 if (ctx->cb_sequence != 0) {
3854 ctx->cb_sequence = 9999;
3855 error (g, "%s: internal error: reply callback called twice", "guestfs_sfdisk");
3859 ml->main_loop_quit (ml, g);
3861 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
3862 error (g, "%s: failed to parse reply header", "guestfs_sfdisk");
3865 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
3866 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
3867 error (g, "%s: failed to parse reply error", "guestfs_sfdisk");
3873 ctx->cb_sequence = 1;
3876 int guestfs_sfdisk (guestfs_h *g,
3881 char * const* const lines)
3883 struct guestfs_sfdisk_args args;
3884 struct sfdisk_ctx ctx;
3885 guestfs_main_loop *ml = guestfs_get_main_loop (g);
3888 if (check_state (g, "guestfs_sfdisk") == -1) return -1;
3889 guestfs_set_busy (g);
3891 memset (&ctx, 0, sizeof ctx);
3893 args.device = (char *) device;
3896 args.sectors = sectors;
3897 args.lines.lines_val = (char **) lines;
3898 for (args.lines.lines_len = 0; lines[args.lines.lines_len]; args.lines.lines_len++) ;
3899 serial = guestfs__send_sync (g, GUESTFS_PROC_SFDISK,
3900 (xdrproc_t) xdr_guestfs_sfdisk_args, (char *) &args);
3902 guestfs_set_ready (g);
3906 guestfs__switch_to_receiving (g);
3907 ctx.cb_sequence = 0;
3908 guestfs_set_reply_callback (g, sfdisk_reply_cb, &ctx);
3909 (void) ml->main_loop_run (ml, g);
3910 guestfs_set_reply_callback (g, NULL, NULL);
3911 if (ctx.cb_sequence != 1) {
3912 error (g, "%s reply failed, see earlier error messages", "guestfs_sfdisk");
3913 guestfs_set_ready (g);
3917 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_SFDISK, serial) == -1) {
3918 guestfs_set_ready (g);
3922 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
3923 error (g, "%s", ctx.err.error_message);
3924 guestfs_set_ready (g);
3928 guestfs_set_ready (g);
3932 struct write_file_ctx {
3933 /* This flag is set by the callbacks, so we know we've done
3934 * the callbacks as expected, and in the right sequence.
3935 * 0 = not called, 1 = reply_cb called.
3938 struct guestfs_message_header hdr;
3939 struct guestfs_message_error err;
3942 static void write_file_reply_cb (guestfs_h *g, void *data, XDR *xdr)
3944 guestfs_main_loop *ml = guestfs_get_main_loop (g);
3945 struct write_file_ctx *ctx = (struct write_file_ctx *) data;
3947 /* This should definitely not happen. */
3948 if (ctx->cb_sequence != 0) {
3949 ctx->cb_sequence = 9999;
3950 error (g, "%s: internal error: reply callback called twice", "guestfs_write_file");
3954 ml->main_loop_quit (ml, g);
3956 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
3957 error (g, "%s: failed to parse reply header", "guestfs_write_file");
3960 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
3961 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
3962 error (g, "%s: failed to parse reply error", "guestfs_write_file");
3968 ctx->cb_sequence = 1;
3971 int guestfs_write_file (guestfs_h *g,
3973 const char *content,
3976 struct guestfs_write_file_args args;
3977 struct write_file_ctx ctx;
3978 guestfs_main_loop *ml = guestfs_get_main_loop (g);
3981 if (check_state (g, "guestfs_write_file") == -1) return -1;
3982 guestfs_set_busy (g);
3984 memset (&ctx, 0, sizeof ctx);
3986 args.path = (char *) path;
3987 args.content = (char *) content;
3989 serial = guestfs__send_sync (g, GUESTFS_PROC_WRITE_FILE,
3990 (xdrproc_t) xdr_guestfs_write_file_args, (char *) &args);
3992 guestfs_set_ready (g);
3996 guestfs__switch_to_receiving (g);
3997 ctx.cb_sequence = 0;
3998 guestfs_set_reply_callback (g, write_file_reply_cb, &ctx);
3999 (void) ml->main_loop_run (ml, g);
4000 guestfs_set_reply_callback (g, NULL, NULL);
4001 if (ctx.cb_sequence != 1) {
4002 error (g, "%s reply failed, see earlier error messages", "guestfs_write_file");
4003 guestfs_set_ready (g);
4007 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_WRITE_FILE, serial) == -1) {
4008 guestfs_set_ready (g);
4012 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
4013 error (g, "%s", ctx.err.error_message);
4014 guestfs_set_ready (g);
4018 guestfs_set_ready (g);
4023 /* This flag is set by the callbacks, so we know we've done
4024 * the callbacks as expected, and in the right sequence.
4025 * 0 = not called, 1 = reply_cb called.
4028 struct guestfs_message_header hdr;
4029 struct guestfs_message_error err;
4032 static void umount_reply_cb (guestfs_h *g, void *data, XDR *xdr)
4034 guestfs_main_loop *ml = guestfs_get_main_loop (g);
4035 struct umount_ctx *ctx = (struct umount_ctx *) data;
4037 /* This should definitely not happen. */
4038 if (ctx->cb_sequence != 0) {
4039 ctx->cb_sequence = 9999;
4040 error (g, "%s: internal error: reply callback called twice", "guestfs_umount");
4044 ml->main_loop_quit (ml, g);
4046 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
4047 error (g, "%s: failed to parse reply header", "guestfs_umount");
4050 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
4051 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
4052 error (g, "%s: failed to parse reply error", "guestfs_umount");
4058 ctx->cb_sequence = 1;
4061 int guestfs_umount (guestfs_h *g,
4062 const char *pathordevice)
4064 struct guestfs_umount_args args;
4065 struct umount_ctx ctx;
4066 guestfs_main_loop *ml = guestfs_get_main_loop (g);
4069 if (check_state (g, "guestfs_umount") == -1) return -1;
4070 guestfs_set_busy (g);
4072 memset (&ctx, 0, sizeof ctx);
4074 args.pathordevice = (char *) pathordevice;
4075 serial = guestfs__send_sync (g, GUESTFS_PROC_UMOUNT,
4076 (xdrproc_t) xdr_guestfs_umount_args, (char *) &args);
4078 guestfs_set_ready (g);
4082 guestfs__switch_to_receiving (g);
4083 ctx.cb_sequence = 0;
4084 guestfs_set_reply_callback (g, umount_reply_cb, &ctx);
4085 (void) ml->main_loop_run (ml, g);
4086 guestfs_set_reply_callback (g, NULL, NULL);
4087 if (ctx.cb_sequence != 1) {
4088 error (g, "%s reply failed, see earlier error messages", "guestfs_umount");
4089 guestfs_set_ready (g);
4093 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_UMOUNT, serial) == -1) {
4094 guestfs_set_ready (g);
4098 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
4099 error (g, "%s", ctx.err.error_message);
4100 guestfs_set_ready (g);
4104 guestfs_set_ready (g);
4109 /* This flag is set by the callbacks, so we know we've done
4110 * the callbacks as expected, and in the right sequence.
4111 * 0 = not called, 1 = reply_cb called.
4114 struct guestfs_message_header hdr;
4115 struct guestfs_message_error err;
4116 struct guestfs_mounts_ret ret;
4119 static void mounts_reply_cb (guestfs_h *g, void *data, XDR *xdr)
4121 guestfs_main_loop *ml = guestfs_get_main_loop (g);
4122 struct mounts_ctx *ctx = (struct mounts_ctx *) data;
4124 /* This should definitely not happen. */
4125 if (ctx->cb_sequence != 0) {
4126 ctx->cb_sequence = 9999;
4127 error (g, "%s: internal error: reply callback called twice", "guestfs_mounts");
4131 ml->main_loop_quit (ml, g);
4133 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
4134 error (g, "%s: failed to parse reply header", "guestfs_mounts");
4137 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
4138 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
4139 error (g, "%s: failed to parse reply error", "guestfs_mounts");
4144 if (!xdr_guestfs_mounts_ret (xdr, &ctx->ret)) {
4145 error (g, "%s: failed to parse reply", "guestfs_mounts");
4149 ctx->cb_sequence = 1;
4152 char **guestfs_mounts (guestfs_h *g)
4154 struct mounts_ctx ctx;
4155 guestfs_main_loop *ml = guestfs_get_main_loop (g);
4158 if (check_state (g, "guestfs_mounts") == -1) return NULL;
4159 guestfs_set_busy (g);
4161 memset (&ctx, 0, sizeof ctx);
4163 serial = guestfs__send_sync (g, GUESTFS_PROC_MOUNTS, NULL, NULL);
4165 guestfs_set_ready (g);
4169 guestfs__switch_to_receiving (g);
4170 ctx.cb_sequence = 0;
4171 guestfs_set_reply_callback (g, mounts_reply_cb, &ctx);
4172 (void) ml->main_loop_run (ml, g);
4173 guestfs_set_reply_callback (g, NULL, NULL);
4174 if (ctx.cb_sequence != 1) {
4175 error (g, "%s reply failed, see earlier error messages", "guestfs_mounts");
4176 guestfs_set_ready (g);
4180 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MOUNTS, serial) == -1) {
4181 guestfs_set_ready (g);
4185 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
4186 error (g, "%s", ctx.err.error_message);
4187 guestfs_set_ready (g);
4191 guestfs_set_ready (g);
4192 /* caller will free this, but we need to add a NULL entry */
4193 ctx.ret.devices.devices_val =
4194 safe_realloc (g, ctx.ret.devices.devices_val,
4195 sizeof (char *) * (ctx.ret.devices.devices_len + 1));
4196 ctx.ret.devices.devices_val[ctx.ret.devices.devices_len] = NULL;
4197 return ctx.ret.devices.devices_val;
4200 struct umount_all_ctx {
4201 /* This flag is set by the callbacks, so we know we've done
4202 * the callbacks as expected, and in the right sequence.
4203 * 0 = not called, 1 = reply_cb called.
4206 struct guestfs_message_header hdr;
4207 struct guestfs_message_error err;
4210 static void umount_all_reply_cb (guestfs_h *g, void *data, XDR *xdr)
4212 guestfs_main_loop *ml = guestfs_get_main_loop (g);
4213 struct umount_all_ctx *ctx = (struct umount_all_ctx *) data;
4215 /* This should definitely not happen. */
4216 if (ctx->cb_sequence != 0) {
4217 ctx->cb_sequence = 9999;
4218 error (g, "%s: internal error: reply callback called twice", "guestfs_umount_all");
4222 ml->main_loop_quit (ml, g);
4224 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
4225 error (g, "%s: failed to parse reply header", "guestfs_umount_all");
4228 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
4229 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
4230 error (g, "%s: failed to parse reply error", "guestfs_umount_all");
4236 ctx->cb_sequence = 1;
4239 int guestfs_umount_all (guestfs_h *g)
4241 struct umount_all_ctx ctx;
4242 guestfs_main_loop *ml = guestfs_get_main_loop (g);
4245 if (check_state (g, "guestfs_umount_all") == -1) return -1;
4246 guestfs_set_busy (g);
4248 memset (&ctx, 0, sizeof ctx);
4250 serial = guestfs__send_sync (g, GUESTFS_PROC_UMOUNT_ALL, NULL, NULL);
4252 guestfs_set_ready (g);
4256 guestfs__switch_to_receiving (g);
4257 ctx.cb_sequence = 0;
4258 guestfs_set_reply_callback (g, umount_all_reply_cb, &ctx);
4259 (void) ml->main_loop_run (ml, g);
4260 guestfs_set_reply_callback (g, NULL, NULL);
4261 if (ctx.cb_sequence != 1) {
4262 error (g, "%s reply failed, see earlier error messages", "guestfs_umount_all");
4263 guestfs_set_ready (g);
4267 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_UMOUNT_ALL, serial) == -1) {
4268 guestfs_set_ready (g);
4272 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
4273 error (g, "%s", ctx.err.error_message);
4274 guestfs_set_ready (g);
4278 guestfs_set_ready (g);
4282 struct lvm_remove_all_ctx {
4283 /* This flag is set by the callbacks, so we know we've done
4284 * the callbacks as expected, and in the right sequence.
4285 * 0 = not called, 1 = reply_cb called.
4288 struct guestfs_message_header hdr;
4289 struct guestfs_message_error err;
4292 static void lvm_remove_all_reply_cb (guestfs_h *g, void *data, XDR *xdr)
4294 guestfs_main_loop *ml = guestfs_get_main_loop (g);
4295 struct lvm_remove_all_ctx *ctx = (struct lvm_remove_all_ctx *) data;
4297 /* This should definitely not happen. */
4298 if (ctx->cb_sequence != 0) {
4299 ctx->cb_sequence = 9999;
4300 error (g, "%s: internal error: reply callback called twice", "guestfs_lvm_remove_all");
4304 ml->main_loop_quit (ml, g);
4306 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
4307 error (g, "%s: failed to parse reply header", "guestfs_lvm_remove_all");
4310 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
4311 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
4312 error (g, "%s: failed to parse reply error", "guestfs_lvm_remove_all");
4318 ctx->cb_sequence = 1;
4321 int guestfs_lvm_remove_all (guestfs_h *g)
4323 struct lvm_remove_all_ctx ctx;
4324 guestfs_main_loop *ml = guestfs_get_main_loop (g);
4327 if (check_state (g, "guestfs_lvm_remove_all") == -1) return -1;
4328 guestfs_set_busy (g);
4330 memset (&ctx, 0, sizeof ctx);
4332 serial = guestfs__send_sync (g, GUESTFS_PROC_LVM_REMOVE_ALL, NULL, NULL);
4334 guestfs_set_ready (g);
4338 guestfs__switch_to_receiving (g);
4339 ctx.cb_sequence = 0;
4340 guestfs_set_reply_callback (g, lvm_remove_all_reply_cb, &ctx);
4341 (void) ml->main_loop_run (ml, g);
4342 guestfs_set_reply_callback (g, NULL, NULL);
4343 if (ctx.cb_sequence != 1) {
4344 error (g, "%s reply failed, see earlier error messages", "guestfs_lvm_remove_all");
4345 guestfs_set_ready (g);
4349 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_LVM_REMOVE_ALL, serial) == -1) {
4350 guestfs_set_ready (g);
4354 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
4355 error (g, "%s", ctx.err.error_message);
4356 guestfs_set_ready (g);
4360 guestfs_set_ready (g);
4365 /* This flag is set by the callbacks, so we know we've done
4366 * the callbacks as expected, and in the right sequence.
4367 * 0 = not called, 1 = reply_cb called.
4370 struct guestfs_message_header hdr;
4371 struct guestfs_message_error err;
4372 struct guestfs_file_ret ret;
4375 static void file_reply_cb (guestfs_h *g, void *data, XDR *xdr)
4377 guestfs_main_loop *ml = guestfs_get_main_loop (g);
4378 struct file_ctx *ctx = (struct file_ctx *) data;
4380 /* This should definitely not happen. */
4381 if (ctx->cb_sequence != 0) {
4382 ctx->cb_sequence = 9999;
4383 error (g, "%s: internal error: reply callback called twice", "guestfs_file");
4387 ml->main_loop_quit (ml, g);
4389 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
4390 error (g, "%s: failed to parse reply header", "guestfs_file");
4393 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
4394 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
4395 error (g, "%s: failed to parse reply error", "guestfs_file");
4400 if (!xdr_guestfs_file_ret (xdr, &ctx->ret)) {
4401 error (g, "%s: failed to parse reply", "guestfs_file");
4405 ctx->cb_sequence = 1;
4408 char *guestfs_file (guestfs_h *g,
4411 struct guestfs_file_args args;
4412 struct file_ctx ctx;
4413 guestfs_main_loop *ml = guestfs_get_main_loop (g);
4416 if (check_state (g, "guestfs_file") == -1) return NULL;
4417 guestfs_set_busy (g);
4419 memset (&ctx, 0, sizeof ctx);
4421 args.path = (char *) path;
4422 serial = guestfs__send_sync (g, GUESTFS_PROC_FILE,
4423 (xdrproc_t) xdr_guestfs_file_args, (char *) &args);
4425 guestfs_set_ready (g);
4429 guestfs__switch_to_receiving (g);
4430 ctx.cb_sequence = 0;
4431 guestfs_set_reply_callback (g, file_reply_cb, &ctx);
4432 (void) ml->main_loop_run (ml, g);
4433 guestfs_set_reply_callback (g, NULL, NULL);
4434 if (ctx.cb_sequence != 1) {
4435 error (g, "%s reply failed, see earlier error messages", "guestfs_file");
4436 guestfs_set_ready (g);
4440 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_FILE, serial) == -1) {
4441 guestfs_set_ready (g);
4445 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
4446 error (g, "%s", ctx.err.error_message);
4447 guestfs_set_ready (g);
4451 guestfs_set_ready (g);
4452 return ctx.ret.description; /* caller will free */
4455 struct command_ctx {
4456 /* This flag is set by the callbacks, so we know we've done
4457 * the callbacks as expected, and in the right sequence.
4458 * 0 = not called, 1 = reply_cb called.
4461 struct guestfs_message_header hdr;
4462 struct guestfs_message_error err;
4463 struct guestfs_command_ret ret;
4466 static void command_reply_cb (guestfs_h *g, void *data, XDR *xdr)
4468 guestfs_main_loop *ml = guestfs_get_main_loop (g);
4469 struct command_ctx *ctx = (struct command_ctx *) data;
4471 /* This should definitely not happen. */
4472 if (ctx->cb_sequence != 0) {
4473 ctx->cb_sequence = 9999;
4474 error (g, "%s: internal error: reply callback called twice", "guestfs_command");
4478 ml->main_loop_quit (ml, g);
4480 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
4481 error (g, "%s: failed to parse reply header", "guestfs_command");
4484 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
4485 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
4486 error (g, "%s: failed to parse reply error", "guestfs_command");
4491 if (!xdr_guestfs_command_ret (xdr, &ctx->ret)) {
4492 error (g, "%s: failed to parse reply", "guestfs_command");
4496 ctx->cb_sequence = 1;
4499 char *guestfs_command (guestfs_h *g,
4500 char * const* const arguments)
4502 struct guestfs_command_args args;
4503 struct command_ctx ctx;
4504 guestfs_main_loop *ml = guestfs_get_main_loop (g);
4507 if (check_state (g, "guestfs_command") == -1) return NULL;
4508 guestfs_set_busy (g);
4510 memset (&ctx, 0, sizeof ctx);
4512 args.arguments.arguments_val = (char **) arguments;
4513 for (args.arguments.arguments_len = 0; arguments[args.arguments.arguments_len]; args.arguments.arguments_len++) ;
4514 serial = guestfs__send_sync (g, GUESTFS_PROC_COMMAND,
4515 (xdrproc_t) xdr_guestfs_command_args, (char *) &args);
4517 guestfs_set_ready (g);
4521 guestfs__switch_to_receiving (g);
4522 ctx.cb_sequence = 0;
4523 guestfs_set_reply_callback (g, command_reply_cb, &ctx);
4524 (void) ml->main_loop_run (ml, g);
4525 guestfs_set_reply_callback (g, NULL, NULL);
4526 if (ctx.cb_sequence != 1) {
4527 error (g, "%s reply failed, see earlier error messages", "guestfs_command");
4528 guestfs_set_ready (g);
4532 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_COMMAND, serial) == -1) {
4533 guestfs_set_ready (g);
4537 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
4538 error (g, "%s", ctx.err.error_message);
4539 guestfs_set_ready (g);
4543 guestfs_set_ready (g);
4544 return ctx.ret.output; /* caller will free */
4547 struct command_lines_ctx {
4548 /* This flag is set by the callbacks, so we know we've done
4549 * the callbacks as expected, and in the right sequence.
4550 * 0 = not called, 1 = reply_cb called.
4553 struct guestfs_message_header hdr;
4554 struct guestfs_message_error err;
4555 struct guestfs_command_lines_ret ret;
4558 static void command_lines_reply_cb (guestfs_h *g, void *data, XDR *xdr)
4560 guestfs_main_loop *ml = guestfs_get_main_loop (g);
4561 struct command_lines_ctx *ctx = (struct command_lines_ctx *) data;
4563 /* This should definitely not happen. */
4564 if (ctx->cb_sequence != 0) {
4565 ctx->cb_sequence = 9999;
4566 error (g, "%s: internal error: reply callback called twice", "guestfs_command_lines");
4570 ml->main_loop_quit (ml, g);
4572 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
4573 error (g, "%s: failed to parse reply header", "guestfs_command_lines");
4576 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
4577 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
4578 error (g, "%s: failed to parse reply error", "guestfs_command_lines");
4583 if (!xdr_guestfs_command_lines_ret (xdr, &ctx->ret)) {
4584 error (g, "%s: failed to parse reply", "guestfs_command_lines");
4588 ctx->cb_sequence = 1;
4591 char **guestfs_command_lines (guestfs_h *g,
4592 char * const* const arguments)
4594 struct guestfs_command_lines_args args;
4595 struct command_lines_ctx ctx;
4596 guestfs_main_loop *ml = guestfs_get_main_loop (g);
4599 if (check_state (g, "guestfs_command_lines") == -1) return NULL;
4600 guestfs_set_busy (g);
4602 memset (&ctx, 0, sizeof ctx);
4604 args.arguments.arguments_val = (char **) arguments;
4605 for (args.arguments.arguments_len = 0; arguments[args.arguments.arguments_len]; args.arguments.arguments_len++) ;
4606 serial = guestfs__send_sync (g, GUESTFS_PROC_COMMAND_LINES,
4607 (xdrproc_t) xdr_guestfs_command_lines_args, (char *) &args);
4609 guestfs_set_ready (g);
4613 guestfs__switch_to_receiving (g);
4614 ctx.cb_sequence = 0;
4615 guestfs_set_reply_callback (g, command_lines_reply_cb, &ctx);
4616 (void) ml->main_loop_run (ml, g);
4617 guestfs_set_reply_callback (g, NULL, NULL);
4618 if (ctx.cb_sequence != 1) {
4619 error (g, "%s reply failed, see earlier error messages", "guestfs_command_lines");
4620 guestfs_set_ready (g);
4624 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_COMMAND_LINES, serial) == -1) {
4625 guestfs_set_ready (g);
4629 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
4630 error (g, "%s", ctx.err.error_message);
4631 guestfs_set_ready (g);
4635 guestfs_set_ready (g);
4636 /* caller will free this, but we need to add a NULL entry */
4637 ctx.ret.lines.lines_val =
4638 safe_realloc (g, ctx.ret.lines.lines_val,
4639 sizeof (char *) * (ctx.ret.lines.lines_len + 1));
4640 ctx.ret.lines.lines_val[ctx.ret.lines.lines_len] = NULL;
4641 return ctx.ret.lines.lines_val;
4645 /* This flag is set by the callbacks, so we know we've done
4646 * the callbacks as expected, and in the right sequence.
4647 * 0 = not called, 1 = reply_cb called.
4650 struct guestfs_message_header hdr;
4651 struct guestfs_message_error err;
4652 struct guestfs_stat_ret ret;
4655 static void stat_reply_cb (guestfs_h *g, void *data, XDR *xdr)
4657 guestfs_main_loop *ml = guestfs_get_main_loop (g);
4658 struct stat_ctx *ctx = (struct stat_ctx *) data;
4660 /* This should definitely not happen. */
4661 if (ctx->cb_sequence != 0) {
4662 ctx->cb_sequence = 9999;
4663 error (g, "%s: internal error: reply callback called twice", "guestfs_stat");
4667 ml->main_loop_quit (ml, g);
4669 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
4670 error (g, "%s: failed to parse reply header", "guestfs_stat");
4673 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
4674 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
4675 error (g, "%s: failed to parse reply error", "guestfs_stat");
4680 if (!xdr_guestfs_stat_ret (xdr, &ctx->ret)) {
4681 error (g, "%s: failed to parse reply", "guestfs_stat");
4685 ctx->cb_sequence = 1;
4688 struct guestfs_stat *guestfs_stat (guestfs_h *g,
4691 struct guestfs_stat_args args;
4692 struct stat_ctx ctx;
4693 guestfs_main_loop *ml = guestfs_get_main_loop (g);
4696 if (check_state (g, "guestfs_stat") == -1) return NULL;
4697 guestfs_set_busy (g);
4699 memset (&ctx, 0, sizeof ctx);
4701 args.path = (char *) path;
4702 serial = guestfs__send_sync (g, GUESTFS_PROC_STAT,
4703 (xdrproc_t) xdr_guestfs_stat_args, (char *) &args);
4705 guestfs_set_ready (g);
4709 guestfs__switch_to_receiving (g);
4710 ctx.cb_sequence = 0;
4711 guestfs_set_reply_callback (g, stat_reply_cb, &ctx);
4712 (void) ml->main_loop_run (ml, g);
4713 guestfs_set_reply_callback (g, NULL, NULL);
4714 if (ctx.cb_sequence != 1) {
4715 error (g, "%s reply failed, see earlier error messages", "guestfs_stat");
4716 guestfs_set_ready (g);
4720 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_STAT, serial) == -1) {
4721 guestfs_set_ready (g);
4725 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
4726 error (g, "%s", ctx.err.error_message);
4727 guestfs_set_ready (g);
4731 guestfs_set_ready (g);
4732 /* caller will free this */
4733 return safe_memdup (g, &ctx.ret.statbuf, sizeof (ctx.ret.statbuf));
4737 /* This flag is set by the callbacks, so we know we've done
4738 * the callbacks as expected, and in the right sequence.
4739 * 0 = not called, 1 = reply_cb called.
4742 struct guestfs_message_header hdr;
4743 struct guestfs_message_error err;
4744 struct guestfs_lstat_ret ret;
4747 static void lstat_reply_cb (guestfs_h *g, void *data, XDR *xdr)
4749 guestfs_main_loop *ml = guestfs_get_main_loop (g);
4750 struct lstat_ctx *ctx = (struct lstat_ctx *) data;
4752 /* This should definitely not happen. */
4753 if (ctx->cb_sequence != 0) {
4754 ctx->cb_sequence = 9999;
4755 error (g, "%s: internal error: reply callback called twice", "guestfs_lstat");
4759 ml->main_loop_quit (ml, g);
4761 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
4762 error (g, "%s: failed to parse reply header", "guestfs_lstat");
4765 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
4766 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
4767 error (g, "%s: failed to parse reply error", "guestfs_lstat");
4772 if (!xdr_guestfs_lstat_ret (xdr, &ctx->ret)) {
4773 error (g, "%s: failed to parse reply", "guestfs_lstat");
4777 ctx->cb_sequence = 1;
4780 struct guestfs_stat *guestfs_lstat (guestfs_h *g,
4783 struct guestfs_lstat_args args;
4784 struct lstat_ctx ctx;
4785 guestfs_main_loop *ml = guestfs_get_main_loop (g);
4788 if (check_state (g, "guestfs_lstat") == -1) return NULL;
4789 guestfs_set_busy (g);
4791 memset (&ctx, 0, sizeof ctx);
4793 args.path = (char *) path;
4794 serial = guestfs__send_sync (g, GUESTFS_PROC_LSTAT,
4795 (xdrproc_t) xdr_guestfs_lstat_args, (char *) &args);
4797 guestfs_set_ready (g);
4801 guestfs__switch_to_receiving (g);
4802 ctx.cb_sequence = 0;
4803 guestfs_set_reply_callback (g, lstat_reply_cb, &ctx);
4804 (void) ml->main_loop_run (ml, g);
4805 guestfs_set_reply_callback (g, NULL, NULL);
4806 if (ctx.cb_sequence != 1) {
4807 error (g, "%s reply failed, see earlier error messages", "guestfs_lstat");
4808 guestfs_set_ready (g);
4812 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_LSTAT, serial) == -1) {
4813 guestfs_set_ready (g);
4817 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
4818 error (g, "%s", ctx.err.error_message);
4819 guestfs_set_ready (g);
4823 guestfs_set_ready (g);
4824 /* caller will free this */
4825 return safe_memdup (g, &ctx.ret.statbuf, sizeof (ctx.ret.statbuf));
4828 struct statvfs_ctx {
4829 /* This flag is set by the callbacks, so we know we've done
4830 * the callbacks as expected, and in the right sequence.
4831 * 0 = not called, 1 = reply_cb called.
4834 struct guestfs_message_header hdr;
4835 struct guestfs_message_error err;
4836 struct guestfs_statvfs_ret ret;
4839 static void statvfs_reply_cb (guestfs_h *g, void *data, XDR *xdr)
4841 guestfs_main_loop *ml = guestfs_get_main_loop (g);
4842 struct statvfs_ctx *ctx = (struct statvfs_ctx *) data;
4844 /* This should definitely not happen. */
4845 if (ctx->cb_sequence != 0) {
4846 ctx->cb_sequence = 9999;
4847 error (g, "%s: internal error: reply callback called twice", "guestfs_statvfs");
4851 ml->main_loop_quit (ml, g);
4853 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
4854 error (g, "%s: failed to parse reply header", "guestfs_statvfs");
4857 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
4858 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
4859 error (g, "%s: failed to parse reply error", "guestfs_statvfs");
4864 if (!xdr_guestfs_statvfs_ret (xdr, &ctx->ret)) {
4865 error (g, "%s: failed to parse reply", "guestfs_statvfs");
4869 ctx->cb_sequence = 1;
4872 struct guestfs_statvfs *guestfs_statvfs (guestfs_h *g,
4875 struct guestfs_statvfs_args args;
4876 struct statvfs_ctx ctx;
4877 guestfs_main_loop *ml = guestfs_get_main_loop (g);
4880 if (check_state (g, "guestfs_statvfs") == -1) return NULL;
4881 guestfs_set_busy (g);
4883 memset (&ctx, 0, sizeof ctx);
4885 args.path = (char *) path;
4886 serial = guestfs__send_sync (g, GUESTFS_PROC_STATVFS,
4887 (xdrproc_t) xdr_guestfs_statvfs_args, (char *) &args);
4889 guestfs_set_ready (g);
4893 guestfs__switch_to_receiving (g);
4894 ctx.cb_sequence = 0;
4895 guestfs_set_reply_callback (g, statvfs_reply_cb, &ctx);
4896 (void) ml->main_loop_run (ml, g);
4897 guestfs_set_reply_callback (g, NULL, NULL);
4898 if (ctx.cb_sequence != 1) {
4899 error (g, "%s reply failed, see earlier error messages", "guestfs_statvfs");
4900 guestfs_set_ready (g);
4904 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_STATVFS, serial) == -1) {
4905 guestfs_set_ready (g);
4909 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
4910 error (g, "%s", ctx.err.error_message);
4911 guestfs_set_ready (g);
4915 guestfs_set_ready (g);
4916 /* caller will free this */
4917 return safe_memdup (g, &ctx.ret.statbuf, sizeof (ctx.ret.statbuf));
4920 struct tune2fs_l_ctx {
4921 /* This flag is set by the callbacks, so we know we've done
4922 * the callbacks as expected, and in the right sequence.
4923 * 0 = not called, 1 = reply_cb called.
4926 struct guestfs_message_header hdr;
4927 struct guestfs_message_error err;
4928 struct guestfs_tune2fs_l_ret ret;
4931 static void tune2fs_l_reply_cb (guestfs_h *g, void *data, XDR *xdr)
4933 guestfs_main_loop *ml = guestfs_get_main_loop (g);
4934 struct tune2fs_l_ctx *ctx = (struct tune2fs_l_ctx *) data;
4936 /* This should definitely not happen. */
4937 if (ctx->cb_sequence != 0) {
4938 ctx->cb_sequence = 9999;
4939 error (g, "%s: internal error: reply callback called twice", "guestfs_tune2fs_l");
4943 ml->main_loop_quit (ml, g);
4945 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
4946 error (g, "%s: failed to parse reply header", "guestfs_tune2fs_l");
4949 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
4950 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
4951 error (g, "%s: failed to parse reply error", "guestfs_tune2fs_l");
4956 if (!xdr_guestfs_tune2fs_l_ret (xdr, &ctx->ret)) {
4957 error (g, "%s: failed to parse reply", "guestfs_tune2fs_l");
4961 ctx->cb_sequence = 1;
4964 char **guestfs_tune2fs_l (guestfs_h *g,
4967 struct guestfs_tune2fs_l_args args;
4968 struct tune2fs_l_ctx ctx;
4969 guestfs_main_loop *ml = guestfs_get_main_loop (g);
4972 if (check_state (g, "guestfs_tune2fs_l") == -1) return NULL;
4973 guestfs_set_busy (g);
4975 memset (&ctx, 0, sizeof ctx);
4977 args.device = (char *) device;
4978 serial = guestfs__send_sync (g, GUESTFS_PROC_TUNE2FS_L,
4979 (xdrproc_t) xdr_guestfs_tune2fs_l_args, (char *) &args);
4981 guestfs_set_ready (g);
4985 guestfs__switch_to_receiving (g);
4986 ctx.cb_sequence = 0;
4987 guestfs_set_reply_callback (g, tune2fs_l_reply_cb, &ctx);
4988 (void) ml->main_loop_run (ml, g);
4989 guestfs_set_reply_callback (g, NULL, NULL);
4990 if (ctx.cb_sequence != 1) {
4991 error (g, "%s reply failed, see earlier error messages", "guestfs_tune2fs_l");
4992 guestfs_set_ready (g);
4996 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_TUNE2FS_L, serial) == -1) {
4997 guestfs_set_ready (g);
5001 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
5002 error (g, "%s", ctx.err.error_message);
5003 guestfs_set_ready (g);
5007 guestfs_set_ready (g);
5008 /* caller will free this, but we need to add a NULL entry */
5009 ctx.ret.superblock.superblock_val =
5010 safe_realloc (g, ctx.ret.superblock.superblock_val,
5011 sizeof (char *) * (ctx.ret.superblock.superblock_len + 1));
5012 ctx.ret.superblock.superblock_val[ctx.ret.superblock.superblock_len] = NULL;
5013 return ctx.ret.superblock.superblock_val;
5016 struct blockdev_setro_ctx {
5017 /* This flag is set by the callbacks, so we know we've done
5018 * the callbacks as expected, and in the right sequence.
5019 * 0 = not called, 1 = reply_cb called.
5022 struct guestfs_message_header hdr;
5023 struct guestfs_message_error err;
5026 static void blockdev_setro_reply_cb (guestfs_h *g, void *data, XDR *xdr)
5028 guestfs_main_loop *ml = guestfs_get_main_loop (g);
5029 struct blockdev_setro_ctx *ctx = (struct blockdev_setro_ctx *) data;
5031 /* This should definitely not happen. */
5032 if (ctx->cb_sequence != 0) {
5033 ctx->cb_sequence = 9999;
5034 error (g, "%s: internal error: reply callback called twice", "guestfs_blockdev_setro");
5038 ml->main_loop_quit (ml, g);
5040 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
5041 error (g, "%s: failed to parse reply header", "guestfs_blockdev_setro");
5044 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
5045 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
5046 error (g, "%s: failed to parse reply error", "guestfs_blockdev_setro");
5052 ctx->cb_sequence = 1;
5055 int guestfs_blockdev_setro (guestfs_h *g,
5058 struct guestfs_blockdev_setro_args args;
5059 struct blockdev_setro_ctx ctx;
5060 guestfs_main_loop *ml = guestfs_get_main_loop (g);
5063 if (check_state (g, "guestfs_blockdev_setro") == -1) return -1;
5064 guestfs_set_busy (g);
5066 memset (&ctx, 0, sizeof ctx);
5068 args.device = (char *) device;
5069 serial = guestfs__send_sync (g, GUESTFS_PROC_BLOCKDEV_SETRO,
5070 (xdrproc_t) xdr_guestfs_blockdev_setro_args, (char *) &args);
5072 guestfs_set_ready (g);
5076 guestfs__switch_to_receiving (g);
5077 ctx.cb_sequence = 0;
5078 guestfs_set_reply_callback (g, blockdev_setro_reply_cb, &ctx);
5079 (void) ml->main_loop_run (ml, g);
5080 guestfs_set_reply_callback (g, NULL, NULL);
5081 if (ctx.cb_sequence != 1) {
5082 error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_setro");
5083 guestfs_set_ready (g);
5087 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_BLOCKDEV_SETRO, serial) == -1) {
5088 guestfs_set_ready (g);
5092 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
5093 error (g, "%s", ctx.err.error_message);
5094 guestfs_set_ready (g);
5098 guestfs_set_ready (g);
5102 struct blockdev_setrw_ctx {
5103 /* This flag is set by the callbacks, so we know we've done
5104 * the callbacks as expected, and in the right sequence.
5105 * 0 = not called, 1 = reply_cb called.
5108 struct guestfs_message_header hdr;
5109 struct guestfs_message_error err;
5112 static void blockdev_setrw_reply_cb (guestfs_h *g, void *data, XDR *xdr)
5114 guestfs_main_loop *ml = guestfs_get_main_loop (g);
5115 struct blockdev_setrw_ctx *ctx = (struct blockdev_setrw_ctx *) data;
5117 /* This should definitely not happen. */
5118 if (ctx->cb_sequence != 0) {
5119 ctx->cb_sequence = 9999;
5120 error (g, "%s: internal error: reply callback called twice", "guestfs_blockdev_setrw");
5124 ml->main_loop_quit (ml, g);
5126 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
5127 error (g, "%s: failed to parse reply header", "guestfs_blockdev_setrw");
5130 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
5131 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
5132 error (g, "%s: failed to parse reply error", "guestfs_blockdev_setrw");
5138 ctx->cb_sequence = 1;
5141 int guestfs_blockdev_setrw (guestfs_h *g,
5144 struct guestfs_blockdev_setrw_args args;
5145 struct blockdev_setrw_ctx ctx;
5146 guestfs_main_loop *ml = guestfs_get_main_loop (g);
5149 if (check_state (g, "guestfs_blockdev_setrw") == -1) return -1;
5150 guestfs_set_busy (g);
5152 memset (&ctx, 0, sizeof ctx);
5154 args.device = (char *) device;
5155 serial = guestfs__send_sync (g, GUESTFS_PROC_BLOCKDEV_SETRW,
5156 (xdrproc_t) xdr_guestfs_blockdev_setrw_args, (char *) &args);
5158 guestfs_set_ready (g);
5162 guestfs__switch_to_receiving (g);
5163 ctx.cb_sequence = 0;
5164 guestfs_set_reply_callback (g, blockdev_setrw_reply_cb, &ctx);
5165 (void) ml->main_loop_run (ml, g);
5166 guestfs_set_reply_callback (g, NULL, NULL);
5167 if (ctx.cb_sequence != 1) {
5168 error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_setrw");
5169 guestfs_set_ready (g);
5173 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_BLOCKDEV_SETRW, serial) == -1) {
5174 guestfs_set_ready (g);
5178 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
5179 error (g, "%s", ctx.err.error_message);
5180 guestfs_set_ready (g);
5184 guestfs_set_ready (g);
5188 struct blockdev_getro_ctx {
5189 /* This flag is set by the callbacks, so we know we've done
5190 * the callbacks as expected, and in the right sequence.
5191 * 0 = not called, 1 = reply_cb called.
5194 struct guestfs_message_header hdr;
5195 struct guestfs_message_error err;
5196 struct guestfs_blockdev_getro_ret ret;
5199 static void blockdev_getro_reply_cb (guestfs_h *g, void *data, XDR *xdr)
5201 guestfs_main_loop *ml = guestfs_get_main_loop (g);
5202 struct blockdev_getro_ctx *ctx = (struct blockdev_getro_ctx *) data;
5204 /* This should definitely not happen. */
5205 if (ctx->cb_sequence != 0) {
5206 ctx->cb_sequence = 9999;
5207 error (g, "%s: internal error: reply callback called twice", "guestfs_blockdev_getro");
5211 ml->main_loop_quit (ml, g);
5213 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
5214 error (g, "%s: failed to parse reply header", "guestfs_blockdev_getro");
5217 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
5218 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
5219 error (g, "%s: failed to parse reply error", "guestfs_blockdev_getro");
5224 if (!xdr_guestfs_blockdev_getro_ret (xdr, &ctx->ret)) {
5225 error (g, "%s: failed to parse reply", "guestfs_blockdev_getro");
5229 ctx->cb_sequence = 1;
5232 int guestfs_blockdev_getro (guestfs_h *g,
5235 struct guestfs_blockdev_getro_args args;
5236 struct blockdev_getro_ctx ctx;
5237 guestfs_main_loop *ml = guestfs_get_main_loop (g);
5240 if (check_state (g, "guestfs_blockdev_getro") == -1) return -1;
5241 guestfs_set_busy (g);
5243 memset (&ctx, 0, sizeof ctx);
5245 args.device = (char *) device;
5246 serial = guestfs__send_sync (g, GUESTFS_PROC_BLOCKDEV_GETRO,
5247 (xdrproc_t) xdr_guestfs_blockdev_getro_args, (char *) &args);
5249 guestfs_set_ready (g);
5253 guestfs__switch_to_receiving (g);
5254 ctx.cb_sequence = 0;
5255 guestfs_set_reply_callback (g, blockdev_getro_reply_cb, &ctx);
5256 (void) ml->main_loop_run (ml, g);
5257 guestfs_set_reply_callback (g, NULL, NULL);
5258 if (ctx.cb_sequence != 1) {
5259 error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_getro");
5260 guestfs_set_ready (g);
5264 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_BLOCKDEV_GETRO, serial) == -1) {
5265 guestfs_set_ready (g);
5269 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
5270 error (g, "%s", ctx.err.error_message);
5271 guestfs_set_ready (g);
5275 guestfs_set_ready (g);
5279 struct blockdev_getss_ctx {
5280 /* This flag is set by the callbacks, so we know we've done
5281 * the callbacks as expected, and in the right sequence.
5282 * 0 = not called, 1 = reply_cb called.
5285 struct guestfs_message_header hdr;
5286 struct guestfs_message_error err;
5287 struct guestfs_blockdev_getss_ret ret;
5290 static void blockdev_getss_reply_cb (guestfs_h *g, void *data, XDR *xdr)
5292 guestfs_main_loop *ml = guestfs_get_main_loop (g);
5293 struct blockdev_getss_ctx *ctx = (struct blockdev_getss_ctx *) data;
5295 /* This should definitely not happen. */
5296 if (ctx->cb_sequence != 0) {
5297 ctx->cb_sequence = 9999;
5298 error (g, "%s: internal error: reply callback called twice", "guestfs_blockdev_getss");
5302 ml->main_loop_quit (ml, g);
5304 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
5305 error (g, "%s: failed to parse reply header", "guestfs_blockdev_getss");
5308 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
5309 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
5310 error (g, "%s: failed to parse reply error", "guestfs_blockdev_getss");
5315 if (!xdr_guestfs_blockdev_getss_ret (xdr, &ctx->ret)) {
5316 error (g, "%s: failed to parse reply", "guestfs_blockdev_getss");
5320 ctx->cb_sequence = 1;
5323 int guestfs_blockdev_getss (guestfs_h *g,
5326 struct guestfs_blockdev_getss_args args;
5327 struct blockdev_getss_ctx ctx;
5328 guestfs_main_loop *ml = guestfs_get_main_loop (g);
5331 if (check_state (g, "guestfs_blockdev_getss") == -1) return -1;
5332 guestfs_set_busy (g);
5334 memset (&ctx, 0, sizeof ctx);
5336 args.device = (char *) device;
5337 serial = guestfs__send_sync (g, GUESTFS_PROC_BLOCKDEV_GETSS,
5338 (xdrproc_t) xdr_guestfs_blockdev_getss_args, (char *) &args);
5340 guestfs_set_ready (g);
5344 guestfs__switch_to_receiving (g);
5345 ctx.cb_sequence = 0;
5346 guestfs_set_reply_callback (g, blockdev_getss_reply_cb, &ctx);
5347 (void) ml->main_loop_run (ml, g);
5348 guestfs_set_reply_callback (g, NULL, NULL);
5349 if (ctx.cb_sequence != 1) {
5350 error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_getss");
5351 guestfs_set_ready (g);
5355 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_BLOCKDEV_GETSS, serial) == -1) {
5356 guestfs_set_ready (g);
5360 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
5361 error (g, "%s", ctx.err.error_message);
5362 guestfs_set_ready (g);
5366 guestfs_set_ready (g);
5367 return ctx.ret.sectorsize;
5370 struct blockdev_getbsz_ctx {
5371 /* This flag is set by the callbacks, so we know we've done
5372 * the callbacks as expected, and in the right sequence.
5373 * 0 = not called, 1 = reply_cb called.
5376 struct guestfs_message_header hdr;
5377 struct guestfs_message_error err;
5378 struct guestfs_blockdev_getbsz_ret ret;
5381 static void blockdev_getbsz_reply_cb (guestfs_h *g, void *data, XDR *xdr)
5383 guestfs_main_loop *ml = guestfs_get_main_loop (g);
5384 struct blockdev_getbsz_ctx *ctx = (struct blockdev_getbsz_ctx *) data;
5386 /* This should definitely not happen. */
5387 if (ctx->cb_sequence != 0) {
5388 ctx->cb_sequence = 9999;
5389 error (g, "%s: internal error: reply callback called twice", "guestfs_blockdev_getbsz");
5393 ml->main_loop_quit (ml, g);
5395 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
5396 error (g, "%s: failed to parse reply header", "guestfs_blockdev_getbsz");
5399 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
5400 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
5401 error (g, "%s: failed to parse reply error", "guestfs_blockdev_getbsz");
5406 if (!xdr_guestfs_blockdev_getbsz_ret (xdr, &ctx->ret)) {
5407 error (g, "%s: failed to parse reply", "guestfs_blockdev_getbsz");
5411 ctx->cb_sequence = 1;
5414 int guestfs_blockdev_getbsz (guestfs_h *g,
5417 struct guestfs_blockdev_getbsz_args args;
5418 struct blockdev_getbsz_ctx ctx;
5419 guestfs_main_loop *ml = guestfs_get_main_loop (g);
5422 if (check_state (g, "guestfs_blockdev_getbsz") == -1) return -1;
5423 guestfs_set_busy (g);
5425 memset (&ctx, 0, sizeof ctx);
5427 args.device = (char *) device;
5428 serial = guestfs__send_sync (g, GUESTFS_PROC_BLOCKDEV_GETBSZ,
5429 (xdrproc_t) xdr_guestfs_blockdev_getbsz_args, (char *) &args);
5431 guestfs_set_ready (g);
5435 guestfs__switch_to_receiving (g);
5436 ctx.cb_sequence = 0;
5437 guestfs_set_reply_callback (g, blockdev_getbsz_reply_cb, &ctx);
5438 (void) ml->main_loop_run (ml, g);
5439 guestfs_set_reply_callback (g, NULL, NULL);
5440 if (ctx.cb_sequence != 1) {
5441 error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_getbsz");
5442 guestfs_set_ready (g);
5446 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_BLOCKDEV_GETBSZ, serial) == -1) {
5447 guestfs_set_ready (g);
5451 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
5452 error (g, "%s", ctx.err.error_message);
5453 guestfs_set_ready (g);
5457 guestfs_set_ready (g);
5458 return ctx.ret.blocksize;
5461 struct blockdev_setbsz_ctx {
5462 /* This flag is set by the callbacks, so we know we've done
5463 * the callbacks as expected, and in the right sequence.
5464 * 0 = not called, 1 = reply_cb called.
5467 struct guestfs_message_header hdr;
5468 struct guestfs_message_error err;
5471 static void blockdev_setbsz_reply_cb (guestfs_h *g, void *data, XDR *xdr)
5473 guestfs_main_loop *ml = guestfs_get_main_loop (g);
5474 struct blockdev_setbsz_ctx *ctx = (struct blockdev_setbsz_ctx *) data;
5476 /* This should definitely not happen. */
5477 if (ctx->cb_sequence != 0) {
5478 ctx->cb_sequence = 9999;
5479 error (g, "%s: internal error: reply callback called twice", "guestfs_blockdev_setbsz");
5483 ml->main_loop_quit (ml, g);
5485 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
5486 error (g, "%s: failed to parse reply header", "guestfs_blockdev_setbsz");
5489 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
5490 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
5491 error (g, "%s: failed to parse reply error", "guestfs_blockdev_setbsz");
5497 ctx->cb_sequence = 1;
5500 int guestfs_blockdev_setbsz (guestfs_h *g,
5504 struct guestfs_blockdev_setbsz_args args;
5505 struct blockdev_setbsz_ctx ctx;
5506 guestfs_main_loop *ml = guestfs_get_main_loop (g);
5509 if (check_state (g, "guestfs_blockdev_setbsz") == -1) return -1;
5510 guestfs_set_busy (g);
5512 memset (&ctx, 0, sizeof ctx);
5514 args.device = (char *) device;
5515 args.blocksize = blocksize;
5516 serial = guestfs__send_sync (g, GUESTFS_PROC_BLOCKDEV_SETBSZ,
5517 (xdrproc_t) xdr_guestfs_blockdev_setbsz_args, (char *) &args);
5519 guestfs_set_ready (g);
5523 guestfs__switch_to_receiving (g);
5524 ctx.cb_sequence = 0;
5525 guestfs_set_reply_callback (g, blockdev_setbsz_reply_cb, &ctx);
5526 (void) ml->main_loop_run (ml, g);
5527 guestfs_set_reply_callback (g, NULL, NULL);
5528 if (ctx.cb_sequence != 1) {
5529 error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_setbsz");
5530 guestfs_set_ready (g);
5534 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_BLOCKDEV_SETBSZ, serial) == -1) {
5535 guestfs_set_ready (g);
5539 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
5540 error (g, "%s", ctx.err.error_message);
5541 guestfs_set_ready (g);
5545 guestfs_set_ready (g);
5549 struct blockdev_getsz_ctx {
5550 /* This flag is set by the callbacks, so we know we've done
5551 * the callbacks as expected, and in the right sequence.
5552 * 0 = not called, 1 = reply_cb called.
5555 struct guestfs_message_header hdr;
5556 struct guestfs_message_error err;
5557 struct guestfs_blockdev_getsz_ret ret;
5560 static void blockdev_getsz_reply_cb (guestfs_h *g, void *data, XDR *xdr)
5562 guestfs_main_loop *ml = guestfs_get_main_loop (g);
5563 struct blockdev_getsz_ctx *ctx = (struct blockdev_getsz_ctx *) data;
5565 /* This should definitely not happen. */
5566 if (ctx->cb_sequence != 0) {
5567 ctx->cb_sequence = 9999;
5568 error (g, "%s: internal error: reply callback called twice", "guestfs_blockdev_getsz");
5572 ml->main_loop_quit (ml, g);
5574 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
5575 error (g, "%s: failed to parse reply header", "guestfs_blockdev_getsz");
5578 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
5579 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
5580 error (g, "%s: failed to parse reply error", "guestfs_blockdev_getsz");
5585 if (!xdr_guestfs_blockdev_getsz_ret (xdr, &ctx->ret)) {
5586 error (g, "%s: failed to parse reply", "guestfs_blockdev_getsz");
5590 ctx->cb_sequence = 1;
5593 int64_t guestfs_blockdev_getsz (guestfs_h *g,
5596 struct guestfs_blockdev_getsz_args args;
5597 struct blockdev_getsz_ctx ctx;
5598 guestfs_main_loop *ml = guestfs_get_main_loop (g);
5601 if (check_state (g, "guestfs_blockdev_getsz") == -1) return -1;
5602 guestfs_set_busy (g);
5604 memset (&ctx, 0, sizeof ctx);
5606 args.device = (char *) device;
5607 serial = guestfs__send_sync (g, GUESTFS_PROC_BLOCKDEV_GETSZ,
5608 (xdrproc_t) xdr_guestfs_blockdev_getsz_args, (char *) &args);
5610 guestfs_set_ready (g);
5614 guestfs__switch_to_receiving (g);
5615 ctx.cb_sequence = 0;
5616 guestfs_set_reply_callback (g, blockdev_getsz_reply_cb, &ctx);
5617 (void) ml->main_loop_run (ml, g);
5618 guestfs_set_reply_callback (g, NULL, NULL);
5619 if (ctx.cb_sequence != 1) {
5620 error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_getsz");
5621 guestfs_set_ready (g);
5625 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_BLOCKDEV_GETSZ, serial) == -1) {
5626 guestfs_set_ready (g);
5630 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
5631 error (g, "%s", ctx.err.error_message);
5632 guestfs_set_ready (g);
5636 guestfs_set_ready (g);
5637 return ctx.ret.sizeinsectors;
5640 struct blockdev_getsize64_ctx {
5641 /* This flag is set by the callbacks, so we know we've done
5642 * the callbacks as expected, and in the right sequence.
5643 * 0 = not called, 1 = reply_cb called.
5646 struct guestfs_message_header hdr;
5647 struct guestfs_message_error err;
5648 struct guestfs_blockdev_getsize64_ret ret;
5651 static void blockdev_getsize64_reply_cb (guestfs_h *g, void *data, XDR *xdr)
5653 guestfs_main_loop *ml = guestfs_get_main_loop (g);
5654 struct blockdev_getsize64_ctx *ctx = (struct blockdev_getsize64_ctx *) data;
5656 /* This should definitely not happen. */
5657 if (ctx->cb_sequence != 0) {
5658 ctx->cb_sequence = 9999;
5659 error (g, "%s: internal error: reply callback called twice", "guestfs_blockdev_getsize64");
5663 ml->main_loop_quit (ml, g);
5665 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
5666 error (g, "%s: failed to parse reply header", "guestfs_blockdev_getsize64");
5669 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
5670 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
5671 error (g, "%s: failed to parse reply error", "guestfs_blockdev_getsize64");
5676 if (!xdr_guestfs_blockdev_getsize64_ret (xdr, &ctx->ret)) {
5677 error (g, "%s: failed to parse reply", "guestfs_blockdev_getsize64");
5681 ctx->cb_sequence = 1;
5684 int64_t guestfs_blockdev_getsize64 (guestfs_h *g,
5687 struct guestfs_blockdev_getsize64_args args;
5688 struct blockdev_getsize64_ctx ctx;
5689 guestfs_main_loop *ml = guestfs_get_main_loop (g);
5692 if (check_state (g, "guestfs_blockdev_getsize64") == -1) return -1;
5693 guestfs_set_busy (g);
5695 memset (&ctx, 0, sizeof ctx);
5697 args.device = (char *) device;
5698 serial = guestfs__send_sync (g, GUESTFS_PROC_BLOCKDEV_GETSIZE64,
5699 (xdrproc_t) xdr_guestfs_blockdev_getsize64_args, (char *) &args);
5701 guestfs_set_ready (g);
5705 guestfs__switch_to_receiving (g);
5706 ctx.cb_sequence = 0;
5707 guestfs_set_reply_callback (g, blockdev_getsize64_reply_cb, &ctx);
5708 (void) ml->main_loop_run (ml, g);
5709 guestfs_set_reply_callback (g, NULL, NULL);
5710 if (ctx.cb_sequence != 1) {
5711 error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_getsize64");
5712 guestfs_set_ready (g);
5716 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_BLOCKDEV_GETSIZE64, serial) == -1) {
5717 guestfs_set_ready (g);
5721 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
5722 error (g, "%s", ctx.err.error_message);
5723 guestfs_set_ready (g);
5727 guestfs_set_ready (g);
5728 return ctx.ret.sizeinbytes;
5731 struct blockdev_flushbufs_ctx {
5732 /* This flag is set by the callbacks, so we know we've done
5733 * the callbacks as expected, and in the right sequence.
5734 * 0 = not called, 1 = reply_cb called.
5737 struct guestfs_message_header hdr;
5738 struct guestfs_message_error err;
5741 static void blockdev_flushbufs_reply_cb (guestfs_h *g, void *data, XDR *xdr)
5743 guestfs_main_loop *ml = guestfs_get_main_loop (g);
5744 struct blockdev_flushbufs_ctx *ctx = (struct blockdev_flushbufs_ctx *) data;
5746 /* This should definitely not happen. */
5747 if (ctx->cb_sequence != 0) {
5748 ctx->cb_sequence = 9999;
5749 error (g, "%s: internal error: reply callback called twice", "guestfs_blockdev_flushbufs");
5753 ml->main_loop_quit (ml, g);
5755 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
5756 error (g, "%s: failed to parse reply header", "guestfs_blockdev_flushbufs");
5759 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
5760 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
5761 error (g, "%s: failed to parse reply error", "guestfs_blockdev_flushbufs");
5767 ctx->cb_sequence = 1;
5770 int guestfs_blockdev_flushbufs (guestfs_h *g,
5773 struct guestfs_blockdev_flushbufs_args args;
5774 struct blockdev_flushbufs_ctx ctx;
5775 guestfs_main_loop *ml = guestfs_get_main_loop (g);
5778 if (check_state (g, "guestfs_blockdev_flushbufs") == -1) return -1;
5779 guestfs_set_busy (g);
5781 memset (&ctx, 0, sizeof ctx);
5783 args.device = (char *) device;
5784 serial = guestfs__send_sync (g, GUESTFS_PROC_BLOCKDEV_FLUSHBUFS,
5785 (xdrproc_t) xdr_guestfs_blockdev_flushbufs_args, (char *) &args);
5787 guestfs_set_ready (g);
5791 guestfs__switch_to_receiving (g);
5792 ctx.cb_sequence = 0;
5793 guestfs_set_reply_callback (g, blockdev_flushbufs_reply_cb, &ctx);
5794 (void) ml->main_loop_run (ml, g);
5795 guestfs_set_reply_callback (g, NULL, NULL);
5796 if (ctx.cb_sequence != 1) {
5797 error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_flushbufs");
5798 guestfs_set_ready (g);
5802 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_BLOCKDEV_FLUSHBUFS, serial) == -1) {
5803 guestfs_set_ready (g);
5807 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
5808 error (g, "%s", ctx.err.error_message);
5809 guestfs_set_ready (g);
5813 guestfs_set_ready (g);
5817 struct blockdev_rereadpt_ctx {
5818 /* This flag is set by the callbacks, so we know we've done
5819 * the callbacks as expected, and in the right sequence.
5820 * 0 = not called, 1 = reply_cb called.
5823 struct guestfs_message_header hdr;
5824 struct guestfs_message_error err;
5827 static void blockdev_rereadpt_reply_cb (guestfs_h *g, void *data, XDR *xdr)
5829 guestfs_main_loop *ml = guestfs_get_main_loop (g);
5830 struct blockdev_rereadpt_ctx *ctx = (struct blockdev_rereadpt_ctx *) data;
5832 /* This should definitely not happen. */
5833 if (ctx->cb_sequence != 0) {
5834 ctx->cb_sequence = 9999;
5835 error (g, "%s: internal error: reply callback called twice", "guestfs_blockdev_rereadpt");
5839 ml->main_loop_quit (ml, g);
5841 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
5842 error (g, "%s: failed to parse reply header", "guestfs_blockdev_rereadpt");
5845 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
5846 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
5847 error (g, "%s: failed to parse reply error", "guestfs_blockdev_rereadpt");
5853 ctx->cb_sequence = 1;
5856 int guestfs_blockdev_rereadpt (guestfs_h *g,
5859 struct guestfs_blockdev_rereadpt_args args;
5860 struct blockdev_rereadpt_ctx ctx;
5861 guestfs_main_loop *ml = guestfs_get_main_loop (g);
5864 if (check_state (g, "guestfs_blockdev_rereadpt") == -1) return -1;
5865 guestfs_set_busy (g);
5867 memset (&ctx, 0, sizeof ctx);
5869 args.device = (char *) device;
5870 serial = guestfs__send_sync (g, GUESTFS_PROC_BLOCKDEV_REREADPT,
5871 (xdrproc_t) xdr_guestfs_blockdev_rereadpt_args, (char *) &args);
5873 guestfs_set_ready (g);
5877 guestfs__switch_to_receiving (g);
5878 ctx.cb_sequence = 0;
5879 guestfs_set_reply_callback (g, blockdev_rereadpt_reply_cb, &ctx);
5880 (void) ml->main_loop_run (ml, g);
5881 guestfs_set_reply_callback (g, NULL, NULL);
5882 if (ctx.cb_sequence != 1) {
5883 error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_rereadpt");
5884 guestfs_set_ready (g);
5888 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_BLOCKDEV_REREADPT, serial) == -1) {
5889 guestfs_set_ready (g);
5893 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
5894 error (g, "%s", ctx.err.error_message);
5895 guestfs_set_ready (g);
5899 guestfs_set_ready (g);
5904 /* This flag is set by the callbacks, so we know we've done
5905 * the callbacks as expected, and in the right sequence.
5906 * 0 = not called, 1 = reply_cb called.
5909 struct guestfs_message_header hdr;
5910 struct guestfs_message_error err;
5913 static void upload_reply_cb (guestfs_h *g, void *data, XDR *xdr)
5915 guestfs_main_loop *ml = guestfs_get_main_loop (g);
5916 struct upload_ctx *ctx = (struct upload_ctx *) data;
5918 /* This should definitely not happen. */
5919 if (ctx->cb_sequence != 0) {
5920 ctx->cb_sequence = 9999;
5921 error (g, "%s: internal error: reply callback called twice", "guestfs_upload");
5925 ml->main_loop_quit (ml, g);
5927 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
5928 error (g, "%s: failed to parse reply header", "guestfs_upload");
5931 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
5932 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
5933 error (g, "%s: failed to parse reply error", "guestfs_upload");
5939 ctx->cb_sequence = 1;
5942 int guestfs_upload (guestfs_h *g,
5943 const char *filename,
5944 const char *remotefilename)
5946 struct guestfs_upload_args args;
5947 struct upload_ctx ctx;
5948 guestfs_main_loop *ml = guestfs_get_main_loop (g);
5951 if (check_state (g, "guestfs_upload") == -1) return -1;
5952 guestfs_set_busy (g);
5954 memset (&ctx, 0, sizeof ctx);
5956 args.remotefilename = (char *) remotefilename;
5957 serial = guestfs__send_sync (g, GUESTFS_PROC_UPLOAD,
5958 (xdrproc_t) xdr_guestfs_upload_args, (char *) &args);
5960 guestfs_set_ready (g);
5967 r = guestfs__send_file_sync (g, filename);
5969 guestfs_set_ready (g);
5972 if (r == -2) /* daemon cancelled */
5977 guestfs__switch_to_receiving (g);
5978 ctx.cb_sequence = 0;
5979 guestfs_set_reply_callback (g, upload_reply_cb, &ctx);
5980 (void) ml->main_loop_run (ml, g);
5981 guestfs_set_reply_callback (g, NULL, NULL);
5982 if (ctx.cb_sequence != 1) {
5983 error (g, "%s reply failed, see earlier error messages", "guestfs_upload");
5984 guestfs_set_ready (g);
5988 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_UPLOAD, serial) == -1) {
5989 guestfs_set_ready (g);
5993 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
5994 error (g, "%s", ctx.err.error_message);
5995 guestfs_set_ready (g);
5999 guestfs_set_ready (g);
6003 struct download_ctx {
6004 /* This flag is set by the callbacks, so we know we've done
6005 * the callbacks as expected, and in the right sequence.
6006 * 0 = not called, 1 = reply_cb called.
6009 struct guestfs_message_header hdr;
6010 struct guestfs_message_error err;
6013 static void download_reply_cb (guestfs_h *g, void *data, XDR *xdr)
6015 guestfs_main_loop *ml = guestfs_get_main_loop (g);
6016 struct download_ctx *ctx = (struct download_ctx *) data;
6018 /* This should definitely not happen. */
6019 if (ctx->cb_sequence != 0) {
6020 ctx->cb_sequence = 9999;
6021 error (g, "%s: internal error: reply callback called twice", "guestfs_download");
6025 ml->main_loop_quit (ml, g);
6027 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
6028 error (g, "%s: failed to parse reply header", "guestfs_download");
6031 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
6032 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
6033 error (g, "%s: failed to parse reply error", "guestfs_download");
6039 ctx->cb_sequence = 1;
6042 int guestfs_download (guestfs_h *g,
6043 const char *remotefilename,
6044 const char *filename)
6046 struct guestfs_download_args args;
6047 struct download_ctx ctx;
6048 guestfs_main_loop *ml = guestfs_get_main_loop (g);
6051 if (check_state (g, "guestfs_download") == -1) return -1;
6052 guestfs_set_busy (g);
6054 memset (&ctx, 0, sizeof ctx);
6056 args.remotefilename = (char *) remotefilename;
6057 serial = guestfs__send_sync (g, GUESTFS_PROC_DOWNLOAD,
6058 (xdrproc_t) xdr_guestfs_download_args, (char *) &args);
6060 guestfs_set_ready (g);
6064 guestfs__switch_to_receiving (g);
6065 ctx.cb_sequence = 0;
6066 guestfs_set_reply_callback (g, download_reply_cb, &ctx);
6067 (void) ml->main_loop_run (ml, g);
6068 guestfs_set_reply_callback (g, NULL, NULL);
6069 if (ctx.cb_sequence != 1) {
6070 error (g, "%s reply failed, see earlier error messages", "guestfs_download");
6071 guestfs_set_ready (g);
6075 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_DOWNLOAD, serial) == -1) {
6076 guestfs_set_ready (g);
6080 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
6081 error (g, "%s", ctx.err.error_message);
6082 guestfs_set_ready (g);
6086 if (guestfs__receive_file_sync (g, filename) == -1) {
6087 guestfs_set_ready (g);
6091 guestfs_set_ready (g);
6095 struct checksum_ctx {
6096 /* This flag is set by the callbacks, so we know we've done
6097 * the callbacks as expected, and in the right sequence.
6098 * 0 = not called, 1 = reply_cb called.
6101 struct guestfs_message_header hdr;
6102 struct guestfs_message_error err;
6103 struct guestfs_checksum_ret ret;
6106 static void checksum_reply_cb (guestfs_h *g, void *data, XDR *xdr)
6108 guestfs_main_loop *ml = guestfs_get_main_loop (g);
6109 struct checksum_ctx *ctx = (struct checksum_ctx *) data;
6111 /* This should definitely not happen. */
6112 if (ctx->cb_sequence != 0) {
6113 ctx->cb_sequence = 9999;
6114 error (g, "%s: internal error: reply callback called twice", "guestfs_checksum");
6118 ml->main_loop_quit (ml, g);
6120 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
6121 error (g, "%s: failed to parse reply header", "guestfs_checksum");
6124 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
6125 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
6126 error (g, "%s: failed to parse reply error", "guestfs_checksum");
6131 if (!xdr_guestfs_checksum_ret (xdr, &ctx->ret)) {
6132 error (g, "%s: failed to parse reply", "guestfs_checksum");
6136 ctx->cb_sequence = 1;
6139 char *guestfs_checksum (guestfs_h *g,
6140 const char *csumtype,
6143 struct guestfs_checksum_args args;
6144 struct checksum_ctx ctx;
6145 guestfs_main_loop *ml = guestfs_get_main_loop (g);
6148 if (check_state (g, "guestfs_checksum") == -1) return NULL;
6149 guestfs_set_busy (g);
6151 memset (&ctx, 0, sizeof ctx);
6153 args.csumtype = (char *) csumtype;
6154 args.path = (char *) path;
6155 serial = guestfs__send_sync (g, GUESTFS_PROC_CHECKSUM,
6156 (xdrproc_t) xdr_guestfs_checksum_args, (char *) &args);
6158 guestfs_set_ready (g);
6162 guestfs__switch_to_receiving (g);
6163 ctx.cb_sequence = 0;
6164 guestfs_set_reply_callback (g, checksum_reply_cb, &ctx);
6165 (void) ml->main_loop_run (ml, g);
6166 guestfs_set_reply_callback (g, NULL, NULL);
6167 if (ctx.cb_sequence != 1) {
6168 error (g, "%s reply failed, see earlier error messages", "guestfs_checksum");
6169 guestfs_set_ready (g);
6173 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_CHECKSUM, serial) == -1) {
6174 guestfs_set_ready (g);
6178 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
6179 error (g, "%s", ctx.err.error_message);
6180 guestfs_set_ready (g);
6184 guestfs_set_ready (g);
6185 return ctx.ret.checksum; /* caller will free */
6189 /* This flag is set by the callbacks, so we know we've done
6190 * the callbacks as expected, and in the right sequence.
6191 * 0 = not called, 1 = reply_cb called.
6194 struct guestfs_message_header hdr;
6195 struct guestfs_message_error err;
6198 static void tar_in_reply_cb (guestfs_h *g, void *data, XDR *xdr)
6200 guestfs_main_loop *ml = guestfs_get_main_loop (g);
6201 struct tar_in_ctx *ctx = (struct tar_in_ctx *) data;
6203 /* This should definitely not happen. */
6204 if (ctx->cb_sequence != 0) {
6205 ctx->cb_sequence = 9999;
6206 error (g, "%s: internal error: reply callback called twice", "guestfs_tar_in");
6210 ml->main_loop_quit (ml, g);
6212 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
6213 error (g, "%s: failed to parse reply header", "guestfs_tar_in");
6216 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
6217 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
6218 error (g, "%s: failed to parse reply error", "guestfs_tar_in");
6224 ctx->cb_sequence = 1;
6227 int guestfs_tar_in (guestfs_h *g,
6228 const char *tarfile,
6229 const char *directory)
6231 struct guestfs_tar_in_args args;
6232 struct tar_in_ctx ctx;
6233 guestfs_main_loop *ml = guestfs_get_main_loop (g);
6236 if (check_state (g, "guestfs_tar_in") == -1) return -1;
6237 guestfs_set_busy (g);
6239 memset (&ctx, 0, sizeof ctx);
6241 args.directory = (char *) directory;
6242 serial = guestfs__send_sync (g, GUESTFS_PROC_TAR_IN,
6243 (xdrproc_t) xdr_guestfs_tar_in_args, (char *) &args);
6245 guestfs_set_ready (g);
6252 r = guestfs__send_file_sync (g, tarfile);
6254 guestfs_set_ready (g);
6257 if (r == -2) /* daemon cancelled */
6262 guestfs__switch_to_receiving (g);
6263 ctx.cb_sequence = 0;
6264 guestfs_set_reply_callback (g, tar_in_reply_cb, &ctx);
6265 (void) ml->main_loop_run (ml, g);
6266 guestfs_set_reply_callback (g, NULL, NULL);
6267 if (ctx.cb_sequence != 1) {
6268 error (g, "%s reply failed, see earlier error messages", "guestfs_tar_in");
6269 guestfs_set_ready (g);
6273 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_TAR_IN, serial) == -1) {
6274 guestfs_set_ready (g);
6278 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
6279 error (g, "%s", ctx.err.error_message);
6280 guestfs_set_ready (g);
6284 guestfs_set_ready (g);
6288 struct tar_out_ctx {
6289 /* This flag is set by the callbacks, so we know we've done
6290 * the callbacks as expected, and in the right sequence.
6291 * 0 = not called, 1 = reply_cb called.
6294 struct guestfs_message_header hdr;
6295 struct guestfs_message_error err;
6298 static void tar_out_reply_cb (guestfs_h *g, void *data, XDR *xdr)
6300 guestfs_main_loop *ml = guestfs_get_main_loop (g);
6301 struct tar_out_ctx *ctx = (struct tar_out_ctx *) data;
6303 /* This should definitely not happen. */
6304 if (ctx->cb_sequence != 0) {
6305 ctx->cb_sequence = 9999;
6306 error (g, "%s: internal error: reply callback called twice", "guestfs_tar_out");
6310 ml->main_loop_quit (ml, g);
6312 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
6313 error (g, "%s: failed to parse reply header", "guestfs_tar_out");
6316 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
6317 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
6318 error (g, "%s: failed to parse reply error", "guestfs_tar_out");
6324 ctx->cb_sequence = 1;
6327 int guestfs_tar_out (guestfs_h *g,
6328 const char *directory,
6329 const char *tarfile)
6331 struct guestfs_tar_out_args args;
6332 struct tar_out_ctx ctx;
6333 guestfs_main_loop *ml = guestfs_get_main_loop (g);
6336 if (check_state (g, "guestfs_tar_out") == -1) return -1;
6337 guestfs_set_busy (g);
6339 memset (&ctx, 0, sizeof ctx);
6341 args.directory = (char *) directory;
6342 serial = guestfs__send_sync (g, GUESTFS_PROC_TAR_OUT,
6343 (xdrproc_t) xdr_guestfs_tar_out_args, (char *) &args);
6345 guestfs_set_ready (g);
6349 guestfs__switch_to_receiving (g);
6350 ctx.cb_sequence = 0;
6351 guestfs_set_reply_callback (g, tar_out_reply_cb, &ctx);
6352 (void) ml->main_loop_run (ml, g);
6353 guestfs_set_reply_callback (g, NULL, NULL);
6354 if (ctx.cb_sequence != 1) {
6355 error (g, "%s reply failed, see earlier error messages", "guestfs_tar_out");
6356 guestfs_set_ready (g);
6360 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_TAR_OUT, serial) == -1) {
6361 guestfs_set_ready (g);
6365 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
6366 error (g, "%s", ctx.err.error_message);
6367 guestfs_set_ready (g);
6371 if (guestfs__receive_file_sync (g, tarfile) == -1) {
6372 guestfs_set_ready (g);
6376 guestfs_set_ready (g);
6381 /* This flag is set by the callbacks, so we know we've done
6382 * the callbacks as expected, and in the right sequence.
6383 * 0 = not called, 1 = reply_cb called.
6386 struct guestfs_message_header hdr;
6387 struct guestfs_message_error err;
6390 static void tgz_in_reply_cb (guestfs_h *g, void *data, XDR *xdr)
6392 guestfs_main_loop *ml = guestfs_get_main_loop (g);
6393 struct tgz_in_ctx *ctx = (struct tgz_in_ctx *) data;
6395 /* This should definitely not happen. */
6396 if (ctx->cb_sequence != 0) {
6397 ctx->cb_sequence = 9999;
6398 error (g, "%s: internal error: reply callback called twice", "guestfs_tgz_in");
6402 ml->main_loop_quit (ml, g);
6404 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
6405 error (g, "%s: failed to parse reply header", "guestfs_tgz_in");
6408 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
6409 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
6410 error (g, "%s: failed to parse reply error", "guestfs_tgz_in");
6416 ctx->cb_sequence = 1;
6419 int guestfs_tgz_in (guestfs_h *g,
6420 const char *tarball,
6421 const char *directory)
6423 struct guestfs_tgz_in_args args;
6424 struct tgz_in_ctx ctx;
6425 guestfs_main_loop *ml = guestfs_get_main_loop (g);
6428 if (check_state (g, "guestfs_tgz_in") == -1) return -1;
6429 guestfs_set_busy (g);
6431 memset (&ctx, 0, sizeof ctx);
6433 args.directory = (char *) directory;
6434 serial = guestfs__send_sync (g, GUESTFS_PROC_TGZ_IN,
6435 (xdrproc_t) xdr_guestfs_tgz_in_args, (char *) &args);
6437 guestfs_set_ready (g);
6444 r = guestfs__send_file_sync (g, tarball);
6446 guestfs_set_ready (g);
6449 if (r == -2) /* daemon cancelled */
6454 guestfs__switch_to_receiving (g);
6455 ctx.cb_sequence = 0;
6456 guestfs_set_reply_callback (g, tgz_in_reply_cb, &ctx);
6457 (void) ml->main_loop_run (ml, g);
6458 guestfs_set_reply_callback (g, NULL, NULL);
6459 if (ctx.cb_sequence != 1) {
6460 error (g, "%s reply failed, see earlier error messages", "guestfs_tgz_in");
6461 guestfs_set_ready (g);
6465 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_TGZ_IN, serial) == -1) {
6466 guestfs_set_ready (g);
6470 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
6471 error (g, "%s", ctx.err.error_message);
6472 guestfs_set_ready (g);
6476 guestfs_set_ready (g);
6480 struct tgz_out_ctx {
6481 /* This flag is set by the callbacks, so we know we've done
6482 * the callbacks as expected, and in the right sequence.
6483 * 0 = not called, 1 = reply_cb called.
6486 struct guestfs_message_header hdr;
6487 struct guestfs_message_error err;
6490 static void tgz_out_reply_cb (guestfs_h *g, void *data, XDR *xdr)
6492 guestfs_main_loop *ml = guestfs_get_main_loop (g);
6493 struct tgz_out_ctx *ctx = (struct tgz_out_ctx *) data;
6495 /* This should definitely not happen. */
6496 if (ctx->cb_sequence != 0) {
6497 ctx->cb_sequence = 9999;
6498 error (g, "%s: internal error: reply callback called twice", "guestfs_tgz_out");
6502 ml->main_loop_quit (ml, g);
6504 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
6505 error (g, "%s: failed to parse reply header", "guestfs_tgz_out");
6508 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
6509 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
6510 error (g, "%s: failed to parse reply error", "guestfs_tgz_out");
6516 ctx->cb_sequence = 1;
6519 int guestfs_tgz_out (guestfs_h *g,
6520 const char *directory,
6521 const char *tarball)
6523 struct guestfs_tgz_out_args args;
6524 struct tgz_out_ctx ctx;
6525 guestfs_main_loop *ml = guestfs_get_main_loop (g);
6528 if (check_state (g, "guestfs_tgz_out") == -1) return -1;
6529 guestfs_set_busy (g);
6531 memset (&ctx, 0, sizeof ctx);
6533 args.directory = (char *) directory;
6534 serial = guestfs__send_sync (g, GUESTFS_PROC_TGZ_OUT,
6535 (xdrproc_t) xdr_guestfs_tgz_out_args, (char *) &args);
6537 guestfs_set_ready (g);
6541 guestfs__switch_to_receiving (g);
6542 ctx.cb_sequence = 0;
6543 guestfs_set_reply_callback (g, tgz_out_reply_cb, &ctx);
6544 (void) ml->main_loop_run (ml, g);
6545 guestfs_set_reply_callback (g, NULL, NULL);
6546 if (ctx.cb_sequence != 1) {
6547 error (g, "%s reply failed, see earlier error messages", "guestfs_tgz_out");
6548 guestfs_set_ready (g);
6552 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_TGZ_OUT, serial) == -1) {
6553 guestfs_set_ready (g);
6557 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
6558 error (g, "%s", ctx.err.error_message);
6559 guestfs_set_ready (g);
6563 if (guestfs__receive_file_sync (g, tarball) == -1) {
6564 guestfs_set_ready (g);
6568 guestfs_set_ready (g);
6572 struct mount_ro_ctx {
6573 /* This flag is set by the callbacks, so we know we've done
6574 * the callbacks as expected, and in the right sequence.
6575 * 0 = not called, 1 = reply_cb called.
6578 struct guestfs_message_header hdr;
6579 struct guestfs_message_error err;
6582 static void mount_ro_reply_cb (guestfs_h *g, void *data, XDR *xdr)
6584 guestfs_main_loop *ml = guestfs_get_main_loop (g);
6585 struct mount_ro_ctx *ctx = (struct mount_ro_ctx *) data;
6587 /* This should definitely not happen. */
6588 if (ctx->cb_sequence != 0) {
6589 ctx->cb_sequence = 9999;
6590 error (g, "%s: internal error: reply callback called twice", "guestfs_mount_ro");
6594 ml->main_loop_quit (ml, g);
6596 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
6597 error (g, "%s: failed to parse reply header", "guestfs_mount_ro");
6600 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
6601 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
6602 error (g, "%s: failed to parse reply error", "guestfs_mount_ro");
6608 ctx->cb_sequence = 1;
6611 int guestfs_mount_ro (guestfs_h *g,
6613 const char *mountpoint)
6615 struct guestfs_mount_ro_args args;
6616 struct mount_ro_ctx ctx;
6617 guestfs_main_loop *ml = guestfs_get_main_loop (g);
6620 if (check_state (g, "guestfs_mount_ro") == -1) return -1;
6621 guestfs_set_busy (g);
6623 memset (&ctx, 0, sizeof ctx);
6625 args.device = (char *) device;
6626 args.mountpoint = (char *) mountpoint;
6627 serial = guestfs__send_sync (g, GUESTFS_PROC_MOUNT_RO,
6628 (xdrproc_t) xdr_guestfs_mount_ro_args, (char *) &args);
6630 guestfs_set_ready (g);
6634 guestfs__switch_to_receiving (g);
6635 ctx.cb_sequence = 0;
6636 guestfs_set_reply_callback (g, mount_ro_reply_cb, &ctx);
6637 (void) ml->main_loop_run (ml, g);
6638 guestfs_set_reply_callback (g, NULL, NULL);
6639 if (ctx.cb_sequence != 1) {
6640 error (g, "%s reply failed, see earlier error messages", "guestfs_mount_ro");
6641 guestfs_set_ready (g);
6645 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MOUNT_RO, serial) == -1) {
6646 guestfs_set_ready (g);
6650 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
6651 error (g, "%s", ctx.err.error_message);
6652 guestfs_set_ready (g);
6656 guestfs_set_ready (g);
6660 struct mount_options_ctx {
6661 /* This flag is set by the callbacks, so we know we've done
6662 * the callbacks as expected, and in the right sequence.
6663 * 0 = not called, 1 = reply_cb called.
6666 struct guestfs_message_header hdr;
6667 struct guestfs_message_error err;
6670 static void mount_options_reply_cb (guestfs_h *g, void *data, XDR *xdr)
6672 guestfs_main_loop *ml = guestfs_get_main_loop (g);
6673 struct mount_options_ctx *ctx = (struct mount_options_ctx *) data;
6675 /* This should definitely not happen. */
6676 if (ctx->cb_sequence != 0) {
6677 ctx->cb_sequence = 9999;
6678 error (g, "%s: internal error: reply callback called twice", "guestfs_mount_options");
6682 ml->main_loop_quit (ml, g);
6684 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
6685 error (g, "%s: failed to parse reply header", "guestfs_mount_options");
6688 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
6689 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
6690 error (g, "%s: failed to parse reply error", "guestfs_mount_options");
6696 ctx->cb_sequence = 1;
6699 int guestfs_mount_options (guestfs_h *g,
6700 const char *options,
6702 const char *mountpoint)
6704 struct guestfs_mount_options_args args;
6705 struct mount_options_ctx ctx;
6706 guestfs_main_loop *ml = guestfs_get_main_loop (g);
6709 if (check_state (g, "guestfs_mount_options") == -1) return -1;
6710 guestfs_set_busy (g);
6712 memset (&ctx, 0, sizeof ctx);
6714 args.options = (char *) options;
6715 args.device = (char *) device;
6716 args.mountpoint = (char *) mountpoint;
6717 serial = guestfs__send_sync (g, GUESTFS_PROC_MOUNT_OPTIONS,
6718 (xdrproc_t) xdr_guestfs_mount_options_args, (char *) &args);
6720 guestfs_set_ready (g);
6724 guestfs__switch_to_receiving (g);
6725 ctx.cb_sequence = 0;
6726 guestfs_set_reply_callback (g, mount_options_reply_cb, &ctx);
6727 (void) ml->main_loop_run (ml, g);
6728 guestfs_set_reply_callback (g, NULL, NULL);
6729 if (ctx.cb_sequence != 1) {
6730 error (g, "%s reply failed, see earlier error messages", "guestfs_mount_options");
6731 guestfs_set_ready (g);
6735 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MOUNT_OPTIONS, serial) == -1) {
6736 guestfs_set_ready (g);
6740 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
6741 error (g, "%s", ctx.err.error_message);
6742 guestfs_set_ready (g);
6746 guestfs_set_ready (g);
6750 struct mount_vfs_ctx {
6751 /* This flag is set by the callbacks, so we know we've done
6752 * the callbacks as expected, and in the right sequence.
6753 * 0 = not called, 1 = reply_cb called.
6756 struct guestfs_message_header hdr;
6757 struct guestfs_message_error err;
6760 static void mount_vfs_reply_cb (guestfs_h *g, void *data, XDR *xdr)
6762 guestfs_main_loop *ml = guestfs_get_main_loop (g);
6763 struct mount_vfs_ctx *ctx = (struct mount_vfs_ctx *) data;
6765 /* This should definitely not happen. */
6766 if (ctx->cb_sequence != 0) {
6767 ctx->cb_sequence = 9999;
6768 error (g, "%s: internal error: reply callback called twice", "guestfs_mount_vfs");
6772 ml->main_loop_quit (ml, g);
6774 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
6775 error (g, "%s: failed to parse reply header", "guestfs_mount_vfs");
6778 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
6779 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
6780 error (g, "%s: failed to parse reply error", "guestfs_mount_vfs");
6786 ctx->cb_sequence = 1;
6789 int guestfs_mount_vfs (guestfs_h *g,
6790 const char *options,
6791 const char *vfstype,
6793 const char *mountpoint)
6795 struct guestfs_mount_vfs_args args;
6796 struct mount_vfs_ctx ctx;
6797 guestfs_main_loop *ml = guestfs_get_main_loop (g);
6800 if (check_state (g, "guestfs_mount_vfs") == -1) return -1;
6801 guestfs_set_busy (g);
6803 memset (&ctx, 0, sizeof ctx);
6805 args.options = (char *) options;
6806 args.vfstype = (char *) vfstype;
6807 args.device = (char *) device;
6808 args.mountpoint = (char *) mountpoint;
6809 serial = guestfs__send_sync (g, GUESTFS_PROC_MOUNT_VFS,
6810 (xdrproc_t) xdr_guestfs_mount_vfs_args, (char *) &args);
6812 guestfs_set_ready (g);
6816 guestfs__switch_to_receiving (g);
6817 ctx.cb_sequence = 0;
6818 guestfs_set_reply_callback (g, mount_vfs_reply_cb, &ctx);
6819 (void) ml->main_loop_run (ml, g);
6820 guestfs_set_reply_callback (g, NULL, NULL);
6821 if (ctx.cb_sequence != 1) {
6822 error (g, "%s reply failed, see earlier error messages", "guestfs_mount_vfs");
6823 guestfs_set_ready (g);
6827 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MOUNT_VFS, serial) == -1) {
6828 guestfs_set_ready (g);
6832 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
6833 error (g, "%s", ctx.err.error_message);
6834 guestfs_set_ready (g);
6838 guestfs_set_ready (g);
6843 /* This flag is set by the callbacks, so we know we've done
6844 * the callbacks as expected, and in the right sequence.
6845 * 0 = not called, 1 = reply_cb called.
6848 struct guestfs_message_header hdr;
6849 struct guestfs_message_error err;
6850 struct guestfs_debug_ret ret;
6853 static void debug_reply_cb (guestfs_h *g, void *data, XDR *xdr)
6855 guestfs_main_loop *ml = guestfs_get_main_loop (g);
6856 struct debug_ctx *ctx = (struct debug_ctx *) data;
6858 /* This should definitely not happen. */
6859 if (ctx->cb_sequence != 0) {
6860 ctx->cb_sequence = 9999;
6861 error (g, "%s: internal error: reply callback called twice", "guestfs_debug");
6865 ml->main_loop_quit (ml, g);
6867 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
6868 error (g, "%s: failed to parse reply header", "guestfs_debug");
6871 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
6872 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
6873 error (g, "%s: failed to parse reply error", "guestfs_debug");
6878 if (!xdr_guestfs_debug_ret (xdr, &ctx->ret)) {
6879 error (g, "%s: failed to parse reply", "guestfs_debug");
6883 ctx->cb_sequence = 1;
6886 char *guestfs_debug (guestfs_h *g,
6888 char * const* const extraargs)
6890 struct guestfs_debug_args args;
6891 struct debug_ctx ctx;
6892 guestfs_main_loop *ml = guestfs_get_main_loop (g);
6895 if (check_state (g, "guestfs_debug") == -1) return NULL;
6896 guestfs_set_busy (g);
6898 memset (&ctx, 0, sizeof ctx);
6900 args.subcmd = (char *) subcmd;
6901 args.extraargs.extraargs_val = (char **) extraargs;
6902 for (args.extraargs.extraargs_len = 0; extraargs[args.extraargs.extraargs_len]; args.extraargs.extraargs_len++) ;
6903 serial = guestfs__send_sync (g, GUESTFS_PROC_DEBUG,
6904 (xdrproc_t) xdr_guestfs_debug_args, (char *) &args);
6906 guestfs_set_ready (g);
6910 guestfs__switch_to_receiving (g);
6911 ctx.cb_sequence = 0;
6912 guestfs_set_reply_callback (g, debug_reply_cb, &ctx);
6913 (void) ml->main_loop_run (ml, g);
6914 guestfs_set_reply_callback (g, NULL, NULL);
6915 if (ctx.cb_sequence != 1) {
6916 error (g, "%s reply failed, see earlier error messages", "guestfs_debug");
6917 guestfs_set_ready (g);
6921 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_DEBUG, serial) == -1) {
6922 guestfs_set_ready (g);
6926 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
6927 error (g, "%s", ctx.err.error_message);
6928 guestfs_set_ready (g);
6932 guestfs_set_ready (g);
6933 return ctx.ret.result; /* caller will free */
6936 struct lvremove_ctx {
6937 /* This flag is set by the callbacks, so we know we've done
6938 * the callbacks as expected, and in the right sequence.
6939 * 0 = not called, 1 = reply_cb called.
6942 struct guestfs_message_header hdr;
6943 struct guestfs_message_error err;
6946 static void lvremove_reply_cb (guestfs_h *g, void *data, XDR *xdr)
6948 guestfs_main_loop *ml = guestfs_get_main_loop (g);
6949 struct lvremove_ctx *ctx = (struct lvremove_ctx *) data;
6951 /* This should definitely not happen. */
6952 if (ctx->cb_sequence != 0) {
6953 ctx->cb_sequence = 9999;
6954 error (g, "%s: internal error: reply callback called twice", "guestfs_lvremove");
6958 ml->main_loop_quit (ml, g);
6960 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
6961 error (g, "%s: failed to parse reply header", "guestfs_lvremove");
6964 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
6965 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
6966 error (g, "%s: failed to parse reply error", "guestfs_lvremove");
6972 ctx->cb_sequence = 1;
6975 int guestfs_lvremove (guestfs_h *g,
6978 struct guestfs_lvremove_args args;
6979 struct lvremove_ctx ctx;
6980 guestfs_main_loop *ml = guestfs_get_main_loop (g);
6983 if (check_state (g, "guestfs_lvremove") == -1) return -1;
6984 guestfs_set_busy (g);
6986 memset (&ctx, 0, sizeof ctx);
6988 args.device = (char *) device;
6989 serial = guestfs__send_sync (g, GUESTFS_PROC_LVREMOVE,
6990 (xdrproc_t) xdr_guestfs_lvremove_args, (char *) &args);
6992 guestfs_set_ready (g);
6996 guestfs__switch_to_receiving (g);
6997 ctx.cb_sequence = 0;
6998 guestfs_set_reply_callback (g, lvremove_reply_cb, &ctx);
6999 (void) ml->main_loop_run (ml, g);
7000 guestfs_set_reply_callback (g, NULL, NULL);
7001 if (ctx.cb_sequence != 1) {
7002 error (g, "%s reply failed, see earlier error messages", "guestfs_lvremove");
7003 guestfs_set_ready (g);
7007 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_LVREMOVE, serial) == -1) {
7008 guestfs_set_ready (g);
7012 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
7013 error (g, "%s", ctx.err.error_message);
7014 guestfs_set_ready (g);
7018 guestfs_set_ready (g);
7022 struct vgremove_ctx {
7023 /* This flag is set by the callbacks, so we know we've done
7024 * the callbacks as expected, and in the right sequence.
7025 * 0 = not called, 1 = reply_cb called.
7028 struct guestfs_message_header hdr;
7029 struct guestfs_message_error err;
7032 static void vgremove_reply_cb (guestfs_h *g, void *data, XDR *xdr)
7034 guestfs_main_loop *ml = guestfs_get_main_loop (g);
7035 struct vgremove_ctx *ctx = (struct vgremove_ctx *) data;
7037 /* This should definitely not happen. */
7038 if (ctx->cb_sequence != 0) {
7039 ctx->cb_sequence = 9999;
7040 error (g, "%s: internal error: reply callback called twice", "guestfs_vgremove");
7044 ml->main_loop_quit (ml, g);
7046 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
7047 error (g, "%s: failed to parse reply header", "guestfs_vgremove");
7050 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
7051 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
7052 error (g, "%s: failed to parse reply error", "guestfs_vgremove");
7058 ctx->cb_sequence = 1;
7061 int guestfs_vgremove (guestfs_h *g,
7064 struct guestfs_vgremove_args args;
7065 struct vgremove_ctx ctx;
7066 guestfs_main_loop *ml = guestfs_get_main_loop (g);
7069 if (check_state (g, "guestfs_vgremove") == -1) return -1;
7070 guestfs_set_busy (g);
7072 memset (&ctx, 0, sizeof ctx);
7074 args.vgname = (char *) vgname;
7075 serial = guestfs__send_sync (g, GUESTFS_PROC_VGREMOVE,
7076 (xdrproc_t) xdr_guestfs_vgremove_args, (char *) &args);
7078 guestfs_set_ready (g);
7082 guestfs__switch_to_receiving (g);
7083 ctx.cb_sequence = 0;
7084 guestfs_set_reply_callback (g, vgremove_reply_cb, &ctx);
7085 (void) ml->main_loop_run (ml, g);
7086 guestfs_set_reply_callback (g, NULL, NULL);
7087 if (ctx.cb_sequence != 1) {
7088 error (g, "%s reply failed, see earlier error messages", "guestfs_vgremove");
7089 guestfs_set_ready (g);
7093 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_VGREMOVE, serial) == -1) {
7094 guestfs_set_ready (g);
7098 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
7099 error (g, "%s", ctx.err.error_message);
7100 guestfs_set_ready (g);
7104 guestfs_set_ready (g);
7108 struct pvremove_ctx {
7109 /* This flag is set by the callbacks, so we know we've done
7110 * the callbacks as expected, and in the right sequence.
7111 * 0 = not called, 1 = reply_cb called.
7114 struct guestfs_message_header hdr;
7115 struct guestfs_message_error err;
7118 static void pvremove_reply_cb (guestfs_h *g, void *data, XDR *xdr)
7120 guestfs_main_loop *ml = guestfs_get_main_loop (g);
7121 struct pvremove_ctx *ctx = (struct pvremove_ctx *) data;
7123 /* This should definitely not happen. */
7124 if (ctx->cb_sequence != 0) {
7125 ctx->cb_sequence = 9999;
7126 error (g, "%s: internal error: reply callback called twice", "guestfs_pvremove");
7130 ml->main_loop_quit (ml, g);
7132 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
7133 error (g, "%s: failed to parse reply header", "guestfs_pvremove");
7136 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
7137 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
7138 error (g, "%s: failed to parse reply error", "guestfs_pvremove");
7144 ctx->cb_sequence = 1;
7147 int guestfs_pvremove (guestfs_h *g,
7150 struct guestfs_pvremove_args args;
7151 struct pvremove_ctx ctx;
7152 guestfs_main_loop *ml = guestfs_get_main_loop (g);
7155 if (check_state (g, "guestfs_pvremove") == -1) return -1;
7156 guestfs_set_busy (g);
7158 memset (&ctx, 0, sizeof ctx);
7160 args.device = (char *) device;
7161 serial = guestfs__send_sync (g, GUESTFS_PROC_PVREMOVE,
7162 (xdrproc_t) xdr_guestfs_pvremove_args, (char *) &args);
7164 guestfs_set_ready (g);
7168 guestfs__switch_to_receiving (g);
7169 ctx.cb_sequence = 0;
7170 guestfs_set_reply_callback (g, pvremove_reply_cb, &ctx);
7171 (void) ml->main_loop_run (ml, g);
7172 guestfs_set_reply_callback (g, NULL, NULL);
7173 if (ctx.cb_sequence != 1) {
7174 error (g, "%s reply failed, see earlier error messages", "guestfs_pvremove");
7175 guestfs_set_ready (g);
7179 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_PVREMOVE, serial) == -1) {
7180 guestfs_set_ready (g);
7184 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
7185 error (g, "%s", ctx.err.error_message);
7186 guestfs_set_ready (g);
7190 guestfs_set_ready (g);
7194 struct set_e2label_ctx {
7195 /* This flag is set by the callbacks, so we know we've done
7196 * the callbacks as expected, and in the right sequence.
7197 * 0 = not called, 1 = reply_cb called.
7200 struct guestfs_message_header hdr;
7201 struct guestfs_message_error err;
7204 static void set_e2label_reply_cb (guestfs_h *g, void *data, XDR *xdr)
7206 guestfs_main_loop *ml = guestfs_get_main_loop (g);
7207 struct set_e2label_ctx *ctx = (struct set_e2label_ctx *) data;
7209 /* This should definitely not happen. */
7210 if (ctx->cb_sequence != 0) {
7211 ctx->cb_sequence = 9999;
7212 error (g, "%s: internal error: reply callback called twice", "guestfs_set_e2label");
7216 ml->main_loop_quit (ml, g);
7218 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
7219 error (g, "%s: failed to parse reply header", "guestfs_set_e2label");
7222 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
7223 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
7224 error (g, "%s: failed to parse reply error", "guestfs_set_e2label");
7230 ctx->cb_sequence = 1;
7233 int guestfs_set_e2label (guestfs_h *g,
7237 struct guestfs_set_e2label_args args;
7238 struct set_e2label_ctx ctx;
7239 guestfs_main_loop *ml = guestfs_get_main_loop (g);
7242 if (check_state (g, "guestfs_set_e2label") == -1) return -1;
7243 guestfs_set_busy (g);
7245 memset (&ctx, 0, sizeof ctx);
7247 args.device = (char *) device;
7248 args.label = (char *) label;
7249 serial = guestfs__send_sync (g, GUESTFS_PROC_SET_E2LABEL,
7250 (xdrproc_t) xdr_guestfs_set_e2label_args, (char *) &args);
7252 guestfs_set_ready (g);
7256 guestfs__switch_to_receiving (g);
7257 ctx.cb_sequence = 0;
7258 guestfs_set_reply_callback (g, set_e2label_reply_cb, &ctx);
7259 (void) ml->main_loop_run (ml, g);
7260 guestfs_set_reply_callback (g, NULL, NULL);
7261 if (ctx.cb_sequence != 1) {
7262 error (g, "%s reply failed, see earlier error messages", "guestfs_set_e2label");
7263 guestfs_set_ready (g);
7267 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_SET_E2LABEL, serial) == -1) {
7268 guestfs_set_ready (g);
7272 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
7273 error (g, "%s", ctx.err.error_message);
7274 guestfs_set_ready (g);
7278 guestfs_set_ready (g);
7282 struct get_e2label_ctx {
7283 /* This flag is set by the callbacks, so we know we've done
7284 * the callbacks as expected, and in the right sequence.
7285 * 0 = not called, 1 = reply_cb called.
7288 struct guestfs_message_header hdr;
7289 struct guestfs_message_error err;
7290 struct guestfs_get_e2label_ret ret;
7293 static void get_e2label_reply_cb (guestfs_h *g, void *data, XDR *xdr)
7295 guestfs_main_loop *ml = guestfs_get_main_loop (g);
7296 struct get_e2label_ctx *ctx = (struct get_e2label_ctx *) data;
7298 /* This should definitely not happen. */
7299 if (ctx->cb_sequence != 0) {
7300 ctx->cb_sequence = 9999;
7301 error (g, "%s: internal error: reply callback called twice", "guestfs_get_e2label");
7305 ml->main_loop_quit (ml, g);
7307 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
7308 error (g, "%s: failed to parse reply header", "guestfs_get_e2label");
7311 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
7312 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
7313 error (g, "%s: failed to parse reply error", "guestfs_get_e2label");
7318 if (!xdr_guestfs_get_e2label_ret (xdr, &ctx->ret)) {
7319 error (g, "%s: failed to parse reply", "guestfs_get_e2label");
7323 ctx->cb_sequence = 1;
7326 char *guestfs_get_e2label (guestfs_h *g,
7329 struct guestfs_get_e2label_args args;
7330 struct get_e2label_ctx ctx;
7331 guestfs_main_loop *ml = guestfs_get_main_loop (g);
7334 if (check_state (g, "guestfs_get_e2label") == -1) return NULL;
7335 guestfs_set_busy (g);
7337 memset (&ctx, 0, sizeof ctx);
7339 args.device = (char *) device;
7340 serial = guestfs__send_sync (g, GUESTFS_PROC_GET_E2LABEL,
7341 (xdrproc_t) xdr_guestfs_get_e2label_args, (char *) &args);
7343 guestfs_set_ready (g);
7347 guestfs__switch_to_receiving (g);
7348 ctx.cb_sequence = 0;
7349 guestfs_set_reply_callback (g, get_e2label_reply_cb, &ctx);
7350 (void) ml->main_loop_run (ml, g);
7351 guestfs_set_reply_callback (g, NULL, NULL);
7352 if (ctx.cb_sequence != 1) {
7353 error (g, "%s reply failed, see earlier error messages", "guestfs_get_e2label");
7354 guestfs_set_ready (g);
7358 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_GET_E2LABEL, serial) == -1) {
7359 guestfs_set_ready (g);
7363 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
7364 error (g, "%s", ctx.err.error_message);
7365 guestfs_set_ready (g);
7369 guestfs_set_ready (g);
7370 return ctx.ret.label; /* caller will free */
7373 struct set_e2uuid_ctx {
7374 /* This flag is set by the callbacks, so we know we've done
7375 * the callbacks as expected, and in the right sequence.
7376 * 0 = not called, 1 = reply_cb called.
7379 struct guestfs_message_header hdr;
7380 struct guestfs_message_error err;
7383 static void set_e2uuid_reply_cb (guestfs_h *g, void *data, XDR *xdr)
7385 guestfs_main_loop *ml = guestfs_get_main_loop (g);
7386 struct set_e2uuid_ctx *ctx = (struct set_e2uuid_ctx *) data;
7388 /* This should definitely not happen. */
7389 if (ctx->cb_sequence != 0) {
7390 ctx->cb_sequence = 9999;
7391 error (g, "%s: internal error: reply callback called twice", "guestfs_set_e2uuid");
7395 ml->main_loop_quit (ml, g);
7397 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
7398 error (g, "%s: failed to parse reply header", "guestfs_set_e2uuid");
7401 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
7402 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
7403 error (g, "%s: failed to parse reply error", "guestfs_set_e2uuid");
7409 ctx->cb_sequence = 1;
7412 int guestfs_set_e2uuid (guestfs_h *g,
7416 struct guestfs_set_e2uuid_args args;
7417 struct set_e2uuid_ctx ctx;
7418 guestfs_main_loop *ml = guestfs_get_main_loop (g);
7421 if (check_state (g, "guestfs_set_e2uuid") == -1) return -1;
7422 guestfs_set_busy (g);
7424 memset (&ctx, 0, sizeof ctx);
7426 args.device = (char *) device;
7427 args.uuid = (char *) uuid;
7428 serial = guestfs__send_sync (g, GUESTFS_PROC_SET_E2UUID,
7429 (xdrproc_t) xdr_guestfs_set_e2uuid_args, (char *) &args);
7431 guestfs_set_ready (g);
7435 guestfs__switch_to_receiving (g);
7436 ctx.cb_sequence = 0;
7437 guestfs_set_reply_callback (g, set_e2uuid_reply_cb, &ctx);
7438 (void) ml->main_loop_run (ml, g);
7439 guestfs_set_reply_callback (g, NULL, NULL);
7440 if (ctx.cb_sequence != 1) {
7441 error (g, "%s reply failed, see earlier error messages", "guestfs_set_e2uuid");
7442 guestfs_set_ready (g);
7446 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_SET_E2UUID, serial) == -1) {
7447 guestfs_set_ready (g);
7451 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
7452 error (g, "%s", ctx.err.error_message);
7453 guestfs_set_ready (g);
7457 guestfs_set_ready (g);
7461 struct get_e2uuid_ctx {
7462 /* This flag is set by the callbacks, so we know we've done
7463 * the callbacks as expected, and in the right sequence.
7464 * 0 = not called, 1 = reply_cb called.
7467 struct guestfs_message_header hdr;
7468 struct guestfs_message_error err;
7469 struct guestfs_get_e2uuid_ret ret;
7472 static void get_e2uuid_reply_cb (guestfs_h *g, void *data, XDR *xdr)
7474 guestfs_main_loop *ml = guestfs_get_main_loop (g);
7475 struct get_e2uuid_ctx *ctx = (struct get_e2uuid_ctx *) data;
7477 /* This should definitely not happen. */
7478 if (ctx->cb_sequence != 0) {
7479 ctx->cb_sequence = 9999;
7480 error (g, "%s: internal error: reply callback called twice", "guestfs_get_e2uuid");
7484 ml->main_loop_quit (ml, g);
7486 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
7487 error (g, "%s: failed to parse reply header", "guestfs_get_e2uuid");
7490 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
7491 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
7492 error (g, "%s: failed to parse reply error", "guestfs_get_e2uuid");
7497 if (!xdr_guestfs_get_e2uuid_ret (xdr, &ctx->ret)) {
7498 error (g, "%s: failed to parse reply", "guestfs_get_e2uuid");
7502 ctx->cb_sequence = 1;
7505 char *guestfs_get_e2uuid (guestfs_h *g,
7508 struct guestfs_get_e2uuid_args args;
7509 struct get_e2uuid_ctx ctx;
7510 guestfs_main_loop *ml = guestfs_get_main_loop (g);
7513 if (check_state (g, "guestfs_get_e2uuid") == -1) return NULL;
7514 guestfs_set_busy (g);
7516 memset (&ctx, 0, sizeof ctx);
7518 args.device = (char *) device;
7519 serial = guestfs__send_sync (g, GUESTFS_PROC_GET_E2UUID,
7520 (xdrproc_t) xdr_guestfs_get_e2uuid_args, (char *) &args);
7522 guestfs_set_ready (g);
7526 guestfs__switch_to_receiving (g);
7527 ctx.cb_sequence = 0;
7528 guestfs_set_reply_callback (g, get_e2uuid_reply_cb, &ctx);
7529 (void) ml->main_loop_run (ml, g);
7530 guestfs_set_reply_callback (g, NULL, NULL);
7531 if (ctx.cb_sequence != 1) {
7532 error (g, "%s reply failed, see earlier error messages", "guestfs_get_e2uuid");
7533 guestfs_set_ready (g);
7537 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_GET_E2UUID, serial) == -1) {
7538 guestfs_set_ready (g);
7542 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
7543 error (g, "%s", ctx.err.error_message);
7544 guestfs_set_ready (g);
7548 guestfs_set_ready (g);
7549 return ctx.ret.uuid; /* caller will free */
7553 /* This flag is set by the callbacks, so we know we've done
7554 * the callbacks as expected, and in the right sequence.
7555 * 0 = not called, 1 = reply_cb called.
7558 struct guestfs_message_header hdr;
7559 struct guestfs_message_error err;
7560 struct guestfs_fsck_ret ret;
7563 static void fsck_reply_cb (guestfs_h *g, void *data, XDR *xdr)
7565 guestfs_main_loop *ml = guestfs_get_main_loop (g);
7566 struct fsck_ctx *ctx = (struct fsck_ctx *) data;
7568 /* This should definitely not happen. */
7569 if (ctx->cb_sequence != 0) {
7570 ctx->cb_sequence = 9999;
7571 error (g, "%s: internal error: reply callback called twice", "guestfs_fsck");
7575 ml->main_loop_quit (ml, g);
7577 if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
7578 error (g, "%s: failed to parse reply header", "guestfs_fsck");
7581 if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
7582 if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
7583 error (g, "%s: failed to parse reply error", "guestfs_fsck");
7588 if (!xdr_guestfs_fsck_ret (xdr, &ctx->ret)) {
7589 error (g, "%s: failed to parse reply", "guestfs_fsck");
7593 ctx->cb_sequence = 1;
7596 int guestfs_fsck (guestfs_h *g,
7600 struct guestfs_fsck_args args;
7601 struct fsck_ctx ctx;
7602 guestfs_main_loop *ml = guestfs_get_main_loop (g);
7605 if (check_state (g, "guestfs_fsck") == -1) return -1;
7606 guestfs_set_busy (g);
7608 memset (&ctx, 0, sizeof ctx);
7610 args.fstype = (char *) fstype;
7611 args.device = (char *) device;
7612 serial = guestfs__send_sync (g, GUESTFS_PROC_FSCK,
7613 (xdrproc_t) xdr_guestfs_fsck_args, (char *) &args);
7615 guestfs_set_ready (g);
7619 guestfs__switch_to_receiving (g);
7620 ctx.cb_sequence = 0;
7621 guestfs_set_reply_callback (g, fsck_reply_cb, &ctx);
7622 (void) ml->main_loop_run (ml, g);
7623 guestfs_set_reply_callback (g, NULL, NULL);
7624 if (ctx.cb_sequence != 1) {
7625 error (g, "%s reply failed, see earlier error messages", "guestfs_fsck");
7626 guestfs_set_ready (g);
7630 if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_FSCK, serial) == -1) {
7631 guestfs_set_ready (g);
7635 if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
7636 error (g, "%s", ctx.err.error_message);
7637 guestfs_set_ready (g);
7641 guestfs_set_ready (g);
7642 return ctx.ret.status;