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 /* http://www.perlmonks.org/?node_id=680842 */
62 XS_unpack_charPtrPtr (SV *arg) {
67 if (!arg || !SvOK (arg) || !SvROK (arg) || SvTYPE (SvRV (arg)) != SVt_PVAV) {
68 croak ("array reference expected");
71 av = (AV *)SvRV (arg);
72 ret = (char **)malloc (av_len (av) + 1 + 1);
74 for (i = 0; i <= av_len (av); i++) {
75 SV **elem = av_fetch (av, i, 0);
78 croak ("missing element in list");
80 ret[i] = SvPV_nolen (*elem);
88 MODULE = Sys::Guestfs PACKAGE = Sys::Guestfs
93 RETVAL = guestfs_create ();
95 croak ("could not create guestfs handle");
96 guestfs_set_error_handler (RETVAL, NULL, NULL);
110 if (guestfs_launch (g) == -1) {
111 croak ("launch: %s", guestfs_last_error (g));
118 if (guestfs_wait_ready (g) == -1) {
119 croak ("wait_ready: %s", guestfs_last_error (g));
126 if (guestfs_kill_subprocess (g) == -1) {
127 croak ("kill_subprocess: %s", guestfs_last_error (g));
131 add_drive (g, filename)
135 if (guestfs_add_drive (g, filename) == -1) {
136 croak ("add_drive: %s", guestfs_last_error (g));
140 add_cdrom (g, filename)
144 if (guestfs_add_cdrom (g, filename) == -1) {
145 croak ("add_cdrom: %s", guestfs_last_error (g));
149 config (g, qemuparam, qemuvalue)
154 if (guestfs_config (g, qemuparam, qemuvalue) == -1) {
155 croak ("config: %s", guestfs_last_error (g));
163 if (guestfs_set_path (g, path) == -1) {
164 croak ("set_path: %s", guestfs_last_error (g));
173 path = guestfs_get_path (g);
175 croak ("get_path: %s", guestfs_last_error (g));
177 RETVAL = newSVpv (path, 0);
182 set_autosync (g, autosync)
186 if (guestfs_set_autosync (g, autosync) == -1) {
187 croak ("set_autosync: %s", guestfs_last_error (g));
196 autosync = guestfs_get_autosync (g);
197 if (autosync == -1) {
198 croak ("get_autosync: %s", guestfs_last_error (g));
200 RETVAL = newSViv (autosync);
205 set_verbose (g, verbose)
209 if (guestfs_set_verbose (g, verbose) == -1) {
210 croak ("set_verbose: %s", guestfs_last_error (g));
219 verbose = guestfs_get_verbose (g);
221 croak ("get_verbose: %s", guestfs_last_error (g));
223 RETVAL = newSViv (verbose);
228 mount (g, device, mountpoint)
233 if (guestfs_mount (g, device, mountpoint) == -1) {
234 croak ("mount: %s", guestfs_last_error (g));
241 if (guestfs_sync (g) == -1) {
242 croak ("sync: %s", guestfs_last_error (g));
250 if (guestfs_touch (g, path) == -1) {
251 croak ("touch: %s", guestfs_last_error (g));
261 content = guestfs_cat (g, path);
262 if (content == NULL) {
263 croak ("cat: %s", guestfs_last_error (g));
265 RETVAL = newSVpv (content, 0);
277 listing = guestfs_ll (g, directory);
278 if (listing == NULL) {
279 croak ("ll: %s", guestfs_last_error (g));
281 RETVAL = newSVpv (listing, 0);
294 listing = guestfs_ls (g, directory);
295 if (listing == NULL) {
296 croak ("ls: %s", guestfs_last_error (g));
298 for (n = 0; listing[n] != NULL; ++n) /**/;
300 for (i = 0; i < n; ++i) {
301 PUSHs (sv_2mortal (newSVpv (listing[i], 0)));
313 devices = guestfs_list_devices (g);
314 if (devices == NULL) {
315 croak ("list_devices: %s", guestfs_last_error (g));
317 for (n = 0; devices[n] != NULL; ++n) /**/;
319 for (i = 0; i < n; ++i) {
320 PUSHs (sv_2mortal (newSVpv (devices[i], 0)));
332 partitions = guestfs_list_partitions (g);
333 if (partitions == NULL) {
334 croak ("list_partitions: %s", guestfs_last_error (g));
336 for (n = 0; partitions[n] != NULL; ++n) /**/;
338 for (i = 0; i < n; ++i) {
339 PUSHs (sv_2mortal (newSVpv (partitions[i], 0)));
340 free (partitions[i]);
351 physvols = guestfs_pvs (g);
352 if (physvols == NULL) {
353 croak ("pvs: %s", guestfs_last_error (g));
355 for (n = 0; physvols[n] != NULL; ++n) /**/;
357 for (i = 0; i < n; ++i) {
358 PUSHs (sv_2mortal (newSVpv (physvols[i], 0)));
370 volgroups = guestfs_vgs (g);
371 if (volgroups == NULL) {
372 croak ("vgs: %s", guestfs_last_error (g));
374 for (n = 0; volgroups[n] != NULL; ++n) /**/;
376 for (i = 0; i < n; ++i) {
377 PUSHs (sv_2mortal (newSVpv (volgroups[i], 0)));
389 logvols = guestfs_lvs (g);
390 if (logvols == NULL) {
391 croak ("lvs: %s", guestfs_last_error (g));
393 for (n = 0; logvols[n] != NULL; ++n) /**/;
395 for (i = 0; i < n; ++i) {
396 PUSHs (sv_2mortal (newSVpv (logvols[i], 0)));
405 struct guestfs_lvm_pv_list *physvols;
409 physvols = guestfs_pvs_full (g);
410 if (physvols == NULL)
411 croak ("pvs_full: %s", guestfs_last_error (g));
412 EXTEND (SP, physvols->len);
413 for (i = 0; i < physvols->len; ++i) {
415 (void) hv_store (hv, "pv_name", 7, newSVpv (physvols->val[i].pv_name, 0), 0);
416 (void) hv_store (hv, "pv_uuid", 7, newSVpv (physvols->val[i].pv_uuid, 32), 0);
417 (void) hv_store (hv, "pv_fmt", 6, newSVpv (physvols->val[i].pv_fmt, 0), 0);
418 (void) hv_store (hv, "pv_size", 7, my_newSVull (physvols->val[i].pv_size), 0);
419 (void) hv_store (hv, "dev_size", 8, my_newSVull (physvols->val[i].dev_size), 0);
420 (void) hv_store (hv, "pv_free", 7, my_newSVull (physvols->val[i].pv_free), 0);
421 (void) hv_store (hv, "pv_used", 7, my_newSVull (physvols->val[i].pv_used), 0);
422 (void) hv_store (hv, "pv_attr", 7, newSVpv (physvols->val[i].pv_attr, 0), 0);
423 (void) hv_store (hv, "pv_pe_count", 11, my_newSVll (physvols->val[i].pv_pe_count), 0);
424 (void) hv_store (hv, "pv_pe_alloc_count", 17, my_newSVll (physvols->val[i].pv_pe_alloc_count), 0);
425 (void) hv_store (hv, "pv_tags", 7, newSVpv (physvols->val[i].pv_tags, 0), 0);
426 (void) hv_store (hv, "pe_start", 8, my_newSVull (physvols->val[i].pe_start), 0);
427 (void) hv_store (hv, "pv_mda_count", 12, my_newSVll (physvols->val[i].pv_mda_count), 0);
428 (void) hv_store (hv, "pv_mda_free", 11, my_newSVull (physvols->val[i].pv_mda_free), 0);
429 PUSHs (sv_2mortal ((SV *) hv));
431 guestfs_free_lvm_pv_list (physvols);
437 struct guestfs_lvm_vg_list *volgroups;
441 volgroups = guestfs_vgs_full (g);
442 if (volgroups == NULL)
443 croak ("vgs_full: %s", guestfs_last_error (g));
444 EXTEND (SP, volgroups->len);
445 for (i = 0; i < volgroups->len; ++i) {
447 (void) hv_store (hv, "vg_name", 7, newSVpv (volgroups->val[i].vg_name, 0), 0);
448 (void) hv_store (hv, "vg_uuid", 7, newSVpv (volgroups->val[i].vg_uuid, 32), 0);
449 (void) hv_store (hv, "vg_fmt", 6, newSVpv (volgroups->val[i].vg_fmt, 0), 0);
450 (void) hv_store (hv, "vg_attr", 7, newSVpv (volgroups->val[i].vg_attr, 0), 0);
451 (void) hv_store (hv, "vg_size", 7, my_newSVull (volgroups->val[i].vg_size), 0);
452 (void) hv_store (hv, "vg_free", 7, my_newSVull (volgroups->val[i].vg_free), 0);
453 (void) hv_store (hv, "vg_sysid", 8, newSVpv (volgroups->val[i].vg_sysid, 0), 0);
454 (void) hv_store (hv, "vg_extent_size", 14, my_newSVull (volgroups->val[i].vg_extent_size), 0);
455 (void) hv_store (hv, "vg_extent_count", 15, my_newSVll (volgroups->val[i].vg_extent_count), 0);
456 (void) hv_store (hv, "vg_free_count", 13, my_newSVll (volgroups->val[i].vg_free_count), 0);
457 (void) hv_store (hv, "max_lv", 6, my_newSVll (volgroups->val[i].max_lv), 0);
458 (void) hv_store (hv, "max_pv", 6, my_newSVll (volgroups->val[i].max_pv), 0);
459 (void) hv_store (hv, "pv_count", 8, my_newSVll (volgroups->val[i].pv_count), 0);
460 (void) hv_store (hv, "lv_count", 8, my_newSVll (volgroups->val[i].lv_count), 0);
461 (void) hv_store (hv, "snap_count", 10, my_newSVll (volgroups->val[i].snap_count), 0);
462 (void) hv_store (hv, "vg_seqno", 8, my_newSVll (volgroups->val[i].vg_seqno), 0);
463 (void) hv_store (hv, "vg_tags", 7, newSVpv (volgroups->val[i].vg_tags, 0), 0);
464 (void) hv_store (hv, "vg_mda_count", 12, my_newSVll (volgroups->val[i].vg_mda_count), 0);
465 (void) hv_store (hv, "vg_mda_free", 11, my_newSVull (volgroups->val[i].vg_mda_free), 0);
466 PUSHs (sv_2mortal ((SV *) hv));
468 guestfs_free_lvm_vg_list (volgroups);
474 struct guestfs_lvm_lv_list *logvols;
478 logvols = guestfs_lvs_full (g);
480 croak ("lvs_full: %s", guestfs_last_error (g));
481 EXTEND (SP, logvols->len);
482 for (i = 0; i < logvols->len; ++i) {
484 (void) hv_store (hv, "lv_name", 7, newSVpv (logvols->val[i].lv_name, 0), 0);
485 (void) hv_store (hv, "lv_uuid", 7, newSVpv (logvols->val[i].lv_uuid, 32), 0);
486 (void) hv_store (hv, "lv_attr", 7, newSVpv (logvols->val[i].lv_attr, 0), 0);
487 (void) hv_store (hv, "lv_major", 8, my_newSVll (logvols->val[i].lv_major), 0);
488 (void) hv_store (hv, "lv_minor", 8, my_newSVll (logvols->val[i].lv_minor), 0);
489 (void) hv_store (hv, "lv_kernel_major", 15, my_newSVll (logvols->val[i].lv_kernel_major), 0);
490 (void) hv_store (hv, "lv_kernel_minor", 15, my_newSVll (logvols->val[i].lv_kernel_minor), 0);
491 (void) hv_store (hv, "lv_size", 7, my_newSVull (logvols->val[i].lv_size), 0);
492 (void) hv_store (hv, "seg_count", 9, my_newSVll (logvols->val[i].seg_count), 0);
493 (void) hv_store (hv, "origin", 6, newSVpv (logvols->val[i].origin, 0), 0);
494 (void) hv_store (hv, "snap_percent", 12, newSVnv (logvols->val[i].snap_percent), 0);
495 (void) hv_store (hv, "copy_percent", 12, newSVnv (logvols->val[i].copy_percent), 0);
496 (void) hv_store (hv, "move_pv", 7, newSVpv (logvols->val[i].move_pv, 0), 0);
497 (void) hv_store (hv, "lv_tags", 7, newSVpv (logvols->val[i].lv_tags, 0), 0);
498 (void) hv_store (hv, "mirror_log", 10, newSVpv (logvols->val[i].mirror_log, 0), 0);
499 (void) hv_store (hv, "modules", 7, newSVpv (logvols->val[i].modules, 0), 0);
500 PUSHs (sv_2mortal ((SV *) hv));
502 guestfs_free_lvm_lv_list (logvols);
512 lines = guestfs_read_lines (g, path);
514 croak ("read_lines: %s", guestfs_last_error (g));
516 for (n = 0; lines[n] != NULL; ++n) /**/;
518 for (i = 0; i < n; ++i) {
519 PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
525 aug_init (g, root, flags)
530 if (guestfs_aug_init (g, root, flags) == -1) {
531 croak ("aug_init: %s", guestfs_last_error (g));
538 if (guestfs_aug_close (g) == -1) {
539 croak ("aug_close: %s", guestfs_last_error (g));
543 aug_defvar (g, name, expr)
550 nrnodes = guestfs_aug_defvar (g, name, expr);
552 croak ("aug_defvar: %s", guestfs_last_error (g));
554 RETVAL = newSViv (nrnodes);
559 aug_defnode (g, name, expr, val)
565 struct guestfs_int_bool *r;
567 r = guestfs_aug_defnode (g, name, expr, val);
569 croak ("aug_defnode: %s", guestfs_last_error (g));
572 PUSHs (sv_2mortal (newSViv (r->i)));
573 PUSHs (sv_2mortal (newSViv (r->b)));
574 guestfs_free_int_bool (r);
583 val = guestfs_aug_get (g, path);
585 croak ("aug_get: %s", guestfs_last_error (g));
587 RETVAL = newSVpv (val, 0);
593 aug_set (g, path, val)
598 if (guestfs_aug_set (g, path, val) == -1) {
599 croak ("aug_set: %s", guestfs_last_error (g));
603 aug_insert (g, path, label, before)
609 if (guestfs_aug_insert (g, path, label, before) == -1) {
610 croak ("aug_insert: %s", guestfs_last_error (g));
620 nrnodes = guestfs_aug_rm (g, path);
622 croak ("aug_rm: %s", guestfs_last_error (g));
624 RETVAL = newSViv (nrnodes);
629 aug_mv (g, src, dest)
634 if (guestfs_aug_mv (g, src, dest) == -1) {
635 croak ("aug_mv: %s", guestfs_last_error (g));
646 matches = guestfs_aug_match (g, path);
647 if (matches == NULL) {
648 croak ("aug_match: %s", guestfs_last_error (g));
650 for (n = 0; matches[n] != NULL; ++n) /**/;
652 for (i = 0; i < n; ++i) {
653 PUSHs (sv_2mortal (newSVpv (matches[i], 0)));
662 if (guestfs_aug_save (g) == -1) {
663 croak ("aug_save: %s", guestfs_last_error (g));
670 if (guestfs_aug_load (g) == -1) {
671 croak ("aug_load: %s", guestfs_last_error (g));
682 matches = guestfs_aug_ls (g, path);
683 if (matches == NULL) {
684 croak ("aug_ls: %s", guestfs_last_error (g));
686 for (n = 0; matches[n] != NULL; ++n) /**/;
688 for (i = 0; i < n; ++i) {
689 PUSHs (sv_2mortal (newSVpv (matches[i], 0)));
699 if (guestfs_rm (g, path) == -1) {
700 croak ("rm: %s", guestfs_last_error (g));
708 if (guestfs_rmdir (g, path) == -1) {
709 croak ("rmdir: %s", guestfs_last_error (g));
717 if (guestfs_rm_rf (g, path) == -1) {
718 croak ("rm_rf: %s", guestfs_last_error (g));
726 if (guestfs_mkdir (g, path) == -1) {
727 croak ("mkdir: %s", guestfs_last_error (g));
735 if (guestfs_mkdir_p (g, path) == -1) {
736 croak ("mkdir_p: %s", guestfs_last_error (g));
740 chmod (g, mode, path)
745 if (guestfs_chmod (g, mode, path) == -1) {
746 croak ("chmod: %s", guestfs_last_error (g));
750 chown (g, owner, group, path)
756 if (guestfs_chown (g, owner, group, path) == -1) {
757 croak ("chown: %s", guestfs_last_error (g));
767 existsflag = guestfs_exists (g, path);
768 if (existsflag == -1) {
769 croak ("exists: %s", guestfs_last_error (g));
771 RETVAL = newSViv (existsflag);
782 fileflag = guestfs_is_file (g, path);
783 if (fileflag == -1) {
784 croak ("is_file: %s", guestfs_last_error (g));
786 RETVAL = newSViv (fileflag);
797 dirflag = guestfs_is_dir (g, path);
799 croak ("is_dir: %s", guestfs_last_error (g));
801 RETVAL = newSViv (dirflag);
810 if (guestfs_pvcreate (g, device) == -1) {
811 croak ("pvcreate: %s", guestfs_last_error (g));
815 vgcreate (g, volgroup, physvols)
820 if (guestfs_vgcreate (g, volgroup, physvols) == -1) {
822 croak ("vgcreate: %s", guestfs_last_error (g));
827 lvcreate (g, logvol, volgroup, mbytes)
833 if (guestfs_lvcreate (g, logvol, volgroup, mbytes) == -1) {
834 croak ("lvcreate: %s", guestfs_last_error (g));
838 mkfs (g, fstype, device)
843 if (guestfs_mkfs (g, fstype, device) == -1) {
844 croak ("mkfs: %s", guestfs_last_error (g));
848 sfdisk (g, device, cyls, heads, sectors, lines)
856 if (guestfs_sfdisk (g, device, cyls, heads, sectors, lines) == -1) {
858 croak ("sfdisk: %s", guestfs_last_error (g));
863 write_file (g, path, content, size)
869 if (guestfs_write_file (g, path, content, size) == -1) {
870 croak ("write_file: %s", guestfs_last_error (g));
874 umount (g, pathordevice)
878 if (guestfs_umount (g, pathordevice) == -1) {
879 croak ("umount: %s", guestfs_last_error (g));
889 devices = guestfs_mounts (g);
890 if (devices == NULL) {
891 croak ("mounts: %s", guestfs_last_error (g));
893 for (n = 0; devices[n] != NULL; ++n) /**/;
895 for (i = 0; i < n; ++i) {
896 PUSHs (sv_2mortal (newSVpv (devices[i], 0)));
905 if (guestfs_umount_all (g) == -1) {
906 croak ("umount_all: %s", guestfs_last_error (g));
913 if (guestfs_lvm_remove_all (g) == -1) {
914 croak ("lvm_remove_all: %s", guestfs_last_error (g));