X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=generator%2Fgenerator_actions.ml;h=c081606da45fd85def4801e9ac049ae79d13dc97;hp=38f1db3ba6d248d2a540839fe1d577a5bb46b0e3;hb=f93cdf1ed3323b8d9451a7f4f6365ac30ab8ba81;hpb=b01ef8eae1acc5105e623a25c8988bcc3326ea1c diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml index 38f1db3..c081606 100644 --- a/generator/generator_actions.ml +++ b/generator/generator_actions.ml @@ -286,11 +286,11 @@ best effort attempt to run C followed by C when the handle is closed (also if the program exits without closing handles). -This is disabled by default (except in guestfish where it is -enabled by default)."); +This is enabled by default (since libguestfs 1.5.24, previously it was +disabled by default)."); ("get_autosync", (RBool "autosync", [], []), -1, [], - [InitNone, Always, TestRun ( + [InitNone, Always, TestOutputTrue ( [["get_autosync"]])], "get autosync mode", "\ @@ -738,6 +738,10 @@ Any Linux-based operating system. Any Microsoft Windows operating system. +=item \"freebsd\" + +FreeBSD. + =item \"unknown\" The operating system type could not be determined. @@ -779,14 +783,38 @@ Currently defined distros are: =over 4 +=item \"archlinux\" + +Arch Linux. + =item \"debian\" -Debian or a Debian-derived distro such as Ubuntu. +Debian. =item \"fedora\" Fedora. +=item \"gentoo\" + +Gentoo. + +=item \"linuxmint\" + +Linux Mint. + +=item \"mandriva\" + +Mandriva. + +=item \"meego\" + +MeeGo. + +=item \"pardus\" + +Pardus. + =item \"redhat-based\" Some Red Hat-derived distro. @@ -795,15 +823,19 @@ Some Red Hat-derived distro. Red Hat Enterprise Linux and some derivatives. -=item \"windows\" +=item \"ubuntu\" -Windows does not have distributions. This string is -returned if the OS type is Windows. +Ubuntu. =item \"unknown\" The distro could not be determined. +=item \"windows\" + +Windows does not have distributions. This string is +returned if the OS type is Windows. + =back Future versions of libguestfs may return other strings here. @@ -1002,6 +1034,263 @@ deprecated C call (q.v.) =back"); + ("inspect_get_windows_systemroot", (RString "systemroot", [Device "root"], []), -1, [], + [], + "get Windows systemroot of inspected operating system", + "\ +This function should only be called with a root device string +as returned by C. + +This returns the Windows systemroot of the inspected guest. +The systemroot is a directory path such as C. + +This call assumes that the guest is Windows and that the +systemroot could be determined by inspection. If this is not +the case then an error is returned. + +Please read L for more details."); + + ("inspect_get_roots", (RStringList "roots", [], []), -1, [], + [], + "return list of operating systems found by last inspection", + "\ +This function is a convenient way to get the list of root +devices, as returned from a previous call to C, +but without redoing the whole inspection process. + +This returns an empty list if either no root devices were +found or the caller has not called C. + +Please read L for more details."); + + ("debug_cmdline", (RStringList "cmdline", [], []), -1, [NotInDocs], + [], + "debug the QEMU command line (internal use only)", + "\ +This returns the internal QEMU command line. 'debug' commands are +not part of the formal API and can be removed or changed at any time."); + + ("add_domain", (RInt "nrdisks", [String "dom"], [String "libvirturi"; Bool "readonly"; String "iface"]), -1, [FishAlias "domain"], + [], + "add the disk(s) from a named libvirt domain", + "\ +This function adds the disk(s) attached to the named libvirt +domain C. It works by connecting to libvirt, requesting +the domain and domain XML from libvirt, parsing it for disks, +and calling C on each one. + +The number of disks added is returned. This operation is atomic: +if an error is returned, then no disks are added. + +This function does some minimal checks to make sure the libvirt +domain is not running (unless C is true). In a future +version we will try to acquire the libvirt lock on each disk. + +Disks must be accessible locally. This often means that adding disks +from a remote libvirt connection (see L) +will fail unless those disks are accessible via the same device path +locally too. + +The optional C parameter sets the libvirt URI +(see L). If this is not set then +we connect to the default libvirt URI (or one set through an +environment variable, see the libvirt documentation for full +details). If you are using the C API directly then it is more +flexible to create the libvirt connection object yourself, get +the domain object, and call C. + +The other optional parameters are passed directly through to +C."); + +(* +This interface is not quite baked yet. -- RWMJ 2010-11-11 + ("add_libvirt_dom", (RInt "nrdisks", [Pointer ("virDomainPtr", "dom")], [Bool "readonly"; String "iface"]), -1, [NotInFish], + [], + "add the disk(s) from a libvirt domain", + "\ +This function adds the disk(s) attached to the libvirt domain C. +It works by requesting the domain XML from libvirt, parsing it for +disks, and calling C on each one. + +In the C API we declare C, but really it has type +C. This is so we don't need Elibvirt.hE. + +The number of disks added is returned. This operation is atomic: +if an error is returned, then no disks are added. + +This function does some minimal checks to make sure the libvirt +domain is not running (unless C is true). In a future +version we will try to acquire the libvirt lock on each disk. + +Disks must be accessible locally. This often means that adding disks +from a remote libvirt connection (see L) +will fail unless those disks are accessible via the same device path +locally too. + +The optional parameters are passed directly through to +C."); +*) + + ("inspect_get_package_format", (RString "packageformat", [Device "root"], []), -1, [], + [], + "get package format used by the operating system", + "\ +This function should only be called with a root device string +as returned by C. + +This function and C return +the package format and package management tool used by the +inspected operating system. For example for Fedora these +functions would return C (package format) and +C (package management). + +This returns the string C if we could not determine the +package format I if the operating system does not have +a real packaging system (eg. Windows). + +Possible strings include: C, C, C, C, C. +Future versions of libguestfs may return other strings. + +Please read L for more details."); + + ("inspect_get_package_management", (RString "packagemanagement", [Device "root"], []), -1, [], + [], + "get package management tool used by the operating system", + "\ +This function should only be called with a root device string +as returned by C. + +C and this function return +the package format and package management tool used by the +inspected operating system. For example for Fedora these +functions would return C (package format) and +C (package management). + +This returns the string C if we could not determine the +package management tool I if the operating system does not have +a real packaging system (eg. Windows). + +Possible strings include: C, C, +C (for all Debian derivatives), +C, C, C, C. +Future versions of libguestfs may return other strings. + +Please read L for more details."); + + ("inspect_list_applications", (RStructList ("applications", "application"), [Device "root"], []), -1, [], + [], + "get list of applications installed in the operating system", + "\ +This function should only be called with a root device string +as returned by C. + +Return the list of applications installed in the operating system. + +I This call works differently from other parts of the +inspection API. You have to call C, then +C, then mount up the disks, +before calling this. Listing applications is a significantly +more difficult operation which requires access to the full +filesystem. Also note that unlike the other +C calls which are just returning +data cached in the libguestfs handle, this call actually reads +parts of the mounted filesystems during the call. + +This returns an empty list if the inspection code was not able +to determine the list of applications. + +The application structure contains the following fields: + +=over 4 + +=item C + +The name of the application. For Red Hat-derived and Debian-derived +Linux guests, this is the package name. + +=item C + +The display name of the application, sometimes localized to the +install language of the guest operating system. + +If unavailable this is returned as an empty string C<\"\">. +Callers needing to display something can use C instead. + +=item C + +For package managers which use epochs, this contains the epoch of +the package (an integer). If unavailable, this is returned as C<0>. + +=item C + +The version string of the application or package. If unavailable +this is returned as an empty string C<\"\">. + +=item C + +The release string of the application or package, for package +managers that use this. If unavailable this is returned as an +empty string C<\"\">. + +=item C + +The installation path of the application (on operating systems +such as Windows which use installation paths). This path is +in the format used by the guest operating system, it is not +a libguestfs path. + +If unavailable this is returned as an empty string C<\"\">. + +=item C + +The install path translated into a libguestfs path. +If unavailable this is returned as an empty string C<\"\">. + +=item C + +The name of the publisher of the application, for package +managers that use this. If unavailable this is returned +as an empty string C<\"\">. + +=item C + +The URL (eg. upstream URL) of the application. +If unavailable this is returned as an empty string C<\"\">. + +=item C + +For packaging systems which support this, the name of the source +package. If unavailable this is returned as an empty string C<\"\">. + +=item C + +A short (usually one line) description of the application or package. +If unavailable this is returned as an empty string C<\"\">. + +=item C + +A longer description of the application or package. +If unavailable this is returned as an empty string C<\"\">. + +=back + +Please read L for more details."); + + ("inspect_get_hostname", (RString "hostname", [Device "root"], []), -1, [], + [], + "get hostname of the operating system", + "\ +This function should only be called with a root device string +as returned by C. + +This function returns the hostname of the operating system +as found by inspection of the guest's configuration files. + +If the hostname could not be determined, then the +string C is returned. + +Please read L for more details."); + ] (* daemon_functions are any functions which cause some action @@ -1117,10 +1406,13 @@ See also C."); ("list_partitions", (RStringList "partitions", [], []), 8, [], [InitBasicFS, Always, TestOutputListOfDevices ( - [["list_partitions"]], ["/dev/sda1"]); + [["list_partitions"]], ["/dev/sda1"; "/dev/sdb1"]); InitEmpty, Always, TestOutputListOfDevices ( - [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"]; - ["list_partitions"]], ["/dev/sda1"; "/dev/sda2"; "/dev/sda3"])], + [["part_init"; "/dev/sda"; "mbr"]; + ["part_add"; "/dev/sda"; "p"; "64"; "204799"]; + ["part_add"; "/dev/sda"; "p"; "204800"; "409599"]; + ["part_add"; "/dev/sda"; "p"; "409600"; "-64"]; + ["list_partitions"]], ["/dev/sda1"; "/dev/sda2"; "/dev/sda3"; "/dev/sdb1"])], "list the partitions", "\ List all the partitions detected on all block devices. @@ -1136,7 +1428,10 @@ See also C."); [InitBasicFSonLVM, Always, TestOutputListOfDevices ( [["pvs"]], ["/dev/sda1"]); InitEmpty, Always, TestOutputListOfDevices ( - [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"]; + [["part_init"; "/dev/sda"; "mbr"]; + ["part_add"; "/dev/sda"; "p"; "64"; "204799"]; + ["part_add"; "/dev/sda"; "p"; "204800"; "409599"]; + ["part_add"; "/dev/sda"; "p"; "409600"; "-64"]; ["pvcreate"; "/dev/sda1"]; ["pvcreate"; "/dev/sda2"]; ["pvcreate"; "/dev/sda3"]; @@ -1155,7 +1450,10 @@ See also C."); [InitBasicFSonLVM, Always, TestOutputList ( [["vgs"]], ["VG"]); InitEmpty, Always, TestOutputList ( - [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"]; + [["part_init"; "/dev/sda"; "mbr"]; + ["part_add"; "/dev/sda"; "p"; "64"; "204799"]; + ["part_add"; "/dev/sda"; "p"; "204800"; "409599"]; + ["part_add"; "/dev/sda"; "p"; "409600"; "-64"]; ["pvcreate"; "/dev/sda1"]; ["pvcreate"; "/dev/sda2"]; ["pvcreate"; "/dev/sda3"]; @@ -1176,7 +1474,10 @@ See also C."); [InitBasicFSonLVM, Always, TestOutputList ( [["lvs"]], ["/dev/VG/LV"]); InitEmpty, Always, TestOutputList ( - [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"]; + [["part_init"; "/dev/sda"; "mbr"]; + ["part_add"; "/dev/sda"; "p"; "64"; "204799"]; + ["part_add"; "/dev/sda"; "p"; "204800"; "409599"]; + ["part_add"; "/dev/sda"; "p"; "409600"; "-64"]; ["pvcreate"; "/dev/sda1"]; ["pvcreate"; "/dev/sda2"]; ["pvcreate"; "/dev/sda3"]; @@ -1532,7 +1833,10 @@ See also C."); ("pvcreate", (RErr, [Device "device"], []), 39, [Optional "lvm2"], [InitEmpty, Always, TestOutputListOfDevices ( - [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"]; + [["part_init"; "/dev/sda"; "mbr"]; + ["part_add"; "/dev/sda"; "p"; "64"; "204799"]; + ["part_add"; "/dev/sda"; "p"; "204800"; "409599"]; + ["part_add"; "/dev/sda"; "p"; "409600"; "-64"]; ["pvcreate"; "/dev/sda1"]; ["pvcreate"; "/dev/sda2"]; ["pvcreate"; "/dev/sda3"]; @@ -1545,7 +1849,10 @@ as C."); ("vgcreate", (RErr, [String "volgroup"; DeviceList "physvols"], []), 40, [Optional "lvm2"], [InitEmpty, Always, TestOutputList ( - [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"]; + [["part_init"; "/dev/sda"; "mbr"]; + ["part_add"; "/dev/sda"; "p"; "64"; "204799"]; + ["part_add"; "/dev/sda"; "p"; "204800"; "409599"]; + ["part_add"; "/dev/sda"; "p"; "409600"; "-64"]; ["pvcreate"; "/dev/sda1"]; ["pvcreate"; "/dev/sda2"]; ["pvcreate"; "/dev/sda3"]; @@ -1559,7 +1866,10 @@ from the non-empty list of physical volumes C."); ("lvcreate", (RErr, [String "logvol"; String "volgroup"; Int "mbytes"], []), 41, [Optional "lvm2"], [InitEmpty, Always, TestOutputList ( - [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"]; + [["part_init"; "/dev/sda"; "mbr"]; + ["part_add"; "/dev/sda"; "p"; "64"; "204799"]; + ["part_add"; "/dev/sda"; "p"; "204800"; "409599"]; + ["part_add"; "/dev/sda"; "p"; "409600"; "-64"]; ["pvcreate"; "/dev/sda1"]; ["pvcreate"; "/dev/sda2"]; ["pvcreate"; "/dev/sda3"]; @@ -1673,7 +1983,10 @@ See also: C"); ["mounts"]], []); (* check that umount_all can unmount nested mounts correctly: *) InitEmpty, Always, TestOutputList ( - [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"]; + [["part_init"; "/dev/sda"; "mbr"]; + ["part_add"; "/dev/sda"; "p"; "64"; "204799"]; + ["part_add"; "/dev/sda"; "p"; "204800"; "409599"]; + ["part_add"; "/dev/sda"; "p"; "409600"; "-64"]; ["mkfs"; "ext2"; "/dev/sda1"]; ["mkfs"; "ext2"; "/dev/sda2"]; ["mkfs"; "ext2"; "/dev/sda3"]; @@ -2196,7 +2509,7 @@ This is the same as the C command, but it allows you to set both the mount options and the vfstype as for the L I<-o> and I<-t> flags."); - ("debug", (RString "result", [String "subcmd"; StringList "extraargs"], []), 76, [], + ("debug", (RString "result", [String "subcmd"; StringList "extraargs"], []), 76, [NotInDocs], [], "debugging and internals", "\ @@ -2348,10 +2661,10 @@ to return the existing UUID of a filesystem."); ("get_e2uuid", (RString "uuid", [Device "device"], []), 83, [DeprecatedBy "vfs_uuid"], (* Regression test for RHBZ#597112. *) (let uuid = uuidgen () in - [InitBasicFS, Always, TestOutput ( - [["mke2journal"; "1024"; "/dev/sdb"]; - ["set_e2uuid"; "/dev/sdb"; uuid]; - ["get_e2uuid"; "/dev/sdb"]], uuid)]), + [InitNone, Always, TestOutput ( + [["mke2journal"; "1024"; "/dev/sdc"]; + ["set_e2uuid"; "/dev/sdc"; uuid]; + ["get_e2uuid"; "/dev/sdc"]], uuid)]), "get the ext2/3/4 filesystem UUID", "\ This returns the ext2/3/4 filesystem UUID of the filesystem on @@ -3394,13 +3707,28 @@ in guestfish: add-ro Fedora-11-i686-Live.iso run mkmountpoint /cd - mkmountpoint /squash - mkmountpoint /ext3 + mkmountpoint /sqsh + mkmountpoint /ext3fs mount /dev/sda /cd - mount-loop /cd/LiveOS/squashfs.img /squash - mount-loop /squash/LiveOS/ext3fs.img /ext3 + mount-loop /cd/LiveOS/squashfs.img /sqsh + mount-loop /sqsh/LiveOS/ext3fs.img /ext3fs + +The inner filesystem is now unpacked under the /ext3fs mountpoint. + +C is not compatible with C. +You may get unexpected errors if you try to mix these calls. It is +safest to manually unmount filesystems and remove mountpoints after use. + +C unmounts filesystems by sorting the paths +longest first, so for this to work for manual mountpoints, you +must ensure that the innermost mountpoints have the longest +pathnames, as in the example code above. -The inner filesystem is now unpacked under the /ext3 mountpoint."); +For more details see L + +Autosync [see C, this is set by default on +handles] means that C is called when the handle +is closed which can also trigger these issues."); ("rmmountpoint", (RErr, [String "exemptpath"], []), 149, [], [], @@ -3651,12 +3979,12 @@ This command disables the libguestfs appliance swap on file."); ("swapon_label", (RErr, [String "label"], []), 174, [], [InitEmpty, Always, TestRun ( - [["part_disk"; "/dev/sdb"; "mbr"]; - ["mkswap_L"; "swapit"; "/dev/sdb1"]; + [["part_disk"; "/dev/sda"; "mbr"]; + ["mkswap_L"; "swapit"; "/dev/sda1"]; ["swapon_label"; "swapit"]; ["swapoff_label"; "swapit"]; - ["zero"; "/dev/sdb"]; - ["blockdev_rereadpt"; "/dev/sdb"]])], + ["zero"; "/dev/sda"]; + ["blockdev_rereadpt"; "/dev/sda"]])], "enable swap on labeled swap partition", "\ This command enables swap to a labeled swap partition. @@ -3672,7 +4000,7 @@ labeled swap partition."); ("swapon_uuid", (RErr, [String "uuid"], []), 176, [Optional "linuxfsuuid"], (let uuid = uuidgen () in [InitEmpty, Always, TestRun ( - [["mkswap_U"; uuid; "/dev/sdb"]; + [["mkswap_U"; uuid; "/dev/sdc"]; ["swapon_uuid"; uuid]; ["swapoff_uuid"; uuid]])]), "enable swap on swap partition by UUID", @@ -3845,7 +4173,9 @@ the requested cluster size."); ("mke2journal", (RErr, [Int "blocksize"; Device "device"], []), 188, [], [InitEmpty, Always, TestOutput ( - [["sfdiskM"; "/dev/sda"; ",100 ,"]; + [["part_init"; "/dev/sda"; "mbr"]; + ["part_add"; "/dev/sda"; "p"; "64"; "204799"]; + ["part_add"; "/dev/sda"; "p"; "204800"; "-64"]; ["mke2journal"; "4096"; "/dev/sda1"]; ["mke2fs_J"; "ext2"; "4096"; "/dev/sda2"; "/dev/sda1"]; ["mount_options"; ""; "/dev/sda2"; "/"]; @@ -3860,7 +4190,9 @@ to the command: ("mke2journal_L", (RErr, [Int "blocksize"; String "label"; Device "device"], []), 189, [], [InitEmpty, Always, TestOutput ( - [["sfdiskM"; "/dev/sda"; ",100 ,"]; + [["part_init"; "/dev/sda"; "mbr"]; + ["part_add"; "/dev/sda"; "p"; "64"; "204799"]; + ["part_add"; "/dev/sda"; "p"; "204800"; "-64"]; ["mke2journal_L"; "4096"; "JOURNAL"; "/dev/sda1"]; ["mke2fs_JL"; "ext2"; "4096"; "/dev/sda2"; "JOURNAL"]; ["mount_options"; ""; "/dev/sda2"; "/"]; @@ -3873,7 +4205,9 @@ This creates an ext2 external journal on C with label C