From: Richard Jones Date: Sat, 18 Apr 2009 21:33:15 +0000 (+0100) Subject: Begin to add the upload and download commands. X-Git-Tag: 1.0.2~11 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=bb07a7f858da5d07c57360e62c0ddfd24ce6be45;p=libguestfs.git Begin to add the upload and download commands. --- diff --git a/daemon/actions.h b/daemon/actions.h index 76ce8fc..01ef882 100644 --- a/daemon/actions.h +++ b/daemon/actions.h @@ -86,3 +86,5 @@ extern int64_t do_blockdev_getsz (const char *device); extern int64_t do_blockdev_getsize64 (const char *device); extern int do_blockdev_flushbufs (const char *device); extern int do_blockdev_rereadpt (const char *device); +extern int do_upload (const char *remotefilename); +extern int do_download (const char *remotefilename); diff --git a/daemon/stubs.c b/daemon/stubs.c index dfadb83..df067cc 100644 --- a/daemon/stubs.c +++ b/daemon/stubs.c @@ -1584,6 +1584,54 @@ done: xdr_free ((xdrproc_t) xdr_guestfs_blockdev_rereadpt_args, (char *) &args); } +static void upload_stub (XDR *xdr_in) +{ + int r; + struct guestfs_upload_args args; + const char *remotefilename; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_upload_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "upload"); + return; + } + remotefilename = args.remotefilename; + + r = do_upload (remotefilename); + if (r == -1) + /* do_upload has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_upload_args, (char *) &args); +} + +static void download_stub (XDR *xdr_in) +{ + int r; + struct guestfs_download_args args; + const char *remotefilename; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_download_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "download"); + return; + } + remotefilename = args.remotefilename; + + r = do_download (remotefilename); + if (r == -1) + /* do_download has already called reply_with_error */ + goto done; + + /* do_download has already sent a reply */ +done: + xdr_free ((xdrproc_t) xdr_guestfs_download_args, (char *) &args); +} + void dispatch_incoming_message (XDR *xdr_in) { switch (proc_nr) { @@ -1782,6 +1830,12 @@ void dispatch_incoming_message (XDR *xdr_in) case GUESTFS_PROC_BLOCKDEV_REREADPT: blockdev_rereadpt_stub (xdr_in); break; + case GUESTFS_PROC_UPLOAD: + upload_stub (xdr_in); + break; + case GUESTFS_PROC_DOWNLOAD: + download_stub (xdr_in); + break; default: reply_with_error ("dispatch_incoming_message: unknown procedure number %d", proc_nr); } diff --git a/fish/cmds.c b/fish/cmds.c index 5270912..9cd23c5 100644 --- a/fish/cmds.c +++ b/fish/cmds.c @@ -62,6 +62,7 @@ void list_commands (void) printf ("%-20s %s\n", "command", "run a command from the guest filesystem"); printf ("%-20s %s\n", "command-lines", "run a command, returning lines"); printf ("%-20s %s\n", "config", "add qemu parameters"); + printf ("%-20s %s\n", "download", "download a file to the local machine"); printf ("%-20s %s\n", "exists", "test if file or directory exists"); printf ("%-20s %s\n", "file", "determine file type"); printf ("%-20s %s\n", "get-autosync", "get autosync mode"); @@ -108,6 +109,7 @@ void list_commands (void) printf ("%-20s %s\n", "tune2fs-l", "get ext2/ext3 superblock details"); printf ("%-20s %s\n", "umount", "unmount a filesystem"); printf ("%-20s %s\n", "umount-all", "unmount all filesystems"); + printf ("%-20s %s\n", "upload", "upload a file from the local machine"); printf ("%-20s %s\n", "vgcreate", "create an LVM volume group"); printf ("%-20s %s\n", "vgs", "list the LVM volume groups (VGs)"); printf ("%-20s %s\n", "vgs-full", "list the LVM volume groups (VGs)"); @@ -360,6 +362,12 @@ void display_command (const char *cmd) if (strcasecmp (cmd, "blockdev_rereadpt") == 0 || strcasecmp (cmd, "blockdev-rereadpt") == 0) pod2text ("blockdev-rereadpt - reread partition table", " blockdev-rereadpt \n\nReread the partition table on C.\n\nThis uses the L command."); else + if (strcasecmp (cmd, "upload") == 0) + pod2text ("upload - upload a file from the local machine", " upload \n\nUpload local file C to C on the\nfilesystem.\n\nC can also be a named pipe.\n\nSee also C."); + else + if (strcasecmp (cmd, "download") == 0) + pod2text ("download - download a file to the local machine", " download \n\nDownload file C and save it as C\non the local machine.\n\nC can also be a named pipe.\n\nSee also C, C."); + else display_builtin_command (cmd); } @@ -1738,6 +1746,38 @@ static int run_blockdev_rereadpt (const char *cmd, int argc, char *argv[]) return r; } +static int run_upload (const char *cmd, int argc, char *argv[]) +{ + int r; + const char *filename; + const char *remotefilename; + if (argc != 2) { + fprintf (stderr, "%s should have 2 parameter(s)\n", cmd); + fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd); + return -1; + } + filename = strcmp (argv[0], "-") != 0 ? argv[0] : "/dev/stdin"; + remotefilename = argv[1]; + r = guestfs_upload (g, filename, remotefilename); + return r; +} + +static int run_download (const char *cmd, int argc, char *argv[]) +{ + int r; + const char *remotefilename; + const char *filename; + if (argc != 2) { + fprintf (stderr, "%s should have 2 parameter(s)\n", cmd); + fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd); + return -1; + } + remotefilename = argv[0]; + filename = strcmp (argv[1], "-") != 0 ? argv[1] : "/dev/stdout"; + r = guestfs_download (g, remotefilename, filename); + return r; +} + int run_action (const char *cmd, int argc, char *argv[]) { if (strcasecmp (cmd, "launch") == 0 || strcasecmp (cmd, "run") == 0) @@ -1983,6 +2023,12 @@ int run_action (const char *cmd, int argc, char *argv[]) if (strcasecmp (cmd, "blockdev_rereadpt") == 0 || strcasecmp (cmd, "blockdev-rereadpt") == 0) return run_blockdev_rereadpt (cmd, argc, argv); else + if (strcasecmp (cmd, "upload") == 0) + return run_upload (cmd, argc, argv); + else + if (strcasecmp (cmd, "download") == 0) + return run_download (cmd, argc, argv); + else { fprintf (stderr, "%s: unknown command\n", cmd); return -1; diff --git a/fish/completion.c b/fish/completion.c index a346ccb..a0ba5ae 100644 --- a/fish/completion.c +++ b/fish/completion.c @@ -68,6 +68,7 @@ static const char *commands[] = { "command", "command-lines", "config", + "download", "exists", "file", "get-autosync", @@ -118,6 +119,7 @@ static const char *commands[] = { "umount-all", "unmount", "unmount-all", + "upload", "verbose", "vgcreate", "vgs", diff --git a/guestfish-actions.pod b/guestfish-actions.pod index 6fa8649..5013a28 100644 --- a/guestfish-actions.pod +++ b/guestfish-actions.pod @@ -358,6 +358,19 @@ The first character of C string must be a C<-> (dash). C can be NULL. +=head2 download + + download remotefilename (filename|-) + +Download file C and save it as C +on the local machine. + +C can also be a named pipe. + +See also C, C. + +Use C<-> instead of a filename to read/write from stdin/stdout. + =head2 exists exists path @@ -803,6 +816,19 @@ This unmounts all mounted filesystems. Some internal mounts are not unmounted by this call. +=head2 upload + + upload (filename|-) remotefilename + +Upload local file C to C on the +filesystem. + +C can also be a named pipe. + +See also C. + +Use C<-> instead of a filename to read/write from stdin/stdout. + =head2 vgcreate vgcreate volgroup physvols,... diff --git a/guestfs-actions.pod b/guestfs-actions.pod index 8667340..21f424f 100644 --- a/guestfs-actions.pod +++ b/guestfs-actions.pod @@ -472,6 +472,21 @@ C can be NULL. This function returns 0 on success or -1 on error. +=head2 guestfs_download + + int guestfs_download (guestfs_h *handle, + const char *remotefilename, + const char *filename); + +Download file C and save it as C +on the local machine. + +C can also be a named pipe. + +See also C, C. + +This function returns 0 on success or -1 on error. + =head2 guestfs_exists int guestfs_exists (guestfs_h *handle, @@ -1079,6 +1094,21 @@ Some internal mounts are not unmounted by this call. This function returns 0 on success or -1 on error. +=head2 guestfs_upload + + int guestfs_upload (guestfs_h *handle, + const char *filename, + const char *remotefilename); + +Upload local file C to C on the +filesystem. + +C can also be a named pipe. + +See also C. + +This function returns 0 on success or -1 on error. + =head2 guestfs_vgcreate int guestfs_vgcreate (guestfs_h *handle, diff --git a/ocaml/guestfs.ml b/ocaml/guestfs.ml index 0ea77c7..f45533b 100644 --- a/ocaml/guestfs.ml +++ b/ocaml/guestfs.ml @@ -197,3 +197,5 @@ external blockdev_getsz : t -> string -> int64 = "ocaml_guestfs_blockdev_getsz" external blockdev_getsize64 : t -> string -> int64 = "ocaml_guestfs_blockdev_getsize64" external blockdev_flushbufs : t -> string -> unit = "ocaml_guestfs_blockdev_flushbufs" external blockdev_rereadpt : t -> string -> unit = "ocaml_guestfs_blockdev_rereadpt" +external upload : t -> string -> string -> unit = "ocaml_guestfs_upload" +external download : t -> string -> string -> unit = "ocaml_guestfs_download" diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli index 6c76363..2257fc0 100644 --- a/ocaml/guestfs.mli +++ b/ocaml/guestfs.mli @@ -370,3 +370,9 @@ val blockdev_flushbufs : t -> string -> unit val blockdev_rereadpt : t -> string -> unit (** reread partition table *) +val upload : t -> string -> string -> unit +(** upload a file from the local machine *) + +val download : t -> string -> string -> unit +(** download a file to the local machine *) + diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c index dd2f6f4..4d7b350 100644 --- a/ocaml/guestfs_c_actions.c +++ b/ocaml/guestfs_c_actions.c @@ -2275,3 +2275,51 @@ ocaml_guestfs_blockdev_rereadpt (value gv, value devicev) CAMLreturn (rv); } +CAMLprim value +ocaml_guestfs_upload (value gv, value filenamev, value remotefilenamev) +{ + CAMLparam3 (gv, filenamev, remotefilenamev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("upload: used handle after closing it"); + + const char *filename = String_val (filenamev); + const char *remotefilename = String_val (remotefilenamev); + int r; + + caml_enter_blocking_section (); + r = guestfs_upload (g, filename, remotefilename); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "upload"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_download (value gv, value remotefilenamev, value filenamev) +{ + CAMLparam3 (gv, remotefilenamev, filenamev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("download: used handle after closing it"); + + const char *remotefilename = String_val (remotefilenamev); + const char *filename = String_val (filenamev); + int r; + + caml_enter_blocking_section (); + r = guestfs_download (g, remotefilename, filename); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "download"); + + rv = Val_unit; + CAMLreturn (rv); +} + diff --git a/perl/Guestfs.xs b/perl/Guestfs.xs index e4a1b50..e498842 100644 --- a/perl/Guestfs.xs +++ b/perl/Guestfs.xs @@ -1297,3 +1297,27 @@ PREINIT: if (r == -1) croak ("blockdev_rereadpt: %s", guestfs_last_error (g)); +void +upload (g, filename, remotefilename) + guestfs_h *g; + char *filename; + char *remotefilename; +PREINIT: + int r; + PPCODE: + r = guestfs_upload (g, filename, remotefilename); + if (r == -1) + croak ("upload: %s", guestfs_last_error (g)); + +void +download (g, remotefilename, filename) + guestfs_h *g; + char *remotefilename; + char *filename; +PREINIT: + int r; + PPCODE: + r = guestfs_download (g, remotefilename, filename); + if (r == -1) + croak ("download: %s", guestfs_last_error (g)); + diff --git a/perl/lib/Sys/Guestfs.pm b/perl/lib/Sys/Guestfs.pm index 7122314..f624c24 100644 --- a/perl/lib/Sys/Guestfs.pm +++ b/perl/lib/Sys/Guestfs.pm @@ -389,6 +389,15 @@ The first character of C string must be a C<-> (dash). C can be NULL. +=item $h->download ($remotefilename, $filename); + +Download file C and save it as C +on the local machine. + +C can also be a named pipe. + +See also C<$h-Eupload>, C<$h-Ecat>. + =item $existsflag = $h->exists ($path); This returns C if and only if there is a file, directory @@ -742,6 +751,15 @@ This unmounts all mounted filesystems. Some internal mounts are not unmounted by this call. +=item $h->upload ($filename, $remotefilename); + +Upload local file C to C on the +filesystem. + +C can also be a named pipe. + +See also C<$h-Edownload>. + =item $h->vgcreate ($volgroup, \@physvols); This creates an LVM volume group called C diff --git a/python/guestfs-py.c b/python/guestfs-py.c index d1f0a9e..69446ae 100644 --- a/python/guestfs-py.c +++ b/python/guestfs-py.c @@ -2436,6 +2436,58 @@ py_guestfs_blockdev_rereadpt (PyObject *self, PyObject *args) return py_r; } +static PyObject * +py_guestfs_upload (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + int r; + const char *filename; + const char *remotefilename; + + if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_upload", + &py_g, &filename, &remotefilename)) + return NULL; + g = get_handle (py_g); + + r = guestfs_upload (g, filename, remotefilename); + if (r == -1) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + Py_INCREF (Py_None); + py_r = Py_None; + return py_r; +} + +static PyObject * +py_guestfs_download (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + int r; + const char *remotefilename; + const char *filename; + + if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_download", + &py_g, &remotefilename, &filename)) + return NULL; + g = get_handle (py_g); + + r = guestfs_download (g, remotefilename, filename); + if (r == -1) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + Py_INCREF (Py_None); + py_r = Py_None; + return py_r; +} + static PyMethodDef methods[] = { { (char *) "create", py_guestfs_create, METH_VARARGS, NULL }, { (char *) "close", py_guestfs_close, METH_VARARGS, NULL }, @@ -2521,6 +2573,8 @@ static PyMethodDef methods[] = { { (char *) "blockdev_getsize64", py_guestfs_blockdev_getsize64, METH_VARARGS, NULL }, { (char *) "blockdev_flushbufs", py_guestfs_blockdev_flushbufs, METH_VARARGS, NULL }, { (char *) "blockdev_rereadpt", py_guestfs_blockdev_rereadpt, METH_VARARGS, NULL }, + { (char *) "upload", py_guestfs_upload, METH_VARARGS, NULL }, + { (char *) "download", py_guestfs_download, METH_VARARGS, NULL }, { NULL, NULL, 0, NULL } }; diff --git a/python/guestfs.py b/python/guestfs.py index 943f80a..fd495fd 100644 --- a/python/guestfs.py +++ b/python/guestfs.py @@ -923,3 +923,23 @@ class GuestFS: """ return libguestfsmod.blockdev_rereadpt (self._o, device) + def upload (self, filename, remotefilename): + u"""Upload local file "filename" to "remotefilename" on the + filesystem. + + "filename" can also be a named pipe. + + See also "g.download". + """ + return libguestfsmod.upload (self._o, filename, remotefilename) + + def download (self, remotefilename, filename): + u"""Download file "remotefilename" and save it as "filename" + on the local machine. + + "filename" can also be a named pipe. + + See also "g.upload", "g.cat". + """ + return libguestfsmod.download (self._o, remotefilename, filename) + diff --git a/ruby/ext/guestfs/_guestfs.c b/ruby/ext/guestfs/_guestfs.c index cd4c271..f73a3b7 100644 --- a/ruby/ext/guestfs/_guestfs.c +++ b/ruby/ext/guestfs/_guestfs.c @@ -1982,6 +1982,56 @@ static VALUE ruby_guestfs_blockdev_rereadpt (VALUE gv, VALUE devicev) return Qnil; } +static VALUE ruby_guestfs_upload (VALUE gv, VALUE filenamev, VALUE remotefilenamev) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "upload"); + + const char *filename = StringValueCStr (filenamev); + if (!filename) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "filename", "upload"); + const char *remotefilename = StringValueCStr (remotefilenamev); + if (!remotefilename) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "remotefilename", "upload"); + + int r; + + r = guestfs_upload (g, filename, remotefilename); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_download (VALUE gv, VALUE remotefilenamev, VALUE filenamev) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "download"); + + const char *remotefilename = StringValueCStr (remotefilenamev); + if (!remotefilename) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "remotefilename", "download"); + const char *filename = StringValueCStr (filenamev); + if (!filename) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "filename", "download"); + + int r; + + r = guestfs_download (g, remotefilename, filename); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + /* Initialize the module. */ void Init__guestfs () { @@ -2156,4 +2206,8 @@ void Init__guestfs () ruby_guestfs_blockdev_flushbufs, 1); rb_define_method (c_guestfs, "blockdev_rereadpt", ruby_guestfs_blockdev_rereadpt, 1); + rb_define_method (c_guestfs, "upload", + ruby_guestfs_upload, 2); + rb_define_method (c_guestfs, "download", + ruby_guestfs_download, 2); } diff --git a/src/generator.ml b/src/generator.ml index 6df04a5..a89886f 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -1253,7 +1253,6 @@ Reread the partition table on C. This uses the L command."); -(* ("upload", (RErr, [FileIn "filename"; String "remotefilename"]), 66, [], [], "upload a file from the local machine", @@ -1275,7 +1274,6 @@ on the local machine. C can also be a named pipe. See also C, C."); -*) ] @@ -2146,8 +2144,7 @@ check_state (guestfs_h *g, const char *caller) pr " /* This flag is set by the callbacks, so we know we've done\n"; pr " * the callbacks as expected, and in the right sequence.\n"; pr " * 0 = not called, 1 = send called,\n"; - pr " * 2.. = send_file called,\n"; - pr " * 1000 = reply called.\n"; + pr " * 1001 = reply called.\n"; pr " */\n"; pr " int cb_sequence;\n"; pr " struct guestfs_message_header hdr;\n"; @@ -2173,7 +2170,6 @@ check_state (guestfs_h *g, const char *caller) pr " guestfs_main_loop *ml = guestfs_get_main_loop (g);\n"; pr " struct %s_ctx *ctx = (struct %s_ctx *) data;\n" shortname shortname; pr "\n"; - pr " guestfs__switch_to_receiving (g);\n"; pr " ctx->cb_sequence = 1;\n"; pr " ml->main_loop_quit (ml, g);\n"; pr "}\n"; @@ -2215,7 +2211,7 @@ check_state (guestfs_h *g, const char *caller) ); pr " done:\n"; - pr " ctx->cb_sequence = 1000;\n"; + pr " ctx->cb_sequence = 1001;\n"; pr " ml->main_loop_quit (ml, g);\n"; pr "}\n\n"; @@ -2291,22 +2287,23 @@ check_state (guestfs_h *g, const char *caller) pr " }\n"; pr "\n"; - (* Send any additional files requested. *) + (* Send any additional files (FileIn) requested. *) List.iter ( function | FileIn n -> - pr " if (send_file (g, %s) == -1)\n" n; + pr " if (guestfs__send_file_sync (ml, g, %s) == -1)\n" n; pr " return %s;\n" error_code; pr "\n"; | _ -> () ) (snd style); (* Wait for the reply from the remote end. *) + pr " guestfs__switch_to_receiving (g);\n"; pr " ctx.cb_sequence = 0;\n"; pr " guestfs_set_reply_callback (g, %s_reply_cb, &ctx);\n" shortname; pr " (void) ml->main_loop_run (ml, g);\n"; pr " guestfs_set_reply_callback (g, NULL, NULL);\n"; - pr " if (ctx.cb_sequence != 1000) {\n"; + pr " if (ctx.cb_sequence != 1001) {\n"; pr " error (g, \"%%s reply failed, see earlier error messages\", \"%s\");\n" name; pr " return %s;\n" error_code; pr " }\n"; @@ -2327,7 +2324,7 @@ check_state (guestfs_h *g, const char *caller) List.iter ( function | FileOut n -> - pr " if (receive_file (g, %s) == -1)\n" n; + pr " if (guestfs__receive_file_sync (ml, g, %s) == -1)\n" n; pr " return %s;\n" error_code; pr "\n"; | _ -> () diff --git a/src/guestfs-actions.c b/src/guestfs-actions.c index e9de5d6..b340bb7 100644 --- a/src/guestfs-actions.c +++ b/src/guestfs-actions.c @@ -87,8 +87,7 @@ struct mount_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -100,7 +99,6 @@ static void mount_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct mount_ctx *ctx = (struct mount_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -122,7 +120,7 @@ static void mount_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -155,11 +153,12 @@ int guestfs_mount (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, mount_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_mount"); return -1; } @@ -179,8 +178,7 @@ struct sync_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -192,7 +190,6 @@ static void sync_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct sync_ctx *ctx = (struct sync_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -214,7 +211,7 @@ static void sync_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -241,11 +238,12 @@ int guestfs_sync (guestfs_h *g) return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, sync_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_sync"); return -1; } @@ -265,8 +263,7 @@ struct touch_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -278,7 +275,6 @@ static void touch_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct touch_ctx *ctx = (struct touch_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -300,7 +296,7 @@ static void touch_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -331,11 +327,12 @@ int guestfs_touch (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, touch_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_touch"); return -1; } @@ -355,8 +352,7 @@ struct cat_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -369,7 +365,6 @@ static void cat_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct cat_ctx *ctx = (struct cat_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -395,7 +390,7 @@ static void cat_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -426,11 +421,12 @@ char *guestfs_cat (guestfs_h *g, return NULL; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, cat_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_cat"); return NULL; } @@ -450,8 +446,7 @@ struct ll_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -464,7 +459,6 @@ static void ll_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct ll_ctx *ctx = (struct ll_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -490,7 +484,7 @@ static void ll_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -521,11 +515,12 @@ char *guestfs_ll (guestfs_h *g, return NULL; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, ll_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_ll"); return NULL; } @@ -545,8 +540,7 @@ struct ls_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -559,7 +553,6 @@ static void ls_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct ls_ctx *ctx = (struct ls_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -585,7 +578,7 @@ static void ls_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -616,11 +609,12 @@ char **guestfs_ls (guestfs_h *g, return NULL; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, ls_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_ls"); return NULL; } @@ -645,8 +639,7 @@ struct list_devices_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -659,7 +652,6 @@ static void list_devices_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct list_devices_ctx *ctx = (struct list_devices_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -685,7 +677,7 @@ static void list_devices_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -712,11 +704,12 @@ char **guestfs_list_devices (guestfs_h *g) return NULL; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, list_devices_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_list_devices"); return NULL; } @@ -741,8 +734,7 @@ struct list_partitions_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -755,7 +747,6 @@ static void list_partitions_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct list_partitions_ctx *ctx = (struct list_partitions_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -781,7 +772,7 @@ static void list_partitions_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -808,11 +799,12 @@ char **guestfs_list_partitions (guestfs_h *g) return NULL; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, list_partitions_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_list_partitions"); return NULL; } @@ -837,8 +829,7 @@ struct pvs_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -851,7 +842,6 @@ static void pvs_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct pvs_ctx *ctx = (struct pvs_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -877,7 +867,7 @@ static void pvs_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -904,11 +894,12 @@ char **guestfs_pvs (guestfs_h *g) return NULL; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, pvs_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_pvs"); return NULL; } @@ -933,8 +924,7 @@ struct vgs_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -947,7 +937,6 @@ static void vgs_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct vgs_ctx *ctx = (struct vgs_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -973,7 +962,7 @@ static void vgs_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -1000,11 +989,12 @@ char **guestfs_vgs (guestfs_h *g) return NULL; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, vgs_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_vgs"); return NULL; } @@ -1029,8 +1019,7 @@ struct lvs_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -1043,7 +1032,6 @@ static void lvs_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct lvs_ctx *ctx = (struct lvs_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -1069,7 +1057,7 @@ static void lvs_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -1096,11 +1084,12 @@ char **guestfs_lvs (guestfs_h *g) return NULL; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, lvs_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_lvs"); return NULL; } @@ -1125,8 +1114,7 @@ struct pvs_full_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -1139,7 +1127,6 @@ static void pvs_full_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct pvs_full_ctx *ctx = (struct pvs_full_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -1165,7 +1152,7 @@ static void pvs_full_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -1192,11 +1179,12 @@ struct guestfs_lvm_pv_list *guestfs_pvs_full (guestfs_h *g) return NULL; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, pvs_full_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_pvs_full"); return NULL; } @@ -1217,8 +1205,7 @@ struct vgs_full_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -1231,7 +1218,6 @@ static void vgs_full_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct vgs_full_ctx *ctx = (struct vgs_full_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -1257,7 +1243,7 @@ static void vgs_full_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -1284,11 +1270,12 @@ struct guestfs_lvm_vg_list *guestfs_vgs_full (guestfs_h *g) return NULL; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, vgs_full_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_vgs_full"); return NULL; } @@ -1309,8 +1296,7 @@ struct lvs_full_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -1323,7 +1309,6 @@ static void lvs_full_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct lvs_full_ctx *ctx = (struct lvs_full_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -1349,7 +1334,7 @@ static void lvs_full_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -1376,11 +1361,12 @@ struct guestfs_lvm_lv_list *guestfs_lvs_full (guestfs_h *g) return NULL; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, lvs_full_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_lvs_full"); return NULL; } @@ -1401,8 +1387,7 @@ struct read_lines_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -1415,7 +1400,6 @@ static void read_lines_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct read_lines_ctx *ctx = (struct read_lines_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -1441,7 +1425,7 @@ static void read_lines_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -1472,11 +1456,12 @@ char **guestfs_read_lines (guestfs_h *g, return NULL; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, read_lines_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_read_lines"); return NULL; } @@ -1501,8 +1486,7 @@ struct aug_init_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -1514,7 +1498,6 @@ static void aug_init_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct aug_init_ctx *ctx = (struct aug_init_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -1536,7 +1519,7 @@ static void aug_init_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -1569,11 +1552,12 @@ int guestfs_aug_init (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, aug_init_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_aug_init"); return -1; } @@ -1593,8 +1577,7 @@ struct aug_close_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -1606,7 +1589,6 @@ static void aug_close_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct aug_close_ctx *ctx = (struct aug_close_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -1628,7 +1610,7 @@ static void aug_close_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -1655,11 +1637,12 @@ int guestfs_aug_close (guestfs_h *g) return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, aug_close_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_aug_close"); return -1; } @@ -1679,8 +1662,7 @@ struct aug_defvar_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -1693,7 +1675,6 @@ static void aug_defvar_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct aug_defvar_ctx *ctx = (struct aug_defvar_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -1719,7 +1700,7 @@ static void aug_defvar_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -1752,11 +1733,12 @@ int guestfs_aug_defvar (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, aug_defvar_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_aug_defvar"); return -1; } @@ -1776,8 +1758,7 @@ struct aug_defnode_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -1790,7 +1771,6 @@ static void aug_defnode_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct aug_defnode_ctx *ctx = (struct aug_defnode_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -1816,7 +1796,7 @@ static void aug_defnode_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -1851,11 +1831,12 @@ struct guestfs_int_bool *guestfs_aug_defnode (guestfs_h *g, return NULL; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, aug_defnode_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_aug_defnode"); return NULL; } @@ -1876,8 +1857,7 @@ struct aug_get_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -1890,7 +1870,6 @@ static void aug_get_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct aug_get_ctx *ctx = (struct aug_get_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -1916,7 +1895,7 @@ static void aug_get_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -1947,11 +1926,12 @@ char *guestfs_aug_get (guestfs_h *g, return NULL; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, aug_get_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_aug_get"); return NULL; } @@ -1971,8 +1951,7 @@ struct aug_set_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -1984,7 +1963,6 @@ static void aug_set_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct aug_set_ctx *ctx = (struct aug_set_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -2006,7 +1984,7 @@ static void aug_set_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -2039,11 +2017,12 @@ int guestfs_aug_set (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, aug_set_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_aug_set"); return -1; } @@ -2063,8 +2042,7 @@ struct aug_insert_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -2076,7 +2054,6 @@ static void aug_insert_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct aug_insert_ctx *ctx = (struct aug_insert_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -2098,7 +2075,7 @@ static void aug_insert_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -2133,11 +2110,12 @@ int guestfs_aug_insert (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, aug_insert_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_aug_insert"); return -1; } @@ -2157,8 +2135,7 @@ struct aug_rm_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -2171,7 +2148,6 @@ static void aug_rm_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct aug_rm_ctx *ctx = (struct aug_rm_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -2197,7 +2173,7 @@ static void aug_rm_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -2228,11 +2204,12 @@ int guestfs_aug_rm (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, aug_rm_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_aug_rm"); return -1; } @@ -2252,8 +2229,7 @@ struct aug_mv_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -2265,7 +2241,6 @@ static void aug_mv_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct aug_mv_ctx *ctx = (struct aug_mv_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -2287,7 +2262,7 @@ static void aug_mv_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -2320,11 +2295,12 @@ int guestfs_aug_mv (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, aug_mv_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_aug_mv"); return -1; } @@ -2344,8 +2320,7 @@ struct aug_match_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -2358,7 +2333,6 @@ static void aug_match_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct aug_match_ctx *ctx = (struct aug_match_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -2384,7 +2358,7 @@ static void aug_match_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -2415,11 +2389,12 @@ char **guestfs_aug_match (guestfs_h *g, return NULL; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, aug_match_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_aug_match"); return NULL; } @@ -2444,8 +2419,7 @@ struct aug_save_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -2457,7 +2431,6 @@ static void aug_save_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct aug_save_ctx *ctx = (struct aug_save_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -2479,7 +2452,7 @@ static void aug_save_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -2506,11 +2479,12 @@ int guestfs_aug_save (guestfs_h *g) return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, aug_save_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_aug_save"); return -1; } @@ -2530,8 +2504,7 @@ struct aug_load_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -2543,7 +2516,6 @@ static void aug_load_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct aug_load_ctx *ctx = (struct aug_load_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -2565,7 +2537,7 @@ static void aug_load_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -2592,11 +2564,12 @@ int guestfs_aug_load (guestfs_h *g) return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, aug_load_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_aug_load"); return -1; } @@ -2616,8 +2589,7 @@ struct aug_ls_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -2630,7 +2602,6 @@ static void aug_ls_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct aug_ls_ctx *ctx = (struct aug_ls_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -2656,7 +2627,7 @@ static void aug_ls_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -2687,11 +2658,12 @@ char **guestfs_aug_ls (guestfs_h *g, return NULL; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, aug_ls_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_aug_ls"); return NULL; } @@ -2716,8 +2688,7 @@ struct rm_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -2729,7 +2700,6 @@ static void rm_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct rm_ctx *ctx = (struct rm_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -2751,7 +2721,7 @@ static void rm_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -2782,11 +2752,12 @@ int guestfs_rm (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, rm_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_rm"); return -1; } @@ -2806,8 +2777,7 @@ struct rmdir_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -2819,7 +2789,6 @@ static void rmdir_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct rmdir_ctx *ctx = (struct rmdir_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -2841,7 +2810,7 @@ static void rmdir_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -2872,11 +2841,12 @@ int guestfs_rmdir (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, rmdir_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_rmdir"); return -1; } @@ -2896,8 +2866,7 @@ struct rm_rf_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -2909,7 +2878,6 @@ static void rm_rf_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct rm_rf_ctx *ctx = (struct rm_rf_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -2931,7 +2899,7 @@ static void rm_rf_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -2962,11 +2930,12 @@ int guestfs_rm_rf (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, rm_rf_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_rm_rf"); return -1; } @@ -2986,8 +2955,7 @@ struct mkdir_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -2999,7 +2967,6 @@ static void mkdir_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct mkdir_ctx *ctx = (struct mkdir_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -3021,7 +2988,7 @@ static void mkdir_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -3052,11 +3019,12 @@ int guestfs_mkdir (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, mkdir_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_mkdir"); return -1; } @@ -3076,8 +3044,7 @@ struct mkdir_p_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -3089,7 +3056,6 @@ static void mkdir_p_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct mkdir_p_ctx *ctx = (struct mkdir_p_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -3111,7 +3077,7 @@ static void mkdir_p_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -3142,11 +3108,12 @@ int guestfs_mkdir_p (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, mkdir_p_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_mkdir_p"); return -1; } @@ -3166,8 +3133,7 @@ struct chmod_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -3179,7 +3145,6 @@ static void chmod_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct chmod_ctx *ctx = (struct chmod_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -3201,7 +3166,7 @@ static void chmod_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -3234,11 +3199,12 @@ int guestfs_chmod (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, chmod_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_chmod"); return -1; } @@ -3258,8 +3224,7 @@ struct chown_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -3271,7 +3236,6 @@ static void chown_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct chown_ctx *ctx = (struct chown_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -3293,7 +3257,7 @@ static void chown_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -3328,11 +3292,12 @@ int guestfs_chown (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, chown_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_chown"); return -1; } @@ -3352,8 +3317,7 @@ struct exists_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -3366,7 +3330,6 @@ static void exists_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct exists_ctx *ctx = (struct exists_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -3392,7 +3355,7 @@ static void exists_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -3423,11 +3386,12 @@ int guestfs_exists (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, exists_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_exists"); return -1; } @@ -3447,8 +3411,7 @@ struct is_file_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -3461,7 +3424,6 @@ static void is_file_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct is_file_ctx *ctx = (struct is_file_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -3487,7 +3449,7 @@ static void is_file_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -3518,11 +3480,12 @@ int guestfs_is_file (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, is_file_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_is_file"); return -1; } @@ -3542,8 +3505,7 @@ struct is_dir_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -3556,7 +3518,6 @@ static void is_dir_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct is_dir_ctx *ctx = (struct is_dir_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -3582,7 +3543,7 @@ static void is_dir_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -3613,11 +3574,12 @@ int guestfs_is_dir (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, is_dir_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_is_dir"); return -1; } @@ -3637,8 +3599,7 @@ struct pvcreate_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -3650,7 +3611,6 @@ static void pvcreate_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct pvcreate_ctx *ctx = (struct pvcreate_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -3672,7 +3632,7 @@ static void pvcreate_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -3703,11 +3663,12 @@ int guestfs_pvcreate (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, pvcreate_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_pvcreate"); return -1; } @@ -3727,8 +3688,7 @@ struct vgcreate_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -3740,7 +3700,6 @@ static void vgcreate_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct vgcreate_ctx *ctx = (struct vgcreate_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -3762,7 +3721,7 @@ static void vgcreate_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -3796,11 +3755,12 @@ int guestfs_vgcreate (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, vgcreate_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_vgcreate"); return -1; } @@ -3820,8 +3780,7 @@ struct lvcreate_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -3833,7 +3792,6 @@ static void lvcreate_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct lvcreate_ctx *ctx = (struct lvcreate_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -3855,7 +3813,7 @@ static void lvcreate_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -3890,11 +3848,12 @@ int guestfs_lvcreate (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, lvcreate_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_lvcreate"); return -1; } @@ -3914,8 +3873,7 @@ struct mkfs_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -3927,7 +3885,6 @@ static void mkfs_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct mkfs_ctx *ctx = (struct mkfs_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -3949,7 +3906,7 @@ static void mkfs_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -3982,11 +3939,12 @@ int guestfs_mkfs (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, mkfs_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_mkfs"); return -1; } @@ -4006,8 +3964,7 @@ struct sfdisk_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -4019,7 +3976,6 @@ static void sfdisk_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct sfdisk_ctx *ctx = (struct sfdisk_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -4041,7 +3997,7 @@ static void sfdisk_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -4081,11 +4037,12 @@ int guestfs_sfdisk (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, sfdisk_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_sfdisk"); return -1; } @@ -4105,8 +4062,7 @@ struct write_file_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -4118,7 +4074,6 @@ static void write_file_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct write_file_ctx *ctx = (struct write_file_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -4140,7 +4095,7 @@ static void write_file_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -4175,11 +4130,12 @@ int guestfs_write_file (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, write_file_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_write_file"); return -1; } @@ -4199,8 +4155,7 @@ struct umount_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -4212,7 +4167,6 @@ static void umount_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct umount_ctx *ctx = (struct umount_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -4234,7 +4188,7 @@ static void umount_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -4265,11 +4219,12 @@ int guestfs_umount (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, umount_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_umount"); return -1; } @@ -4289,8 +4244,7 @@ struct mounts_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -4303,7 +4257,6 @@ static void mounts_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct mounts_ctx *ctx = (struct mounts_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -4329,7 +4282,7 @@ static void mounts_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -4356,11 +4309,12 @@ char **guestfs_mounts (guestfs_h *g) return NULL; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, mounts_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_mounts"); return NULL; } @@ -4385,8 +4339,7 @@ struct umount_all_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -4398,7 +4351,6 @@ static void umount_all_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct umount_all_ctx *ctx = (struct umount_all_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -4420,7 +4372,7 @@ static void umount_all_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -4447,11 +4399,12 @@ int guestfs_umount_all (guestfs_h *g) return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, umount_all_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_umount_all"); return -1; } @@ -4471,8 +4424,7 @@ struct lvm_remove_all_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -4484,7 +4436,6 @@ static void lvm_remove_all_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct lvm_remove_all_ctx *ctx = (struct lvm_remove_all_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -4506,7 +4457,7 @@ static void lvm_remove_all_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -4533,11 +4484,12 @@ int guestfs_lvm_remove_all (guestfs_h *g) return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, lvm_remove_all_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_lvm_remove_all"); return -1; } @@ -4557,8 +4509,7 @@ struct file_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -4571,7 +4522,6 @@ static void file_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct file_ctx *ctx = (struct file_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -4597,7 +4547,7 @@ static void file_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -4628,11 +4578,12 @@ char *guestfs_file (guestfs_h *g, return NULL; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, file_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_file"); return NULL; } @@ -4652,8 +4603,7 @@ struct command_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -4666,7 +4616,6 @@ static void command_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct command_ctx *ctx = (struct command_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -4692,7 +4641,7 @@ static void command_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -4724,11 +4673,12 @@ char *guestfs_command (guestfs_h *g, return NULL; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, command_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_command"); return NULL; } @@ -4748,8 +4698,7 @@ struct command_lines_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -4762,7 +4711,6 @@ static void command_lines_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct command_lines_ctx *ctx = (struct command_lines_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -4788,7 +4736,7 @@ static void command_lines_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -4820,11 +4768,12 @@ char **guestfs_command_lines (guestfs_h *g, return NULL; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, command_lines_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_command_lines"); return NULL; } @@ -4849,8 +4798,7 @@ struct stat_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -4863,7 +4811,6 @@ static void stat_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct stat_ctx *ctx = (struct stat_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -4889,7 +4836,7 @@ static void stat_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -4920,11 +4867,12 @@ struct guestfs_stat *guestfs_stat (guestfs_h *g, return NULL; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, stat_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_stat"); return NULL; } @@ -4945,8 +4893,7 @@ struct lstat_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -4959,7 +4906,6 @@ static void lstat_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct lstat_ctx *ctx = (struct lstat_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -4985,7 +4931,7 @@ static void lstat_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -5016,11 +4962,12 @@ struct guestfs_stat *guestfs_lstat (guestfs_h *g, return NULL; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, lstat_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_lstat"); return NULL; } @@ -5041,8 +4988,7 @@ struct statvfs_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -5055,7 +5001,6 @@ static void statvfs_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct statvfs_ctx *ctx = (struct statvfs_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -5081,7 +5026,7 @@ static void statvfs_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -5112,11 +5057,12 @@ struct guestfs_statvfs *guestfs_statvfs (guestfs_h *g, return NULL; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, statvfs_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_statvfs"); return NULL; } @@ -5137,8 +5083,7 @@ struct tune2fs_l_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -5151,7 +5096,6 @@ static void tune2fs_l_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct tune2fs_l_ctx *ctx = (struct tune2fs_l_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -5177,7 +5121,7 @@ static void tune2fs_l_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -5208,11 +5152,12 @@ char **guestfs_tune2fs_l (guestfs_h *g, return NULL; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, tune2fs_l_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_tune2fs_l"); return NULL; } @@ -5237,8 +5182,7 @@ struct blockdev_setro_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -5250,7 +5194,6 @@ static void blockdev_setro_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct blockdev_setro_ctx *ctx = (struct blockdev_setro_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -5272,7 +5215,7 @@ static void blockdev_setro_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -5303,11 +5246,12 @@ int guestfs_blockdev_setro (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, blockdev_setro_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_setro"); return -1; } @@ -5327,8 +5271,7 @@ struct blockdev_setrw_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -5340,7 +5283,6 @@ static void blockdev_setrw_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct blockdev_setrw_ctx *ctx = (struct blockdev_setrw_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -5362,7 +5304,7 @@ static void blockdev_setrw_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -5393,11 +5335,12 @@ int guestfs_blockdev_setrw (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, blockdev_setrw_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_setrw"); return -1; } @@ -5417,8 +5360,7 @@ struct blockdev_getro_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -5431,7 +5373,6 @@ static void blockdev_getro_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct blockdev_getro_ctx *ctx = (struct blockdev_getro_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -5457,7 +5398,7 @@ static void blockdev_getro_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -5488,11 +5429,12 @@ int guestfs_blockdev_getro (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, blockdev_getro_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_getro"); return -1; } @@ -5512,8 +5454,7 @@ struct blockdev_getss_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -5526,7 +5467,6 @@ static void blockdev_getss_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct blockdev_getss_ctx *ctx = (struct blockdev_getss_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -5552,7 +5492,7 @@ static void blockdev_getss_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -5583,11 +5523,12 @@ int guestfs_blockdev_getss (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, blockdev_getss_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_getss"); return -1; } @@ -5607,8 +5548,7 @@ struct blockdev_getbsz_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -5621,7 +5561,6 @@ static void blockdev_getbsz_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct blockdev_getbsz_ctx *ctx = (struct blockdev_getbsz_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -5647,7 +5586,7 @@ static void blockdev_getbsz_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -5678,11 +5617,12 @@ int guestfs_blockdev_getbsz (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, blockdev_getbsz_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_getbsz"); return -1; } @@ -5702,8 +5642,7 @@ struct blockdev_setbsz_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -5715,7 +5654,6 @@ static void blockdev_setbsz_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct blockdev_setbsz_ctx *ctx = (struct blockdev_setbsz_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -5737,7 +5675,7 @@ static void blockdev_setbsz_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -5770,11 +5708,12 @@ int guestfs_blockdev_setbsz (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, blockdev_setbsz_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_setbsz"); return -1; } @@ -5794,8 +5733,7 @@ struct blockdev_getsz_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -5808,7 +5746,6 @@ static void blockdev_getsz_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct blockdev_getsz_ctx *ctx = (struct blockdev_getsz_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -5834,7 +5771,7 @@ static void blockdev_getsz_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -5865,11 +5802,12 @@ int64_t guestfs_blockdev_getsz (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, blockdev_getsz_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_getsz"); return -1; } @@ -5889,8 +5827,7 @@ struct blockdev_getsize64_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -5903,7 +5840,6 @@ static void blockdev_getsize64_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct blockdev_getsize64_ctx *ctx = (struct blockdev_getsize64_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -5929,7 +5865,7 @@ static void blockdev_getsize64_reply_cb (guestfs_h *g, void *data, XDR *xdr) return; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -5960,11 +5896,12 @@ int64_t guestfs_blockdev_getsize64 (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, blockdev_getsize64_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_getsize64"); return -1; } @@ -5984,8 +5921,7 @@ struct blockdev_flushbufs_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -5997,7 +5933,6 @@ static void blockdev_flushbufs_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct blockdev_flushbufs_ctx *ctx = (struct blockdev_flushbufs_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -6019,7 +5954,7 @@ static void blockdev_flushbufs_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -6050,11 +5985,12 @@ int guestfs_blockdev_flushbufs (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, blockdev_flushbufs_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_flushbufs"); return -1; } @@ -6074,8 +6010,7 @@ struct blockdev_rereadpt_ctx { /* This flag is set by the callbacks, so we know we've done * the callbacks as expected, and in the right sequence. * 0 = not called, 1 = send called, - * 2.. = send_file called, - * 1000 = reply called. + * 1001 = reply called. */ int cb_sequence; struct guestfs_message_header hdr; @@ -6087,7 +6022,6 @@ static void blockdev_rereadpt_send_cb (guestfs_h *g, void *data) guestfs_main_loop *ml = guestfs_get_main_loop (g); struct blockdev_rereadpt_ctx *ctx = (struct blockdev_rereadpt_ctx *) data; - guestfs__switch_to_receiving (g); ctx->cb_sequence = 1; ml->main_loop_quit (ml, g); } @@ -6109,7 +6043,7 @@ static void blockdev_rereadpt_reply_cb (guestfs_h *g, void *data, XDR *xdr) goto done; } done: - ctx->cb_sequence = 1000; + ctx->cb_sequence = 1001; ml->main_loop_quit (ml, g); } @@ -6140,11 +6074,12 @@ int guestfs_blockdev_rereadpt (guestfs_h *g, return -1; } + guestfs__switch_to_receiving (g); ctx.cb_sequence = 0; guestfs_set_reply_callback (g, blockdev_rereadpt_reply_cb, &ctx); (void) ml->main_loop_run (ml, g); guestfs_set_reply_callback (g, NULL, NULL); - if (ctx.cb_sequence != 1000) { + if (ctx.cb_sequence != 1001) { error (g, "%s reply failed, see earlier error messages", "guestfs_blockdev_rereadpt"); return -1; } @@ -6160,3 +6095,189 @@ int guestfs_blockdev_rereadpt (guestfs_h *g, return 0; } +struct upload_ctx { + /* This flag is set by the callbacks, so we know we've done + * the callbacks as expected, and in the right sequence. + * 0 = not called, 1 = send called, + * 1001 = reply called. + */ + int cb_sequence; + struct guestfs_message_header hdr; + struct guestfs_message_error err; +}; + +static void upload_send_cb (guestfs_h *g, void *data) +{ + guestfs_main_loop *ml = guestfs_get_main_loop (g); + struct upload_ctx *ctx = (struct upload_ctx *) data; + + ctx->cb_sequence = 1; + ml->main_loop_quit (ml, g); +} + +static void upload_reply_cb (guestfs_h *g, void *data, XDR *xdr) +{ + guestfs_main_loop *ml = guestfs_get_main_loop (g); + struct upload_ctx *ctx = (struct upload_ctx *) data; + + if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) { + error (g, "%s: failed to parse reply header", "guestfs_upload"); + return; + } + if (ctx->hdr.status == GUESTFS_STATUS_ERROR) { + if (!xdr_guestfs_message_error (xdr, &ctx->err)) { + error (g, "%s: failed to parse reply error", "guestfs_upload"); + return; + } + goto done; + } + done: + ctx->cb_sequence = 1001; + ml->main_loop_quit (ml, g); +} + +int guestfs_upload (guestfs_h *g, + const char *filename, + const char *remotefilename) +{ + struct guestfs_upload_args args; + struct upload_ctx ctx; + guestfs_main_loop *ml = guestfs_get_main_loop (g); + int serial; + + if (check_state (g, "guestfs_upload") == -1) return -1; + + memset (&ctx, 0, sizeof ctx); + + args.remotefilename = (char *) remotefilename; + serial = guestfs__send (g, GUESTFS_PROC_UPLOAD, + (xdrproc_t) xdr_guestfs_upload_args, (char *) &args); + if (serial == -1) + return -1; + + ctx.cb_sequence = 0; + guestfs_set_send_callback (g, upload_send_cb, &ctx); + (void) ml->main_loop_run (ml, g); + guestfs_set_send_callback (g, NULL, NULL); + if (ctx.cb_sequence != 1) { + error (g, "%s send failed, see earlier error messages", "guestfs_upload"); + return -1; + } + + if (guestfs__send_file_sync (ml, g, filename) == -1) + return -1; + + guestfs__switch_to_receiving (g); + ctx.cb_sequence = 0; + guestfs_set_reply_callback (g, upload_reply_cb, &ctx); + (void) ml->main_loop_run (ml, g); + guestfs_set_reply_callback (g, NULL, NULL); + if (ctx.cb_sequence != 1001) { + error (g, "%s reply failed, see earlier error messages", "guestfs_upload"); + return -1; + } + + if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_UPLOAD, serial) == -1) + return -1; + + if (ctx.hdr.status == GUESTFS_STATUS_ERROR) { + error (g, "%s", ctx.err.error_message); + return -1; + } + + return 0; +} + +struct download_ctx { + /* This flag is set by the callbacks, so we know we've done + * the callbacks as expected, and in the right sequence. + * 0 = not called, 1 = send called, + * 1001 = reply called. + */ + int cb_sequence; + struct guestfs_message_header hdr; + struct guestfs_message_error err; +}; + +static void download_send_cb (guestfs_h *g, void *data) +{ + guestfs_main_loop *ml = guestfs_get_main_loop (g); + struct download_ctx *ctx = (struct download_ctx *) data; + + ctx->cb_sequence = 1; + ml->main_loop_quit (ml, g); +} + +static void download_reply_cb (guestfs_h *g, void *data, XDR *xdr) +{ + guestfs_main_loop *ml = guestfs_get_main_loop (g); + struct download_ctx *ctx = (struct download_ctx *) data; + + if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) { + error (g, "%s: failed to parse reply header", "guestfs_download"); + return; + } + if (ctx->hdr.status == GUESTFS_STATUS_ERROR) { + if (!xdr_guestfs_message_error (xdr, &ctx->err)) { + error (g, "%s: failed to parse reply error", "guestfs_download"); + return; + } + goto done; + } + done: + ctx->cb_sequence = 1001; + ml->main_loop_quit (ml, g); +} + +int guestfs_download (guestfs_h *g, + const char *remotefilename, + const char *filename) +{ + struct guestfs_download_args args; + struct download_ctx ctx; + guestfs_main_loop *ml = guestfs_get_main_loop (g); + int serial; + + if (check_state (g, "guestfs_download") == -1) return -1; + + memset (&ctx, 0, sizeof ctx); + + args.remotefilename = (char *) remotefilename; + serial = guestfs__send (g, GUESTFS_PROC_DOWNLOAD, + (xdrproc_t) xdr_guestfs_download_args, (char *) &args); + if (serial == -1) + return -1; + + ctx.cb_sequence = 0; + guestfs_set_send_callback (g, download_send_cb, &ctx); + (void) ml->main_loop_run (ml, g); + guestfs_set_send_callback (g, NULL, NULL); + if (ctx.cb_sequence != 1) { + error (g, "%s send failed, see earlier error messages", "guestfs_download"); + return -1; + } + + guestfs__switch_to_receiving (g); + ctx.cb_sequence = 0; + guestfs_set_reply_callback (g, download_reply_cb, &ctx); + (void) ml->main_loop_run (ml, g); + guestfs_set_reply_callback (g, NULL, NULL); + if (ctx.cb_sequence != 1001) { + error (g, "%s reply failed, see earlier error messages", "guestfs_download"); + return -1; + } + + if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_DOWNLOAD, serial) == -1) + return -1; + + if (ctx.hdr.status == GUESTFS_STATUS_ERROR) { + error (g, "%s", ctx.err.error_message); + return -1; + } + + if (guestfs__receive_file_sync (ml, g, filename) == -1) + return -1; + + return 0; +} + diff --git a/src/guestfs-actions.h b/src/guestfs-actions.h index 9ad13f6..2ec2d40 100644 --- a/src/guestfs-actions.h +++ b/src/guestfs-actions.h @@ -101,3 +101,5 @@ extern int64_t guestfs_blockdev_getsz (guestfs_h *handle, const char *device); extern int64_t guestfs_blockdev_getsize64 (guestfs_h *handle, const char *device); extern int guestfs_blockdev_flushbufs (guestfs_h *handle, const char *device); extern int guestfs_blockdev_rereadpt (guestfs_h *handle, const char *device); +extern int guestfs_upload (guestfs_h *handle, const char *filename, const char *remotefilename); +extern int guestfs_download (guestfs_h *handle, const char *remotefilename, const char *filename); diff --git a/src/guestfs.c b/src/guestfs.c index 47272f2..fd42f19 100644 --- a/src/guestfs.c +++ b/src/guestfs.c @@ -1428,11 +1428,25 @@ guestfs__switch_to_receiving (guestfs_h *g) return 0; } +int +guestfs__send_file_sync (guestfs_main_loop *ml, guestfs_h *g, + const char *filename) +{ + return -1; +} + +int +guestfs__receive_file_sync (guestfs_main_loop *ml, guestfs_h *g, + const char *filename) +{ + return -1; +} + #if 0 static int cancel = 0; /* XXX Implement file cancellation. */ -static int -send_file (guestfs_h *g, const char *filename) +int +guestfs__send_file (guestfs_h *g, const char *filename) { char buf[GUESTFS_MAX_CHUNK_SIZE]; int fd, r; diff --git a/src/guestfs.h b/src/guestfs.h index 39b2687..2b49cbe 100644 --- a/src/guestfs.h +++ b/src/guestfs.h @@ -27,6 +27,7 @@ #include typedef struct guestfs_h guestfs_h; +typedef struct guestfs_main_loop guestfs_main_loop; /* Connection management. */ extern guestfs_h *guestfs_create (void); @@ -76,6 +77,8 @@ extern void *guestfs_safe_memdup (guestfs_h *g, void *ptr, size_t size); extern int guestfs__send (guestfs_h *g, int proc_nr, xdrproc_t xdrp, char *args); extern int guestfs__switch_to_sending (guestfs_h *g); extern int guestfs__switch_to_receiving (guestfs_h *g); +extern int guestfs__send_file_sync (guestfs_main_loop *ml, guestfs_h *g, const char *filename); +extern int guestfs__receive_file_sync (guestfs_main_loop *ml, guestfs_h *g, const char *filename); /* Main loop. */ #define GUESTFS_HANDLE_READABLE 0x1 @@ -83,16 +86,14 @@ extern int guestfs__switch_to_receiving (guestfs_h *g); #define GUESTFS_HANDLE_HANGUP 0x4 #define GUESTFS_HANDLE_ERROR 0x8 -struct guestfs_main_loop; - -typedef void (*guestfs_handle_event_cb) (struct guestfs_main_loop *ml, guestfs_h *g, void *data, int watch, int fd, int events); -typedef int (*guestfs_add_handle_cb) (struct guestfs_main_loop *ml, guestfs_h *g, int fd, int events, guestfs_handle_event_cb cb, void *data); -typedef int (*guestfs_remove_handle_cb) (struct guestfs_main_loop *ml, guestfs_h *g, int watch); -typedef void (*guestfs_handle_timeout_cb) (struct guestfs_main_loop *ml, guestfs_h *g, void *data, int timer); -typedef int (*guestfs_add_timeout_cb) (struct guestfs_main_loop *ml, guestfs_h *g, int interval, guestfs_handle_timeout_cb cb, void *data); -typedef int (*guestfs_remove_timeout_cb) (struct guestfs_main_loop *ml, guestfs_h *g, int timer); -typedef int (*guestfs_main_loop_run_cb) (struct guestfs_main_loop *ml, guestfs_h *g); -typedef int (*guestfs_main_loop_quit_cb) (struct guestfs_main_loop *ml, guestfs_h *g); +typedef void (*guestfs_handle_event_cb) (guestfs_main_loop *ml, guestfs_h *g, void *data, int watch, int fd, int events); +typedef int (*guestfs_add_handle_cb) (guestfs_main_loop *ml, guestfs_h *g, int fd, int events, guestfs_handle_event_cb cb, void *data); +typedef int (*guestfs_remove_handle_cb) (guestfs_main_loop *ml, guestfs_h *g, int watch); +typedef void (*guestfs_handle_timeout_cb) (guestfs_main_loop *ml, guestfs_h *g, void *data, int timer); +typedef int (*guestfs_add_timeout_cb) (guestfs_main_loop *ml, guestfs_h *g, int interval, guestfs_handle_timeout_cb cb, void *data); +typedef int (*guestfs_remove_timeout_cb) (guestfs_main_loop *ml, guestfs_h *g, int timer); +typedef int (*guestfs_main_loop_run_cb) (guestfs_main_loop *ml, guestfs_h *g); +typedef int (*guestfs_main_loop_quit_cb) (guestfs_main_loop *ml, guestfs_h *g); /* This is the head of the main loop structure. Concrete implementations * use additional private data after this struct. @@ -105,7 +106,6 @@ struct guestfs_main_loop { guestfs_main_loop_run_cb main_loop_run; guestfs_main_loop_quit_cb main_loop_quit; }; -typedef struct guestfs_main_loop guestfs_main_loop; extern void guestfs_set_main_loop (guestfs_h *handle, guestfs_main_loop *main_loop); extern guestfs_main_loop *guestfs_get_main_loop (guestfs_h *handle); diff --git a/src/guestfs_protocol.c b/src/guestfs_protocol.c index c4246d6..24b14a0 100644 --- a/src/guestfs_protocol.c +++ b/src/guestfs_protocol.c @@ -1187,6 +1187,26 @@ xdr_guestfs_blockdev_rereadpt_args (XDR *xdrs, guestfs_blockdev_rereadpt_args *o } bool_t +xdr_guestfs_upload_args (XDR *xdrs, guestfs_upload_args *objp) +{ + register int32_t *buf; + + if (!xdr_string (xdrs, &objp->remotefilename, ~0)) + return FALSE; + return TRUE; +} + +bool_t +xdr_guestfs_download_args (XDR *xdrs, guestfs_download_args *objp) +{ + register int32_t *buf; + + if (!xdr_string (xdrs, &objp->remotefilename, ~0)) + return FALSE; + return TRUE; +} + +bool_t xdr_guestfs_procedure (XDR *xdrs, guestfs_procedure *objp) { register int32_t *buf; diff --git a/src/guestfs_protocol.h b/src/guestfs_protocol.h index c863c85..0747a38 100644 --- a/src/guestfs_protocol.h +++ b/src/guestfs_protocol.h @@ -616,6 +616,16 @@ struct guestfs_blockdev_rereadpt_args { }; typedef struct guestfs_blockdev_rereadpt_args guestfs_blockdev_rereadpt_args; +struct guestfs_upload_args { + char *remotefilename; +}; +typedef struct guestfs_upload_args guestfs_upload_args; + +struct guestfs_download_args { + char *remotefilename; +}; +typedef struct guestfs_download_args guestfs_download_args; + enum guestfs_procedure { GUESTFS_PROC_MOUNT = 1, GUESTFS_PROC_SYNC = 2, @@ -682,7 +692,9 @@ enum guestfs_procedure { GUESTFS_PROC_BLOCKDEV_GETSIZE64 = 63, GUESTFS_PROC_BLOCKDEV_FLUSHBUFS = 64, GUESTFS_PROC_BLOCKDEV_REREADPT = 65, - GUESTFS_PROC_NR_PROCS = 65 + 1, + GUESTFS_PROC_UPLOAD = 66, + GUESTFS_PROC_DOWNLOAD = 67, + GUESTFS_PROC_NR_PROCS = 67 + 1, }; typedef enum guestfs_procedure guestfs_procedure; #define GUESTFS_MESSAGE_MAX 4194304 @@ -823,6 +835,8 @@ extern bool_t xdr_guestfs_blockdev_getsize64_args (XDR *, guestfs_blockdev_gets extern bool_t xdr_guestfs_blockdev_getsize64_ret (XDR *, guestfs_blockdev_getsize64_ret*); extern bool_t xdr_guestfs_blockdev_flushbufs_args (XDR *, guestfs_blockdev_flushbufs_args*); extern bool_t xdr_guestfs_blockdev_rereadpt_args (XDR *, guestfs_blockdev_rereadpt_args*); +extern bool_t xdr_guestfs_upload_args (XDR *, guestfs_upload_args*); +extern bool_t xdr_guestfs_download_args (XDR *, guestfs_download_args*); extern bool_t xdr_guestfs_procedure (XDR *, guestfs_procedure*); extern bool_t xdr_guestfs_message_direction (XDR *, guestfs_message_direction*); extern bool_t xdr_guestfs_message_status (XDR *, guestfs_message_status*); @@ -924,6 +938,8 @@ extern bool_t xdr_guestfs_blockdev_getsize64_args (); extern bool_t xdr_guestfs_blockdev_getsize64_ret (); extern bool_t xdr_guestfs_blockdev_flushbufs_args (); extern bool_t xdr_guestfs_blockdev_rereadpt_args (); +extern bool_t xdr_guestfs_upload_args (); +extern bool_t xdr_guestfs_download_args (); extern bool_t xdr_guestfs_procedure (); extern bool_t xdr_guestfs_message_direction (); extern bool_t xdr_guestfs_message_status (); diff --git a/src/guestfs_protocol.x b/src/guestfs_protocol.x index d68a60a..4291809 100644 --- a/src/guestfs_protocol.x +++ b/src/guestfs_protocol.x @@ -475,6 +475,14 @@ struct guestfs_blockdev_rereadpt_args { string device<>; }; +struct guestfs_upload_args { + string remotefilename<>; +}; + +struct guestfs_download_args { + string remotefilename<>; +}; + enum guestfs_procedure { GUESTFS_PROC_MOUNT = 1, GUESTFS_PROC_SYNC = 2, @@ -541,6 +549,8 @@ enum guestfs_procedure { GUESTFS_PROC_BLOCKDEV_GETSIZE64 = 63, GUESTFS_PROC_BLOCKDEV_FLUSHBUFS = 64, GUESTFS_PROC_BLOCKDEV_REREADPT = 65, + GUESTFS_PROC_UPLOAD = 66, + GUESTFS_PROC_DOWNLOAD = 67, GUESTFS_PROC_NR_PROCS }; diff --git a/tests.c b/tests.c index 7feee5c..f1cf32a 100644 --- a/tests.c +++ b/tests.c @@ -99,6 +99,8 @@ static void no_test_warnings (void) fprintf (stderr, "warning: \"guestfs_command_lines\" has no tests\n"); fprintf (stderr, "warning: \"guestfs_tune2fs_l\" has no tests\n"); fprintf (stderr, "warning: \"guestfs_blockdev_setbsz\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_upload\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_download\" has no tests\n"); } static int test_blockdev_rereadpt_0 (void)