X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=generator%2Fgenerator_actions.ml;h=ac8dab218fe283c02f98caf18e39b1930720ebce;hb=425374ddc84c4f9f74a5218e8d35452bb511d9f3;hp=2e015070fcf601fae06fa6b631aa4674fb4d32d7;hpb=000c4a82fbd78667849551114b6d08f391324796;p=libguestfs.git diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml index 2e01507..d73a999 100644 --- a/generator/generator_actions.ml +++ b/generator/generator_actions.ml @@ -1,5 +1,5 @@ (* libguestfs - * Copyright (C) 2009-2010 Red Hat Inc. + * Copyright (C) 2009-2011 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 @@ -58,7 +58,7 @@ let test_all_rets = [ ] let test_functions = [ - ("test0", (RErr, test_all_args), -1, [NotInFish; NotInDocs], + ("test0", (RErr, test_all_args, []), -1, [NotInFish; NotInDocs], [], "internal test function - do not use", "\ @@ -72,7 +72,7 @@ You probably don't want to call this function."); ] @ List.flatten ( List.map ( fun (name, ret) -> - [(name, (ret, [String "val"]), -1, [NotInFish; NotInDocs], + [(name, (ret, [String "val"], []), -1, [NotInFish; NotInDocs], [], "internal test function - do not use", "\ @@ -83,7 +83,7 @@ return type correctly. It converts string C to the return type. You probably don't want to call this function."); - (name ^ "err", (ret, []), -1, [NotInFish; NotInDocs], + (name ^ "err", (ret, [], []), -1, [NotInFish; NotInDocs], [], "internal test function - do not use", "\ @@ -103,7 +103,7 @@ You probably don't want to call this function.")] *) let non_daemon_functions = test_functions @ [ - ("launch", (RErr, []), -1, [FishAlias "run"], + ("launch", (RErr, [], []), -1, [FishAlias "run"; Progress], [], "launch the qemu subprocess", "\ @@ -113,7 +113,7 @@ using L. You should call this after configuring the handle (eg. adding drives) but before performing any actions."); - ("wait_ready", (RErr, []), -1, [NotInFish], + ("wait_ready", (RErr, [], []), -1, [NotInFish; DeprecatedBy "launch"], [], "wait until the qemu subprocess launches (no op)", "\ @@ -128,50 +128,34 @@ If you see any calls to this function in code then you can just remove them, unless you want to retain compatibility with older versions of the API."); - ("kill_subprocess", (RErr, []), -1, [], + ("kill_subprocess", (RErr, [], []), -1, [], [], "kill the qemu subprocess", "\ This kills the qemu subprocess. You should never need to call this."); - ("add_drive", (RErr, [String "filename"]), -1, [FishAlias "add"], + ("add_drive", (RErr, [String "filename"], []), -1, [], [], "add an image to examine or modify", "\ -This function adds a virtual machine disk image C to the -guest. The first time you call this function, the disk appears as IDE -disk 0 (C) in the guest, the second time as C, 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 is equivalent to the qemu parameter -C<-drive file=filename,cache=off,if=...>. +This function is the equivalent of calling C +with no optional parameters, so the disk is added writable, with +the format being detected automatically. -C is omitted in cases where it is not supported by -the underlying filesystem. +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. Therefore you should think about replacing +calls to this function with calls to C, +and specifying the format."); -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 -the general C call instead."); - - ("add_cdrom", (RErr, [String "filename"]), -1, [FishAlias "cdrom"], + ("add_cdrom", (RErr, [String "filename"], []), -1, [DeprecatedBy "add_drive_opts"], [], "add a CD-ROM disk image to examine", "\ This function adds a virtual CD-ROM disk image to the guest. -This is equivalent to the qemu parameter C<-cdrom filename>. +This is equivalent to the qemu parameter I<-cdrom filename>. Notes: @@ -192,38 +176,21 @@ should probably use C instead. =back"); - ("add_drive_ro", (RErr, [String "filename"]), -1, [FishAlias "add-ro"], + ("add_drive_ro", (RErr, [String "filename"], []), -1, [FishAlias "add-ro"], [], "add a drive in snapshot mode (read-only)", "\ -This adds a drive in snapshot mode, making it effectively -read-only. - -Note that writes to the device are allowed, and will be seen for -the duration of the guestfs handle, but they are written -to a temporary file which is discarded as soon as the guestfs -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 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 -the general C call instead."); +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."); - ("config", (RErr, [String "qemuparam"; OptString "qemuvalue"]), -1, [], + ("config", (RErr, [String "qemuparam"; OptString "qemuvalue"], []), -1, [], [], "add qemu parameters", "\ This can be used to add arbitrary qemu command line parameters -of the form C<-param value>. Actually it's not quite arbitrary - we +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. @@ -231,7 +198,7 @@ The first character of C string must be a C<-> (dash). C can be NULL."); - ("set_qemu", (RErr, [OptString "qemu"]), -1, [FishAlias "qemu"], + ("set_qemu", (RErr, [OptString "qemu"], []), -1, [FishAlias "qemu"], [], "set the qemu binary", "\ @@ -253,7 +220,7 @@ 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, [], + ("get_qemu", (RConstString "qemu", [], []), -1, [], [InitNone, Always, TestRun ( [["get_qemu"]])], "get the qemu binary", @@ -263,7 +230,7 @@ Return the current qemu binary. This is always non-NULL. If it wasn't set already, then this will return the default qemu binary name."); - ("set_path", (RErr, [OptString "searchpath"]), -1, [FishAlias "path"], + ("set_path", (RErr, [OptString "searchpath"], []), -1, [FishAlias "path"], [], "set the search path", "\ @@ -274,7 +241,7 @@ C environment variable. Setting C to C restores the default path."); - ("get_path", (RConstString "path", []), -1, [], + ("get_path", (RConstString "path", [], []), -1, [], [InitNone, Always, TestRun ( [["get_path"]])], "get the search path", @@ -284,7 +251,7 @@ Return the current search path. This is always non-NULL. If it wasn't set already, then this will return the default path."); - ("set_append", (RErr, [OptString "append"]), -1, [FishAlias "append"], + ("set_append", (RErr, [OptString "append"], []), -1, [FishAlias "append"], [], "add options to kernel command line", "\ @@ -297,7 +264,7 @@ C environment variable. Setting C to C means I additional options are passed (libguestfs always adds a few of its own)."); - ("get_append", (RConstOptString "append", []), -1, [], + ("get_append", (RConstOptString "append", [], []), -1, [], (* This cannot be tested with the current framework. The * function can return NULL in normal operations, which the * test framework interprets as an error. @@ -310,41 +277,45 @@ guest kernel command line. If C then no options are added."); - ("set_autosync", (RErr, [Bool "autosync"]), -1, [FishAlias "autosync"], + ("set_autosync", (RErr, [Bool "autosync"], []), -1, [FishAlias "autosync"], [], "set autosync mode", "\ If C is true, this enables autosync. Libguestfs will make a -best effort attempt to run C followed by -C when the handle is closed +best effort attempt to make filesystems consistent and synchronized +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 ( + ("get_autosync", (RBool "autosync", [], []), -1, [], + [InitNone, Always, TestOutputTrue ( [["get_autosync"]])], "get autosync mode", "\ Get the autosync flag."); - ("set_verbose", (RErr, [Bool "verbose"]), -1, [FishAlias "verbose"], + ("set_verbose", (RErr, [Bool "verbose"], []), -1, [FishAlias "verbose"], [], "set verbose mode", "\ -If C is true, this turns on verbose messages (to C). +If C is true, this turns on verbose messages. Verbose messages are disabled unless the environment variable -C is defined and set to C<1>."); +C is defined and set to C<1>. - ("get_verbose", (RBool "verbose", []), -1, [], +Verbose messages are normally sent to C, unless you +register a callback to send them somewhere else (see +C)."); + + ("get_verbose", (RBool "verbose", [], []), -1, [], [], "get verbose mode", "\ This returns the verbose messages flag."); - ("is_ready", (RBool "ready", []), -1, [], + ("is_ready", (RBool "ready", [], []), -1, [], [InitNone, Always, TestOutputTrue ( [["is_ready"]])], "is ready to accept commands", @@ -354,7 +325,7 @@ This returns true iff this handle is ready to accept commands For more information on states, see L."); - ("is_config", (RBool "config", []), -1, [], + ("is_config", (RBool "config", [], []), -1, [], [InitNone, Always, TestOutputFalse ( [["is_config"]])], "is in configuration state", @@ -364,7 +335,7 @@ This returns true iff this handle is being configured For more information on states, see L."); - ("is_launching", (RBool "launching", []), -1, [], + ("is_launching", (RBool "launching", [], []), -1, [], [InitNone, Always, TestOutputFalse ( [["is_launching"]])], "is launching subprocess", @@ -374,7 +345,7 @@ This returns true iff this handle is launching the subprocess For more information on states, see L."); - ("is_busy", (RBool "busy", []), -1, [], + ("is_busy", (RBool "busy", [], []), -1, [], [InitNone, Always, TestOutputFalse ( [["is_busy"]])], "is busy processing a command", @@ -384,7 +355,7 @@ This returns true iff this handle is busy processing a command For more information on states, see L."); - ("get_state", (RInt "state", []), -1, [], + ("get_state", (RInt "state", [], []), -1, [], [], "get the current state", "\ @@ -393,7 +364,7 @@ only useful for printing debug and internal error messages. For more information on states, see L."); - ("set_memsize", (RErr, [Int "memsize"]), -1, [FishAlias "memsize"], + ("set_memsize", (RErr, [Int "memsize"], []), -1, [FishAlias "memsize"], [InitNone, Always, TestOutputInt ( [["set_memsize"; "500"]; ["get_memsize"]], 500)], @@ -410,7 +381,7 @@ created. For more information on the architecture of libguestfs, see L."); - ("get_memsize", (RInt "memsize", []), -1, [], + ("get_memsize", (RInt "memsize", [], []), -1, [], [InitNone, Always, TestOutputIntOp ( [["get_memsize"]], ">=", 256)], "get memory allocated to the qemu subprocess", @@ -425,7 +396,7 @@ then this returns the compiled-in default value for memsize. For more information on the architecture of libguestfs, see L."); - ("get_pid", (RInt "pid", []), -1, [FishAlias "pid"], + ("get_pid", (RInt "pid", [], []), -1, [FishAlias "pid"], [InitNone, Always, TestOutputIntOp ( [["get_pid"]], ">=", 1)], "get PID of qemu subprocess", @@ -435,7 +406,7 @@ qemu subprocess, then this will return an error. This is an internal call used for debugging and testing."); - ("version", (RStruct ("version", "version"), []), -1, [], + ("version", (RStruct ("version", "version"), [], []), -1, [], [InitNone, Always, TestOutputStruct ( [["version"]], [CompareWithInt ("major", 1)])], "get the library version number", @@ -471,7 +442,7 @@ features from later versions into earlier versions, making this an unreliable way to test for features. Use C instead."); - ("set_selinux", (RErr, [Bool "selinux"]), -1, [FishAlias "selinux"], + ("set_selinux", (RErr, [Bool "selinux"], []), -1, [FishAlias "selinux"], [InitNone, Always, TestOutputTrue ( [["set_selinux"; "true"]; ["get_selinux"]])], @@ -486,7 +457,7 @@ Permissive mode (C). For more information on the architecture of libguestfs, see L."); - ("get_selinux", (RBool "selinux", []), -1, [], + ("get_selinux", (RBool "selinux", [], []), -1, [], [], "get SELinux enabled flag", "\ @@ -496,33 +467,33 @@ is passed to the appliance at boot time. See C. For more information on the architecture of libguestfs, see L."); - ("set_trace", (RErr, [Bool "trace"]), -1, [FishAlias "trace"], + ("set_trace", (RErr, [Bool "trace"], []), -1, [FishAlias "trace"], [InitNone, Always, TestOutputFalse ( [["set_trace"; "false"]; ["get_trace"]])], "enable or disable command traces", "\ -If the command trace flag is set to 1, then commands are -printed on stderr before they are executed in a format -which is very similar to the one used by guestfish. In -other words, you can run a program with this enabled, and -you will get out a script which you can feed to guestfish -to perform the same set of actions. +If the command trace flag is set to 1, then libguestfs +calls, parameters and return values are traced. If you want to trace C API calls into libguestfs (and other libraries) then possibly a better way is to use the external ltrace(1) command. Command traces are disabled unless the environment variable -C is defined and set to C<1>."); +C is defined and set to C<1>. + +Trace messages are normally sent to C, unless you +register a callback to send them somewhere else (see +C)."); - ("get_trace", (RBool "trace", []), -1, [], + ("get_trace", (RBool "trace", [], []), -1, [], [], "get command trace enabled flag", "\ Return the command trace flag."); - ("set_direct", (RErr, [Bool "direct"]), -1, [FishAlias "direct"], + ("set_direct", (RErr, [Bool "direct"], []), -1, [FishAlias "direct"], [InitNone, Always, TestOutputFalse ( [["set_direct"; "false"]; ["get_direct"]])], @@ -541,13 +512,13 @@ are doing. The default is disabled."); - ("get_direct", (RBool "direct", []), -1, [], + ("get_direct", (RBool "direct", [], []), -1, [], [], "get direct appliance mode flag", "\ Return the direct appliance mode flag."); - ("set_recovery_proc", (RErr, [Bool "recoveryproc"]), -1, [FishAlias "recovery-proc"], + ("set_recovery_proc", (RErr, [Bool "recoveryproc"], []), -1, [FishAlias "recovery-proc"], [InitNone, Always, TestOutputTrue ( [["set_recovery_proc"; "true"]; ["get_recovery_proc"]])], @@ -567,27 +538,27 @@ if the main process will fork itself into the background thinks that the main program has disappeared and so kills qemu, which is not very helpful."); - ("get_recovery_proc", (RBool "recoveryproc", []), -1, [], + ("get_recovery_proc", (RBool "recoveryproc", [], []), -1, [], [], "get recovery process enabled flag", "\ Return the recovery process enabled flag."); - ("add_drive_with_if", (RErr, [String "filename"; String "iface"]), -1, [], + ("add_drive_with_if", (RErr, [String "filename"; String "iface"], []), -1, [DeprecatedBy "add_drive_opts"], [], "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_drive_ro_with_if", (RErr, [String "filename"; String "iface"], []), -1, [DeprecatedBy "add_drive_opts"], [], "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."); - ("file_architecture", (RString "arch", [Pathname "filename"]), -1, [], + ("file_architecture", (RString "arch", [Pathname "filename"], []), -1, [], [InitISOFS, Always, TestOutput ( [["file_architecture"; "/bin-i586-dynamic"]], "i386"); InitISOFS, Always, TestOutput ( @@ -715,7 +686,7 @@ initrd or kernel module(s) instead. =back"); - ("inspect_os", (RStringList "roots", []), -1, [], + ("inspect_os", (RStringList "roots", [], []), -1, [], [], "inspect disk and return list of operating systems found", "\ @@ -751,13 +722,10 @@ Please read L for more details. See also C."); - ("inspect_get_type", (RString "name", [Device "root"]), -1, [], + ("inspect_get_type", (RString "name", [Device "root"], []), -1, [], [], "get type of inspected operating system", "\ -This function should only be called with a root device string -as returned by C. - This returns the type of the inspected operating system. Currently defined types are: @@ -771,6 +739,14 @@ Any Linux-based operating system. Any Microsoft Windows operating system. +=item \"freebsd\" + +FreeBSD. + +=item \"netbsd\" + +NetBSD. + =item \"unknown\" The operating system type could not be determined. @@ -782,13 +758,10 @@ The caller should be prepared to handle any string. Please read L for more details."); - ("inspect_get_arch", (RString "arch", [Device "root"]), -1, [], + ("inspect_get_arch", (RString "arch", [Device "root"], []), -1, [], [], "get architecture of inspected operating system", "\ -This function should only be called with a root device string -as returned by C. - This returns the architecture of the inspected operating system. The possible return values are listed under C. @@ -798,13 +771,10 @@ string C is returned. Please read L for more details."); - ("inspect_get_distro", (RString "distro", [Device "root"]), -1, [], + ("inspect_get_distro", (RString "distro", [Device "root"], []), -1, [], [], "get distro of inspected operating system", "\ -This function should only be called with a root device string -as returned by C. - This returns the distro (distribution) of the inspected operating system. @@ -812,31 +782,83 @@ Currently defined distros are: =over 4 +=item \"archlinux\" + +Arch Linux. + +=item \"centos\" + +CentOS. + =item \"debian\" -Debian or a Debian-derived distro such as Ubuntu. +Debian. =item \"fedora\" Fedora. +=item \"gentoo\" + +Gentoo. + +=item \"linuxmint\" + +Linux Mint. + +=item \"mageia\" + +Mageia. + +=item \"mandriva\" + +Mandriva. + +=item \"meego\" + +MeeGo. + +=item \"opensuse\" + +OpenSUSE. + +=item \"pardus\" + +Pardus. + =item \"redhat-based\" Some Red Hat-derived distro. =item \"rhel\" -Red Hat Enterprise Linux and some derivatives. +Red Hat Enterprise Linux. -=item \"windows\" +=item \"scientificlinux\" -Windows does not have distributions. This string is -returned if the OS type is Windows. +Scientific Linux. + +=item \"slackware\" + +Slackware. + +=item \"ttylinux\" + +ttylinux. + +=item \"ubuntu\" + +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. @@ -844,13 +866,10 @@ The caller should be prepared to handle any string. Please read L for more details."); - ("inspect_get_major_version", (RInt "major", [Device "root"]), -1, [], + ("inspect_get_major_version", (RInt "major", [Device "root"], []), -1, [], [], "get major version of inspected operating system", "\ -This function should only be called with a root device string -as returned by C. - This returns the major version number of the inspected operating system. @@ -865,13 +884,10 @@ If the version could not be determined, then C<0> is returned. Please read L for more details."); - ("inspect_get_minor_version", (RInt "minor", [Device "root"]), -1, [], + ("inspect_get_minor_version", (RInt "minor", [Device "root"], []), -1, [], [], "get minor version of inspected operating system", "\ -This function should only be called with a root device string -as returned by C. - This returns the minor version number of the inspected operating system. @@ -880,13 +896,10 @@ If the version could not be determined, then C<0> is returned. Please read L for more details. See also C."); - ("inspect_get_product_name", (RString "product", [Device "root"]), -1, [], + ("inspect_get_product_name", (RString "product", [Device "root"], []), -1, [], [], "get product name of inspected operating system", "\ -This function should only be called with a root device string -as returned by C. - This returns the product name of the inspected operating system. The product name is generally some freeform string which can be displayed to the user, but should not be @@ -897,17 +910,18 @@ string C is returned. Please read L for more details."); - ("inspect_get_mountpoints", (RHashtable "mountpoints", [Device "root"]), -1, [], + ("inspect_get_mountpoints", (RHashtable "mountpoints", [Device "root"], []), -1, [], [], "get mountpoints of inspected operating system", "\ -This function should only be called with a root device string -as returned by C. - This returns a hash of where we think the filesystems associated with this operating system should be mounted. Callers should note that this is at best an educated guess made by reading configuration files such as C. +I that this may return filesystems +which are non-existent or not mountable and callers should +be prepared to handle or ignore failures if they try to +mount them. Each element in the returned hashtable has a key which is the path of the mountpoint (eg. C) and a value @@ -917,16 +931,19 @@ which is the filesystem that would be mounted there Non-mounted devices such as swap devices are I returned in this list. +For operating systems like Windows which still use drive +letters, this call will only return an entry for the first +drive \"mounted on\" C. For information about the +mapping of drive letters to partitions, see +C. + Please read L for more details. See also C."); - ("inspect_get_filesystems", (RStringList "filesystems", [Device "root"]), -1, [], + ("inspect_get_filesystems", (RStringList "filesystems", [Device "root"], []), -1, [], [], "get filesystems associated with inspected operating system", "\ -This function should only be called with a root device string -as returned by C. - This returns a list of all the filesystems that we think are associated with this operating system. This includes the root filesystem, other ordinary filesystems, and @@ -938,7 +955,7 @@ for a filesystem to be shared between operating systems. Please read L for more details. See also C."); - ("set_network", (RErr, [Bool "network"]), -1, [FishAlias "network"], + ("set_network", (RErr, [Bool "network"], []), -1, [FishAlias "network"], [], "set enable network flag", "\ @@ -951,13 +968,13 @@ This affects whether commands are able to access the network You must call this before calling C, otherwise it has no effect."); - ("get_network", (RBool "network", []), -1, [], + ("get_network", (RBool "network", [], []), -1, [], [], "get enable network flag", "\ This returns the enable network flag."); - ("list_filesystems", (RHashtable "fses", []), -1, [], + ("list_filesystems", (RHashtable "fses", [], []), -1, [], [], "list filesystems", "\ @@ -990,1170 +1007,1859 @@ be mountable but require special options. Filesystems may not all belong to a single logical operating system (use C to look for OSes)."); -] + ("add_drive_opts", (RErr, [String "filename"], [Bool "readonly"; String "format"; String "iface"; String "name"]), -1, [FishAlias "add"], + [], + "add an image to examine or modify", + "\ +This function adds a virtual machine disk image C to +libguestfs. The first time you call this function, the disk +appears as C, the second time as C, and +so on. -(* daemon_functions are any functions which cause some action - * to take place in the daemon. - *) +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). -let daemon_functions = [ - ("mount", (RErr, [Device "device"; String "mountpoint"]), 1, [], - [InitEmpty, Always, TestOutput ( - [["part_disk"; "/dev/sda"; "mbr"]; - ["mkfs"; "ext2"; "/dev/sda1"]; - ["mount"; "/dev/sda1"; "/"]; - ["write"; "/new"; "new file contents"]; - ["cat"; "/new"]], "new file contents")], - "mount a guest disk at a position in the filesystem", - "\ -Mount a guest disk at a position in the filesystem. Block devices -are named C, C and so on, as they were added to -the guest. If those block devices contain partitions, they will have -the usual names (eg. C). Also LVM C-style -names can be used. +This call checks that C exists. -The rules are the same as for L: A filesystem must -first be mounted on C before others can be mounted. Other -filesystems can only be mounted on directories which already -exist. +The optional arguments are: -The mounted filesystem is writable, if we have sufficient permissions -on the underlying device. +=over 4 -B -When you use this call, the filesystem options C and C -are set implicitly. This was originally done because we thought it -would improve reliability, but it turns out that I<-o sync> has a -very large negative performance impact and negligible effect on -reliability. Therefore we recommend that you avoid using -C in any code that needs performance, and instead -use C (use an empty string for the first -parameter if you don't want any options)."); - - ("sync", (RErr, []), 2, [], - [ InitEmpty, Always, TestRun [["sync"]]], - "sync disks, writes are flushed through to the disk image", - "\ -This syncs the disk, so that any writes are flushed through to the -underlying disk image. +=item C -You should always call this if you have modified a disk image, before -closing the handle."); +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. - ("touch", (RErr, [Pathname "path"]), 3, [], - [InitBasicFS, Always, TestOutputTrue ( - [["touch"; "/new"]; - ["exists"; "/new"]])], - "update file timestamps or create a new file", - "\ -Touch acts like the L command. It can be used to -update the timestamps on a file, or, if the file does not exist, -to create a new zero-length file. +=item C -This command only works on regular files, and will fail on other -file types such as directories, symbolic links, block special etc."); +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. - ("cat", (RString "content", [Pathname "path"]), 4, [ProtocolLimitWarning], - [InitISOFS, Always, TestOutput ( - [["cat"; "/known-2"]], "abcdef\n")], - "list the contents of a file", - "\ -Return the contents of the file named 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. -Note that this function cannot correctly handle binary files -(specifically, files containing C<\\0> character which is treated -as end of string). For those you need to use the C -or C functions which have a more complex interface."); +=item C - ("ll", (RString "listing", [Pathname "directory"]), 5, [], - [], (* XXX Tricky to test because it depends on the exact format - * of the 'ls -l' command, which changes between F10 and F11. - *) - "list the files in a directory (long format)", - "\ -List the files in C (relative to the root directory, -there is no cwd) in the format of 'ls -la'. +This rarely-used option lets you emulate the behaviour of the +deprecated C call (q.v.) -This command is mostly useful for interactive sessions. It -is I intended that you try to parse the output string."); +=item C - ("ls", (RStringList "listing", [Pathname "directory"]), 6, [], - [InitBasicFS, Always, TestOutputList ( - [["touch"; "/new"]; - ["touch"; "/newer"]; - ["touch"; "/newest"]; - ["ls"; "/"]], ["lost+found"; "new"; "newer"; "newest"])], - "list the files in a directory", - "\ -List the files in C (relative to the root directory, -there is no cwd). The '.' and '..' entries are not returned, but -hidden files are shown. +The name the drive had in the original guest, e.g. /dev/sdb. This is used as a +hint to the guest inspection process if it is available. -This command is mostly useful for interactive sessions. Programs -should probably use C instead."); +=back"); - ("list_devices", (RStringList "devices", []), 7, [], - [InitEmpty, Always, TestOutputListOfDevices ( - [["list_devices"]], ["/dev/sda"; "/dev/sdb"; "/dev/sdc"; "/dev/sdd"])], - "list the block devices", + ("inspect_get_windows_systemroot", (RString "systemroot", [Device "root"], []), -1, [], + [], + "get Windows systemroot of inspected operating system", "\ -List all the block devices. +This returns the Windows systemroot of the inspected guest. +The systemroot is a directory path such as C. -The full block device names are returned, eg. 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. -See also C."); +Please read L for more details."); - ("list_partitions", (RStringList "partitions", []), 8, [], - [InitBasicFS, Always, TestOutputListOfDevices ( - [["list_partitions"]], ["/dev/sda1"]); - InitEmpty, Always, TestOutputListOfDevices ( - [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"]; - ["list_partitions"]], ["/dev/sda1"; "/dev/sda2"; "/dev/sda3"])], - "list the partitions", + ("inspect_get_roots", (RStringList "roots", [], []), -1, [], + [], + "return list of operating systems found by last inspection", "\ -List all the partitions detected on all block devices. +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. -The full partition device names are returned, eg. C +This returns an empty list if either no root devices were +found or the caller has not called C. -This does not return logical volumes. For that you will need to -call C. +Please read L for more details."); -See also C."); + ("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."); - ("pvs", (RStringList "physvols", []), 9, [Optional "lvm2"], - [InitBasicFSonLVM, Always, TestOutputListOfDevices ( - [["pvs"]], ["/dev/sda1"]); - InitEmpty, Always, TestOutputListOfDevices ( - [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"]; - ["pvcreate"; "/dev/sda1"]; - ["pvcreate"; "/dev/sda2"]; - ["pvcreate"; "/dev/sda3"]; - ["pvs"]], ["/dev/sda1"; "/dev/sda2"; "/dev/sda3"])], - "list the LVM physical volumes (PVs)", + ("debug_drives", (RStringList "cmdline", [], []), -1, [NotInDocs], + [], + "debug the drives (internal use only)", "\ -List all the physical volumes detected. This is the equivalent -of the L command. +This returns the internal list of drives. 'debug' commands are +not part of the formal API and can be removed or changed at any time."); -This returns a list of just the device names that contain -PVs (eg. C). + ("add_domain", (RInt "nrdisks", [String "dom"], [String "libvirturi"; Bool "readonly"; String "iface"; Bool "live"; Bool "allowuuid"; String "readonlydisk"]), -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). + +The optional C flag controls whether this call will try +to connect to a running virtual machine C process if +it sees a suitable EchannelE element in the libvirt +XML definition. The default (if the flag is omitted) is never +to try. See L for more +information. + +If the C flag is true (default is false) then a UUID +I be passed instead of the domain name. The C string is +treated as a UUID first and looked up, and if that lookup fails +then we treat C as a name as usual. + +The optional C parameter controls what we do for +disks which are marked Ereadonly/E in the libvirt XML. +Possible values are: -See also C."); +=over 4 - ("vgs", (RStringList "volgroups", []), 10, [Optional "lvm2"], - [InitBasicFSonLVM, Always, TestOutputList ( - [["vgs"]], ["VG"]); - InitEmpty, Always, TestOutputList ( - [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"]; - ["pvcreate"; "/dev/sda1"]; - ["pvcreate"; "/dev/sda2"]; - ["pvcreate"; "/dev/sda3"]; - ["vgcreate"; "VG1"; "/dev/sda1 /dev/sda2"]; - ["vgcreate"; "VG2"; "/dev/sda3"]; - ["vgs"]], ["VG1"; "VG2"])], - "list the LVM volume groups (VGs)", - "\ -List all the volumes groups detected. This is the equivalent -of the L command. +=item readonlydisk = \"error\" -This returns a list of just the volume group names that were -detected (eg. C). +If C is false: -See also C."); +The whole call is aborted with an error if any disk with +the Ereadonly/E flag is found. - ("lvs", (RStringList "logvols", []), 11, [Optional "lvm2"], - [InitBasicFSonLVM, Always, TestOutputList ( - [["lvs"]], ["/dev/VG/LV"]); - InitEmpty, Always, TestOutputList ( - [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"]; - ["pvcreate"; "/dev/sda1"]; - ["pvcreate"; "/dev/sda2"]; - ["pvcreate"; "/dev/sda3"]; - ["vgcreate"; "VG1"; "/dev/sda1 /dev/sda2"]; - ["vgcreate"; "VG2"; "/dev/sda3"]; - ["lvcreate"; "LV1"; "VG1"; "50"]; - ["lvcreate"; "LV2"; "VG1"; "50"]; - ["lvcreate"; "LV3"; "VG2"; "50"]; - ["lvs"]], ["/dev/VG1/LV1"; "/dev/VG1/LV2"; "/dev/VG2/LV3"])], - "list the LVM logical volumes (LVs)", - "\ -List all the logical volumes detected. This is the equivalent -of the L command. +If C is true: -This returns a list of the logical volume device names -(eg. C). +Disks with the Ereadonly/E flag are added read-only. -See also C, C."); +=item readonlydisk = \"read\" - ("pvs_full", (RStructList ("physvols", "lvm_pv"), []), 12, [Optional "lvm2"], - [], (* XXX how to test? *) - "list the LVM physical volumes (PVs)", - "\ -List all the physical volumes detected. This is the equivalent -of the L command. The \"full\" version includes all fields."); +If C is false: - ("vgs_full", (RStructList ("volgroups", "lvm_vg"), []), 13, [Optional "lvm2"], - [], (* XXX how to test? *) - "list the LVM volume groups (VGs)", - "\ -List all the volumes groups detected. This is the equivalent -of the L command. The \"full\" version includes all fields."); +Disks with the Ereadonly/E flag are added read-only. +Other disks are added read/write. - ("lvs_full", (RStructList ("logvols", "lvm_lv"), []), 14, [Optional "lvm2"], - [], (* XXX how to test? *) - "list the LVM logical volumes (LVs)", - "\ -List all the logical volumes detected. This is the equivalent -of the L command. The \"full\" version includes all fields."); +If C is true: - ("read_lines", (RStringList "lines", [Pathname "path"]), 15, [], - [InitISOFS, Always, TestOutputList ( - [["read_lines"; "/known-4"]], ["abc"; "def"; "ghi"]); - InitISOFS, Always, TestOutputList ( - [["read_lines"; "/empty"]], [])], - "read file as lines", - "\ -Return the contents of the file named C. +Disks with the Ereadonly/E flag are added read-only. -The file contents are returned as a list of lines. Trailing -C and C character sequences are I returned. +=item readonlydisk = \"write\" (default) -Note that this function cannot correctly handle binary files -(specifically, files containing C<\\0> character which is treated -as end of line). For those you need to use the C -function which has a more complex interface."); +If C is false: - ("aug_init", (RErr, [Pathname "root"; Int "flags"]), 16, [Optional "augeas"], - [], (* XXX Augeas code needs tests. *) - "create a new Augeas handle", - "\ -Create a new Augeas handle for editing configuration files. -If there was any previous Augeas handle associated with this -guestfs session, then it is closed. +Disks with the Ereadonly/E flag are added read/write. -You must call this before using any other C -commands. +If C is true: -C is the filesystem root. C must not be NULL, -use C instead. +Disks with the Ereadonly/E flag are added read-only. -The flags are the same as the flags defined in -Eaugeas.hE, the logical I of the following -integers: +=item readonlydisk = \"ignore\" -=over 4 +If C is true or false: -=item C = 1 +Disks with the Ereadonly/E flag are skipped. -Keep the original file with a C<.augsave> extension. +=back -=item C = 2 +The other optional parameters are passed directly through to +C."); -Save changes into a file with extension C<.augnew>, and -do not overwrite original. Overrides C. +(* +This interface is not quite baked yet. -- RWMJ 2010-11-11 + ("add_libvirt_dom", (RInt "nrdisks", [Pointer ("virDomainPtr", "dom")], [Bool "readonly"; String "iface"; Bool "live"; String "readonlydisk"]), -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. -=item C = 4 +In the C API we declare C, but really it has type +C. This is so we don't need Elibvirt.hE. -Typecheck lenses (can be expensive). +The number of disks added is returned. This operation is atomic: +if an error is returned, then no disks are added. -=item C = 8 +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. -Do not use standard load path for modules. +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. -=item C = 16 +The optional C flag controls whether this call will try +to connect to a running virtual machine C process if +it sees a suitable EchannelE element in the libvirt +XML definition. The default (if the flag is omitted) is never +to try. See L for more +information. -Make save a no-op, just record what would have been changed. +The optional C parameter controls what we do for +disks which are marked Ereadonly/E in the libvirt XML. +See C for possible values. -=item C = 32 +The other optional parameters are passed directly through to +C."); +*) -Do not load the tree in C. + ("inspect_get_package_format", (RString "packageformat", [Device "root"], []), -1, [], + [], + "get package format used by the operating system", + "\ +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). -=back +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). -To close the handle, you can call C. +Possible strings include: +C, C, C, C, C, C. +Future versions of libguestfs may return other strings. -To find out more about Augeas, see L."); +Please read L for more details."); - ("aug_close", (RErr, []), 26, [Optional "augeas"], - [], (* XXX Augeas code needs tests. *) - "close the current Augeas handle", + ("inspect_get_package_management", (RString "packagemanagement", [Device "root"], []), -1, [], + [], + "get package management tool used by the operating system", "\ -Close the current Augeas handle and free up any resources -used by it. After calling this, you have to call -C again before you can use any other -Augeas functions."); +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). - ("aug_defvar", (RInt "nrnodes", [String "name"; OptString "expr"]), 17, [Optional "augeas"], - [], (* XXX Augeas code needs tests. *) - "define an Augeas variable", - "\ -Defines an Augeas variable C whose value is the result -of evaluating C. If C is NULL, then C is -undefined. +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). -On success this returns the number of nodes in C, or -C<0> if C evaluates to something which is not a nodeset."); +Possible strings include: C, C, +C (for all Debian derivatives), +C, C, C, C, C. +Future versions of libguestfs may return other strings. - ("aug_defnode", (RStruct ("nrnodescreated", "int_bool"), [String "name"; String "expr"; String "val"]), 18, [Optional "augeas"], - [], (* XXX Augeas code needs tests. *) - "define an Augeas node", - "\ -Defines a variable C whose value is the result of -evaluating C. +Please read L for more details."); -If C evaluates to an empty nodeset, a node is created, -equivalent to calling C C, C. -C will be the nodeset containing that single node. + ("inspect_list_applications", (RStructList ("applications", "application"), [Device "root"], []), -1, [], + [], + "get list of applications installed in the operating system", + "\ +Return the list of applications installed in the operating system. -On success this returns a pair containing the -number of nodes in the nodeset, and a boolean flag -if a node was created."); +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. - ("aug_get", (RString "val", [String "augpath"]), 19, [Optional "augeas"], - [], (* XXX Augeas code needs tests. *) - "look up the value of an Augeas path", - "\ -Look up the value associated with C. If C -matches exactly one node, the C is returned."); +This returns an empty list if the inspection code was not able +to determine the list of applications. - ("aug_set", (RErr, [String "augpath"; String "val"]), 20, [Optional "augeas"], - [], (* XXX Augeas code needs tests. *) - "set Augeas path to value", - "\ -Set the value associated with C to C. +The application structure contains the following fields: -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."); +=over 4 - ("aug_insert", (RErr, [String "augpath"; String "label"; Bool "before"]), 21, [Optional "augeas"], - [], (* XXX Augeas code needs tests. *) - "insert a sibling Augeas node", - "\ -Create a new sibling C