X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=src%2Fgenerator.ml;h=88698420ca8fe28038911ae41e9d58d71039f17e;hp=10381dcb00dad0d79bfe2832d6e9b002cbfe7adc;hb=61ab83d19009a8006dd73ebe16d22494b78be4d1;hpb=b177f05ed6e65a9fe1fddc6ca602edcb912ac363 diff --git a/src/generator.ml b/src/generator.ml index 10381dc..8869842 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -19,17 +19,17 @@ (* This script generates a large amount of code and documentation for * all the daemon actions. - * + * * To add a new action there are only two files you need to change, * this one to describe the interface (see the big table of * 'daemon_functions' below), and daemon/.c to write the * implementation. - * + * * After editing this file, run it (./src/generator.ml) to regenerate * all the output files. 'make' will rerun this automatically when * necessary. Note that if you are using a separate build directory * you must run generator.ml from the _source_ directory. - * + * * IMPORTANT: This script should NOT print any warnings. If it prints * warnings, you should treat them as errors. * @@ -42,6 +42,7 @@ #load "unix.cma";; #load "str.cma";; #directory "+xml-light";; +#directory "+../pkg-lib/xml-light";; (* for GODI users *) #load "xml-light.cma";; open Unix @@ -181,11 +182,16 @@ type flags = | DangerWillRobinson (* flags particularly dangerous commands *) | FishAlias of string (* provide an alias for this cmd in guestfish *) | FishAction of string (* call this function in guestfish *) + | FishOutput of fish_output_t (* how to display output in guestfish *) | NotInFish (* do not export via guestfish *) | NotInDocs (* do not add this function to documentation *) | DeprecatedBy of string (* function is deprecated, use .. instead *) | Optional of string (* function is part of an optional group *) +and fish_output_t = + | FishOutputOctal (* for int return, print in octal *) + | FishOutputHexadecimal (* for int return, print in hex *) + (* You can supply zero or as many tests as you want per API call. * * Note that the test environment has 3 block devices, of size 500MB, @@ -489,9 +495,15 @@ image). This is equivalent to the qemu parameter C<-drive file=filename,cache=off,if=...>. + C is omitted in cases where it is not supported by the underlying filesystem. +C is set at compile time by the configuration option +C<./configure --with-drive-if=...>. In the rare case where you +might need to change this at run time, use C +or C. + Note that this call checks for the existence of C. This stops you from specifying other types of drive which are supported by qemu such as C and C URLs. To specify those, use @@ -505,10 +517,24 @@ This function adds a virtual CD-ROM disk image to the guest. This is equivalent to the qemu parameter C<-cdrom filename>. -Note that this call checks for the existence of C. This +Notes: + +=over 4 + +=item * + +This call checks for the existence of C. This stops you from specifying other types of drive which are supported by qemu such as C and C URLs. To specify those, use -the general C call instead."); +the general C call instead. + +=item * + +If you just want to add an ISO file (often you use this as an +efficient way to transfer large files into the guest), then you +should probably use C instead. + +=back"); ("add_drive_ro", (RErr, [String "filename"]), -1, [FishAlias "add-ro"], [], @@ -524,7 +550,14 @@ handle is closed. We don't currently have any method to enable changes to be committed, although qemu can support this. This is equivalent to the qemu parameter -C<-drive file=filename,snapshot=on,if=...>. +C<-drive file=filename,snapshot=on,readonly=on,if=...>. + +C is set at compile time by the configuration option +C<./configure --with-drive-if=...>. In the rare case where you +might need to change this at run time, use C +or C. + +C is only added where qemu supports this option. Note that this call checks for the existence of C. This stops you from specifying other types of drive which are supported @@ -556,7 +589,15 @@ configure script. You can also override this by setting the C environment variable. -Setting C to C restores the default qemu binary."); +Setting C to C restores the default qemu binary. + +Note that you should call this function as early as possible +after creating the handle. This is because some pre-launch +operations depend on testing qemu features (by running C). +If the qemu binary changes, we don't retest features, and +so you might see inconsistent results. Using the environment +variable C is safest of all since that picks +the qemu binary at the same time as the handle is created."); ("get_qemu", (RConstString "qemu", []), -1, [], [InitNone, Always, TestRun ( @@ -873,6 +914,20 @@ qemu, which is not very helpful."); "\ Return the recovery process enabled flag."); + ("add_drive_with_if", (RErr, [String "filename"; String "iface"]), -1, [], + [], + "add a drive specifying the QEMU block emulation to use", + "\ +This is the same as C but it allows you +to specify the QEMU interface emulation to use at run time."); + + ("add_drive_ro_with_if", (RErr, [String "filename"; String "iface"]), -1, [], + [], + "add a drive read-only specifying the QEMU block emulation to use", + "\ +This is the same as C but it allows you +to specify the QEMU interface emulation to use at run time."); + ] (* daemon_functions are any functions which cause some action @@ -1188,7 +1243,12 @@ matches exactly one node, the C is returned."); [], (* XXX Augeas code needs tests. *) "set Augeas path to value", "\ -Set the value associated with C to C."); +Set the value associated with C to C. + +In the Augeas API, it is possible to clear a node by setting +the value to NULL. Due to an oversight in the libguestfs API +you cannot do that with this call. Instead you must use the +C call."); ("aug_insert", (RErr, [String "augpath"; String "label"; Bool "before"]), 21, [Optional "augeas"], [], (* XXX Augeas code needs tests. *) @@ -1326,7 +1386,13 @@ as necessary. This is like the C shell command."); "change file mode", "\ Change the mode (permissions) of C to C. Only -numeric modes are supported."); +numeric modes are supported. + +I: When using this command from guestfish, C +by default would be decimal, unless you prefix it with +C<0> to get octal, ie. use C<0700> not C<700>. + +The mode actually set is affected by the umask."); ("chown", (RErr, [Int "owner"; Int "group"; Pathname "path"]), 35, [], [], (* XXX Need stat command to test *) @@ -1419,16 +1485,16 @@ from the non-empty list of physical volumes C."); ["lvs"]], ["/dev/VG1/LV1"; "/dev/VG1/LV2"; "/dev/VG2/LV3"; "/dev/VG2/LV4"; "/dev/VG2/LV5"])], - "create an LVM volume group", + "create an LVM logical volume", "\ -This creates an LVM volume group called C +This creates an LVM logical volume called C on the volume group C, with C megabytes."); ("mkfs", (RErr, [String "fstype"; Device "device"]), 42, [], [InitEmpty, Always, TestOutput ( [["part_disk"; "/dev/sda"; "mbr"]; ["mkfs"; "ext2"; "/dev/sda1"]; - ["mount"; "/dev/sda1"; "/"]; + ["mount_options"; ""; "/dev/sda1"; "/"]; ["write_file"; "/new"; "new file contents"; "0"]; ["cat"; "/new"]], "new file contents")], "make a filesystem", @@ -1504,12 +1570,12 @@ use C."); [InitEmpty, Always, TestOutputListOfDevices ( [["part_disk"; "/dev/sda"; "mbr"]; ["mkfs"; "ext2"; "/dev/sda1"]; - ["mount"; "/dev/sda1"; "/"]; + ["mount_options"; ""; "/dev/sda1"; "/"]; ["mounts"]], ["/dev/sda1"]); InitEmpty, Always, TestOutputList ( [["part_disk"; "/dev/sda"; "mbr"]; ["mkfs"; "ext2"; "/dev/sda1"]; - ["mount"; "/dev/sda1"; "/"]; + ["mount_options"; ""; "/dev/sda1"; "/"]; ["umount"; "/"]; ["mounts"]], [])], "unmount a filesystem", @@ -1540,11 +1606,11 @@ See also: C"); ["mkfs"; "ext2"; "/dev/sda1"]; ["mkfs"; "ext2"; "/dev/sda2"]; ["mkfs"; "ext2"; "/dev/sda3"]; - ["mount"; "/dev/sda1"; "/"]; + ["mount_options"; ""; "/dev/sda1"; "/"]; ["mkdir"; "/mp1"]; - ["mount"; "/dev/sda2"; "/mp1"]; + ["mount_options"; ""; "/dev/sda2"; "/mp1"]; ["mkdir"; "/mp1/mp2"]; - ["mount"; "/dev/sda3"; "/mp1/mp2"]; + ["mount_options"; ""; "/dev/sda3"; "/mp1/mp2"]; ["mkdir"; "/mp1/mp2/mp3"]; ["umount_all"]; ["mounts"]], [])], @@ -1971,7 +2037,8 @@ The checksum is returned as a printable string."); This command uploads and unpacks local file C (an I tar file) into C. -To upload a compressed tarball, use C."); +To upload a compressed tarball, use C +or C."); ("tar_out", (RErr, [String "directory"; FileOut "tarfile"]), 70, [], [], @@ -1980,7 +2047,8 @@ To upload a compressed tarball, use C."); This command packs the contents of C and downloads it to local file C. -To download a compressed tarball, use C."); +To download a compressed tarball, use C +or C."); ("tgz_in", (RErr, [FileIn "tarball"; String "directory"]), 71, [], [InitBasicFS, Always, TestOutput ( @@ -2189,7 +2257,7 @@ to return the existing UUID of a filesystem."); This returns the ext2/3/4 filesystem UUID of the filesystem on C."); - ("fsck", (RInt "status", [String "fstype"; Device "device"]), 84, [], + ("fsck", (RInt "status", [String "fstype"; Device "device"]), 84, [FishOutput FishOutputHexadecimal], [InitBasicFS, Always, TestOutputInt ( [["umount"; "/dev/sda1"]; ["fsck"; "ext2"; "/dev/sda1"]], 0); @@ -2240,7 +2308,7 @@ How many blocks are zeroed isn't specified (but it's I enough to securely wipe the device). It should be sufficient to remove any partition tables, filesystem superblocks and so on. -See also: C."); +See also: C, C."); ("grub_install", (RErr, [Pathname "root"; Device "device"]), 86, [], (* Test disabled because grub-install incompatible with virtio-blk driver. @@ -2401,11 +2469,11 @@ the human-readable, canonical hex dump of the file."); [InitNone, Always, TestOutput ( [["part_disk"; "/dev/sda"; "mbr"]; ["mkfs"; "ext3"; "/dev/sda1"]; - ["mount"; "/dev/sda1"; "/"]; + ["mount_options"; ""; "/dev/sda1"; "/"]; ["write_file"; "/new"; "test file"; "0"]; ["umount"; "/dev/sda1"]; ["zerofree"; "/dev/sda1"]; - ["mount"; "/dev/sda1"; "/"]; + ["mount_options"; ""; "/dev/sda1"; "/"]; ["cat"; "/new"]], "test file")], "zero unused inodes and disk blocks on ext2/3 filesystem", "\ @@ -2506,13 +2574,13 @@ are activated or deactivated."); ["vgcreate"; "VG"; "/dev/sda1"]; ["lvcreate"; "LV"; "VG"; "10"]; ["mkfs"; "ext2"; "/dev/VG/LV"]; - ["mount"; "/dev/VG/LV"; "/"]; + ["mount_options"; ""; "/dev/VG/LV"; "/"]; ["write_file"; "/new"; "test content"; "0"]; ["umount"; "/"]; ["lvresize"; "/dev/VG/LV"; "20"]; ["e2fsck_f"; "/dev/VG/LV"]; ["resize2fs"; "/dev/VG/LV"]; - ["mount"; "/dev/VG/LV"; "/"]; + ["mount_options"; ""; "/dev/VG/LV"; "/"]; ["cat"; "/new"]], "test content")], "resize an LVM logical volume", "\ @@ -2919,7 +2987,9 @@ named pipes (FIFOs). The C parameter should be the mode, using the standard constants. C and C are the device major and minor numbers, only used when creating block -and character special devices."); +and character special devices. + +The mode actually set is affected by the umask."); ("mkfifo", (RErr, [Int "mode"; Pathname "path"]), 134, [Optional "mknod"], [InitBasicFS, Always, TestOutputStruct ( @@ -2929,7 +2999,9 @@ and character special devices."); "\ This call creates a FIFO (named pipe) called C with mode C. It is just a convenient wrapper around -C."); +C. + +The mode actually set is affected by the umask."); ("mknod_b", (RErr, [Int "mode"; Int "devmajor"; Int "devminor"; Pathname "path"]), 135, [Optional "mknod"], [InitBasicFS, Always, TestOutputStruct ( @@ -2939,7 +3011,9 @@ C."); "\ This call creates a block device node called C with mode C and device major/minor C and C. -It is just a convenient wrapper around C."); +It is just a convenient wrapper around C. + +The mode actually set is affected by the umask."); ("mknod_c", (RErr, [Int "mode"; Int "devmajor"; Int "devminor"; Pathname "path"]), 136, [Optional "mknod"], [InitBasicFS, Always, TestOutputStruct ( @@ -2949,12 +3023,13 @@ It is just a convenient wrapper around C."); "\ This call creates a char device node called C with mode C and device major/minor C and C. -It is just a convenient wrapper around C."); +It is just a convenient wrapper around C. - ("umask", (RInt "oldmask", [Int "mask"]), 137, [], - [], (* XXX umask is one of those stateful things that we should - * reset between each test. - *) +The mode actually set is affected by the umask."); + + ("umask", (RInt "oldmask", [Int "mask"]), 137, [FishOutput FishOutputOctal], + [InitEmpty, Always, TestOutputInt ( + [["umask"; "0o22"]], 0o22)], "set file mode creation mask (umask)", "\ This function sets the mask used for creating new files and @@ -2969,7 +3044,8 @@ The default umask is C<022>. This is important because it means that directories and device nodes will be created with C<0644> or C<0755> mode even if you specify C<0777>. -See also L, C, C. +See also C, +L, C, C. This call returns the previous umask."); @@ -3556,7 +3632,7 @@ and C"); [InitEmpty, Always, TestOutput ( [["part_disk"; "/dev/sda"; "mbr"]; ["mkfs_b"; "ext2"; "4096"; "/dev/sda1"]; - ["mount"; "/dev/sda1"; "/"]; + ["mount_options"; ""; "/dev/sda1"; "/"]; ["write_file"; "/new"; "new file contents"; "0"]; ["cat"; "/new"]], "new file contents")], "make a filesystem with block size", @@ -3571,7 +3647,7 @@ are C<1024>, C<2048> or C<4096> only."); [["sfdiskM"; "/dev/sda"; ",100 ,"]; ["mke2journal"; "4096"; "/dev/sda1"]; ["mke2fs_J"; "ext2"; "4096"; "/dev/sda2"; "/dev/sda1"]; - ["mount"; "/dev/sda2"; "/"]; + ["mount_options"; ""; "/dev/sda2"; "/"]; ["write_file"; "/new"; "new file contents"; "0"]; ["cat"; "/new"]], "new file contents")], "make ext2/3/4 external journal", @@ -3586,7 +3662,7 @@ to the command: [["sfdiskM"; "/dev/sda"; ",100 ,"]; ["mke2journal_L"; "4096"; "JOURNAL"; "/dev/sda1"]; ["mke2fs_JL"; "ext2"; "4096"; "/dev/sda2"; "JOURNAL"]; - ["mount"; "/dev/sda2"; "/"]; + ["mount_options"; ""; "/dev/sda2"; "/"]; ["write_file"; "/new"; "new file contents"; "0"]; ["cat"; "/new"]], "new file contents")], "make ext2/3/4 external journal with label", @@ -3599,7 +3675,7 @@ This creates an ext2 external journal on C with label C