1 (* libguestfs OCaml bindings
2 * Copyright (C) 2010 Red Hat Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 (* Start a background thread which does lots of allocation and
24 let thread = Thread.create (
28 ignore (Array.init 1000 (fun i -> Thread.yield (); String.create (8*i)))
33 let g = Guestfs.create () in
35 let fd = openfile "test.img" [O_WRONLY;O_CREAT;O_NOCTTY;O_TRUNC] 0o666 in
36 ftruncate fd (500 * 1024 * 1024);
39 (* Copy these strings so they're located on the heap and
40 * subject to garbage collection.
42 let s = String.copy "test.img" in
43 Guestfs.add_drive_ro g s;
46 let dev = String.copy "/dev/sda" in
47 Guestfs.pvcreate g dev;
48 let vg = String.copy "VG" in
49 Guestfs.vgcreate g vg [|dev|];
50 let s = String.copy "LV1" in
51 Guestfs.lvcreate g s vg 200;
52 let s = String.copy "LV2" in
53 Guestfs.lvcreate g s vg 200;
55 let lvs = Guestfs.lvs g in
56 if lvs <> [|"/dev/VG/LV1"; "/dev/VG/LV2"|] then
57 failwith "Guestfs.lvs returned incorrect result";
59 let s = String.copy "ext3" in
60 let lv = String.copy "/dev/VG/LV1" in
62 let s = String.copy "/" in
63 Guestfs.mount_options g "" lv s;
64 let s = String.copy "/test" in