X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=src%2Fgenerator.ml;h=e3453a3adae9fb704bb93248d11e5ce5fe988313;hp=c9b3315656b16892f0bb8c2eb5548d031c2c88d6;hb=0c07f0d23698798475e0d09491812aca52440328;hpb=8ae7e1057f43e9b79260cdf191f39d657fdf0293 diff --git a/src/generator.ml b/src/generator.ml index c9b3315..e3453a3 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -134,6 +134,7 @@ and args = argt list (* Function parameters, guestfs handle is implicit. *) *) and argt = | String of string (* const char *name, cannot be NULL *) + | Device of string (* /dev device name, cannot be NULL *) | OptString of string (* const char *name, may be NULL *) | StringList of string(* list of strings (each string cannot be NULL) *) | Bool of string (* boolean *) @@ -301,6 +302,12 @@ and test_init = (* Block devices are empty and no filesystems are mounted. *) | InitEmpty + (* /dev/sda contains a single partition /dev/sda1, with random + * content. /dev/sdb and /dev/sdc may have random content. + * No LVM. + *) + | InitPartition + (* /dev/sda contains a single partition /dev/sda1, which is formatted * as ext2, empty [except for lost+found] and mounted on /. * /dev/sdb and /dev/sdc may have random content. @@ -448,6 +455,8 @@ 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. Note that this call checks for the existence of C. This stops you from specifying other types of drive which are supported @@ -755,6 +764,31 @@ C<$major.$minor.$release$extra> I Don't use this call to test for availability of features. Distro backports makes this unreliable."); + ("set_selinux", (RErr, [Bool "selinux"]), -1, [FishAlias "selinux"], + [InitNone, Always, TestOutputTrue ( + [["set_selinux"; "true"]; + ["get_selinux"]])], + "set SELinux enabled or disabled at appliance boot", + "\ +This sets the selinux flag that is passed to the appliance +at boot time. The default is C (disabled). + +Note that if SELinux is enabled, it is always in +Permissive mode (C). + +For more information on the architecture of libguestfs, +see L."); + + ("get_selinux", (RBool "selinux", []), -1, [], + [], + "get SELinux enabled flag", + "\ +This returns the current setting of the selinux flag which +is passed to the appliance at boot time. See C. + +For more information on the architecture of libguestfs, +see L."); + ] (* daemon_functions are any functions which cause some action @@ -762,7 +796,7 @@ of features. Distro backports makes this unreliable."); *) let daemon_functions = [ - ("mount", (RErr, [String "device"; String "mountpoint"]), 1, [], + ("mount", (RErr, [Device "device"; String "mountpoint"]), 1, [], [InitEmpty, Always, TestOutput ( [["sfdiskM"; "/dev/sda"; ","]; ["mkfs"; "ext2"; "/dev/sda1"]; @@ -1258,7 +1292,7 @@ other objects like files. See also C."); - ("pvcreate", (RErr, [String "device"]), 39, [], + ("pvcreate", (RErr, [Device "device"]), 39, [], [InitEmpty, Always, TestOutputListOfDevices ( [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"]; ["pvcreate"; "/dev/sda1"]; @@ -1306,7 +1340,7 @@ from the non-empty list of physical volumes C."); This creates an LVM volume group called C on the volume group C, with C megabytes."); - ("mkfs", (RErr, [String "fstype"; String "device"]), 42, [], + ("mkfs", (RErr, [String "fstype"; Device "device"]), 42, [], [InitEmpty, Always, TestOutput ( [["sfdiskM"; "/dev/sda"; ","]; ["mkfs"; "ext2"; "/dev/sda1"]; @@ -1319,7 +1353,7 @@ This creates a filesystem on C (usually a partition or LVM logical volume). The filesystem type is C, for example C."); - ("sfdisk", (RErr, [String "device"; + ("sfdisk", (RErr, [Device "device"; Int "cyls"; Int "heads"; Int "sectors"; StringList "lines"]), 43, [DangerWillRobinson], [], @@ -1619,8 +1653,7 @@ This is the same as the C system call."); ("statvfs", (RStruct ("statbuf", "statvfs"), [String "path"]), 54, [], [InitSquashFS, Always, TestOutputStruct ( - [["statvfs"; "/"]], [CompareWithInt ("namemax", 256); - CompareWithInt ("bsize", 131072)])], + [["statvfs"; "/"]], [CompareWithInt ("namemax", 256)])], "get file system statistics", "\ Returns file system statistics for any mounted file system. @@ -1629,7 +1662,7 @@ C should be a file or directory in the mounted file system This is the same as the C system call."); - ("tune2fs_l", (RHashtable "superblock", [String "device"]), 55, [], + ("tune2fs_l", (RHashtable "superblock", [Device "device"]), 55, [], [], (* XXX test *) "get ext2/ext3/ext4 superblock details", "\ @@ -1641,7 +1674,7 @@ manpage for more details. The list of fields returned isn't clearly defined, and depends on both the version of C that libguestfs was built against, and the filesystem itself."); - ("blockdev_setro", (RErr, [String "device"]), 56, [], + ("blockdev_setro", (RErr, [Device "device"]), 56, [], [InitEmpty, Always, TestOutputTrue ( [["blockdev_setro"; "/dev/sda"]; ["blockdev_getro"; "/dev/sda"]])], @@ -1651,7 +1684,7 @@ Sets the block device named C to read-only. This uses the L command."); - ("blockdev_setrw", (RErr, [String "device"]), 57, [], + ("blockdev_setrw", (RErr, [Device "device"]), 57, [], [InitEmpty, Always, TestOutputFalse ( [["blockdev_setrw"; "/dev/sda"]; ["blockdev_getro"; "/dev/sda"]])], @@ -1661,7 +1694,7 @@ Sets the block device named C to read-write. This uses the L command."); - ("blockdev_getro", (RBool "ro", [String "device"]), 58, [], + ("blockdev_getro", (RBool "ro", [Device "device"]), 58, [], [InitEmpty, Always, TestOutputTrue ( [["blockdev_setro"; "/dev/sda"]; ["blockdev_getro"; "/dev/sda"]])], @@ -1672,7 +1705,7 @@ Returns a boolean indicating if the block device is read-only This uses the L command."); - ("blockdev_getss", (RInt "sectorsize", [String "device"]), 59, [], + ("blockdev_getss", (RInt "sectorsize", [Device "device"]), 59, [], [InitEmpty, Always, TestOutputInt ( [["blockdev_getss"; "/dev/sda"]], 512)], "get sectorsize of block device", @@ -1685,7 +1718,7 @@ for that). This uses the L command."); - ("blockdev_getbsz", (RInt "blocksize", [String "device"]), 60, [], + ("blockdev_getbsz", (RInt "blocksize", [Device "device"]), 60, [], [InitEmpty, Always, TestOutputInt ( [["blockdev_getbsz"; "/dev/sda"]], 4096)], "get blocksize of block device", @@ -1697,7 +1730,7 @@ I). This uses the L command."); - ("blockdev_setbsz", (RErr, [String "device"; Int "blocksize"]), 61, [], + ("blockdev_setbsz", (RErr, [Device "device"; Int "blocksize"]), 61, [], [], (* XXX test *) "set blocksize of block device", "\ @@ -1708,7 +1741,7 @@ I). This uses the L command."); - ("blockdev_getsz", (RInt64 "sizeinsectors", [String "device"]), 62, [], + ("blockdev_getsz", (RInt64 "sizeinsectors", [Device "device"]), 62, [], [InitEmpty, Always, TestOutputInt ( [["blockdev_getsz"; "/dev/sda"]], 1024000)], "get total size of device in 512-byte sectors", @@ -1722,7 +1755,7 @@ useful I. This uses the L command."); - ("blockdev_getsize64", (RInt64 "sizeinbytes", [String "device"]), 63, [], + ("blockdev_getsize64", (RInt64 "sizeinbytes", [Device "device"]), 63, [], [InitEmpty, Always, TestOutputInt ( [["blockdev_getsize64"; "/dev/sda"]], 524288000)], "get total size of device in bytes", @@ -1733,7 +1766,7 @@ See also C. This uses the L command."); - ("blockdev_flushbufs", (RErr, [String "device"]), 64, [], + ("blockdev_flushbufs", (RErr, [Device "device"]), 64, [], [InitEmpty, Always, TestRun [["blockdev_flushbufs"; "/dev/sda"]]], "flush device buffers", @@ -1743,7 +1776,7 @@ with C. This uses the L command."); - ("blockdev_rereadpt", (RErr, [String "device"]), 65, [], + ("blockdev_rereadpt", (RErr, [Device "device"]), 65, [], [InitEmpty, Always, TestRun [["blockdev_rereadpt"; "/dev/sda"]]], "reread partition table", @@ -1756,7 +1789,8 @@ This uses the L command."); [InitBasicFS, Always, TestOutput ( (* Pick a file from cwd which isn't likely to change. *) [["upload"; "../COPYING.LIB"; "/COPYING.LIB"]; - ["checksum"; "md5"; "/COPYING.LIB"]], "e3eda01d9815f8d24aae2dbd89b68b06")], + ["checksum"; "md5"; "/COPYING.LIB"]], + Digest.to_hex (Digest.file "COPYING.LIB"))], "upload a file from the local machine", "\ Upload local file C to C on the @@ -1772,7 +1806,8 @@ See also C."); [["upload"; "../COPYING.LIB"; "/COPYING.LIB"]; ["download"; "/COPYING.LIB"; "testdownload.tmp"]; ["upload"; "testdownload.tmp"; "/upload"]; - ["checksum"; "md5"; "/upload"]], "e3eda01d9815f8d24aae2dbd89b68b06")], + ["checksum"; "md5"; "/upload"]], + Digest.to_hex (Digest.file "COPYING.LIB"))], "download a file to the local machine", "\ Download file C and save it as C @@ -1882,7 +1917,7 @@ it to local file C. To download an uncompressed tarball, use C."); - ("mount_ro", (RErr, [String "device"; String "mountpoint"]), 73, [], + ("mount_ro", (RErr, [Device "device"; String "mountpoint"]), 73, [], [InitBasicFS, Always, TestLastFail ( [["umount"; "/"]; ["mount_ro"; "/dev/sda1"; "/"]; @@ -1897,7 +1932,7 @@ To download an uncompressed tarball, use C."); This is the same as the C command, but it mounts the filesystem with the read-only (I<-o ro>) flag."); - ("mount_options", (RErr, [String "options"; String "device"; String "mountpoint"]), 74, [], + ("mount_options", (RErr, [String "options"; Device "device"; String "mountpoint"]), 74, [], [], "mount a guest disk with mount options", "\ @@ -1905,7 +1940,7 @@ This is the same as the C command, but it allows you to set the mount options as for the L I<-o> flag."); - ("mount_vfs", (RErr, [String "options"; String "vfstype"; String "device"; String "mountpoint"]), 75, [], + ("mount_vfs", (RErr, [String "options"; String "vfstype"; Device "device"; String "mountpoint"]), 75, [], [], "mount a guest disk with mount options and vfstype", "\ @@ -1925,7 +1960,7 @@ There is no comprehensive help for this command. You have to look at the file C in the libguestfs source to find out what you can do."); - ("lvremove", (RErr, [String "device"]), 77, [], + ("lvremove", (RErr, [Device "device"]), 77, [], [InitEmpty, Always, TestOutputList ( [["sfdiskM"; "/dev/sda"; ","]; ["pvcreate"; "/dev/sda1"]; @@ -1982,7 +2017,7 @@ Remove an LVM volume group C, (for example C). This also forcibly removes all logical volumes in the volume group (if any)."); - ("pvremove", (RErr, [String "device"]), 79, [], + ("pvremove", (RErr, [Device "device"]), 79, [], [InitEmpty, Always, TestOutputListOfDevices ( [["sfdiskM"; "/dev/sda"; ","]; ["pvcreate"; "/dev/sda1"]; @@ -2019,7 +2054,7 @@ The implementation uses the C command which refuses to wipe physical volumes that contain any volume groups, so you have to remove those first."); - ("set_e2label", (RErr, [String "device"; String "label"]), 80, [], + ("set_e2label", (RErr, [Device "device"; String "label"]), 80, [], [InitBasicFS, Always, TestOutput ( [["set_e2label"; "/dev/sda1"; "testlabel"]; ["get_e2label"; "/dev/sda1"]], "testlabel")], @@ -2032,14 +2067,14 @@ C to C