X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=src%2Fgenerator.ml;h=960973da0071709623e88cf8574d063e46dc02f0;hp=73ba813e45ca06793dd04545feded00923000480;hb=f850e1f065fb04df7cc87a921ab3c658741cc393;hpb=05273da8830f2f10e417115a3981924a8b14228a diff --git a/src/generator.ml b/src/generator.ml index 73ba813..960973d 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -598,6 +598,35 @@ actions using the low-level API. For more information on states, see L."); + ("set_memsize", (RErr, [Int "memsize"]), -1, [FishAlias "memsize"], + [], + "set memory allocated to the qemu subprocess", + "\ +This sets the memory size in megabytes allocated to the +qemu subprocess. This only has any effect if called before +C. + +You can also change this by setting the environment +variable C before the handle is +created. + +For more information on the architecture of libguestfs, +see L."); + + ("get_memsize", (RInt "memsize", []), -1, [], + [], + "get memory allocated to the qemu subprocess", + "\ +This gets the memory size in megabytes allocated to the +qemu subprocess. + +If C was not called +on this handle, and if C was not set, +then this returns the compiled-in default value for memsize. + +For more information on the architecture of libguestfs, +see L."); + ] (* daemon_functions are any functions which cause some action @@ -1314,51 +1343,51 @@ particular that the filename is not prepended to the output ("command", (RString "output", [StringList "arguments"]), 50, [ProtocolLimitWarning], [InitBasicFS, Always, TestOutput ( [["upload"; "test-command"; "/test-command"]; - ["chmod"; "493"; "/test-command"]; + ["chmod"; "0o755"; "/test-command"]; ["command"; "/test-command 1"]], "Result1"); InitBasicFS, Always, TestOutput ( [["upload"; "test-command"; "/test-command"]; - ["chmod"; "493"; "/test-command"]; + ["chmod"; "0o755"; "/test-command"]; ["command"; "/test-command 2"]], "Result2\n"); InitBasicFS, Always, TestOutput ( [["upload"; "test-command"; "/test-command"]; - ["chmod"; "493"; "/test-command"]; + ["chmod"; "0o755"; "/test-command"]; ["command"; "/test-command 3"]], "\nResult3"); InitBasicFS, Always, TestOutput ( [["upload"; "test-command"; "/test-command"]; - ["chmod"; "493"; "/test-command"]; + ["chmod"; "0o755"; "/test-command"]; ["command"; "/test-command 4"]], "\nResult4\n"); InitBasicFS, Always, TestOutput ( [["upload"; "test-command"; "/test-command"]; - ["chmod"; "493"; "/test-command"]; + ["chmod"; "0o755"; "/test-command"]; ["command"; "/test-command 5"]], "\nResult5\n\n"); InitBasicFS, Always, TestOutput ( [["upload"; "test-command"; "/test-command"]; - ["chmod"; "493"; "/test-command"]; + ["chmod"; "0o755"; "/test-command"]; ["command"; "/test-command 6"]], "\n\nResult6\n\n"); InitBasicFS, Always, TestOutput ( [["upload"; "test-command"; "/test-command"]; - ["chmod"; "493"; "/test-command"]; + ["chmod"; "0o755"; "/test-command"]; ["command"; "/test-command 7"]], ""); InitBasicFS, Always, TestOutput ( [["upload"; "test-command"; "/test-command"]; - ["chmod"; "493"; "/test-command"]; + ["chmod"; "0o755"; "/test-command"]; ["command"; "/test-command 8"]], "\n"); InitBasicFS, Always, TestOutput ( [["upload"; "test-command"; "/test-command"]; - ["chmod"; "493"; "/test-command"]; + ["chmod"; "0o755"; "/test-command"]; ["command"; "/test-command 9"]], "\n\n"); InitBasicFS, Always, TestOutput ( [["upload"; "test-command"; "/test-command"]; - ["chmod"; "493"; "/test-command"]; + ["chmod"; "0o755"; "/test-command"]; ["command"; "/test-command 10"]], "Result10-1\nResult10-2\n"); InitBasicFS, Always, TestOutput ( [["upload"; "test-command"; "/test-command"]; - ["chmod"; "493"; "/test-command"]; + ["chmod"; "0o755"; "/test-command"]; ["command"; "/test-command 11"]], "Result11-1\nResult11-2"); InitBasicFS, Always, TestLastFail ( [["upload"; "test-command"; "/test-command"]; - ["chmod"; "493"; "/test-command"]; + ["chmod"; "0o755"; "/test-command"]; ["command"; "/test-command"]])], "run a command from the guest filesystem", "\ @@ -1395,47 +1424,47 @@ locations."); ("command_lines", (RStringList "lines", [StringList "arguments"]), 51, [ProtocolLimitWarning], [InitBasicFS, Always, TestOutputList ( [["upload"; "test-command"; "/test-command"]; - ["chmod"; "493"; "/test-command"]; + ["chmod"; "0o755"; "/test-command"]; ["command_lines"; "/test-command 1"]], ["Result1"]); InitBasicFS, Always, TestOutputList ( [["upload"; "test-command"; "/test-command"]; - ["chmod"; "493"; "/test-command"]; + ["chmod"; "0o755"; "/test-command"]; ["command_lines"; "/test-command 2"]], ["Result2"]); InitBasicFS, Always, TestOutputList ( [["upload"; "test-command"; "/test-command"]; - ["chmod"; "493"; "/test-command"]; + ["chmod"; "0o755"; "/test-command"]; ["command_lines"; "/test-command 3"]], ["";"Result3"]); InitBasicFS, Always, TestOutputList ( [["upload"; "test-command"; "/test-command"]; - ["chmod"; "493"; "/test-command"]; + ["chmod"; "0o755"; "/test-command"]; ["command_lines"; "/test-command 4"]], ["";"Result4"]); InitBasicFS, Always, TestOutputList ( [["upload"; "test-command"; "/test-command"]; - ["chmod"; "493"; "/test-command"]; + ["chmod"; "0o755"; "/test-command"]; ["command_lines"; "/test-command 5"]], ["";"Result5";""]); InitBasicFS, Always, TestOutputList ( [["upload"; "test-command"; "/test-command"]; - ["chmod"; "493"; "/test-command"]; + ["chmod"; "0o755"; "/test-command"]; ["command_lines"; "/test-command 6"]], ["";"";"Result6";""]); InitBasicFS, Always, TestOutputList ( [["upload"; "test-command"; "/test-command"]; - ["chmod"; "493"; "/test-command"]; + ["chmod"; "0o755"; "/test-command"]; ["command_lines"; "/test-command 7"]], []); InitBasicFS, Always, TestOutputList ( [["upload"; "test-command"; "/test-command"]; - ["chmod"; "493"; "/test-command"]; + ["chmod"; "0o755"; "/test-command"]; ["command_lines"; "/test-command 8"]], [""]); InitBasicFS, Always, TestOutputList ( [["upload"; "test-command"; "/test-command"]; - ["chmod"; "493"; "/test-command"]; + ["chmod"; "0o755"; "/test-command"]; ["command_lines"; "/test-command 9"]], ["";""]); InitBasicFS, Always, TestOutputList ( [["upload"; "test-command"; "/test-command"]; - ["chmod"; "493"; "/test-command"]; + ["chmod"; "0o755"; "/test-command"]; ["command_lines"; "/test-command 10"]], ["Result10-1";"Result10-2"]); InitBasicFS, Always, TestOutputList ( [["upload"; "test-command"; "/test-command"]; - ["chmod"; "493"; "/test-command"]; + ["chmod"; "0o755"; "/test-command"]; ["command_lines"; "/test-command 11"]], ["Result11-1";"Result11-2"])], "run a command, returning lines", "\ @@ -2131,7 +2160,13 @@ The returned strings are transcoded to UTF-8."); ("hexdump", (RString "dump", [String "path"]), 96, [ProtocolLimitWarning], [InitBasicFS, Always, TestOutput ( [["write_file"; "/new"; "hello\nworld\n"; "12"]; - ["hexdump"; "/new"]], "00000000 68 65 6c 6c 6f 0a 77 6f 72 6c 64 0a |hello.world.|\n0000000c\n")], + ["hexdump"; "/new"]], "00000000 68 65 6c 6c 6f 0a 77 6f 72 6c 64 0a |hello.world.|\n0000000c\n"); + (* Test for RHBZ#501888c2 regression which caused large hexdump + * commands to segfault. + *) + InitBasicFS, Always, TestRun ( + [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"]; + ["hexdump"; "/100krandom"]])], "dump a file in hexadecimal", "\ This runs C on the given C. The result is @@ -2167,7 +2202,7 @@ or data on the filesystem."); This resizes (expands or shrinks) an existing LVM physical volume to match the new size of the underlying device."); - ("sfdisk_N", (RErr, [String "device"; Int "n"; + ("sfdisk_N", (RErr, [String "device"; Int "partnum"; Int "cyls"; Int "heads"; Int "sectors"; String "line"]), 99, [DangerWillRobinson], [], @@ -2467,6 +2502,250 @@ directory and its contents after use. See also: L"); + ("wc_l", (RInt "lines", [String "path"]), 118, [], + [InitBasicFS, Always, TestOutputInt ( + [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"]; + ["wc_l"; "/10klines"]], 10000)], + "count lines in a file", + "\ +This command counts the lines in a file, using the +C external command."); + + ("wc_w", (RInt "words", [String "path"]), 119, [], + [InitBasicFS, Always, TestOutputInt ( + [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"]; + ["wc_w"; "/10klines"]], 10000)], + "count words in a file", + "\ +This command counts the words in a file, using the +C external command."); + + ("wc_c", (RInt "chars", [String "path"]), 120, [], + [InitBasicFS, Always, TestOutputInt ( + [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"]; + ["wc_c"; "/100kallspaces"]], 102400)], + "count characters in a file", + "\ +This command counts the characters in a file, using the +C external command."); + + ("head", (RStringList "lines", [String "path"]), 121, [ProtocolLimitWarning], + [InitBasicFS, Always, TestOutputList ( + [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"]; + ["head"; "/10klines"]], ["0abcdefghijklmnopqrstuvwxyz";"1abcdefghijklmnopqrstuvwxyz";"2abcdefghijklmnopqrstuvwxyz";"3abcdefghijklmnopqrstuvwxyz";"4abcdefghijklmnopqrstuvwxyz";"5abcdefghijklmnopqrstuvwxyz";"6abcdefghijklmnopqrstuvwxyz";"7abcdefghijklmnopqrstuvwxyz";"8abcdefghijklmnopqrstuvwxyz";"9abcdefghijklmnopqrstuvwxyz"])], + "return first 10 lines of a file", + "\ +This command returns up to the first 10 lines of a file as +a list of strings."); + + ("head_n", (RStringList "lines", [Int "nrlines"; String "path"]), 122, [ProtocolLimitWarning], + [InitBasicFS, Always, TestOutputList ( + [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"]; + ["head_n"; "3"; "/10klines"]], ["0abcdefghijklmnopqrstuvwxyz";"1abcdefghijklmnopqrstuvwxyz";"2abcdefghijklmnopqrstuvwxyz"]); + InitBasicFS, Always, TestOutputList ( + [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"]; + ["head_n"; "-9997"; "/10klines"]], ["0abcdefghijklmnopqrstuvwxyz";"1abcdefghijklmnopqrstuvwxyz";"2abcdefghijklmnopqrstuvwxyz"]); + InitBasicFS, Always, TestOutputList ( + [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"]; + ["head_n"; "0"; "/10klines"]], [])], + "return first N lines of a file", + "\ +If the parameter C is a positive number, this returns the first +C lines of the file C. + +If the parameter C is a negative number, this returns lines +from the file C, excluding the last C lines. + +If the parameter C is zero, this returns an empty list."); + + ("tail", (RStringList "lines", [String "path"]), 123, [ProtocolLimitWarning], + [InitBasicFS, Always, TestOutputList ( + [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"]; + ["tail"; "/10klines"]], ["9990abcdefghijklmnopqrstuvwxyz";"9991abcdefghijklmnopqrstuvwxyz";"9992abcdefghijklmnopqrstuvwxyz";"9993abcdefghijklmnopqrstuvwxyz";"9994abcdefghijklmnopqrstuvwxyz";"9995abcdefghijklmnopqrstuvwxyz";"9996abcdefghijklmnopqrstuvwxyz";"9997abcdefghijklmnopqrstuvwxyz";"9998abcdefghijklmnopqrstuvwxyz";"9999abcdefghijklmnopqrstuvwxyz"])], + "return last 10 lines of a file", + "\ +This command returns up to the last 10 lines of a file as +a list of strings."); + + ("tail_n", (RStringList "lines", [Int "nrlines"; String "path"]), 124, [ProtocolLimitWarning], + [InitBasicFS, Always, TestOutputList ( + [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"]; + ["tail_n"; "3"; "/10klines"]], ["9997abcdefghijklmnopqrstuvwxyz";"9998abcdefghijklmnopqrstuvwxyz";"9999abcdefghijklmnopqrstuvwxyz"]); + InitBasicFS, Always, TestOutputList ( + [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"]; + ["tail_n"; "-9998"; "/10klines"]], ["9997abcdefghijklmnopqrstuvwxyz";"9998abcdefghijklmnopqrstuvwxyz";"9999abcdefghijklmnopqrstuvwxyz"]); + InitBasicFS, Always, TestOutputList ( + [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"]; + ["tail_n"; "0"; "/10klines"]], [])], + "return last N lines of a file", + "\ +If the parameter C is a positive number, this returns the last +C lines of the file C. + +If the parameter C is a negative number, this returns lines +from the file C, starting with the C<-nrlines>th line. + +If the parameter C is zero, this returns an empty list."); + + ("df", (RString "output", []), 125, [], + [], (* XXX Tricky to test because it depends on the exact format + * of the 'df' command and other imponderables. + *) + "report file system disk space usage", + "\ +This command runs the C command to report disk space used. + +This command is mostly useful for interactive sessions. It +is I intended that you try to parse the output string. +Use C from programs."); + + ("df_h", (RString "output", []), 126, [], + [], (* XXX Tricky to test because it depends on the exact format + * of the 'df' command and other imponderables. + *) + "report file system disk space usage (human readable)", + "\ +This command runs the C command to report disk space used +in human-readable format. + +This command is mostly useful for interactive sessions. It +is I intended that you try to parse the output string. +Use C from programs."); + + ("du", (RInt64 "sizekb", [String "path"]), 127, [], + [InitBasicFS, Always, TestOutputInt ( + [["mkdir"; "/p"]; + ["du"; "/p"]], 1 (* ie. 1 block, so depends on ext3 blocksize *))], + "estimate file space usage", + "\ +This command runs the C command to estimate file space +usage for C. + +C can be a file or a directory. If C is a directory +then the estimate includes the contents of the directory and all +subdirectories (recursively). + +The result is the estimated size in I +(ie. units of 1024 bytes)."); + + ("initrd_list", (RStringList "filenames", [String "path"]), 128, [], + [InitBasicFS, Always, TestOutputList ( + [["mount_vfs"; "ro"; "squashfs"; "/dev/sdd"; "/"]; + ["initrd_list"; "/initrd"]], ["empty";"known-1";"known-2";"known-3"])], + "list files in an initrd", + "\ +This command lists out files contained in an initrd. + +The files are listed without any initial C character. The +files are listed in the order they appear (not necessarily +alphabetical). Directory names are listed as separate items. + +Old Linux kernels (2.4 and earlier) used a compressed ext2 +filesystem as initrd. We I support the newer initramfs +format (compressed cpio files)."); + + ("mount_loop", (RErr, [String "file"; String "mountpoint"]), 129, [], + [], + "mount a file using the loop device", + "\ +This command lets you mount C (a filesystem image +in a file) on a mount point. It is entirely equivalent to +the command C."); + + ("mkswap", (RErr, [String "device"]), 130, [], + [InitEmpty, Always, TestRun ( + [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ","]; + ["mkswap"; "/dev/sda1"]])], + "create a swap partition", + "\ +Create a swap partition on C."); + + ("mkswap_L", (RErr, [String "label"; String "device"]), 131, [], + [InitEmpty, Always, TestRun ( + [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ","]; + ["mkswap_L"; "hello"; "/dev/sda1"]])], + "create a swap partition with a label", + "\ +Create a swap partition on C with label C