(* libguestfs * Copyright (C) 2009-2025 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *) (* Please read generator/README first. *) open Utils open Types (* "Core" APIs. *) let non_daemon_functions = [ { defaults with name = "launch"; added = (0, 0, 3); style = RErr, [], []; fish_alias = ["run"]; progress = true; config_only = true; shortdesc = "launch the backend"; longdesc = {|You should call this after configuring the handle (eg. adding drives) but before performing any actions. Do not call C twice on the same handle. Although it will not give an error (for historical reasons), the precise behaviour when you do this is not well defined. Handles are very cheap to create, so create a new one for each launch.|} }; { defaults with name = "add_drive_ro"; added = (1, 0, 38); style = RErr, [String (PlainString, "filename")], []; fish_alias = ["add-ro"]; config_only = true; blocking = false; shortdesc = "add a drive in snapshot mode (read-only)"; longdesc = "\ This function is the equivalent of calling C with the optional parameter C set to 1, so the disk is added read-only, with the format being detected automatically." }; { defaults with name = "config"; added = (0, 0, 3); style = RErr, [String (PlainString, "hvparam"); OptString "hvvalue"], []; config_only = true; blocking = false; shortdesc = "add hypervisor parameters"; longdesc = {|This can be used to add arbitrary hypervisor parameters of the form I<-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.|} }; { defaults with name = "is_ready"; added = (1, 0, 2); style = RBool "ready", [], []; visibility = VStateTest; blocking = false; tests = [ InitNone, Always, TestResultTrue ( [["is_ready"]]), [] ]; shortdesc = "is ready to accept commands"; longdesc = "\ This returns true iff this handle is ready to accept commands (in the C state). For more information on states, see L." }; { defaults with name = "is_config"; added = (1, 0, 2); style = RBool "config", [], []; blocking = false; tests = [ InitNone, Always, TestResultFalse ( [["is_config"]]), [] ]; shortdesc = "is in configuration state"; longdesc = "\ This returns true iff this handle is being configured (in the C state). For more information on states, see L." }; { defaults with name = "is_launching"; added = (1, 0, 2); style = RBool "launching", [], []; visibility = VStateTest; blocking = false; tests = [ InitNone, Always, TestResultFalse ( [["is_launching"]]), [] ]; shortdesc = "is launching subprocess"; longdesc = "\ This returns true iff this handle is launching the subprocess (in the C state). For more information on states, see L." }; { defaults with name = "is_busy"; added = (1, 0, 2); style = RBool "busy", [], []; visibility = VStateTest; blocking = false; tests = [ InitNone, Always, TestResultFalse ( [["is_busy"]]), [] ]; shortdesc = "is busy processing a command"; longdesc = "\ This always returns false. This function is deprecated with no replacement. Do not use this function. For more information on states, see L." }; { defaults with name = "get_state"; added = (1, 0, 2); style = RInt "state", [], []; visibility = VStateTest; blocking = false; shortdesc = "get the current state"; longdesc = "\ This returns the current state as an opaque integer. This is only useful for printing debug and internal error messages. For more information on states, see L." }; { defaults with name = "readdir"; added = (1, 0, 55); style = RStructList ("entries", "dirent"), [String (Pathname, "dir")], []; progress = true; cancellable = true; shortdesc = "read directories entries"; longdesc = {|This returns the list of directory entries in directory C. All entries in the directory are returned, including C<.> and C<..>. The entries are I sorted, but returned in the same order as the underlying filesystem. Also this call returns basic file type information about each file. The C field will contain one of the following characters: =over 4 =item 'b' Block special =item 'c' Char special =item 'd' Directory =item 'f' FIFO (named pipe) =item 'l' Symbolic link =item 'r' Regular file =item 's' Socket =item 'u' Unknown file type =item '?' The L call returned a C field with an unexpected value =back This function is primarily intended for use by programs. To get a simple list of names, use C. To get a printable directory for human consumption, use C.|} }; { defaults with name = "version"; added = (1, 0, 58); style = RStruct ("version", "version"), [], []; blocking = false; tests = [ InitNone, Always, TestResult ( [["version"]], "ret->major == 1"), [] ]; shortdesc = "get the library version number"; longdesc = {|Return the libguestfs version number that the program is linked against. Note that because of dynamic linking this is not necessarily the version of libguestfs that you compiled against. You can compile the program, and then at runtime dynamically link against a completely different F library. This call was added in version C<1.0.58>. In previous versions of libguestfs there was no way to get the version number. From C code you can use dynamic linker functions to find out if this symbol exists (if it doesn't, then it’s an earlier version). The call returns a structure with four elements. The first three (C, C and C) are numbers and correspond to the usual version triplet. The fourth element (C) is a string and is normally empty, but may be used for distro-specific information. To construct the original version string: C<$major.$minor.$release$extra> See also: L. I Don't use this call to test for availability of features. In enterprise distributions we backport features from later versions into earlier versions, making this an unreliable way to test for features. Use C or C instead.|} }; { defaults with name = "mountable_device"; added = (1, 33, 15); style = RString (RDevice, "device"), [String (Mountable, "mountable")], []; shortdesc = "extract the device part of a mountable"; longdesc = {|Returns the device name of a mountable. In quite a lot of cases, the mountable is the device name. However this doesn't apply for btrfs subvolumes, where the mountable is a combination of both the device name and the subvolume path (see also C to extract the subvolume path of the mountable if any).|} }; { defaults with name = "mountable_subvolume"; added = (1, 33, 15); style = RString (RPlainString, "subvolume"), [String (Mountable, "mountable")], []; shortdesc = "extract the subvolume part of a mountable"; longdesc = {|Returns the subvolume path of a mountable. Btrfs subvolumes mountables are a combination of both the device name and the subvolume path (see also C to extract the device of the mountable). If the mountable does not represent a btrfs subvolume, then this function fails and the C is set to C.|} }; { defaults with name = "add_drive"; added = (0, 0, 3); style = RErr, [String (PlainString, "filename")], [OBool "readonly"; OString "format"; OString "iface"; OString "name"; OString "label"; OString "protocol"; OStringList "server"; OString "username"; OString "secret"; OString "cachemode"; OString "discard"; OBool "copyonread"; OInt "blocksize"]; once_had_no_optargs = true; blocking = false; fish_alias = ["add"]; shortdesc = "add an image to examine or modify"; longdesc = {|This function adds a disk image called F to the handle. F may be a regular host file or a host device. When this function is called before C (the usual case) then the first time you call this function, the disk appears in the API as F, the second time as F, 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 call checks that F exists. F may be the special string C<"/dev/null">. See L. The optional arguments are: =over 4 =item C If true then the image is treated as read-only. Writes are still allowed, but they are stored in a temporary snapshot overlay which is discarded at the end. The disk that you add is not modified. =item C This forces the image format. If you omit this (or use C or C) then the format is automatically detected. Possible formats include C and C. Automatic detection of the format opens you up to a potential security hole when dealing with untrusted raw-format images. See CVE-2010-3851 and RHBZ#642934. Specifying the format closes this security hole. =item C This rarely-used option lets you emulate the behaviour of the deprecated C call (q.v.) =item C This field used to be passed as a hint for guest inspection, but it is no longer used. =item C