X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=src%2Fgenerator.ml;h=d44b7a749e865ead1f14af689a7f002aca7295cc;hp=ed5810bf7bb6eb1c245d98d0a6ae2440e0ac35ae;hb=7cbb86e4c8b6b8bca8606d219c5571549ceabba6;hpb=b2c76a898b9d6fff09af05e4e3bd1d54c8816a95 diff --git a/src/generator.ml b/src/generator.ml index ed5810b..d44b7a7 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -121,7 +121,7 @@ type flags = | NotInDocs (* do not add this function to documentation *) let protocol_limit_warning = - "Because of the message protocol, there is a transfer limit + "Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. To transfer large files you should use FTP." @@ -632,6 +632,15 @@ 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 of qemu subprocess", + "\ +Return the process ID of the qemu subprocess. If there is no +qemu subprocess, then this will return an error. + +This is an internal call used for debugging and testing."); + ] (* daemon_functions are any functions which cause some action @@ -4686,7 +4695,7 @@ and generate_one_test_body name i test_name init test = List.iter (generate_test_command_call test_name) seq | TestOutput (seq, expected) -> pr " /* TestOutput for %s (%d) */\n" name i; - pr " char expected[] = \"%s\";\n" (c_quote expected); + pr " const char *expected = \"%s\";\n" (c_quote expected); let seq, last = get_seq_last seq in let test () = pr " if (strcmp (r, expected) != 0) {\n"; @@ -4708,7 +4717,7 @@ and generate_one_test_body name i test_name init test = pr " return -1;\n"; pr " }\n"; pr " {\n"; - pr " char expected[] = \"%s\";\n" (c_quote str); + pr " const char *expected = \"%s\";\n" (c_quote str); pr " if (strcmp (r[%d], expected) != 0) {\n" i; pr " fprintf (stderr, \"%s: expected \\\"%%s\\\" but got \\\"%%s\\\"\\n\", expected, r[%d]);\n" test_name i; pr " return -1;\n"; @@ -4736,7 +4745,7 @@ and generate_one_test_body name i test_name init test = pr " return -1;\n"; pr " }\n"; pr " {\n"; - pr " char expected[] = \"%s\";\n" (c_quote str); + pr " const char *expected = \"%s\";\n" (c_quote str); pr " r[%d][5] = 's';\n" i; pr " if (strcmp (r[%d], expected) != 0) {\n" i; pr " fprintf (stderr, \"%s: expected \\\"%%s\\\" but got \\\"%%s\\\"\\n\", expected, r[%d]);\n" test_name i; @@ -4882,7 +4891,7 @@ and generate_test_command_call ?(expect_error = false) ?test test_name cmd = | OptString n, "NULL" -> () | String n, arg | OptString n, arg -> - pr " char %s[] = \"%s\";\n" n (c_quote arg); + pr " const char *%s = \"%s\";\n" n (c_quote arg); | Int _, _ | Bool _, _ | FileIn _, _ | FileOut _, _ -> () @@ -4890,9 +4899,9 @@ and generate_test_command_call ?(expect_error = false) ?test test_name cmd = let strs = string_split " " arg in iteri ( fun i str -> - pr " char %s_%d[] = \"%s\";\n" n i (c_quote str); + pr " const char *%s_%d = \"%s\";\n" n i (c_quote str); ) strs; - pr " char *%s[] = {\n" n; + pr " const char *%s[] = {\n" n; iteri ( fun i _ -> pr " %s_%d,\n" n i ) strs; @@ -6396,7 +6405,7 @@ Sys::Guestfs - Perl bindings for libguestfs =head1 SYNOPSIS use Sys::Guestfs; - + my $h = Sys::Guestfs->new (); $h->add_drive ('guest.img'); $h->launch (); @@ -8144,6 +8153,8 @@ and generate_bindtests () = #include \"guestfs_protocol.h\" #define error guestfs_error +#define safe_calloc guestfs_safe_calloc +#define safe_malloc guestfs_safe_malloc static void print_strings (char * const* const argv) @@ -8219,70 +8230,70 @@ print_strings (char * const* const argv) pr " char **strs;\n"; pr " int n, i;\n"; pr " sscanf (val, \"%%d\", &n);\n"; - pr " strs = malloc ((n+1) * sizeof (char *));\n"; + pr " strs = safe_malloc (g, (n+1) * sizeof (char *));\n"; pr " for (i = 0; i < n; ++i) {\n"; - pr " strs[i] = malloc (16);\n"; + pr " strs[i] = safe_malloc (g, 16);\n"; pr " snprintf (strs[i], 16, \"%%d\", i);\n"; pr " }\n"; pr " strs[n] = NULL;\n"; pr " return strs;\n" | RIntBool _ -> pr " struct guestfs_int_bool *r;\n"; - pr " r = malloc (sizeof (struct guestfs_int_bool));\n"; + pr " r = safe_malloc (g, sizeof *r);\n"; pr " sscanf (val, \"%%\" SCNi32, &r->i);\n"; pr " r->b = 0;\n"; pr " return r;\n" | RPVList _ -> pr " struct guestfs_lvm_pv_list *r;\n"; pr " int i;\n"; - pr " r = malloc (sizeof (struct guestfs_lvm_pv_list));\n"; + pr " r = safe_malloc (g, sizeof *r);\n"; pr " sscanf (val, \"%%d\", &r->len);\n"; - pr " r->val = calloc (r->len, sizeof (struct guestfs_lvm_pv));\n"; + pr " r->val = safe_calloc (g, r->len, sizeof *r->val);\n"; pr " for (i = 0; i < r->len; ++i) {\n"; - pr " r->val[i].pv_name = malloc (16);\n"; + pr " r->val[i].pv_name = safe_malloc (g, 16);\n"; pr " snprintf (r->val[i].pv_name, 16, \"%%d\", i);\n"; pr " }\n"; pr " return r;\n" | RVGList _ -> pr " struct guestfs_lvm_vg_list *r;\n"; pr " int i;\n"; - pr " r = malloc (sizeof (struct guestfs_lvm_vg_list));\n"; + pr " r = safe_malloc (g, sizeof *r);\n"; pr " sscanf (val, \"%%d\", &r->len);\n"; - pr " r->val = calloc (r->len, sizeof (struct guestfs_lvm_vg));\n"; + pr " r->val = safe_calloc (g, r->len, sizeof *r->val);\n"; pr " for (i = 0; i < r->len; ++i) {\n"; - pr " r->val[i].vg_name = malloc (16);\n"; + pr " r->val[i].vg_name = safe_malloc (g, 16);\n"; pr " snprintf (r->val[i].vg_name, 16, \"%%d\", i);\n"; pr " }\n"; pr " return r;\n" | RLVList _ -> pr " struct guestfs_lvm_lv_list *r;\n"; pr " int i;\n"; - pr " r = malloc (sizeof (struct guestfs_lvm_lv_list));\n"; + pr " r = safe_malloc (g, sizeof *r);\n"; pr " sscanf (val, \"%%d\", &r->len);\n"; - pr " r->val = calloc (r->len, sizeof (struct guestfs_lvm_lv));\n"; + pr " r->val = safe_calloc (g, r->len, sizeof *r->val);\n"; pr " for (i = 0; i < r->len; ++i) {\n"; - pr " r->val[i].lv_name = malloc (16);\n"; + pr " r->val[i].lv_name = safe_malloc (g, 16);\n"; pr " snprintf (r->val[i].lv_name, 16, \"%%d\", i);\n"; pr " }\n"; pr " return r;\n" | RStat _ -> pr " struct guestfs_stat *r;\n"; - pr " r = calloc (1, sizeof (*r));\n"; + pr " r = safe_calloc (g, 1, sizeof (*r));\n"; pr " sscanf (val, \"%%\" SCNi64, &r->dev);\n"; pr " return r;\n" | RStatVFS _ -> pr " struct guestfs_statvfs *r;\n"; - pr " r = calloc (1, sizeof (*r));\n"; + pr " r = safe_calloc (g, 1, sizeof (*r));\n"; pr " sscanf (val, \"%%\" SCNi64, &r->bsize);\n"; pr " return r;\n" | RHashtable _ -> pr " char **strs;\n"; pr " int n, i;\n"; pr " sscanf (val, \"%%d\", &n);\n"; - pr " strs = malloc ((n*2+1) * sizeof (char *));\n"; + pr " strs = safe_malloc (g, (n*2+1) * sizeof (*strs));\n"; pr " for (i = 0; i < n; ++i) {\n"; - pr " strs[i*2] = malloc (16);\n"; - pr " strs[i*2+1] = malloc (16);\n"; + pr " strs[i*2] = safe_malloc (g, 16);\n"; + pr " strs[i*2+1] = safe_malloc (g, 16);\n"; pr " snprintf (strs[i*2], 16, \"%%d\", i);\n"; pr " snprintf (strs[i*2+1], 16, \"%%d\", i);\n"; pr " }\n"; @@ -8291,9 +8302,9 @@ print_strings (char * const* const argv) | RDirentList _ -> pr " struct guestfs_dirent_list *r;\n"; pr " int i;\n"; - pr " r = malloc (sizeof (struct guestfs_dirent_list));\n"; + pr " r = safe_malloc (g, sizeof *r);\n"; pr " sscanf (val, \"%%d\", &r->len);\n"; - pr " r->val = calloc (r->len, sizeof (struct guestfs_dirent));\n"; + pr " r->val = safe_calloc (g, r->len, sizeof *r->val);\n"; pr " for (i = 0; i < r->len; ++i)\n"; pr " r->val[i].ino = i;\n"; pr " return r;\n" @@ -8605,7 +8616,7 @@ let output_to filename = let () = check_functions (); - if not (Sys.file_exists "configure.ac") then ( + if not (Sys.file_exists "config.status") then ( eprintf "\ You are probably running this from the wrong directory. Run it from the top source directory using the command