1 /* libguestfs generated file
2 * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
3 * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
5 * Copyright (C) 2009 Red Hat Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33 my_newSVll(long long val) {
39 len = snprintf(buf, 100, "%" PRId64, val);
40 return newSVpv(buf, len);
49 my_newSVull(unsigned long long val) {
55 len = snprintf(buf, 100, "%" PRIu64, val);
56 return newSVpv(buf, len);
60 /* XXX Not thread-safe, and in general not safe if the caller is
61 * issuing multiple requests in parallel (on different guestfs
62 * handles). We should use the guestfs_h handle passed to the
63 * error handle to distinguish these cases.
65 static char *last_error = NULL;
68 error_handler (guestfs_h *g,
72 if (last_error != NULL) free (last_error);
73 last_error = strdup (msg);
76 MODULE = Sys::Guestfs PACKAGE = Sys::Guestfs
81 RETVAL = guestfs_create ();
83 croak ("could not create guestfs handle");
84 guestfs_set_error_handler (RETVAL, error_handler, NULL);
95 add_drive (g, filename)
99 if (guestfs_add_drive (g, filename) == -1)
100 croak ("add_drive: %s", last_error);
103 add_cdrom (g, filename)
105 const char *filename;
107 if (guestfs_add_cdrom (g, filename) == -1)
108 croak ("add_cdrom: %s", last_error);
111 config (g, param, value)
116 if (guestfs_config (g, param, value) == -1)
117 croak ("config: %s", last_error);
123 if (guestfs_launch (g) == -1)
124 croak ("launch: %s", last_error);
130 if (guestfs_wait_ready (g) == -1)
131 croak ("wait_ready: %s", last_error);
138 guestfs_set_path (g, path);
146 path = guestfs_get_path (g);
147 RETVAL = newSVpv (path, 0);
152 set_autosync (g, autosync)
156 guestfs_set_autosync (g, autosync);
164 autosync = guestfs_get_autosync (g);
165 RETVAL = newSViv (autosync);
170 set_verbose (g, verbose)
174 guestfs_set_verbose (g, verbose);
182 verbose = guestfs_get_verbose (g);
183 RETVAL = newSViv (verbose);
188 mount (g, device, mountpoint)
193 if (guestfs_mount (g, device, mountpoint) == -1)
194 croak ("mount: %s", last_error);
200 if (guestfs_sync (g) == -1)
201 croak ("sync: %s", last_error);
208 if (guestfs_touch (g, path) == -1)
209 croak ("touch: %s", last_error);
218 content = guestfs_cat (g, path);
220 croak ("cat: %s", last_error);
221 RETVAL = newSVpv (content, 0);
233 listing = guestfs_ll (g, directory);
235 croak ("ll: %s", last_error);
236 RETVAL = newSVpv (listing, 0);
249 listing = guestfs_ls (g, directory);
251 croak ("ls: %s", last_error);
252 for (n = 0; listing[n] != NULL; ++n) /**/;
254 for (i = 0; i < n; ++i) {
255 PUSHs (sv_2mortal (newSVpv (listing[i], 0)));
267 devices = guestfs_list_devices (g);
269 croak ("list_devices: %s", last_error);
270 for (n = 0; devices[n] != NULL; ++n) /**/;
272 for (i = 0; i < n; ++i) {
273 PUSHs (sv_2mortal (newSVpv (devices[i], 0)));
285 partitions = guestfs_list_partitions (g);
286 if (partitions == NULL)
287 croak ("list_partitions: %s", last_error);
288 for (n = 0; partitions[n] != NULL; ++n) /**/;
290 for (i = 0; i < n; ++i) {
291 PUSHs (sv_2mortal (newSVpv (partitions[i], 0)));
292 free (partitions[i]);
303 physvols = guestfs_pvs (g);
304 if (physvols == NULL)
305 croak ("pvs: %s", last_error);
306 for (n = 0; physvols[n] != NULL; ++n) /**/;
308 for (i = 0; i < n; ++i) {
309 PUSHs (sv_2mortal (newSVpv (physvols[i], 0)));
321 volgroups = guestfs_vgs (g);
322 if (volgroups == NULL)
323 croak ("vgs: %s", last_error);
324 for (n = 0; volgroups[n] != NULL; ++n) /**/;
326 for (i = 0; i < n; ++i) {
327 PUSHs (sv_2mortal (newSVpv (volgroups[i], 0)));
339 logvols = guestfs_lvs (g);
341 croak ("lvs: %s", last_error);
342 for (n = 0; logvols[n] != NULL; ++n) /**/;
344 for (i = 0; i < n; ++i) {
345 PUSHs (sv_2mortal (newSVpv (logvols[i], 0)));
354 struct guestfs_lvm_pv_list *physvols;
358 physvols = guestfs_pvs_full (g);
359 if (physvols == NULL)
360 croak ("pvs_full: %s", last_error);
361 EXTEND (SP, physvols->len);
362 for (i = 0; i < physvols->len; ++i) {
364 (void) hv_store (hv, "pv_name", 7, newSVpv (physvols->val[i].pv_name, 0), 0);
365 (void) hv_store (hv, "pv_uuid", 7, newSVpv (physvols->val[i].pv_uuid, 32), 0);
366 (void) hv_store (hv, "pv_fmt", 6, newSVpv (physvols->val[i].pv_fmt, 0), 0);
367 (void) hv_store (hv, "pv_size", 7, my_newSVull (physvols->val[i].pv_size), 0);
368 (void) hv_store (hv, "dev_size", 8, my_newSVull (physvols->val[i].dev_size), 0);
369 (void) hv_store (hv, "pv_free", 7, my_newSVull (physvols->val[i].pv_free), 0);
370 (void) hv_store (hv, "pv_used", 7, my_newSVull (physvols->val[i].pv_used), 0);
371 (void) hv_store (hv, "pv_attr", 7, newSVpv (physvols->val[i].pv_attr, 0), 0);
372 (void) hv_store (hv, "pv_pe_count", 11, my_newSVll (physvols->val[i].pv_pe_count), 0);
373 (void) hv_store (hv, "pv_pe_alloc_count", 17, my_newSVll (physvols->val[i].pv_pe_alloc_count), 0);
374 (void) hv_store (hv, "pv_tags", 7, newSVpv (physvols->val[i].pv_tags, 0), 0);
375 (void) hv_store (hv, "pe_start", 8, my_newSVull (physvols->val[i].pe_start), 0);
376 (void) hv_store (hv, "pv_mda_count", 12, my_newSVll (physvols->val[i].pv_mda_count), 0);
377 (void) hv_store (hv, "pv_mda_free", 11, my_newSVull (physvols->val[i].pv_mda_free), 0);
378 PUSHs (sv_2mortal ((SV *) hv));
380 guestfs_free_lvm_pv_list (physvols);
386 struct guestfs_lvm_vg_list *volgroups;
390 volgroups = guestfs_vgs_full (g);
391 if (volgroups == NULL)
392 croak ("vgs_full: %s", last_error);
393 EXTEND (SP, volgroups->len);
394 for (i = 0; i < volgroups->len; ++i) {
396 (void) hv_store (hv, "vg_name", 7, newSVpv (volgroups->val[i].vg_name, 0), 0);
397 (void) hv_store (hv, "vg_uuid", 7, newSVpv (volgroups->val[i].vg_uuid, 32), 0);
398 (void) hv_store (hv, "vg_fmt", 6, newSVpv (volgroups->val[i].vg_fmt, 0), 0);
399 (void) hv_store (hv, "vg_attr", 7, newSVpv (volgroups->val[i].vg_attr, 0), 0);
400 (void) hv_store (hv, "vg_size", 7, my_newSVull (volgroups->val[i].vg_size), 0);
401 (void) hv_store (hv, "vg_free", 7, my_newSVull (volgroups->val[i].vg_free), 0);
402 (void) hv_store (hv, "vg_sysid", 8, newSVpv (volgroups->val[i].vg_sysid, 0), 0);
403 (void) hv_store (hv, "vg_extent_size", 14, my_newSVull (volgroups->val[i].vg_extent_size), 0);
404 (void) hv_store (hv, "vg_extent_count", 15, my_newSVll (volgroups->val[i].vg_extent_count), 0);
405 (void) hv_store (hv, "vg_free_count", 13, my_newSVll (volgroups->val[i].vg_free_count), 0);
406 (void) hv_store (hv, "max_lv", 6, my_newSVll (volgroups->val[i].max_lv), 0);
407 (void) hv_store (hv, "max_pv", 6, my_newSVll (volgroups->val[i].max_pv), 0);
408 (void) hv_store (hv, "pv_count", 8, my_newSVll (volgroups->val[i].pv_count), 0);
409 (void) hv_store (hv, "lv_count", 8, my_newSVll (volgroups->val[i].lv_count), 0);
410 (void) hv_store (hv, "snap_count", 10, my_newSVll (volgroups->val[i].snap_count), 0);
411 (void) hv_store (hv, "vg_seqno", 8, my_newSVll (volgroups->val[i].vg_seqno), 0);
412 (void) hv_store (hv, "vg_tags", 7, newSVpv (volgroups->val[i].vg_tags, 0), 0);
413 (void) hv_store (hv, "vg_mda_count", 12, my_newSVll (volgroups->val[i].vg_mda_count), 0);
414 (void) hv_store (hv, "vg_mda_free", 11, my_newSVull (volgroups->val[i].vg_mda_free), 0);
415 PUSHs (sv_2mortal ((SV *) hv));
417 guestfs_free_lvm_vg_list (volgroups);
423 struct guestfs_lvm_lv_list *logvols;
427 logvols = guestfs_lvs_full (g);
429 croak ("lvs_full: %s", last_error);
430 EXTEND (SP, logvols->len);
431 for (i = 0; i < logvols->len; ++i) {
433 (void) hv_store (hv, "lv_name", 7, newSVpv (logvols->val[i].lv_name, 0), 0);
434 (void) hv_store (hv, "lv_uuid", 7, newSVpv (logvols->val[i].lv_uuid, 32), 0);
435 (void) hv_store (hv, "lv_attr", 7, newSVpv (logvols->val[i].lv_attr, 0), 0);
436 (void) hv_store (hv, "lv_major", 8, my_newSVll (logvols->val[i].lv_major), 0);
437 (void) hv_store (hv, "lv_minor", 8, my_newSVll (logvols->val[i].lv_minor), 0);
438 (void) hv_store (hv, "lv_kernel_major", 15, my_newSVll (logvols->val[i].lv_kernel_major), 0);
439 (void) hv_store (hv, "lv_kernel_minor", 15, my_newSVll (logvols->val[i].lv_kernel_minor), 0);
440 (void) hv_store (hv, "lv_size", 7, my_newSVull (logvols->val[i].lv_size), 0);
441 (void) hv_store (hv, "seg_count", 9, my_newSVll (logvols->val[i].seg_count), 0);
442 (void) hv_store (hv, "origin", 6, newSVpv (logvols->val[i].origin, 0), 0);
443 (void) hv_store (hv, "snap_percent", 12, newSVnv (logvols->val[i].snap_percent), 0);
444 (void) hv_store (hv, "copy_percent", 12, newSVnv (logvols->val[i].copy_percent), 0);
445 (void) hv_store (hv, "move_pv", 7, newSVpv (logvols->val[i].move_pv, 0), 0);
446 (void) hv_store (hv, "lv_tags", 7, newSVpv (logvols->val[i].lv_tags, 0), 0);
447 (void) hv_store (hv, "mirror_log", 10, newSVpv (logvols->val[i].mirror_log, 0), 0);
448 (void) hv_store (hv, "modules", 7, newSVpv (logvols->val[i].modules, 0), 0);
449 PUSHs (sv_2mortal ((SV *) hv));
451 guestfs_free_lvm_lv_list (logvols);