diff options
author | Richard Jones <rjones@redhat.com> | 2009-04-18 15:31:53 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2009-04-18 15:31:53 +0100 |
commit | ef499de8946cf4b8120ef7917b2e5d7f9115041f (patch) | |
tree | 8972aedf961b05a1d836ab15dcf946e837d12b42 /ocaml | |
parent | ad1d84a142169baaed293de71fb9430178d9f999 (diff) | |
download | libguestfs-ef499de8946cf4b8120ef7917b2e5d7f9115041f.tar.gz libguestfs-ef499de8946cf4b8120ef7917b2e5d7f9115041f.tar.xz libguestfs-ef499de8946cf4b8120ef7917b2e5d7f9115041f.zip |
Separate out the high-level API actions.
- Split out the high-level API actions so that they are in a
separate file, and use the defined guestfs C API, instead of
fiddling around with internal structures.
Diffstat (limited to 'ocaml')
-rw-r--r-- | ocaml/guestfs.ml | 5 | ||||
-rw-r--r-- | ocaml/guestfs.mli | 15 | ||||
-rw-r--r-- | ocaml/guestfs_c_actions.c | 110 |
3 files changed, 130 insertions, 0 deletions
diff --git a/ocaml/guestfs.ml b/ocaml/guestfs.ml index 6477e95b..0ea77c70 100644 --- a/ocaml/guestfs.ml +++ b/ocaml/guestfs.ml @@ -127,6 +127,11 @@ external set_autosync : t -> bool -> unit = "ocaml_guestfs_set_autosync" external get_autosync : t -> bool = "ocaml_guestfs_get_autosync" external set_verbose : t -> bool -> unit = "ocaml_guestfs_set_verbose" external get_verbose : t -> bool = "ocaml_guestfs_get_verbose" +external is_ready : t -> bool = "ocaml_guestfs_is_ready" +external is_config : t -> bool = "ocaml_guestfs_is_config" +external is_launching : t -> bool = "ocaml_guestfs_is_launching" +external is_busy : t -> bool = "ocaml_guestfs_is_busy" +external get_state : t -> int = "ocaml_guestfs_get_state" external mount : t -> string -> string -> unit = "ocaml_guestfs_mount" external sync : t -> unit = "ocaml_guestfs_sync" external touch : t -> string -> unit = "ocaml_guestfs_touch" diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli index b9b9f522..6c763631 100644 --- a/ocaml/guestfs.mli +++ b/ocaml/guestfs.mli @@ -160,6 +160,21 @@ val set_verbose : t -> bool -> unit val get_verbose : t -> bool (** get verbose mode *) +val is_ready : t -> bool +(** is ready to accept commands *) + +val is_config : t -> bool +(** is in configuration state *) + +val is_launching : t -> bool +(** is launching subprocess *) + +val is_busy : t -> bool +(** is busy processing a command *) + +val get_state : t -> int +(** get the current state *) + val mount : t -> string -> string -> unit (** mount a guest disk at a position in the filesystem *) diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c index c0618b29..dd2f6f47 100644 --- a/ocaml/guestfs_c_actions.c +++ b/ocaml/guestfs_c_actions.c @@ -601,6 +601,116 @@ ocaml_guestfs_get_verbose (value gv) } CAMLprim value +ocaml_guestfs_is_ready (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("is_ready: used handle after closing it"); + + int r; + + caml_enter_blocking_section (); + r = guestfs_is_ready (g); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "is_ready"); + + rv = Val_bool (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_is_config (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("is_config: used handle after closing it"); + + int r; + + caml_enter_blocking_section (); + r = guestfs_is_config (g); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "is_config"); + + rv = Val_bool (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_is_launching (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("is_launching: used handle after closing it"); + + int r; + + caml_enter_blocking_section (); + r = guestfs_is_launching (g); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "is_launching"); + + rv = Val_bool (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_is_busy (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("is_busy: used handle after closing it"); + + int r; + + caml_enter_blocking_section (); + r = guestfs_is_busy (g); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "is_busy"); + + rv = Val_bool (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_get_state (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("get_state: used handle after closing it"); + + int r; + + caml_enter_blocking_section (); + r = guestfs_get_state (g); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "get_state"); + + rv = Val_int (r); + CAMLreturn (rv); +} + +CAMLprim value ocaml_guestfs_mount (value gv, value devicev, value mountpointv) { CAMLparam3 (gv, devicev, mountpointv); |