X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=src%2Fgenerator.ml;h=3f42c391f6e9fa1fd4f1d612f74b813c232f487a;hp=69981f04cd8265e5cad52c919d48fd069977add1;hb=e7eca50046e9a69dac27c0bee832af0a3014e02c;hpb=7ea56c8d0bca01a602df8e87e52d90c5b44e2cc2 diff --git a/src/generator.ml b/src/generator.ml index 69981f0..3f42c39 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -32,11 +32,25 @@ and ret = * indication, ie. 0 or -1. *) | Err - (* "RString" and "RStringList" require special treatment because - * the caller must free them. + (* "Int" as a return value means an int which is -1 for error + * or any value >= 0 on success. *) + | RInt of string + (* "RBool" is a bool return value which can be true/false or + * -1 for error. + *) + | RBool of string + (* "RConstString" is a string that refers to a constant value. + * Try to avoid using this. In particular you cannot use this + * for values returned from the daemon, because there is no + * thread-safe way to return them in the C API. + *) + | RConstString of string + (* "RString" and "RStringList" are caller-frees. *) | RString of string | RStringList of string + (* Some limited tuples are possible: *) + | RIntBool of string * string (* LVM PVs, VGs and LVs. *) | RPVList of string | RVGList of string @@ -46,12 +60,134 @@ and args = | P0 | P1 of argt | P2 of argt * argt + | P3 of argt * argt * argt and argt = | String of string (* const char *name, cannot be NULL *) + | OptString of string (* const char *name, may be NULL *) + | Bool of string (* boolean *) + | Int of string (* int (smallish ints, signed, <= 31 bits) *) + +type flags = + | ProtocolLimitWarning (* display warning about protocol size limits *) + | FishAlias of string (* provide an alias for this cmd in guestfish *) + | FishAction of string (* call this function in guestfish *) + | NotInFish (* do not export via guestfish *) + +(* Note about long descriptions: When referring to another + * action, use the format C (ie. the full name of + * the C function). This will be replaced as appropriate in other + * language bindings. + * + * Apart from that, long descriptions are just perldoc paragraphs. + *) + +let non_daemon_functions = [ + ("launch", (Err, P0), -1, [FishAlias "run"; FishAction "launch"], + "launch the qemu subprocess", + "\ +Internally libguestfs is implemented by running a virtual machine +using L. + +You should call this after configuring the handle +(eg. adding drives) but before performing any actions."); + + ("wait_ready", (Err, P0), -1, [NotInFish], + "wait until the qemu subprocess launches", + "\ +Internally libguestfs is implemented by running a virtual machine +using L. + +You should call this after C to wait for the launch +to complete."); + + ("kill_subprocess", (Err, P0), -1, [], + "kill the qemu subprocess", + "\ +This kills the qemu subprocess. You should never need to call this."); -type flags = ProtocolLimitWarning + ("add_drive", (Err, P1 (String "filename")), -1, [FishAlias "add"], + "add an image to examine or modify", + "\ +This function adds a virtual machine disk image C to the +guest. The first time you call this function, the disk appears as IDE +disk 0 (C) in the guest, the second time as C, and +so on. + +You don't necessarily need to be root when using libguestfs. However +you obviously do need sufficient permissions to access the filename +for whatever operations you want to perform (ie. read access if you +just want to read the image or write access if you want to modify the +image). + +This is equivalent to the qemu parameter C<-drive file=filename>."); + + ("add_cdrom", (Err, P1 (String "filename")), -1, [FishAlias "cdrom"], + "add a CD-ROM disk image to examine", + "\ +This function adds a virtual CD-ROM disk image to the guest. + +This is equivalent to the qemu parameter C<-cdrom filename>."); + + ("config", (Err, P2 (String "qemuparam", OptString "qemuvalue")), -1, [], + "add qemu parameters", + "\ +This can be used to add arbitrary qemu command line parameters +of the form C<-param value>. Actually it's not quite arbitrary - we +prevent you from setting some parameters which would interfere with +parameters that we use. + +The first character of C string must be a C<-> (dash). + +C can be NULL."); + + ("set_path", (Err, P1 (String "path")), -1, [FishAlias "path"], + "set the search path", + "\ +Set the path that libguestfs searches for kernel and initrd.img. -let functions = [ +The default is C<$libdir/guestfs> unless overridden by setting +C environment variable. + +The string C is stashed in the libguestfs handle, so the caller +must make sure it remains valid for the lifetime of the handle. + +Setting C to C restores the default path."); + + ("get_path", (RConstString "path", P0), -1, [], + "get the search path", + "\ +Return the current search path. + +This is always non-NULL. If it wasn't set already, then this will +return the default path."); + + ("set_autosync", (Err, P1 (Bool "autosync")), -1, [FishAlias "autosync"], + "set autosync mode", + "\ +If C is true, this enables autosync. Libguestfs will make a +best effort attempt to run C when the handle is closed +(also if the program exits without closing handles)."); + + ("get_autosync", (RBool "autosync", P0), -1, [], + "get autosync mode", + "\ +Get the autosync flag."); + + ("set_verbose", (Err, P1 (Bool "verbose")), -1, [FishAlias "verbose"], + "set verbose mode", + "\ +If C is true, this turns on verbose messages (to C). + +Verbose messages are disabled unless the environment variable +C is defined and set to C<1>."); + + ("get_verbose", (RBool "verbose", P0), -1, [], + "get verbose mode", + "\ +This returns the verbose messages flag.") +] + +let daemon_functions = [ ("mount", (Err, P2 (String "device", String "mountpoint")), 1, [], "mount a guest disk at a position in the filesystem", "\ @@ -79,7 +215,7 @@ This syncs the disk, so that any writes are flushed through to the underlying disk image. You should always call this if you have modified a disk image, before -calling C."); +closing the handle."); ("touch", (Err, P1 (String "path")), 3, [], "update file timestamps or create a new file", @@ -122,8 +258,7 @@ should probably use C instead."); "\ List all the block devices. -The full block device names are returned, eg. C -"); +The full block device names are returned, eg. C"); ("list_partitions", (RStringList "partitions", P0), 8, [], "list the partitions", @@ -135,45 +270,219 @@ The full partition device names are returned, eg. C This does not return logical volumes. For that you will need to call C."); -(* - ("pvs", (RPVList "physvols", P0), 9, [], + ("pvs", (RStringList "physvols", P0), 9, [], "list the LVM physical volumes (PVs)", "\ List all the physical volumes detected. This is the equivalent -of the L command."); +of the L command. + +This returns a list of just the device names that contain +PVs (eg. C). + +See also C."); - ("vgs", (RVGList "volgroups", P0), 10, [], + ("vgs", (RStringList "volgroups", P0), 10, [], "list the LVM volume groups (VGs)", "\ List all the volumes groups detected. This is the equivalent -of the L command."); +of the L command. - ("lvs", (RLVList "logvols", P0), 11, [], +This returns a list of just the volume group names that were +detected (eg. C). + +See also C."); + + ("lvs", (RStringList "logvols", P0), 11, [], "list the LVM logical volumes (LVs)", "\ List all the logical volumes detected. This is the equivalent -of the L command."); -*) +of the L command. + +This returns a list of the logical volume device names +(eg. C). + +See also C."); ("pvs_full", (RPVList "physvols", P0), 12, [], "list the LVM physical volumes (PVs)", "\ List all the physical volumes detected. This is the equivalent -of the L command."); +of the L command. The \"full\" version includes all fields."); ("vgs_full", (RVGList "volgroups", P0), 13, [], "list the LVM volume groups (VGs)", "\ List all the volumes groups detected. This is the equivalent -of the L command."); +of the L command. The \"full\" version includes all fields."); ("lvs_full", (RLVList "logvols", P0), 14, [], "list the LVM logical volumes (LVs)", "\ List all the logical volumes detected. This is the equivalent -of the L command."); +of the L command. The \"full\" version includes all fields."); + + ("read_lines", (RStringList "lines", P1 (String "path")), 15, [], + "read file as lines", + "\ +Return the contents of the file named C. + +The file contents are returned as a list of lines. Trailing +C and C character sequences are I returned. + +Note that this function cannot correctly handle binary files +(specifically, files containing C<\\0> character which is treated +as end of line). For those you need to use the C +function which has a more complex interface."); + + ("aug_init", (Err, P2 (String "root", Int "flags")), 16, [], + "create a new Augeas handle", + "\ +Create a new Augeas handle for editing configuration files. +If there was any previous Augeas handle associated with this +guestfs session, then it is closed. + +You must call this before using any other C +commands. + +C is the filesystem root. C must not be NULL, +use C instead. + +The flags are the same as the flags defined in +Eaugeas.hE, the logical I of the following +integers: + +=over 4 + +=item 1 C + +Keep the original file with a C<.augsave> extension. + +=item 2 C + +Save changes into a file with extension C<.augnew>, and +do not overwrite original. Overrides C. + +=item 4 C + +Typecheck lenses (can be expensive). + +=item 8 C + +Do not use standard load path for modules. + +=item 16 C + +Make save a no-op, just record what would have been changed. + +=item 32 C + +Do not load the tree in C. + +=back + +To close the handle, you can call C. + +To find out more about Augeas, see L."); + + ("aug_close", (Err, P0), 26, [], + "close the current Augeas handle", + "\ +Close the current Augeas handle and free up any resources +used by it. After calling this, you have to call +C again before you can use any other +Augeas functions."); + + ("aug_defvar", (RInt "nrnodes", P2 (String "name", OptString "expr")), 17, [], + "define an Augeas variable", + "\ +Defines an Augeas variable C whose value is the result +of evaluating C. If C is NULL, then C is +undefined. + +On success this returns the number of nodes in C, or +C<0> if C evaluates to something which is not a nodeset."); + + ("aug_defnode", (RIntBool ("nrnodes", "created"), P3 (String "name", String "expr", String "val")), 18, [], + "define an Augeas node", + "\ +Defines a variable C whose value is the result of +evaluating C. + +If C evaluates to an empty nodeset, a node is created, +equivalent to calling C C, C. +C will be the nodeset containing that single node. + +On success this returns a pair containing the +number of nodes in the nodeset, and a boolean flag +if a node was created."); + + ("aug_get", (RString "val", P1 (String "path")), 19, [], + "look up the value of an Augeas path", + "\ +Look up the value associated with C. If C +matches exactly one node, the C is returned."); + + ("aug_set", (Err, P2 (String "path", String "val")), 20, [], + "set Augeas path to value", + "\ +Set the value associated with C to C."); + + ("aug_insert", (Err, P3 (String "path", String "label", Bool "before")), 21, [], + "insert a sibling Augeas node", + "\ +Create a new sibling C