X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=src%2Fgenerator.ml;h=9d190977c6cd58f0cf8678bd1758d7c61843050b;hp=4f569ba5feb883dc9ec6535a79a0cab11c774c52;hb=50195d6ec4e893f894ef1bbf7af6eeda56f96600;hpb=5442f45aea522a728fa5b06396d4f08d8506d7de diff --git a/src/generator.ml b/src/generator.ml index 4f569ba..9d19097 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -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 @@ -544,13 +545,15 @@ 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 by qemu such as C and C URLs. To specify those, use @@ -2022,7 +2025,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, [], [], @@ -2031,7 +2035,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 ( @@ -2291,7 +2296,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. @@ -4237,7 +4242,7 @@ example to duplicate a filesystem. If the destination is a device, it must be as large or larger than the source file or device, otherwise the copy will fail. -This command cannot do partial copies."); +This command cannot do partial copies (see C)."); ("filesize", (RInt64 "size", [Pathname "file"]), 218, [], [InitBasicFS, Always, TestOutputInt ( @@ -4288,6 +4293,86 @@ contained in a Linux initrd or initramfs image: See also C."); + ("pvuuid", (RString "uuid", [Device "device"]), 222, [], + [], + "get the UUID of a physical volume", + "\ +This command returns the UUID of the LVM PV C."); + + ("vguuid", (RString "uuid", [String "vgname"]), 223, [], + [], + "get the UUID of a volume group", + "\ +This command returns the UUID of the LVM VG named C."); + + ("lvuuid", (RString "uuid", [Device "device"]), 224, [], + [], + "get the UUID of a logical volume", + "\ +This command returns the UUID of the LVM LV C."); + + ("vgpvuuids", (RStringList "uuids", [String "vgname"]), 225, [], + [], + "get the PV UUIDs containing the volume group", + "\ +Given a VG called C, this returns the UUIDs of all +the physical volumes that this volume group resides on. + +You can use this along with C and C +calls to associate physical volumes and volume groups. + +See also C."); + + ("vglvuuids", (RStringList "uuids", [String "vgname"]), 226, [], + [], + "get the LV UUIDs of all LVs in the volume group", + "\ +Given a VG called C, this returns the UUIDs of all +the logical volumes created in this volume group. + +You can use this along with C and C +calls to associate logical volumes and volume groups. + +See also C."); + + ("copy_size", (RErr, [Dev_or_Path "src"; Dev_or_Path "dest"; Int64 "size"]), 227, [], + [InitBasicFS, Always, TestOutputBuffer ( + [["write_file"; "/src"; "hello, world"; "0"]; + ["copy_size"; "/src"; "/dest"; "5"]; + ["read_file"; "/dest"]], "hello")], + "copy size bytes from source to destination using dd", + "\ +This command copies exactly C bytes from one source device +or file C to another destination device or file C. + +Note this will fail if the source is too short or if the destination +is not large enough."); + + ("zero_device", (RErr, [Device "device"]), 228, [DangerWillRobinson], + [InitBasicFSonLVM, Always, TestRun ( + [["zero_device"; "/dev/VG/LV"]])], + "write zeroes to an entire device", + "\ +This command writes zeroes over the entire C. Compare +with C which just zeroes the first few blocks of +a device."); + + ("txz_in", (RErr, [FileIn "tarball"; String "directory"]), 229, [], + [InitBasicFS, Always, TestOutput ( + [["txz_in"; "../images/helloworld.tar.xz"; "/"]; + ["cat"; "/hello"]], "hello\n")], + "unpack compressed tarball to directory", + "\ +This command uploads and unpacks local file C (an +I tar file) into C."); + + ("txz_out", (RErr, [Pathname "directory"; FileOut "tarball"]), 230, [], + [], + "pack directory into compressed tarball", + "\ +This command packs the contents of C and downloads +it to local file C (as an xz compressed tar archive)."); + ] let all_functions = non_daemon_functions @ daemon_functions @@ -5348,6 +5433,7 @@ and generate_client_actions () = #include #include #include +#include #include #include \"guestfs.h\" @@ -6086,7 +6172,7 @@ and generate_daemon_actions () = pr " ret->guestfs_int_lvm_%s_list_val = NULL;\n" typ; pr "\n"; pr " r = command (&out, &err,\n"; - pr " \"/sbin/lvm\", \"%ss\",\n" typ; + pr " \"lvm\", \"%ss\",\n" typ; pr " \"-o\", lvm_%s_cols, \"--unbuffered\", \"--noheadings\",\n" typ; pr " \"--nosuffix\", \"--separator\", \",\", \"--units\", \"b\", NULL);\n"; pr " if (r == -1) {\n"; @@ -6391,14 +6477,14 @@ int main (int argc, char *argv[]) exit (EXIT_FAILURE); } + /* Set a timeout in case qemu hangs during launch (RHBZ#505329). */ + alarm (600); + if (guestfs_launch (g) == -1) { printf (\"guestfs_launch FAILED\\n\"); exit (EXIT_FAILURE); } - /* Set a timeout in case qemu hangs during launch (RHBZ#505329). */ - alarm (600); - /* Cancel previous alarm. */ alarm (0); @@ -7335,6 +7421,8 @@ and generate_fish_cmds () = ) all_functions; pr " {\n"; pr " fprintf (stderr, _(\"%%s: unknown command\\n\"), cmd);\n"; + pr " if (command_num == 1)\n"; + pr " extended_help_message ();\n"; pr " return -1;\n"; pr " }\n"; pr " return 0;\n"; @@ -7413,7 +7501,16 @@ generator (const char *text, int state) #endif /* HAVE_LIBREADLINE */ -char **do_completion (const char *text, int start, int end) +#ifdef HAVE_RL_COMPLETION_MATCHES +#define RL_COMPLETION_MATCHES rl_completion_matches +#else +#ifdef HAVE_COMPLETION_MATCHES +#define RL_COMPLETION_MATCHES completion_matches +#endif +#endif /* else just fail if we don't have either symbol */ + +char ** +do_completion (const char *text, int start, int end) { char **matches = NULL; @@ -7421,9 +7518,9 @@ char **do_completion (const char *text, int start, int end) rl_completion_append_character = ' '; if (start == 0) - matches = rl_completion_matches (text, generator); + matches = RL_COMPLETION_MATCHES (text, generator); else if (complete_dest_paths) - matches = rl_completion_matches (text, complete_dest_paths_generator); + matches = RL_COMPLETION_MATCHES (text, complete_dest_paths_generator); #endif return matches; @@ -8259,7 +8356,7 @@ DESTROY (g) do_cleanups (); pr " if (%s == NULL)\n" n; pr " croak (\"%%s\", guestfs_last_error (g));\n"; - pr " RETVAL = newSVpv (%s, size);\n" n; + pr " RETVAL = newSVpvn (%s, size);\n" n; pr " free (%s);\n" n; pr " OUTPUT:\n"; pr " RETVAL\n" @@ -8292,7 +8389,7 @@ and generate_perl_struct_list_code typ cols name style n do_cleanups = pr " (void) hv_store (hv, \"%s\", %d, newSVpv (%s->val[i].%s, 32), 0);\n" name (String.length name) n name | name, FBuffer -> - pr " (void) hv_store (hv, \"%s\", %d, newSVpv (%s->val[i].%s, %s->val[i].%s_len), 0);\n" + pr " (void) hv_store (hv, \"%s\", %d, newSVpvn (%s->val[i].%s, %s->val[i].%s_len), 0);\n" name (String.length name) n name n name | name, (FBytes|FUInt64) -> pr " (void) hv_store (hv, \"%s\", %d, my_newSVull (%s->val[i].%s), 0);\n" @@ -8334,7 +8431,7 @@ and generate_perl_struct_code typ cols name style n do_cleanups = pr " PUSHs (sv_2mortal (newSVpv (%s->%s, 0)));\n" n name | name, FBuffer -> - pr " PUSHs (sv_2mortal (newSVpv (%s->%s, %s->%s_len)));\n" + pr " PUSHs (sv_2mortal (newSVpvn (%s->%s, %s->%s_len)));\n" n name n name | name, FUUID -> pr " PUSHs (sv_2mortal (newSVpv (%s->%s, 32)));\n"