Volume.delete takes a flags parameter
[ocaml-libvirt.git] / libvirt / libvirt_c.c
1 /* !!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!!
2  *
3  * THIS FILE IS AUTOMATICALLY GENERATED BY 'generator.pl'.
4  *
5  * Any changes you make to this file may be overwritten.
6  */
7
8 /* OCaml bindings for libvirt.
9  * (C) Copyright 2007-2008 Richard W.M. Jones, Red Hat Inc.
10  * http://libvirt.org/
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 2 of the License, or (at your option) any later version,
16  * with the OCaml linking exception described in ../COPYING.LIB.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21  * Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public
24  * License along with this library; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
26  */
27
28 #include "config.h"
29
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33
34 #include <libvirt/libvirt.h>
35 #include <libvirt/virterror.h>
36
37 #include <caml/config.h>
38 #include <caml/alloc.h>
39 #include <caml/callback.h>
40 #include <caml/custom.h>
41 #include <caml/fail.h>
42 #include <caml/memory.h>
43 #include <caml/misc.h>
44 #include <caml/mlvalues.h>
45 #include <caml/signals.h>
46
47 #include "libvirt_c_prologue.c"
48
49 #include "libvirt_c_oneoffs.c"
50
51 /* Automatically generated binding for virConnectClose.
52  * In generator.pl this function has signature "conn : free".
53  */
54
55 CAMLprim value
56 ocaml_libvirt_connect_close (value connv)
57 {
58   CAMLparam1 (connv);
59
60   virConnectPtr conn = Connect_val (connv);
61   int r;
62
63   NONBLOCKING (r = virConnectClose (conn));
64   CHECK_ERROR (r == -1, conn, "virConnectClose");
65
66   /* So that we don't double-free in the finalizer: */
67   Connect_val (connv) = NULL;
68
69   CAMLreturn (Val_unit);
70 }
71
72 /* Automatically generated binding for virConnectGetHostname.
73  * In generator.pl this function has signature "conn : string".
74  */
75
76 #ifdef HAVE_WEAK_SYMBOLS
77 #ifdef HAVE_VIRCONNECTGETHOSTNAME
78 extern char *virConnectGetHostname (virConnectPtr conn) __attribute__((weak));
79 #endif
80 #endif
81
82 CAMLprim value
83 ocaml_libvirt_connect_get_hostname (value connv)
84 {
85   CAMLparam1 (connv);
86 #ifndef HAVE_VIRCONNECTGETHOSTNAME
87   /* Symbol virConnectGetHostname not found at compile time. */
88   not_supported ("virConnectGetHostname");
89   CAMLnoreturn;
90 #else
91   /* Check that the symbol virConnectGetHostname
92    * is in runtime version of libvirt.
93    */
94   WEAK_SYMBOL_CHECK (virConnectGetHostname);
95
96   CAMLlocal1 (rv);
97   virConnectPtr conn = Connect_val (connv);
98   char *r;
99
100   NONBLOCKING (r = virConnectGetHostname (conn));
101   CHECK_ERROR (!r, conn, "virConnectGetHostname");
102
103   rv = caml_copy_string (r);
104   free (r);
105   CAMLreturn (rv);
106 #endif
107 }
108
109 /* Automatically generated binding for virConnectGetURI.
110  * In generator.pl this function has signature "conn : string".
111  */
112
113 #ifdef HAVE_WEAK_SYMBOLS
114 #ifdef HAVE_VIRCONNECTGETURI
115 extern char *virConnectGetURI (virConnectPtr conn) __attribute__((weak));
116 #endif
117 #endif
118
119 CAMLprim value
120 ocaml_libvirt_connect_get_uri (value connv)
121 {
122   CAMLparam1 (connv);
123 #ifndef HAVE_VIRCONNECTGETURI
124   /* Symbol virConnectGetURI not found at compile time. */
125   not_supported ("virConnectGetURI");
126   CAMLnoreturn;
127 #else
128   /* Check that the symbol virConnectGetURI
129    * is in runtime version of libvirt.
130    */
131   WEAK_SYMBOL_CHECK (virConnectGetURI);
132
133   CAMLlocal1 (rv);
134   virConnectPtr conn = Connect_val (connv);
135   char *r;
136
137   NONBLOCKING (r = virConnectGetURI (conn));
138   CHECK_ERROR (!r, conn, "virConnectGetURI");
139
140   rv = caml_copy_string (r);
141   free (r);
142   CAMLreturn (rv);
143 #endif
144 }
145
146 /* Automatically generated binding for virConnectGetType.
147  * In generator.pl this function has signature "conn : static string".
148  */
149
150 CAMLprim value
151 ocaml_libvirt_connect_get_type (value connv)
152 {
153   CAMLparam1 (connv);
154
155   CAMLlocal1 (rv);
156   virConnectPtr conn = Connect_val (connv);
157   const char *r;
158
159   NONBLOCKING (r = virConnectGetType (conn));
160   CHECK_ERROR (!r, conn, "virConnectGetType");
161
162   rv = caml_copy_string (r);
163   CAMLreturn (rv);
164 }
165
166 /* Automatically generated binding for virConnectNumOfDomains.
167  * In generator.pl this function has signature "conn : int".
168  */
169
170 CAMLprim value
171 ocaml_libvirt_connect_num_of_domains (value connv)
172 {
173   CAMLparam1 (connv);
174
175   virConnectPtr conn = Connect_val (connv);
176   int r;
177
178   NONBLOCKING (r = virConnectNumOfDomains (conn));
179   CHECK_ERROR (r == -1, conn, "virConnectNumOfDomains");
180
181   CAMLreturn (Val_int (r));
182 }
183
184 /* Automatically generated binding for virConnectListDomains.
185  * In generator.pl this function has signature "conn, int : int array".
186  */
187
188 CAMLprim value
189 ocaml_libvirt_connect_list_domains (value connv, value iv)
190 {
191   CAMLparam2 (connv, iv);
192
193   CAMLlocal1 (rv);
194   virConnectPtr conn = Connect_val (connv);
195   int i = Int_val (iv);
196   int ids[i], r;
197
198   /* Some libvirt List* functions still throw exceptions if i == 0,
199    * so catch that and return an empty array directly.  This changes
200    * the semantics slightly (masking other failures) but it's
201    * unlikely anyone will care.  RWMJ 2008/06/10
202    */
203   if (i == 0) {
204     rv = caml_alloc (0, 0);
205     CAMLreturn (rv);
206   }
207
208   NONBLOCKING (r = virConnectListDomains (conn, ids, i));
209   CHECK_ERROR (r == -1, conn, "virConnectListDomains");
210
211   rv = caml_alloc (r, 0);
212   for (i = 0; i < r; ++i)
213     Store_field (rv, i, Val_int (ids[i]));
214
215   CAMLreturn (rv);
216 }
217
218 /* Automatically generated binding for virConnectNumOfDefinedDomains.
219  * In generator.pl this function has signature "conn : int".
220  */
221
222 CAMLprim value
223 ocaml_libvirt_connect_num_of_defined_domains (value connv)
224 {
225   CAMLparam1 (connv);
226
227   virConnectPtr conn = Connect_val (connv);
228   int r;
229
230   NONBLOCKING (r = virConnectNumOfDefinedDomains (conn));
231   CHECK_ERROR (r == -1, conn, "virConnectNumOfDefinedDomains");
232
233   CAMLreturn (Val_int (r));
234 }
235
236 /* Automatically generated binding for virConnectListDefinedDomains.
237  * In generator.pl this function has signature "conn, int : string array".
238  */
239
240 CAMLprim value
241 ocaml_libvirt_connect_list_defined_domains (value connv, value iv)
242 {
243   CAMLparam2 (connv, iv);
244
245   CAMLlocal2 (rv, strv);
246   virConnectPtr conn = Connect_val (connv);
247   int i = Int_val (iv);
248   char *names[i];
249   int r;
250
251   /* Some libvirt List* functions still throw exceptions if i == 0,
252    * so catch that and return an empty array directly.  This changes
253    * the semantics slightly (masking other failures) but it's
254    * unlikely anyone will care.  RWMJ 2008/06/10
255    */
256   if (i == 0) {
257     rv = caml_alloc (0, 0);
258     CAMLreturn (rv);
259   }
260
261   NONBLOCKING (r = virConnectListDefinedDomains (conn, names, i));
262   CHECK_ERROR (r == -1, conn, "virConnectListDefinedDomains");
263
264   rv = caml_alloc (r, 0);
265   for (i = 0; i < r; ++i) {
266     strv = caml_copy_string (names[i]);
267     Store_field (rv, i, strv);
268     free (names[i]);
269   }
270
271   CAMLreturn (rv);
272 }
273
274 /* Automatically generated binding for virConnectNumOfNetworks.
275  * In generator.pl this function has signature "conn : int".
276  */
277
278 CAMLprim value
279 ocaml_libvirt_connect_num_of_networks (value connv)
280 {
281   CAMLparam1 (connv);
282
283   virConnectPtr conn = Connect_val (connv);
284   int r;
285
286   NONBLOCKING (r = virConnectNumOfNetworks (conn));
287   CHECK_ERROR (r == -1, conn, "virConnectNumOfNetworks");
288
289   CAMLreturn (Val_int (r));
290 }
291
292 /* Automatically generated binding for virConnectListNetworks.
293  * In generator.pl this function has signature "conn, int : string array".
294  */
295
296 CAMLprim value
297 ocaml_libvirt_connect_list_networks (value connv, value iv)
298 {
299   CAMLparam2 (connv, iv);
300
301   CAMLlocal2 (rv, strv);
302   virConnectPtr conn = Connect_val (connv);
303   int i = Int_val (iv);
304   char *names[i];
305   int r;
306
307   /* Some libvirt List* functions still throw exceptions if i == 0,
308    * so catch that and return an empty array directly.  This changes
309    * the semantics slightly (masking other failures) but it's
310    * unlikely anyone will care.  RWMJ 2008/06/10
311    */
312   if (i == 0) {
313     rv = caml_alloc (0, 0);
314     CAMLreturn (rv);
315   }
316
317   NONBLOCKING (r = virConnectListNetworks (conn, names, i));
318   CHECK_ERROR (r == -1, conn, "virConnectListNetworks");
319
320   rv = caml_alloc (r, 0);
321   for (i = 0; i < r; ++i) {
322     strv = caml_copy_string (names[i]);
323     Store_field (rv, i, strv);
324     free (names[i]);
325   }
326
327   CAMLreturn (rv);
328 }
329
330 /* Automatically generated binding for virConnectNumOfDefinedNetworks.
331  * In generator.pl this function has signature "conn : int".
332  */
333
334 CAMLprim value
335 ocaml_libvirt_connect_num_of_defined_networks (value connv)
336 {
337   CAMLparam1 (connv);
338
339   virConnectPtr conn = Connect_val (connv);
340   int r;
341
342   NONBLOCKING (r = virConnectNumOfDefinedNetworks (conn));
343   CHECK_ERROR (r == -1, conn, "virConnectNumOfDefinedNetworks");
344
345   CAMLreturn (Val_int (r));
346 }
347
348 /* Automatically generated binding for virConnectListDefinedNetworks.
349  * In generator.pl this function has signature "conn, int : string array".
350  */
351
352 CAMLprim value
353 ocaml_libvirt_connect_list_defined_networks (value connv, value iv)
354 {
355   CAMLparam2 (connv, iv);
356
357   CAMLlocal2 (rv, strv);
358   virConnectPtr conn = Connect_val (connv);
359   int i = Int_val (iv);
360   char *names[i];
361   int r;
362
363   /* Some libvirt List* functions still throw exceptions if i == 0,
364    * so catch that and return an empty array directly.  This changes
365    * the semantics slightly (masking other failures) but it's
366    * unlikely anyone will care.  RWMJ 2008/06/10
367    */
368   if (i == 0) {
369     rv = caml_alloc (0, 0);
370     CAMLreturn (rv);
371   }
372
373   NONBLOCKING (r = virConnectListDefinedNetworks (conn, names, i));
374   CHECK_ERROR (r == -1, conn, "virConnectListDefinedNetworks");
375
376   rv = caml_alloc (r, 0);
377   for (i = 0; i < r; ++i) {
378     strv = caml_copy_string (names[i]);
379     Store_field (rv, i, strv);
380     free (names[i]);
381   }
382
383   CAMLreturn (rv);
384 }
385
386 /* Automatically generated binding for virConnectNumOfStoragePools.
387  * In generator.pl this function has signature "conn : int".
388  */
389
390 #ifdef HAVE_WEAK_SYMBOLS
391 #ifdef HAVE_VIRCONNECTNUMOFSTORAGEPOOLS
392 extern int virConnectNumOfStoragePools (virConnectPtr conn) __attribute__((weak));
393 #endif
394 #endif
395
396 CAMLprim value
397 ocaml_libvirt_connect_num_of_storage_pools (value connv)
398 {
399   CAMLparam1 (connv);
400 #ifndef HAVE_VIRCONNECTNUMOFSTORAGEPOOLS
401   /* Symbol virConnectNumOfStoragePools not found at compile time. */
402   not_supported ("virConnectNumOfStoragePools");
403   CAMLnoreturn;
404 #else
405   /* Check that the symbol virConnectNumOfStoragePools
406    * is in runtime version of libvirt.
407    */
408   WEAK_SYMBOL_CHECK (virConnectNumOfStoragePools);
409
410   virConnectPtr conn = Connect_val (connv);
411   int r;
412
413   NONBLOCKING (r = virConnectNumOfStoragePools (conn));
414   CHECK_ERROR (r == -1, conn, "virConnectNumOfStoragePools");
415
416   CAMLreturn (Val_int (r));
417 #endif
418 }
419
420 /* Automatically generated binding for virConnectListStoragePools.
421  * In generator.pl this function has signature "conn, int : string array".
422  */
423
424 #ifdef HAVE_WEAK_SYMBOLS
425 #ifdef HAVE_VIRCONNECTLISTSTORAGEPOOLS
426 extern int virConnectListStoragePools (virConnectPtr conn, char **const names, int maxnames) __attribute__((weak));
427 #endif
428 #endif
429
430 CAMLprim value
431 ocaml_libvirt_connect_list_storage_pools (value connv, value iv)
432 {
433   CAMLparam2 (connv, iv);
434 #ifndef HAVE_VIRCONNECTLISTSTORAGEPOOLS
435   /* Symbol virConnectListStoragePools not found at compile time. */
436   not_supported ("virConnectListStoragePools");
437   CAMLnoreturn;
438 #else
439   /* Check that the symbol virConnectListStoragePools
440    * is in runtime version of libvirt.
441    */
442   WEAK_SYMBOL_CHECK (virConnectListStoragePools);
443
444   CAMLlocal2 (rv, strv);
445   virConnectPtr conn = Connect_val (connv);
446   int i = Int_val (iv);
447   char *names[i];
448   int r;
449
450   /* Some libvirt List* functions still throw exceptions if i == 0,
451    * so catch that and return an empty array directly.  This changes
452    * the semantics slightly (masking other failures) but it's
453    * unlikely anyone will care.  RWMJ 2008/06/10
454    */
455   if (i == 0) {
456     rv = caml_alloc (0, 0);
457     CAMLreturn (rv);
458   }
459
460   NONBLOCKING (r = virConnectListStoragePools (conn, names, i));
461   CHECK_ERROR (r == -1, conn, "virConnectListStoragePools");
462
463   rv = caml_alloc (r, 0);
464   for (i = 0; i < r; ++i) {
465     strv = caml_copy_string (names[i]);
466     Store_field (rv, i, strv);
467     free (names[i]);
468   }
469
470   CAMLreturn (rv);
471 #endif
472 }
473
474 /* Automatically generated binding for virConnectNumOfDefinedStoragePools.
475  * In generator.pl this function has signature "conn : int".
476  */
477
478 #ifdef HAVE_WEAK_SYMBOLS
479 #ifdef HAVE_VIRCONNECTNUMOFDEFINEDSTORAGEPOOLS
480 extern int virConnectNumOfDefinedStoragePools (virConnectPtr conn) __attribute__((weak));
481 #endif
482 #endif
483
484 CAMLprim value
485 ocaml_libvirt_connect_num_of_defined_storage_pools (value connv)
486 {
487   CAMLparam1 (connv);
488 #ifndef HAVE_VIRCONNECTNUMOFDEFINEDSTORAGEPOOLS
489   /* Symbol virConnectNumOfDefinedStoragePools not found at compile time. */
490   not_supported ("virConnectNumOfDefinedStoragePools");
491   CAMLnoreturn;
492 #else
493   /* Check that the symbol virConnectNumOfDefinedStoragePools
494    * is in runtime version of libvirt.
495    */
496   WEAK_SYMBOL_CHECK (virConnectNumOfDefinedStoragePools);
497
498   virConnectPtr conn = Connect_val (connv);
499   int r;
500
501   NONBLOCKING (r = virConnectNumOfDefinedStoragePools (conn));
502   CHECK_ERROR (r == -1, conn, "virConnectNumOfDefinedStoragePools");
503
504   CAMLreturn (Val_int (r));
505 #endif
506 }
507
508 /* Automatically generated binding for virConnectListDefinedStoragePools.
509  * In generator.pl this function has signature "conn, int : string array".
510  */
511
512 #ifdef HAVE_WEAK_SYMBOLS
513 #ifdef HAVE_VIRCONNECTLISTDEFINEDSTORAGEPOOLS
514 extern int virConnectListDefinedStoragePools (virConnectPtr conn, char **const names, int maxnames) __attribute__((weak));
515 #endif
516 #endif
517
518 CAMLprim value
519 ocaml_libvirt_connect_list_defined_storage_pools (value connv, value iv)
520 {
521   CAMLparam2 (connv, iv);
522 #ifndef HAVE_VIRCONNECTLISTDEFINEDSTORAGEPOOLS
523   /* Symbol virConnectListDefinedStoragePools not found at compile time. */
524   not_supported ("virConnectListDefinedStoragePools");
525   CAMLnoreturn;
526 #else
527   /* Check that the symbol virConnectListDefinedStoragePools
528    * is in runtime version of libvirt.
529    */
530   WEAK_SYMBOL_CHECK (virConnectListDefinedStoragePools);
531
532   CAMLlocal2 (rv, strv);
533   virConnectPtr conn = Connect_val (connv);
534   int i = Int_val (iv);
535   char *names[i];
536   int r;
537
538   /* Some libvirt List* functions still throw exceptions if i == 0,
539    * so catch that and return an empty array directly.  This changes
540    * the semantics slightly (masking other failures) but it's
541    * unlikely anyone will care.  RWMJ 2008/06/10
542    */
543   if (i == 0) {
544     rv = caml_alloc (0, 0);
545     CAMLreturn (rv);
546   }
547
548   NONBLOCKING (r = virConnectListDefinedStoragePools (conn, names, i));
549   CHECK_ERROR (r == -1, conn, "virConnectListDefinedStoragePools");
550
551   rv = caml_alloc (r, 0);
552   for (i = 0; i < r; ++i) {
553     strv = caml_copy_string (names[i]);
554     Store_field (rv, i, strv);
555     free (names[i]);
556   }
557
558   CAMLreturn (rv);
559 #endif
560 }
561
562 /* Automatically generated binding for virConnectGetCapabilities.
563  * In generator.pl this function has signature "conn : string".
564  */
565
566 CAMLprim value
567 ocaml_libvirt_connect_get_capabilities (value connv)
568 {
569   CAMLparam1 (connv);
570
571   CAMLlocal1 (rv);
572   virConnectPtr conn = Connect_val (connv);
573   char *r;
574
575   NONBLOCKING (r = virConnectGetCapabilities (conn));
576   CHECK_ERROR (!r, conn, "virConnectGetCapabilities");
577
578   rv = caml_copy_string (r);
579   free (r);
580   CAMLreturn (rv);
581 }
582
583 /* Automatically generated binding for virDomainCreateLinux.
584  * In generator.pl this function has signature "conn, string, 0U : dom".
585  */
586
587 CAMLprim value
588 ocaml_libvirt_domain_create_linux (value connv, value strv)
589 {
590   CAMLparam2 (connv, strv);
591
592   CAMLlocal1 (rv);
593   virConnectPtr conn = Connect_val (connv);
594   char *str = String_val (strv);
595   virDomainPtr r;
596
597   NONBLOCKING (r = virDomainCreateLinux (conn, str, 0));
598   CHECK_ERROR (!r, conn, "virDomainCreateLinux");
599
600   rv = Val_domain (r, connv);
601
602   CAMLreturn (rv);
603 }
604
605 /* Automatically generated binding for virDomainFree.
606  * In generator.pl this function has signature "dom : free".
607  */
608
609 CAMLprim value
610 ocaml_libvirt_domain_free (value domv)
611 {
612   CAMLparam1 (domv);
613
614   virDomainPtr dom = Domain_val (domv);
615   virConnectPtr conn = Connect_domv (domv);
616   int r;
617
618   NONBLOCKING (r = virDomainFree (dom));
619   CHECK_ERROR (r == -1, conn, "virDomainFree");
620
621   /* So that we don't double-free in the finalizer: */
622   Domain_val (domv) = NULL;
623
624   CAMLreturn (Val_unit);
625 }
626
627 /* Automatically generated binding for virDomainDestroy.
628  * In generator.pl this function has signature "dom : free".
629  */
630
631 CAMLprim value
632 ocaml_libvirt_domain_destroy (value domv)
633 {
634   CAMLparam1 (domv);
635
636   virDomainPtr dom = Domain_val (domv);
637   virConnectPtr conn = Connect_domv (domv);
638   int r;
639
640   NONBLOCKING (r = virDomainDestroy (dom));
641   CHECK_ERROR (r == -1, conn, "virDomainDestroy");
642
643   /* So that we don't double-free in the finalizer: */
644   Domain_val (domv) = NULL;
645
646   CAMLreturn (Val_unit);
647 }
648
649 /* Automatically generated binding for virDomainLookupByName.
650  * In generator.pl this function has signature "conn, string : dom".
651  */
652
653 CAMLprim value
654 ocaml_libvirt_domain_lookup_by_name (value connv, value strv)
655 {
656   CAMLparam2 (connv, strv);
657
658   CAMLlocal1 (rv);
659   virConnectPtr conn = Connect_val (connv);
660   char *str = String_val (strv);
661   virDomainPtr r;
662
663   NONBLOCKING (r = virDomainLookupByName (conn, str));
664   CHECK_ERROR (!r, conn, "virDomainLookupByName");
665
666   rv = Val_domain (r, connv);
667
668   CAMLreturn (rv);
669 }
670
671 /* Automatically generated binding for virDomainLookupByID.
672  * In generator.pl this function has signature "conn, int : dom".
673  */
674
675 CAMLprim value
676 ocaml_libvirt_domain_lookup_by_id (value connv, value iv)
677 {
678   CAMLparam2 (connv, iv);
679
680   CAMLlocal1 (rv);
681   virConnectPtr conn = Connect_val (connv);
682   int i = Int_val (iv);
683   virDomainPtr r;
684
685   NONBLOCKING (r = virDomainLookupByID (conn, i));
686   CHECK_ERROR (!r, conn, "virDomainLookupByID");
687
688   rv = Val_domain (r, connv);
689
690   CAMLreturn (rv);
691 }
692
693 /* Automatically generated binding for virDomainLookupByUUID.
694  * In generator.pl this function has signature "conn, uuid : dom".
695  */
696
697 CAMLprim value
698 ocaml_libvirt_domain_lookup_by_uuid (value connv, value uuidv)
699 {
700   CAMLparam2 (connv, uuidv);
701
702   CAMLlocal1 (rv);
703   virConnectPtr conn = Connect_val (connv);
704   unsigned char *uuid = (unsigned char *) String_val (uuidv);
705   virDomainPtr r;
706
707   NONBLOCKING (r = virDomainLookupByUUID (conn, uuid));
708   CHECK_ERROR (!r, conn, "virDomainLookupByUUID");
709
710   rv = Val_domain (r, connv);
711
712   CAMLreturn (rv);
713 }
714
715 /* Automatically generated binding for virDomainLookupByUUIDString.
716  * In generator.pl this function has signature "conn, string : dom".
717  */
718
719 CAMLprim value
720 ocaml_libvirt_domain_lookup_by_uuid_string (value connv, value strv)
721 {
722   CAMLparam2 (connv, strv);
723
724   CAMLlocal1 (rv);
725   virConnectPtr conn = Connect_val (connv);
726   char *str = String_val (strv);
727   virDomainPtr r;
728
729   NONBLOCKING (r = virDomainLookupByUUIDString (conn, str));
730   CHECK_ERROR (!r, conn, "virDomainLookupByUUIDString");
731
732   rv = Val_domain (r, connv);
733
734   CAMLreturn (rv);
735 }
736
737 /* Automatically generated binding for virDomainGetName.
738  * In generator.pl this function has signature "dom : static string".
739  */
740
741 CAMLprim value
742 ocaml_libvirt_domain_get_name (value domv)
743 {
744   CAMLparam1 (domv);
745
746   CAMLlocal1 (rv);
747   virDomainPtr dom = Domain_val (domv);
748   virConnectPtr conn = Connect_domv (domv);
749   const char *r;
750
751   NONBLOCKING (r = virDomainGetName (dom));
752   CHECK_ERROR (!r, conn, "virDomainGetName");
753
754   rv = caml_copy_string (r);
755   CAMLreturn (rv);
756 }
757
758 /* Automatically generated binding for virDomainGetOSType.
759  * In generator.pl this function has signature "dom : string".
760  */
761
762 CAMLprim value
763 ocaml_libvirt_domain_get_os_type (value domv)
764 {
765   CAMLparam1 (domv);
766
767   CAMLlocal1 (rv);
768   virDomainPtr dom = Domain_val (domv);
769   virConnectPtr conn = Connect_domv (domv);
770   char *r;
771
772   NONBLOCKING (r = virDomainGetOSType (dom));
773   CHECK_ERROR (!r, conn, "virDomainGetOSType");
774
775   rv = caml_copy_string (r);
776   free (r);
777   CAMLreturn (rv);
778 }
779
780 /* Automatically generated binding for virDomainGetXMLDesc.
781  * In generator.pl this function has signature "dom, 0 : string".
782  */
783
784 CAMLprim value
785 ocaml_libvirt_domain_get_xml_desc (value domv)
786 {
787   CAMLparam1 (domv);
788
789   CAMLlocal1 (rv);
790   virDomainPtr dom = Domain_val (domv);
791   virConnectPtr conn = Connect_domv (domv);
792   char *r;
793
794   NONBLOCKING (r = virDomainGetXMLDesc (dom, 0));
795   CHECK_ERROR (!r, conn, "virDomainGetXMLDesc");
796
797   rv = caml_copy_string (r);
798   free (r);
799   CAMLreturn (rv);
800 }
801
802 /* Automatically generated binding for virDomainGetUUID.
803  * In generator.pl this function has signature "dom : uuid".
804  */
805
806 CAMLprim value
807 ocaml_libvirt_domain_get_uuid (value domv)
808 {
809   CAMLparam1 (domv);
810
811   CAMLlocal1 (rv);
812   virDomainPtr dom = Domain_val (domv);
813   virConnectPtr conn = Connect_domv (domv);
814   unsigned char uuid[VIR_UUID_BUFLEN];
815   int r;
816
817   NONBLOCKING (r = virDomainGetUUID (dom, uuid));
818   CHECK_ERROR (r == -1, conn, "virDomainGetUUID");
819
820   /* UUIDs are byte arrays with a fixed length. */
821   rv = caml_alloc_string (VIR_UUID_BUFLEN);
822   memcpy (String_val (rv), uuid, VIR_UUID_BUFLEN);
823   CAMLreturn (rv);
824 }
825
826 /* Automatically generated binding for virDomainGetUUIDString.
827  * In generator.pl this function has signature "dom : uuid string".
828  */
829
830 CAMLprim value
831 ocaml_libvirt_domain_get_uuid_string (value domv)
832 {
833   CAMLparam1 (domv);
834
835   CAMLlocal1 (rv);
836   virDomainPtr dom = Domain_val (domv);
837   virConnectPtr conn = Connect_domv (domv);
838   char uuid[VIR_UUID_STRING_BUFLEN];
839   int r;
840
841   NONBLOCKING (r = virDomainGetUUIDString (dom, uuid));
842   CHECK_ERROR (r == -1, conn, "virDomainGetUUIDString");
843
844   rv = caml_copy_string (uuid);
845   CAMLreturn (rv);
846 }
847
848 /* Automatically generated binding for virDomainGetMaxVcpus.
849  * In generator.pl this function has signature "dom : int".
850  */
851
852 CAMLprim value
853 ocaml_libvirt_domain_get_max_vcpus (value domv)
854 {
855   CAMLparam1 (domv);
856
857   virDomainPtr dom = Domain_val (domv);
858   virConnectPtr conn = Connect_domv (domv);
859   int r;
860
861   NONBLOCKING (r = virDomainGetMaxVcpus (dom));
862   CHECK_ERROR (r == -1, conn, "virDomainGetMaxVcpus");
863
864   CAMLreturn (Val_int (r));
865 }
866
867 /* Automatically generated binding for virDomainSave.
868  * In generator.pl this function has signature "dom, string : unit".
869  */
870
871 CAMLprim value
872 ocaml_libvirt_domain_save (value domv, value strv)
873 {
874   CAMLparam2 (domv, strv);
875
876   virDomainPtr dom = Domain_val (domv);
877   virConnectPtr conn = Connect_domv (domv);
878   char *str = String_val (strv);
879   int r;
880
881   NONBLOCKING (r = virDomainSave (dom, str));
882   CHECK_ERROR (r == -1, conn, "virDomainSave");
883
884   CAMLreturn (Val_unit);
885 }
886
887 /* Automatically generated binding for virDomainRestore.
888  * In generator.pl this function has signature "conn, string : unit".
889  */
890
891 CAMLprim value
892 ocaml_libvirt_domain_restore (value connv, value strv)
893 {
894   CAMLparam2 (connv, strv);
895
896   virConnectPtr conn = Connect_val (connv);
897   char *str = String_val (strv);
898   int r;
899
900   NONBLOCKING (r = virDomainRestore (conn, str));
901   CHECK_ERROR (r == -1, conn, "virDomainRestore");
902
903   CAMLreturn (Val_unit);
904 }
905
906 /* Automatically generated binding for virDomainCoreDump.
907  * In generator.pl this function has signature "dom, string, 0 : unit".
908  */
909
910 CAMLprim value
911 ocaml_libvirt_domain_core_dump (value domv, value strv)
912 {
913   CAMLparam2 (domv, strv);
914
915   CAMLlocal1 (rv);
916   virDomainPtr dom = Domain_val (domv);
917   virConnectPtr conn = Connect_domv (domv);
918   char *str = String_val (strv);
919   int r;
920
921   NONBLOCKING (r = virDomainCoreDump (dom, str, 0));
922   CHECK_ERROR (!r, conn, "virDomainCoreDump");
923
924   CAMLreturn (Val_unit);
925 }
926
927 /* Automatically generated binding for virDomainSuspend.
928  * In generator.pl this function has signature "dom : unit".
929  */
930
931 CAMLprim value
932 ocaml_libvirt_domain_suspend (value domv)
933 {
934   CAMLparam1 (domv);
935
936   virDomainPtr dom = Domain_val (domv);
937   virConnectPtr conn = Connect_domv (domv);
938   int r;
939
940   NONBLOCKING (r = virDomainSuspend (dom));
941   CHECK_ERROR (r == -1, conn, "virDomainSuspend");
942
943   CAMLreturn (Val_unit);
944 }
945
946 /* Automatically generated binding for virDomainResume.
947  * In generator.pl this function has signature "dom : unit".
948  */
949
950 CAMLprim value
951 ocaml_libvirt_domain_resume (value domv)
952 {
953   CAMLparam1 (domv);
954
955   virDomainPtr dom = Domain_val (domv);
956   virConnectPtr conn = Connect_domv (domv);
957   int r;
958
959   NONBLOCKING (r = virDomainResume (dom));
960   CHECK_ERROR (r == -1, conn, "virDomainResume");
961
962   CAMLreturn (Val_unit);
963 }
964
965 /* Automatically generated binding for virDomainShutdown.
966  * In generator.pl this function has signature "dom : unit".
967  */
968
969 CAMLprim value
970 ocaml_libvirt_domain_shutdown (value domv)
971 {
972   CAMLparam1 (domv);
973
974   virDomainPtr dom = Domain_val (domv);
975   virConnectPtr conn = Connect_domv (domv);
976   int r;
977
978   NONBLOCKING (r = virDomainShutdown (dom));
979   CHECK_ERROR (r == -1, conn, "virDomainShutdown");
980
981   CAMLreturn (Val_unit);
982 }
983
984 /* Automatically generated binding for virDomainReboot.
985  * In generator.pl this function has signature "dom, 0 : unit".
986  */
987
988 CAMLprim value
989 ocaml_libvirt_domain_reboot (value domv)
990 {
991   CAMLparam1 (domv);
992
993   virDomainPtr dom = Domain_val (domv);
994   virConnectPtr conn = Connect_domv (domv);
995   int r;
996
997   NONBLOCKING (r = virDomainReboot (dom, 0));
998   CHECK_ERROR (r == -1, conn, "virDomainReboot");
999
1000   CAMLreturn (Val_unit);
1001 }
1002
1003 /* Automatically generated binding for virDomainDefineXML.
1004  * In generator.pl this function has signature "conn, string : dom".
1005  */
1006
1007 CAMLprim value
1008 ocaml_libvirt_domain_define_xml (value connv, value strv)
1009 {
1010   CAMLparam2 (connv, strv);
1011
1012   CAMLlocal1 (rv);
1013   virConnectPtr conn = Connect_val (connv);
1014   char *str = String_val (strv);
1015   virDomainPtr r;
1016
1017   NONBLOCKING (r = virDomainDefineXML (conn, str));
1018   CHECK_ERROR (!r, conn, "virDomainDefineXML");
1019
1020   rv = Val_domain (r, connv);
1021
1022   CAMLreturn (rv);
1023 }
1024
1025 /* Automatically generated binding for virDomainUndefine.
1026  * In generator.pl this function has signature "dom : unit".
1027  */
1028
1029 CAMLprim value
1030 ocaml_libvirt_domain_undefine (value domv)
1031 {
1032   CAMLparam1 (domv);
1033
1034   virDomainPtr dom = Domain_val (domv);
1035   virConnectPtr conn = Connect_domv (domv);
1036   int r;
1037
1038   NONBLOCKING (r = virDomainUndefine (dom));
1039   CHECK_ERROR (r == -1, conn, "virDomainUndefine");
1040
1041   CAMLreturn (Val_unit);
1042 }
1043
1044 /* Automatically generated binding for virDomainCreate.
1045  * In generator.pl this function has signature "dom : unit".
1046  */
1047
1048 CAMLprim value
1049 ocaml_libvirt_domain_create (value domv)
1050 {
1051   CAMLparam1 (domv);
1052
1053   virDomainPtr dom = Domain_val (domv);
1054   virConnectPtr conn = Connect_domv (domv);
1055   int r;
1056
1057   NONBLOCKING (r = virDomainCreate (dom));
1058   CHECK_ERROR (r == -1, conn, "virDomainCreate");
1059
1060   CAMLreturn (Val_unit);
1061 }
1062
1063 /* Automatically generated binding for virDomainAttachDevice.
1064  * In generator.pl this function has signature "dom, string : unit".
1065  */
1066
1067 CAMLprim value
1068 ocaml_libvirt_domain_attach_device (value domv, value strv)
1069 {
1070   CAMLparam2 (domv, strv);
1071
1072   virDomainPtr dom = Domain_val (domv);
1073   virConnectPtr conn = Connect_domv (domv);
1074   char *str = String_val (strv);
1075   int r;
1076
1077   NONBLOCKING (r = virDomainAttachDevice (dom, str));
1078   CHECK_ERROR (r == -1, conn, "virDomainAttachDevice");
1079
1080   CAMLreturn (Val_unit);
1081 }
1082
1083 /* Automatically generated binding for virDomainDetachDevice.
1084  * In generator.pl this function has signature "dom, string : unit".
1085  */
1086
1087 CAMLprim value
1088 ocaml_libvirt_domain_detach_device (value domv, value strv)
1089 {
1090   CAMLparam2 (domv, strv);
1091
1092   virDomainPtr dom = Domain_val (domv);
1093   virConnectPtr conn = Connect_domv (domv);
1094   char *str = String_val (strv);
1095   int r;
1096
1097   NONBLOCKING (r = virDomainDetachDevice (dom, str));
1098   CHECK_ERROR (r == -1, conn, "virDomainDetachDevice");
1099
1100   CAMLreturn (Val_unit);
1101 }
1102
1103 /* Automatically generated binding for virDomainGetAutostart.
1104  * In generator.pl this function has signature "dom : bool".
1105  */
1106
1107 CAMLprim value
1108 ocaml_libvirt_domain_get_autostart (value domv)
1109 {
1110   CAMLparam1 (domv);
1111
1112   virDomainPtr dom = Domain_val (domv);
1113   virConnectPtr conn = Connect_domv (domv);
1114   int r, b;
1115
1116   NONBLOCKING (r = virDomainGetAutostart (dom, &b));
1117   CHECK_ERROR (r == -1, conn, "virDomainGetAutostart");
1118
1119   CAMLreturn (b ? Val_true : Val_false);
1120 }
1121
1122 /* Automatically generated binding for virDomainSetAutostart.
1123  * In generator.pl this function has signature "dom, bool : unit".
1124  */
1125
1126 CAMLprim value
1127 ocaml_libvirt_domain_set_autostart (value domv, value bv)
1128 {
1129   CAMLparam2 (domv, bv);
1130
1131   virDomainPtr dom = Domain_val (domv);
1132   virConnectPtr conn = Connect_domv (domv);
1133   int r, b;
1134
1135   b = bv == Val_true ? 1 : 0;
1136
1137   NONBLOCKING (r = virDomainSetAutostart (dom, b));
1138   CHECK_ERROR (r == -1, conn, "virDomainSetAutostart");
1139
1140   CAMLreturn (Val_unit);
1141 }
1142
1143 /* Automatically generated binding for virNetworkFree.
1144  * In generator.pl this function has signature "net : free".
1145  */
1146
1147 CAMLprim value
1148 ocaml_libvirt_network_free (value netv)
1149 {
1150   CAMLparam1 (netv);
1151
1152   virNetworkPtr net = Network_val (netv);
1153   virConnectPtr conn = Connect_netv (netv);
1154   int r;
1155
1156   NONBLOCKING (r = virNetworkFree (net));
1157   CHECK_ERROR (r == -1, conn, "virNetworkFree");
1158
1159   /* So that we don't double-free in the finalizer: */
1160   Network_val (netv) = NULL;
1161
1162   CAMLreturn (Val_unit);
1163 }
1164
1165 /* Automatically generated binding for virNetworkDestroy.
1166  * In generator.pl this function has signature "net : free".
1167  */
1168
1169 CAMLprim value
1170 ocaml_libvirt_network_destroy (value netv)
1171 {
1172   CAMLparam1 (netv);
1173
1174   virNetworkPtr net = Network_val (netv);
1175   virConnectPtr conn = Connect_netv (netv);
1176   int r;
1177
1178   NONBLOCKING (r = virNetworkDestroy (net));
1179   CHECK_ERROR (r == -1, conn, "virNetworkDestroy");
1180
1181   /* So that we don't double-free in the finalizer: */
1182   Network_val (netv) = NULL;
1183
1184   CAMLreturn (Val_unit);
1185 }
1186
1187 /* Automatically generated binding for virNetworkLookupByName.
1188  * In generator.pl this function has signature "conn, string : net".
1189  */
1190
1191 CAMLprim value
1192 ocaml_libvirt_network_lookup_by_name (value connv, value strv)
1193 {
1194   CAMLparam2 (connv, strv);
1195
1196   CAMLlocal1 (rv);
1197   virConnectPtr conn = Connect_val (connv);
1198   char *str = String_val (strv);
1199   virNetworkPtr r;
1200
1201   NONBLOCKING (r = virNetworkLookupByName (conn, str));
1202   CHECK_ERROR (!r, conn, "virNetworkLookupByName");
1203
1204   rv = Val_network (r, connv);
1205
1206   CAMLreturn (rv);
1207 }
1208
1209 /* Automatically generated binding for virNetworkLookupByUUID.
1210  * In generator.pl this function has signature "conn, uuid : net".
1211  */
1212
1213 CAMLprim value
1214 ocaml_libvirt_network_lookup_by_uuid (value connv, value uuidv)
1215 {
1216   CAMLparam2 (connv, uuidv);
1217
1218   CAMLlocal1 (rv);
1219   virConnectPtr conn = Connect_val (connv);
1220   unsigned char *uuid = (unsigned char *) String_val (uuidv);
1221   virNetworkPtr r;
1222
1223   NONBLOCKING (r = virNetworkLookupByUUID (conn, uuid));
1224   CHECK_ERROR (!r, conn, "virNetworkLookupByUUID");
1225
1226   rv = Val_network (r, connv);
1227
1228   CAMLreturn (rv);
1229 }
1230
1231 /* Automatically generated binding for virNetworkLookupByUUIDString.
1232  * In generator.pl this function has signature "conn, string : net".
1233  */
1234
1235 CAMLprim value
1236 ocaml_libvirt_network_lookup_by_uuid_string (value connv, value strv)
1237 {
1238   CAMLparam2 (connv, strv);
1239
1240   CAMLlocal1 (rv);
1241   virConnectPtr conn = Connect_val (connv);
1242   char *str = String_val (strv);
1243   virNetworkPtr r;
1244
1245   NONBLOCKING (r = virNetworkLookupByUUIDString (conn, str));
1246   CHECK_ERROR (!r, conn, "virNetworkLookupByUUIDString");
1247
1248   rv = Val_network (r, connv);
1249
1250   CAMLreturn (rv);
1251 }
1252
1253 /* Automatically generated binding for virNetworkGetName.
1254  * In generator.pl this function has signature "net : static string".
1255  */
1256
1257 CAMLprim value
1258 ocaml_libvirt_network_get_name (value netv)
1259 {
1260   CAMLparam1 (netv);
1261
1262   CAMLlocal1 (rv);
1263   virNetworkPtr net = Network_val (netv);
1264   virConnectPtr conn = Connect_netv (netv);
1265   const char *r;
1266
1267   NONBLOCKING (r = virNetworkGetName (net));
1268   CHECK_ERROR (!r, conn, "virNetworkGetName");
1269
1270   rv = caml_copy_string (r);
1271   CAMLreturn (rv);
1272 }
1273
1274 /* Automatically generated binding for virNetworkGetXMLDesc.
1275  * In generator.pl this function has signature "net, 0 : string".
1276  */
1277
1278 CAMLprim value
1279 ocaml_libvirt_network_get_xml_desc (value netv)
1280 {
1281   CAMLparam1 (netv);
1282
1283   CAMLlocal1 (rv);
1284   virNetworkPtr net = Network_val (netv);
1285   virConnectPtr conn = Connect_netv (netv);
1286   char *r;
1287
1288   NONBLOCKING (r = virNetworkGetXMLDesc (net, 0));
1289   CHECK_ERROR (!r, conn, "virNetworkGetXMLDesc");
1290
1291   rv = caml_copy_string (r);
1292   free (r);
1293   CAMLreturn (rv);
1294 }
1295
1296 /* Automatically generated binding for virNetworkGetBridgeName.
1297  * In generator.pl this function has signature "net : string".
1298  */
1299
1300 CAMLprim value
1301 ocaml_libvirt_network_get_bridge_name (value netv)
1302 {
1303   CAMLparam1 (netv);
1304
1305   CAMLlocal1 (rv);
1306   virNetworkPtr net = Network_val (netv);
1307   virConnectPtr conn = Connect_netv (netv);
1308   char *r;
1309
1310   NONBLOCKING (r = virNetworkGetBridgeName (net));
1311   CHECK_ERROR (!r, conn, "virNetworkGetBridgeName");
1312
1313   rv = caml_copy_string (r);
1314   free (r);
1315   CAMLreturn (rv);
1316 }
1317
1318 /* Automatically generated binding for virNetworkGetUUID.
1319  * In generator.pl this function has signature "net : uuid".
1320  */
1321
1322 CAMLprim value
1323 ocaml_libvirt_network_get_uuid (value netv)
1324 {
1325   CAMLparam1 (netv);
1326
1327   CAMLlocal1 (rv);
1328   virNetworkPtr net = Network_val (netv);
1329   virConnectPtr conn = Connect_netv (netv);
1330   unsigned char uuid[VIR_UUID_BUFLEN];
1331   int r;
1332
1333   NONBLOCKING (r = virNetworkGetUUID (net, uuid));
1334   CHECK_ERROR (r == -1, conn, "virNetworkGetUUID");
1335
1336   /* UUIDs are byte arrays with a fixed length. */
1337   rv = caml_alloc_string (VIR_UUID_BUFLEN);
1338   memcpy (String_val (rv), uuid, VIR_UUID_BUFLEN);
1339   CAMLreturn (rv);
1340 }
1341
1342 /* Automatically generated binding for virNetworkGetUUIDString.
1343  * In generator.pl this function has signature "net : uuid string".
1344  */
1345
1346 CAMLprim value
1347 ocaml_libvirt_network_get_uuid_string (value netv)
1348 {
1349   CAMLparam1 (netv);
1350
1351   CAMLlocal1 (rv);
1352   virNetworkPtr net = Network_val (netv);
1353   virConnectPtr conn = Connect_netv (netv);
1354   char uuid[VIR_UUID_STRING_BUFLEN];
1355   int r;
1356
1357   NONBLOCKING (r = virNetworkGetUUIDString (net, uuid));
1358   CHECK_ERROR (r == -1, conn, "virNetworkGetUUIDString");
1359
1360   rv = caml_copy_string (uuid);
1361   CAMLreturn (rv);
1362 }
1363
1364 /* Automatically generated binding for virNetworkUndefine.
1365  * In generator.pl this function has signature "net : unit".
1366  */
1367
1368 CAMLprim value
1369 ocaml_libvirt_network_undefine (value netv)
1370 {
1371   CAMLparam1 (netv);
1372
1373   virNetworkPtr net = Network_val (netv);
1374   virConnectPtr conn = Connect_netv (netv);
1375   int r;
1376
1377   NONBLOCKING (r = virNetworkUndefine (net));
1378   CHECK_ERROR (r == -1, conn, "virNetworkUndefine");
1379
1380   CAMLreturn (Val_unit);
1381 }
1382
1383 /* Automatically generated binding for virNetworkCreateXML.
1384  * In generator.pl this function has signature "conn, string : net".
1385  */
1386
1387 CAMLprim value
1388 ocaml_libvirt_network_create_xml (value connv, value strv)
1389 {
1390   CAMLparam2 (connv, strv);
1391
1392   CAMLlocal1 (rv);
1393   virConnectPtr conn = Connect_val (connv);
1394   char *str = String_val (strv);
1395   virNetworkPtr r;
1396
1397   NONBLOCKING (r = virNetworkCreateXML (conn, str));
1398   CHECK_ERROR (!r, conn, "virNetworkCreateXML");
1399
1400   rv = Val_network (r, connv);
1401
1402   CAMLreturn (rv);
1403 }
1404
1405 /* Automatically generated binding for virNetworkDefineXML.
1406  * In generator.pl this function has signature "conn, string : net".
1407  */
1408
1409 CAMLprim value
1410 ocaml_libvirt_network_define_xml (value connv, value strv)
1411 {
1412   CAMLparam2 (connv, strv);
1413
1414   CAMLlocal1 (rv);
1415   virConnectPtr conn = Connect_val (connv);
1416   char *str = String_val (strv);
1417   virNetworkPtr r;
1418
1419   NONBLOCKING (r = virNetworkDefineXML (conn, str));
1420   CHECK_ERROR (!r, conn, "virNetworkDefineXML");
1421
1422   rv = Val_network (r, connv);
1423
1424   CAMLreturn (rv);
1425 }
1426
1427 /* Automatically generated binding for virNetworkCreate.
1428  * In generator.pl this function has signature "net : unit".
1429  */
1430
1431 CAMLprim value
1432 ocaml_libvirt_network_create (value netv)
1433 {
1434   CAMLparam1 (netv);
1435
1436   virNetworkPtr net = Network_val (netv);
1437   virConnectPtr conn = Connect_netv (netv);
1438   int r;
1439
1440   NONBLOCKING (r = virNetworkCreate (net));
1441   CHECK_ERROR (r == -1, conn, "virNetworkCreate");
1442
1443   CAMLreturn (Val_unit);
1444 }
1445
1446 /* Automatically generated binding for virNetworkGetAutostart.
1447  * In generator.pl this function has signature "net : bool".
1448  */
1449
1450 CAMLprim value
1451 ocaml_libvirt_network_get_autostart (value netv)
1452 {
1453   CAMLparam1 (netv);
1454
1455   virNetworkPtr net = Network_val (netv);
1456   virConnectPtr conn = Connect_netv (netv);
1457   int r, b;
1458
1459   NONBLOCKING (r = virNetworkGetAutostart (net, &b));
1460   CHECK_ERROR (r == -1, conn, "virNetworkGetAutostart");
1461
1462   CAMLreturn (b ? Val_true : Val_false);
1463 }
1464
1465 /* Automatically generated binding for virNetworkSetAutostart.
1466  * In generator.pl this function has signature "net, bool : unit".
1467  */
1468
1469 CAMLprim value
1470 ocaml_libvirt_network_set_autostart (value netv, value bv)
1471 {
1472   CAMLparam2 (netv, bv);
1473
1474   virNetworkPtr net = Network_val (netv);
1475   virConnectPtr conn = Connect_netv (netv);
1476   int r, b;
1477
1478   b = bv == Val_true ? 1 : 0;
1479
1480   NONBLOCKING (r = virNetworkSetAutostart (net, b));
1481   CHECK_ERROR (r == -1, conn, "virNetworkSetAutostart");
1482
1483   CAMLreturn (Val_unit);
1484 }
1485
1486 /* Automatically generated binding for virStoragePoolFree.
1487  * In generator.pl this function has signature "pool : free".
1488  */
1489
1490 #ifdef HAVE_WEAK_SYMBOLS
1491 #ifdef HAVE_VIRSTORAGEPOOLFREE
1492 extern int virStoragePoolFree (virStoragePoolPtr pool) __attribute__((weak));
1493 #endif
1494 #endif
1495
1496 CAMLprim value
1497 ocaml_libvirt_storage_pool_free (value poolv)
1498 {
1499   CAMLparam1 (poolv);
1500 #ifndef HAVE_VIRSTORAGEPOOLFREE
1501   /* Symbol virStoragePoolFree not found at compile time. */
1502   not_supported ("virStoragePoolFree");
1503   CAMLnoreturn;
1504 #else
1505   /* Check that the symbol virStoragePoolFree
1506    * is in runtime version of libvirt.
1507    */
1508   WEAK_SYMBOL_CHECK (virStoragePoolFree);
1509
1510   virStoragePoolPtr pool = Pool_val (poolv);
1511   virConnectPtr conn = Connect_polv (poolv);
1512   int r;
1513
1514   NONBLOCKING (r = virStoragePoolFree (pool));
1515   CHECK_ERROR (r == -1, conn, "virStoragePoolFree");
1516
1517   /* So that we don't double-free in the finalizer: */
1518   Pool_val (poolv) = NULL;
1519
1520   CAMLreturn (Val_unit);
1521 #endif
1522 }
1523
1524 /* Automatically generated binding for virStoragePoolDestroy.
1525  * In generator.pl this function has signature "pool : free".
1526  */
1527
1528 #ifdef HAVE_WEAK_SYMBOLS
1529 #ifdef HAVE_VIRSTORAGEPOOLDESTROY
1530 extern int virStoragePoolDestroy (virStoragePoolPtr pool) __attribute__((weak));
1531 #endif
1532 #endif
1533
1534 CAMLprim value
1535 ocaml_libvirt_storage_pool_destroy (value poolv)
1536 {
1537   CAMLparam1 (poolv);
1538 #ifndef HAVE_VIRSTORAGEPOOLDESTROY
1539   /* Symbol virStoragePoolDestroy not found at compile time. */
1540   not_supported ("virStoragePoolDestroy");
1541   CAMLnoreturn;
1542 #else
1543   /* Check that the symbol virStoragePoolDestroy
1544    * is in runtime version of libvirt.
1545    */
1546   WEAK_SYMBOL_CHECK (virStoragePoolDestroy);
1547
1548   virStoragePoolPtr pool = Pool_val (poolv);
1549   virConnectPtr conn = Connect_polv (poolv);
1550   int r;
1551
1552   NONBLOCKING (r = virStoragePoolDestroy (pool));
1553   CHECK_ERROR (r == -1, conn, "virStoragePoolDestroy");
1554
1555   /* So that we don't double-free in the finalizer: */
1556   Pool_val (poolv) = NULL;
1557
1558   CAMLreturn (Val_unit);
1559 #endif
1560 }
1561
1562 /* Automatically generated binding for virStoragePoolLookupByName.
1563  * In generator.pl this function has signature "conn, string : pool".
1564  */
1565
1566 #ifdef HAVE_WEAK_SYMBOLS
1567 #ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYNAME
1568 extern virStoragePoolPtr virStoragePoolLookupByName (virConnectPtr conn, const char *str) __attribute__((weak));
1569 #endif
1570 #endif
1571
1572 CAMLprim value
1573 ocaml_libvirt_storage_pool_lookup_by_name (value connv, value strv)
1574 {
1575   CAMLparam2 (connv, strv);
1576 #ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYNAME
1577   /* Symbol virStoragePoolLookupByName not found at compile time. */
1578   not_supported ("virStoragePoolLookupByName");
1579   CAMLnoreturn;
1580 #else
1581   /* Check that the symbol virStoragePoolLookupByName
1582    * is in runtime version of libvirt.
1583    */
1584   WEAK_SYMBOL_CHECK (virStoragePoolLookupByName);
1585
1586   CAMLlocal1 (rv);
1587   virConnectPtr conn = Connect_val (connv);
1588   char *str = String_val (strv);
1589   virStoragePoolPtr r;
1590
1591   NONBLOCKING (r = virStoragePoolLookupByName (conn, str));
1592   CHECK_ERROR (!r, conn, "virStoragePoolLookupByName");
1593
1594   rv = Val_pool (r, connv);
1595
1596   CAMLreturn (rv);
1597 #endif
1598 }
1599
1600 /* Automatically generated binding for virStoragePoolLookupByUUID.
1601  * In generator.pl this function has signature "conn, uuid : pool".
1602  */
1603
1604 #ifdef HAVE_WEAK_SYMBOLS
1605 #ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYUUID
1606 extern virStoragePoolPtr virStoragePoolLookupByUUID (virConnectPtr conn, const unsigned char *str) __attribute__((weak));
1607 #endif
1608 #endif
1609
1610 CAMLprim value
1611 ocaml_libvirt_storage_pool_lookup_by_uuid (value connv, value uuidv)
1612 {
1613   CAMLparam2 (connv, uuidv);
1614 #ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYUUID
1615   /* Symbol virStoragePoolLookupByUUID not found at compile time. */
1616   not_supported ("virStoragePoolLookupByUUID");
1617   CAMLnoreturn;
1618 #else
1619   /* Check that the symbol virStoragePoolLookupByUUID
1620    * is in runtime version of libvirt.
1621    */
1622   WEAK_SYMBOL_CHECK (virStoragePoolLookupByUUID);
1623
1624   CAMLlocal1 (rv);
1625   virConnectPtr conn = Connect_val (connv);
1626   unsigned char *uuid = (unsigned char *) String_val (uuidv);
1627   virStoragePoolPtr r;
1628
1629   NONBLOCKING (r = virStoragePoolLookupByUUID (conn, uuid));
1630   CHECK_ERROR (!r, conn, "virStoragePoolLookupByUUID");
1631
1632   rv = Val_pool (r, connv);
1633
1634   CAMLreturn (rv);
1635 #endif
1636 }
1637
1638 /* Automatically generated binding for virStoragePoolLookupByUUIDString.
1639  * In generator.pl this function has signature "conn, string : pool".
1640  */
1641
1642 #ifdef HAVE_WEAK_SYMBOLS
1643 #ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYUUIDSTRING
1644 extern virStoragePoolPtr virStoragePoolLookupByUUIDString (virConnectPtr conn, const char *str) __attribute__((weak));
1645 #endif
1646 #endif
1647
1648 CAMLprim value
1649 ocaml_libvirt_storage_pool_lookup_by_uuid_string (value connv, value strv)
1650 {
1651   CAMLparam2 (connv, strv);
1652 #ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYUUIDSTRING
1653   /* Symbol virStoragePoolLookupByUUIDString not found at compile time. */
1654   not_supported ("virStoragePoolLookupByUUIDString");
1655   CAMLnoreturn;
1656 #else
1657   /* Check that the symbol virStoragePoolLookupByUUIDString
1658    * is in runtime version of libvirt.
1659    */
1660   WEAK_SYMBOL_CHECK (virStoragePoolLookupByUUIDString);
1661
1662   CAMLlocal1 (rv);
1663   virConnectPtr conn = Connect_val (connv);
1664   char *str = String_val (strv);
1665   virStoragePoolPtr r;
1666
1667   NONBLOCKING (r = virStoragePoolLookupByUUIDString (conn, str));
1668   CHECK_ERROR (!r, conn, "virStoragePoolLookupByUUIDString");
1669
1670   rv = Val_pool (r, connv);
1671
1672   CAMLreturn (rv);
1673 #endif
1674 }
1675
1676 /* Automatically generated binding for virStoragePoolGetName.
1677  * In generator.pl this function has signature "pool : static string".
1678  */
1679
1680 #ifdef HAVE_WEAK_SYMBOLS
1681 #ifdef HAVE_VIRSTORAGEPOOLGETNAME
1682 extern const char *virStoragePoolGetName (virStoragePoolPtr pool) __attribute__((weak));
1683 #endif
1684 #endif
1685
1686 CAMLprim value
1687 ocaml_libvirt_storage_pool_get_name (value poolv)
1688 {
1689   CAMLparam1 (poolv);
1690 #ifndef HAVE_VIRSTORAGEPOOLGETNAME
1691   /* Symbol virStoragePoolGetName not found at compile time. */
1692   not_supported ("virStoragePoolGetName");
1693   CAMLnoreturn;
1694 #else
1695   /* Check that the symbol virStoragePoolGetName
1696    * is in runtime version of libvirt.
1697    */
1698   WEAK_SYMBOL_CHECK (virStoragePoolGetName);
1699
1700   CAMLlocal1 (rv);
1701   virStoragePoolPtr pool = Pool_val (poolv);
1702   virConnectPtr conn = Connect_polv (poolv);
1703   const char *r;
1704
1705   NONBLOCKING (r = virStoragePoolGetName (pool));
1706   CHECK_ERROR (!r, conn, "virStoragePoolGetName");
1707
1708   rv = caml_copy_string (r);
1709   CAMLreturn (rv);
1710 #endif
1711 }
1712
1713 /* Automatically generated binding for virStoragePoolGetXMLDesc.
1714  * In generator.pl this function has signature "pool, 0U : string".
1715  */
1716
1717 #ifdef HAVE_WEAK_SYMBOLS
1718 #ifdef HAVE_VIRSTORAGEPOOLGETXMLDESC
1719 extern char *virStoragePoolGetXMLDesc (virStoragePoolPtr pool, unsigned  int flags) __attribute__((weak));
1720 #endif
1721 #endif
1722
1723 CAMLprim value
1724 ocaml_libvirt_storage_pool_get_xml_desc (value poolv)
1725 {
1726   CAMLparam1 (poolv);
1727 #ifndef HAVE_VIRSTORAGEPOOLGETXMLDESC
1728   /* Symbol virStoragePoolGetXMLDesc not found at compile time. */
1729   not_supported ("virStoragePoolGetXMLDesc");
1730   CAMLnoreturn;
1731 #else
1732   /* Check that the symbol virStoragePoolGetXMLDesc
1733    * is in runtime version of libvirt.
1734    */
1735   WEAK_SYMBOL_CHECK (virStoragePoolGetXMLDesc);
1736
1737   CAMLlocal1 (rv);
1738   virStoragePoolPtr pool = Pool_val (poolv);
1739   virConnectPtr conn = Connect_polv (poolv);
1740   char *r;
1741
1742   NONBLOCKING (r = virStoragePoolGetXMLDesc (pool, 0));
1743   CHECK_ERROR (!r, conn, "virStoragePoolGetXMLDesc");
1744
1745   rv = caml_copy_string (r);
1746   free (r);
1747   CAMLreturn (rv);
1748 #endif
1749 }
1750
1751 /* Automatically generated binding for virStoragePoolGetUUID.
1752  * In generator.pl this function has signature "pool : uuid".
1753  */
1754
1755 #ifdef HAVE_WEAK_SYMBOLS
1756 #ifdef HAVE_VIRSTORAGEPOOLGETUUID
1757 extern int virStoragePoolGetUUID (virStoragePoolPtr pool, unsigned char *) __attribute__((weak));
1758 #endif
1759 #endif
1760
1761 CAMLprim value
1762 ocaml_libvirt_storage_pool_get_uuid (value poolv)
1763 {
1764   CAMLparam1 (poolv);
1765 #ifndef HAVE_VIRSTORAGEPOOLGETUUID
1766   /* Symbol virStoragePoolGetUUID not found at compile time. */
1767   not_supported ("virStoragePoolGetUUID");
1768   CAMLnoreturn;
1769 #else
1770   /* Check that the symbol virStoragePoolGetUUID
1771    * is in runtime version of libvirt.
1772    */
1773   WEAK_SYMBOL_CHECK (virStoragePoolGetUUID);
1774
1775   CAMLlocal1 (rv);
1776   virStoragePoolPtr pool = Pool_val (poolv);
1777   virConnectPtr conn = Connect_polv (poolv);
1778   unsigned char uuid[VIR_UUID_BUFLEN];
1779   int r;
1780
1781   NONBLOCKING (r = virStoragePoolGetUUID (pool, uuid));
1782   CHECK_ERROR (r == -1, conn, "virStoragePoolGetUUID");
1783
1784   /* UUIDs are byte arrays with a fixed length. */
1785   rv = caml_alloc_string (VIR_UUID_BUFLEN);
1786   memcpy (String_val (rv), uuid, VIR_UUID_BUFLEN);
1787   CAMLreturn (rv);
1788 #endif
1789 }
1790
1791 /* Automatically generated binding for virStoragePoolGetUUIDString.
1792  * In generator.pl this function has signature "pool : uuid string".
1793  */
1794
1795 #ifdef HAVE_WEAK_SYMBOLS
1796 #ifdef HAVE_VIRSTORAGEPOOLGETUUIDSTRING
1797 extern int virStoragePoolGetUUIDString (virStoragePoolPtr pool, char *) __attribute__((weak));
1798 #endif
1799 #endif
1800
1801 CAMLprim value
1802 ocaml_libvirt_storage_pool_get_uuid_string (value poolv)
1803 {
1804   CAMLparam1 (poolv);
1805 #ifndef HAVE_VIRSTORAGEPOOLGETUUIDSTRING
1806   /* Symbol virStoragePoolGetUUIDString not found at compile time. */
1807   not_supported ("virStoragePoolGetUUIDString");
1808   CAMLnoreturn;
1809 #else
1810   /* Check that the symbol virStoragePoolGetUUIDString
1811    * is in runtime version of libvirt.
1812    */
1813   WEAK_SYMBOL_CHECK (virStoragePoolGetUUIDString);
1814
1815   CAMLlocal1 (rv);
1816   virStoragePoolPtr pool = Pool_val (poolv);
1817   virConnectPtr conn = Connect_polv (poolv);
1818   char uuid[VIR_UUID_STRING_BUFLEN];
1819   int r;
1820
1821   NONBLOCKING (r = virStoragePoolGetUUIDString (pool, uuid));
1822   CHECK_ERROR (r == -1, conn, "virStoragePoolGetUUIDString");
1823
1824   rv = caml_copy_string (uuid);
1825   CAMLreturn (rv);
1826 #endif
1827 }
1828
1829 /* Automatically generated binding for virStoragePoolCreateXML.
1830  * In generator.pl this function has signature "conn, string, 0U : pool".
1831  */
1832
1833 #ifdef HAVE_WEAK_SYMBOLS
1834 #ifdef HAVE_VIRSTORAGEPOOLCREATEXML
1835 extern virStoragePoolPtr virStoragePoolCreateXML (virConnectPtr conn, const char *str, unsigned int flags) __attribute__((weak));
1836 #endif
1837 #endif
1838
1839 CAMLprim value
1840 ocaml_libvirt_storage_pool_create_xml (value connv, value strv)
1841 {
1842   CAMLparam2 (connv, strv);
1843 #ifndef HAVE_VIRSTORAGEPOOLCREATEXML
1844   /* Symbol virStoragePoolCreateXML not found at compile time. */
1845   not_supported ("virStoragePoolCreateXML");
1846   CAMLnoreturn;
1847 #else
1848   /* Check that the symbol virStoragePoolCreateXML
1849    * is in runtime version of libvirt.
1850    */
1851   WEAK_SYMBOL_CHECK (virStoragePoolCreateXML);
1852
1853   CAMLlocal1 (rv);
1854   virConnectPtr conn = Connect_val (connv);
1855   char *str = String_val (strv);
1856   virStoragePoolPtr r;
1857
1858   NONBLOCKING (r = virStoragePoolCreateXML (conn, str, 0));
1859   CHECK_ERROR (!r, conn, "virStoragePoolCreateXML");
1860
1861   rv = Val_pool (r, connv);
1862
1863   CAMLreturn (rv);
1864 #endif
1865 }
1866
1867 /* Automatically generated binding for virStoragePoolDefineXML.
1868  * In generator.pl this function has signature "conn, string, 0U : pool".
1869  */
1870
1871 #ifdef HAVE_WEAK_SYMBOLS
1872 #ifdef HAVE_VIRSTORAGEPOOLDEFINEXML
1873 extern virStoragePoolPtr virStoragePoolDefineXML (virConnectPtr conn, const char *str, unsigned int flags) __attribute__((weak));
1874 #endif
1875 #endif
1876
1877 CAMLprim value
1878 ocaml_libvirt_storage_pool_define_xml (value connv, value strv)
1879 {
1880   CAMLparam2 (connv, strv);
1881 #ifndef HAVE_VIRSTORAGEPOOLDEFINEXML
1882   /* Symbol virStoragePoolDefineXML not found at compile time. */
1883   not_supported ("virStoragePoolDefineXML");
1884   CAMLnoreturn;
1885 #else
1886   /* Check that the symbol virStoragePoolDefineXML
1887    * is in runtime version of libvirt.
1888    */
1889   WEAK_SYMBOL_CHECK (virStoragePoolDefineXML);
1890
1891   CAMLlocal1 (rv);
1892   virConnectPtr conn = Connect_val (connv);
1893   char *str = String_val (strv);
1894   virStoragePoolPtr r;
1895
1896   NONBLOCKING (r = virStoragePoolDefineXML (conn, str, 0));
1897   CHECK_ERROR (!r, conn, "virStoragePoolDefineXML");
1898
1899   rv = Val_pool (r, connv);
1900
1901   CAMLreturn (rv);
1902 #endif
1903 }
1904
1905 /* Automatically generated binding for virStoragePoolBuild.
1906  * In generator.pl this function has signature "pool, uint : unit".
1907  */
1908
1909 #ifdef HAVE_WEAK_SYMBOLS
1910 #ifdef HAVE_VIRSTORAGEPOOLBUILD
1911 extern int virStoragePoolBuild (virStoragePoolPtr pool, unsigned int i) __attribute__((weak));
1912 #endif
1913 #endif
1914
1915 CAMLprim value
1916 ocaml_libvirt_storage_pool_build (value poolv, value iv)
1917 {
1918   CAMLparam2 (poolv, iv);
1919 #ifndef HAVE_VIRSTORAGEPOOLBUILD
1920   /* Symbol virStoragePoolBuild not found at compile time. */
1921   not_supported ("virStoragePoolBuild");
1922   CAMLnoreturn;
1923 #else
1924   /* Check that the symbol virStoragePoolBuild
1925    * is in runtime version of libvirt.
1926    */
1927   WEAK_SYMBOL_CHECK (virStoragePoolBuild);
1928
1929   virStoragePoolPtr pool = Pool_val (poolv);
1930   virConnectPtr conn = Connect_polv (poolv);
1931   unsigned int i = Int_val (iv);
1932   int r;
1933
1934   NONBLOCKING (r = virStoragePoolBuild (pool, i));
1935   CHECK_ERROR (!r, conn, "virStoragePoolBuild");
1936
1937   CAMLreturn (Val_unit);
1938 #endif
1939 }
1940
1941 /* Automatically generated binding for virStoragePoolUndefine.
1942  * In generator.pl this function has signature "pool : unit".
1943  */
1944
1945 #ifdef HAVE_WEAK_SYMBOLS
1946 #ifdef HAVE_VIRSTORAGEPOOLUNDEFINE
1947 extern int virStoragePoolUndefine (virStoragePoolPtr pool) __attribute__((weak));
1948 #endif
1949 #endif
1950
1951 CAMLprim value
1952 ocaml_libvirt_storage_pool_undefine (value poolv)
1953 {
1954   CAMLparam1 (poolv);
1955 #ifndef HAVE_VIRSTORAGEPOOLUNDEFINE
1956   /* Symbol virStoragePoolUndefine not found at compile time. */
1957   not_supported ("virStoragePoolUndefine");
1958   CAMLnoreturn;
1959 #else
1960   /* Check that the symbol virStoragePoolUndefine
1961    * is in runtime version of libvirt.
1962    */
1963   WEAK_SYMBOL_CHECK (virStoragePoolUndefine);
1964
1965   virStoragePoolPtr pool = Pool_val (poolv);
1966   virConnectPtr conn = Connect_polv (poolv);
1967   int r;
1968
1969   NONBLOCKING (r = virStoragePoolUndefine (pool));
1970   CHECK_ERROR (r == -1, conn, "virStoragePoolUndefine");
1971
1972   CAMLreturn (Val_unit);
1973 #endif
1974 }
1975
1976 /* Automatically generated binding for virStoragePoolCreate.
1977  * In generator.pl this function has signature "pool, 0U : unit".
1978  */
1979
1980 #ifdef HAVE_WEAK_SYMBOLS
1981 #ifdef HAVE_VIRSTORAGEPOOLCREATE
1982 extern int virStoragePoolCreate (virStoragePoolPtr pool, unsigned  int flags) __attribute__((weak));
1983 #endif
1984 #endif
1985
1986 CAMLprim value
1987 ocaml_libvirt_storage_pool_create (value poolv)
1988 {
1989   CAMLparam1 (poolv);
1990 #ifndef HAVE_VIRSTORAGEPOOLCREATE
1991   /* Symbol virStoragePoolCreate not found at compile time. */
1992   not_supported ("virStoragePoolCreate");
1993   CAMLnoreturn;
1994 #else
1995   /* Check that the symbol virStoragePoolCreate
1996    * is in runtime version of libvirt.
1997    */
1998   WEAK_SYMBOL_CHECK (virStoragePoolCreate);
1999
2000   virStoragePoolPtr pool = Pool_val (poolv);
2001   virConnectPtr conn = Connect_polv (poolv);
2002   int r;
2003
2004   NONBLOCKING (r = virStoragePoolCreate (pool, 0));
2005   CHECK_ERROR (r == -1, conn, "virStoragePoolCreate");
2006
2007   CAMLreturn (Val_unit);
2008 #endif
2009 }
2010
2011 /* Automatically generated binding for virStoragePoolDelete.
2012  * In generator.pl this function has signature "pool, uint : unit".
2013  */
2014
2015 #ifdef HAVE_WEAK_SYMBOLS
2016 #ifdef HAVE_VIRSTORAGEPOOLDELETE
2017 extern int virStoragePoolDelete (virStoragePoolPtr pool, unsigned int i) __attribute__((weak));
2018 #endif
2019 #endif
2020
2021 CAMLprim value
2022 ocaml_libvirt_storage_pool_delete (value poolv, value iv)
2023 {
2024   CAMLparam2 (poolv, iv);
2025 #ifndef HAVE_VIRSTORAGEPOOLDELETE
2026   /* Symbol virStoragePoolDelete not found at compile time. */
2027   not_supported ("virStoragePoolDelete");
2028   CAMLnoreturn;
2029 #else
2030   /* Check that the symbol virStoragePoolDelete
2031    * is in runtime version of libvirt.
2032    */
2033   WEAK_SYMBOL_CHECK (virStoragePoolDelete);
2034
2035   virStoragePoolPtr pool = Pool_val (poolv);
2036   virConnectPtr conn = Connect_polv (poolv);
2037   unsigned int i = Int_val (iv);
2038   int r;
2039
2040   NONBLOCKING (r = virStoragePoolDelete (pool, i));
2041   CHECK_ERROR (!r, conn, "virStoragePoolDelete");
2042
2043   CAMLreturn (Val_unit);
2044 #endif
2045 }
2046
2047 /* Automatically generated binding for virStoragePoolRefresh.
2048  * In generator.pl this function has signature "pool, 0U : unit".
2049  */
2050
2051 #ifdef HAVE_WEAK_SYMBOLS
2052 #ifdef HAVE_VIRSTORAGEPOOLREFRESH
2053 extern int virStoragePoolRefresh (virStoragePoolPtr pool, unsigned  int flags) __attribute__((weak));
2054 #endif
2055 #endif
2056
2057 CAMLprim value
2058 ocaml_libvirt_storage_pool_refresh (value poolv)
2059 {
2060   CAMLparam1 (poolv);
2061 #ifndef HAVE_VIRSTORAGEPOOLREFRESH
2062   /* Symbol virStoragePoolRefresh not found at compile time. */
2063   not_supported ("virStoragePoolRefresh");
2064   CAMLnoreturn;
2065 #else
2066   /* Check that the symbol virStoragePoolRefresh
2067    * is in runtime version of libvirt.
2068    */
2069   WEAK_SYMBOL_CHECK (virStoragePoolRefresh);
2070
2071   virStoragePoolPtr pool = Pool_val (poolv);
2072   virConnectPtr conn = Connect_polv (poolv);
2073   int r;
2074
2075   NONBLOCKING (r = virStoragePoolRefresh (pool, 0));
2076   CHECK_ERROR (r == -1, conn, "virStoragePoolRefresh");
2077
2078   CAMLreturn (Val_unit);
2079 #endif
2080 }
2081
2082 /* Automatically generated binding for virStoragePoolGetAutostart.
2083  * In generator.pl this function has signature "pool : bool".
2084  */
2085
2086 #ifdef HAVE_WEAK_SYMBOLS
2087 #ifdef HAVE_VIRSTORAGEPOOLGETAUTOSTART
2088 extern int virStoragePoolGetAutostart (virStoragePoolPtr pool, int *r) __attribute__((weak));
2089 #endif
2090 #endif
2091
2092 CAMLprim value
2093 ocaml_libvirt_storage_pool_get_autostart (value poolv)
2094 {
2095   CAMLparam1 (poolv);
2096 #ifndef HAVE_VIRSTORAGEPOOLGETAUTOSTART
2097   /* Symbol virStoragePoolGetAutostart not found at compile time. */
2098   not_supported ("virStoragePoolGetAutostart");
2099   CAMLnoreturn;
2100 #else
2101   /* Check that the symbol virStoragePoolGetAutostart
2102    * is in runtime version of libvirt.
2103    */
2104   WEAK_SYMBOL_CHECK (virStoragePoolGetAutostart);
2105
2106   virStoragePoolPtr pool = Pool_val (poolv);
2107   virConnectPtr conn = Connect_polv (poolv);
2108   int r, b;
2109
2110   NONBLOCKING (r = virStoragePoolGetAutostart (pool, &b));
2111   CHECK_ERROR (r == -1, conn, "virStoragePoolGetAutostart");
2112
2113   CAMLreturn (b ? Val_true : Val_false);
2114 #endif
2115 }
2116
2117 /* Automatically generated binding for virStoragePoolSetAutostart.
2118  * In generator.pl this function has signature "pool, bool : unit".
2119  */
2120
2121 #ifdef HAVE_WEAK_SYMBOLS
2122 #ifdef HAVE_VIRSTORAGEPOOLSETAUTOSTART
2123 extern int virStoragePoolSetAutostart (virStoragePoolPtr pool, int b) __attribute__((weak));
2124 #endif
2125 #endif
2126
2127 CAMLprim value
2128 ocaml_libvirt_storage_pool_set_autostart (value poolv, value bv)
2129 {
2130   CAMLparam2 (poolv, bv);
2131 #ifndef HAVE_VIRSTORAGEPOOLSETAUTOSTART
2132   /* Symbol virStoragePoolSetAutostart not found at compile time. */
2133   not_supported ("virStoragePoolSetAutostart");
2134   CAMLnoreturn;
2135 #else
2136   /* Check that the symbol virStoragePoolSetAutostart
2137    * is in runtime version of libvirt.
2138    */
2139   WEAK_SYMBOL_CHECK (virStoragePoolSetAutostart);
2140
2141   virStoragePoolPtr pool = Pool_val (poolv);
2142   virConnectPtr conn = Connect_polv (poolv);
2143   int r, b;
2144
2145   b = bv == Val_true ? 1 : 0;
2146
2147   NONBLOCKING (r = virStoragePoolSetAutostart (pool, b));
2148   CHECK_ERROR (r == -1, conn, "virStoragePoolSetAutostart");
2149
2150   CAMLreturn (Val_unit);
2151 #endif
2152 }
2153
2154 /* Automatically generated binding for virStoragePoolNumOfVolumes.
2155  * In generator.pl this function has signature "pool : int".
2156  */
2157
2158 #ifdef HAVE_WEAK_SYMBOLS
2159 #ifdef HAVE_VIRSTORAGEPOOLNUMOFVOLUMES
2160 extern int virStoragePoolNumOfVolumes (virStoragePoolPtr pool) __attribute__((weak));
2161 #endif
2162 #endif
2163
2164 CAMLprim value
2165 ocaml_libvirt_storage_pool_num_of_volumes (value poolv)
2166 {
2167   CAMLparam1 (poolv);
2168 #ifndef HAVE_VIRSTORAGEPOOLNUMOFVOLUMES
2169   /* Symbol virStoragePoolNumOfVolumes not found at compile time. */
2170   not_supported ("virStoragePoolNumOfVolumes");
2171   CAMLnoreturn;
2172 #else
2173   /* Check that the symbol virStoragePoolNumOfVolumes
2174    * is in runtime version of libvirt.
2175    */
2176   WEAK_SYMBOL_CHECK (virStoragePoolNumOfVolumes);
2177
2178   virStoragePoolPtr pool = Pool_val (poolv);
2179   virConnectPtr conn = Connect_polv (poolv);
2180   int r;
2181
2182   NONBLOCKING (r = virStoragePoolNumOfVolumes (pool));
2183   CHECK_ERROR (r == -1, conn, "virStoragePoolNumOfVolumes");
2184
2185   CAMLreturn (Val_int (r));
2186 #endif
2187 }
2188
2189 /* Automatically generated binding for virStoragePoolListVolumes.
2190  * In generator.pl this function has signature "pool, int : string array".
2191  */
2192
2193 #ifdef HAVE_WEAK_SYMBOLS
2194 #ifdef HAVE_VIRSTORAGEPOOLLISTVOLUMES
2195 extern int virStoragePoolListVolumes (virStoragePoolPtr pool, char **const names, int maxnames) __attribute__((weak));
2196 #endif
2197 #endif
2198
2199 CAMLprim value
2200 ocaml_libvirt_storage_pool_list_volumes (value poolv, value iv)
2201 {
2202   CAMLparam2 (poolv, iv);
2203 #ifndef HAVE_VIRSTORAGEPOOLLISTVOLUMES
2204   /* Symbol virStoragePoolListVolumes not found at compile time. */
2205   not_supported ("virStoragePoolListVolumes");
2206   CAMLnoreturn;
2207 #else
2208   /* Check that the symbol virStoragePoolListVolumes
2209    * is in runtime version of libvirt.
2210    */
2211   WEAK_SYMBOL_CHECK (virStoragePoolListVolumes);
2212
2213   CAMLlocal2 (rv, strv);
2214   virStoragePoolPtr pool = Pool_val (poolv);
2215   virConnectPtr conn = Connect_polv (poolv);
2216   int i = Int_val (iv);
2217   char *names[i];
2218   int r;
2219
2220   /* Some libvirt List* functions still throw exceptions if i == 0,
2221    * so catch that and return an empty array directly.  This changes
2222    * the semantics slightly (masking other failures) but it's
2223    * unlikely anyone will care.  RWMJ 2008/06/10
2224    */
2225   if (i == 0) {
2226     rv = caml_alloc (0, 0);
2227     CAMLreturn (rv);
2228   }
2229
2230   NONBLOCKING (r = virStoragePoolListVolumes (pool, names, i));
2231   CHECK_ERROR (r == -1, conn, "virStoragePoolListVolumes");
2232
2233   rv = caml_alloc (r, 0);
2234   for (i = 0; i < r; ++i) {
2235     strv = caml_copy_string (names[i]);
2236     Store_field (rv, i, strv);
2237     free (names[i]);
2238   }
2239
2240   CAMLreturn (rv);
2241 #endif
2242 }
2243
2244 /* Automatically generated binding for virStorageVolFree.
2245  * In generator.pl this function has signature "vol : free".
2246  */
2247
2248 #ifdef HAVE_WEAK_SYMBOLS
2249 #ifdef HAVE_VIRSTORAGEVOLFREE
2250 extern int virStorageVolFree (virStorageVolPtr vol) __attribute__((weak));
2251 #endif
2252 #endif
2253
2254 CAMLprim value
2255 ocaml_libvirt_storage_vol_free (value volv)
2256 {
2257   CAMLparam1 (volv);
2258 #ifndef HAVE_VIRSTORAGEVOLFREE
2259   /* Symbol virStorageVolFree not found at compile time. */
2260   not_supported ("virStorageVolFree");
2261   CAMLnoreturn;
2262 #else
2263   /* Check that the symbol virStorageVolFree
2264    * is in runtime version of libvirt.
2265    */
2266   WEAK_SYMBOL_CHECK (virStorageVolFree);
2267
2268   virStorageVolPtr vol = Volume_val (volv);
2269   virConnectPtr conn = Connect_volv (volv);
2270   int r;
2271
2272   NONBLOCKING (r = virStorageVolFree (vol));
2273   CHECK_ERROR (r == -1, conn, "virStorageVolFree");
2274
2275   /* So that we don't double-free in the finalizer: */
2276   Volume_val (volv) = NULL;
2277
2278   CAMLreturn (Val_unit);
2279 #endif
2280 }
2281
2282 /* Automatically generated binding for virStorageVolDelete.
2283  * In generator.pl this function has signature "vol, uint : unit".
2284  */
2285
2286 #ifdef HAVE_WEAK_SYMBOLS
2287 #ifdef HAVE_VIRSTORAGEVOLDELETE
2288 extern int virStorageVolDelete (virStorageVolPtr vol, unsigned int i) __attribute__((weak));
2289 #endif
2290 #endif
2291
2292 CAMLprim value
2293 ocaml_libvirt_storage_vol_delete (value volv, value iv)
2294 {
2295   CAMLparam2 (volv, iv);
2296 #ifndef HAVE_VIRSTORAGEVOLDELETE
2297   /* Symbol virStorageVolDelete not found at compile time. */
2298   not_supported ("virStorageVolDelete");
2299   CAMLnoreturn;
2300 #else
2301   /* Check that the symbol virStorageVolDelete
2302    * is in runtime version of libvirt.
2303    */
2304   WEAK_SYMBOL_CHECK (virStorageVolDelete);
2305
2306   virStorageVolPtr vol = Volume_val (volv);
2307   virConnectPtr conn = Connect_volv (volv);
2308   unsigned int i = Int_val (iv);
2309   int r;
2310
2311   NONBLOCKING (r = virStorageVolDelete (vol, i));
2312   CHECK_ERROR (!r, conn, "virStorageVolDelete");
2313
2314   CAMLreturn (Val_unit);
2315 #endif
2316 }
2317
2318 /* Automatically generated binding for virStorageVolLookupByName.
2319  * In generator.pl this function has signature "pool, string : vol from pool".
2320  */
2321
2322 #ifdef HAVE_WEAK_SYMBOLS
2323 #ifdef HAVE_VIRSTORAGEVOLLOOKUPBYNAME
2324 extern virStorageVolPtr virStorageVolLookupByName (virStoragePoolPtr pool, const char *str) __attribute__((weak));
2325 #endif
2326 #endif
2327
2328 CAMLprim value
2329 ocaml_libvirt_storage_vol_lookup_by_name (value poolv, value strv)
2330 {
2331   CAMLparam2 (poolv, strv);
2332 #ifndef HAVE_VIRSTORAGEVOLLOOKUPBYNAME
2333   /* Symbol virStorageVolLookupByName not found at compile time. */
2334   not_supported ("virStorageVolLookupByName");
2335   CAMLnoreturn;
2336 #else
2337   /* Check that the symbol virStorageVolLookupByName
2338    * is in runtime version of libvirt.
2339    */
2340   WEAK_SYMBOL_CHECK (virStorageVolLookupByName);
2341
2342   CAMLlocal2 (rv, connv);
2343   virStoragePoolPtr pool = Pool_val (poolv);
2344   virConnectPtr conn = Connect_polv (poolv);
2345   char *str = String_val (strv);
2346   virStorageVolPtr r;
2347
2348   NONBLOCKING (r = virStorageVolLookupByName (pool, str));
2349   CHECK_ERROR (!r, conn, "virStorageVolLookupByName");
2350
2351   connv = Field (poolv, 1);
2352   rv = Val_volume (r, connv);
2353
2354   CAMLreturn (rv);
2355 #endif
2356 }
2357
2358 /* Automatically generated binding for virStorageVolLookupByKey.
2359  * In generator.pl this function has signature "conn, string : vol".
2360  */
2361
2362 #ifdef HAVE_WEAK_SYMBOLS
2363 #ifdef HAVE_VIRSTORAGEVOLLOOKUPBYKEY
2364 extern virStorageVolPtr virStorageVolLookupByKey (virConnectPtr conn, const char *str) __attribute__((weak));
2365 #endif
2366 #endif
2367
2368 CAMLprim value
2369 ocaml_libvirt_storage_vol_lookup_by_key (value connv, value strv)
2370 {
2371   CAMLparam2 (connv, strv);
2372 #ifndef HAVE_VIRSTORAGEVOLLOOKUPBYKEY
2373   /* Symbol virStorageVolLookupByKey not found at compile time. */
2374   not_supported ("virStorageVolLookupByKey");
2375   CAMLnoreturn;
2376 #else
2377   /* Check that the symbol virStorageVolLookupByKey
2378    * is in runtime version of libvirt.
2379    */
2380   WEAK_SYMBOL_CHECK (virStorageVolLookupByKey);
2381
2382   CAMLlocal1 (rv);
2383   virConnectPtr conn = Connect_val (connv);
2384   char *str = String_val (strv);
2385   virStorageVolPtr r;
2386
2387   NONBLOCKING (r = virStorageVolLookupByKey (conn, str));
2388   CHECK_ERROR (!r, conn, "virStorageVolLookupByKey");
2389
2390   rv = Val_volume (r, connv);
2391
2392   CAMLreturn (rv);
2393 #endif
2394 }
2395
2396 /* Automatically generated binding for virStorageVolLookupByPath.
2397  * In generator.pl this function has signature "conn, string : vol".
2398  */
2399
2400 #ifdef HAVE_WEAK_SYMBOLS
2401 #ifdef HAVE_VIRSTORAGEVOLLOOKUPBYPATH
2402 extern virStorageVolPtr virStorageVolLookupByPath (virConnectPtr conn, const char *str) __attribute__((weak));
2403 #endif
2404 #endif
2405
2406 CAMLprim value
2407 ocaml_libvirt_storage_vol_lookup_by_path (value connv, value strv)
2408 {
2409   CAMLparam2 (connv, strv);
2410 #ifndef HAVE_VIRSTORAGEVOLLOOKUPBYPATH
2411   /* Symbol virStorageVolLookupByPath not found at compile time. */
2412   not_supported ("virStorageVolLookupByPath");
2413   CAMLnoreturn;
2414 #else
2415   /* Check that the symbol virStorageVolLookupByPath
2416    * is in runtime version of libvirt.
2417    */
2418   WEAK_SYMBOL_CHECK (virStorageVolLookupByPath);
2419
2420   CAMLlocal1 (rv);
2421   virConnectPtr conn = Connect_val (connv);
2422   char *str = String_val (strv);
2423   virStorageVolPtr r;
2424
2425   NONBLOCKING (r = virStorageVolLookupByPath (conn, str));
2426   CHECK_ERROR (!r, conn, "virStorageVolLookupByPath");
2427
2428   rv = Val_volume (r, connv);
2429
2430   CAMLreturn (rv);
2431 #endif
2432 }
2433
2434 /* Automatically generated binding for virStorageVolCreateXML.
2435  * In generator.pl this function has signature "pool, string, 0U : vol from pool".
2436  */
2437
2438 #ifdef HAVE_WEAK_SYMBOLS
2439 #ifdef HAVE_VIRSTORAGEVOLCREATEXML
2440 extern virStorageVolPtr virStorageVolCreateXML (virStoragePoolPtr pool, const char *str, unsigned  int flags) __attribute__((weak));
2441 #endif
2442 #endif
2443
2444 CAMLprim value
2445 ocaml_libvirt_storage_vol_create_xml (value poolv, value strv)
2446 {
2447   CAMLparam2 (poolv, strv);
2448 #ifndef HAVE_VIRSTORAGEVOLCREATEXML
2449   /* Symbol virStorageVolCreateXML not found at compile time. */
2450   not_supported ("virStorageVolCreateXML");
2451   CAMLnoreturn;
2452 #else
2453   /* Check that the symbol virStorageVolCreateXML
2454    * is in runtime version of libvirt.
2455    */
2456   WEAK_SYMBOL_CHECK (virStorageVolCreateXML);
2457
2458   CAMLlocal2 (rv, connv);
2459   virStoragePoolPtr pool = Pool_val (poolv);
2460   virConnectPtr conn = Connect_polv (poolv);
2461   char *str = String_val (strv);
2462   virStorageVolPtr r;
2463
2464   NONBLOCKING (r = virStorageVolCreateXML (pool, str, 0));
2465   CHECK_ERROR (!r, conn, "virStorageVolCreateXML");
2466
2467   connv = Field (poolv, 1);
2468   rv = Val_volume (r, connv);
2469
2470   CAMLreturn (rv);
2471 #endif
2472 }
2473
2474 /* Automatically generated binding for virStorageVolGetXMLDesc.
2475  * In generator.pl this function has signature "vol, 0U : string".
2476  */
2477
2478 #ifdef HAVE_WEAK_SYMBOLS
2479 #ifdef HAVE_VIRSTORAGEVOLGETXMLDESC
2480 extern char *virStorageVolGetXMLDesc (virStorageVolPtr vol, unsigned  int flags) __attribute__((weak));
2481 #endif
2482 #endif
2483
2484 CAMLprim value
2485 ocaml_libvirt_storage_vol_get_xml_desc (value volv)
2486 {
2487   CAMLparam1 (volv);
2488 #ifndef HAVE_VIRSTORAGEVOLGETXMLDESC
2489   /* Symbol virStorageVolGetXMLDesc not found at compile time. */
2490   not_supported ("virStorageVolGetXMLDesc");
2491   CAMLnoreturn;
2492 #else
2493   /* Check that the symbol virStorageVolGetXMLDesc
2494    * is in runtime version of libvirt.
2495    */
2496   WEAK_SYMBOL_CHECK (virStorageVolGetXMLDesc);
2497
2498   CAMLlocal1 (rv);
2499   virStorageVolPtr vol = Volume_val (volv);
2500   virConnectPtr conn = Connect_volv (volv);
2501   char *r;
2502
2503   NONBLOCKING (r = virStorageVolGetXMLDesc (vol, 0));
2504   CHECK_ERROR (!r, conn, "virStorageVolGetXMLDesc");
2505
2506   rv = caml_copy_string (r);
2507   free (r);
2508   CAMLreturn (rv);
2509 #endif
2510 }
2511
2512 /* Automatically generated binding for virStorageVolGetPath.
2513  * In generator.pl this function has signature "vol : string".
2514  */
2515
2516 #ifdef HAVE_WEAK_SYMBOLS
2517 #ifdef HAVE_VIRSTORAGEVOLGETPATH
2518 extern char *virStorageVolGetPath (virStorageVolPtr vol) __attribute__((weak));
2519 #endif
2520 #endif
2521
2522 CAMLprim value
2523 ocaml_libvirt_storage_vol_get_path (value volv)
2524 {
2525   CAMLparam1 (volv);
2526 #ifndef HAVE_VIRSTORAGEVOLGETPATH
2527   /* Symbol virStorageVolGetPath not found at compile time. */
2528   not_supported ("virStorageVolGetPath");
2529   CAMLnoreturn;
2530 #else
2531   /* Check that the symbol virStorageVolGetPath
2532    * is in runtime version of libvirt.
2533    */
2534   WEAK_SYMBOL_CHECK (virStorageVolGetPath);
2535
2536   CAMLlocal1 (rv);
2537   virStorageVolPtr vol = Volume_val (volv);
2538   virConnectPtr conn = Connect_volv (volv);
2539   char *r;
2540
2541   NONBLOCKING (r = virStorageVolGetPath (vol));
2542   CHECK_ERROR (!r, conn, "virStorageVolGetPath");
2543
2544   rv = caml_copy_string (r);
2545   free (r);
2546   CAMLreturn (rv);
2547 #endif
2548 }
2549
2550 /* Automatically generated binding for virStorageVolGetKey.
2551  * In generator.pl this function has signature "vol : static string".
2552  */
2553
2554 #ifdef HAVE_WEAK_SYMBOLS
2555 #ifdef HAVE_VIRSTORAGEVOLGETKEY
2556 extern const char *virStorageVolGetKey (virStorageVolPtr vol) __attribute__((weak));
2557 #endif
2558 #endif
2559
2560 CAMLprim value
2561 ocaml_libvirt_storage_vol_get_key (value volv)
2562 {
2563   CAMLparam1 (volv);
2564 #ifndef HAVE_VIRSTORAGEVOLGETKEY
2565   /* Symbol virStorageVolGetKey not found at compile time. */
2566   not_supported ("virStorageVolGetKey");
2567   CAMLnoreturn;
2568 #else
2569   /* Check that the symbol virStorageVolGetKey
2570    * is in runtime version of libvirt.
2571    */
2572   WEAK_SYMBOL_CHECK (virStorageVolGetKey);
2573
2574   CAMLlocal1 (rv);
2575   virStorageVolPtr vol = Volume_val (volv);
2576   virConnectPtr conn = Connect_volv (volv);
2577   const char *r;
2578
2579   NONBLOCKING (r = virStorageVolGetKey (vol));
2580   CHECK_ERROR (!r, conn, "virStorageVolGetKey");
2581
2582   rv = caml_copy_string (r);
2583   CAMLreturn (rv);
2584 #endif
2585 }
2586
2587 /* Automatically generated binding for virStorageVolGetName.
2588  * In generator.pl this function has signature "vol : static string".
2589  */
2590
2591 #ifdef HAVE_WEAK_SYMBOLS
2592 #ifdef HAVE_VIRSTORAGEVOLGETNAME
2593 extern const char *virStorageVolGetName (virStorageVolPtr vol) __attribute__((weak));
2594 #endif
2595 #endif
2596
2597 CAMLprim value
2598 ocaml_libvirt_storage_vol_get_name (value volv)
2599 {
2600   CAMLparam1 (volv);
2601 #ifndef HAVE_VIRSTORAGEVOLGETNAME
2602   /* Symbol virStorageVolGetName not found at compile time. */
2603   not_supported ("virStorageVolGetName");
2604   CAMLnoreturn;
2605 #else
2606   /* Check that the symbol virStorageVolGetName
2607    * is in runtime version of libvirt.
2608    */
2609   WEAK_SYMBOL_CHECK (virStorageVolGetName);
2610
2611   CAMLlocal1 (rv);
2612   virStorageVolPtr vol = Volume_val (volv);
2613   virConnectPtr conn = Connect_volv (volv);
2614   const char *r;
2615
2616   NONBLOCKING (r = virStorageVolGetName (vol));
2617   CHECK_ERROR (!r, conn, "virStorageVolGetName");
2618
2619   rv = caml_copy_string (r);
2620   CAMLreturn (rv);
2621 #endif
2622 }
2623
2624 /* Automatically generated binding for virStoragePoolLookupByVolume.
2625  * In generator.pl this function has signature "vol : pool from vol".
2626  */
2627
2628 #ifdef HAVE_WEAK_SYMBOLS
2629 #ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYVOLUME
2630 extern virStoragePoolPtr virStoragePoolLookupByVolume (virStorageVolPtr vol) __attribute__((weak));
2631 #endif
2632 #endif
2633
2634 CAMLprim value
2635 ocaml_libvirt_storage_pool_lookup_by_volume (value volv)
2636 {
2637   CAMLparam1 (volv);
2638 #ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYVOLUME
2639   /* Symbol virStoragePoolLookupByVolume not found at compile time. */
2640   not_supported ("virStoragePoolLookupByVolume");
2641   CAMLnoreturn;
2642 #else
2643   /* Check that the symbol virStoragePoolLookupByVolume
2644    * is in runtime version of libvirt.
2645    */
2646   WEAK_SYMBOL_CHECK (virStoragePoolLookupByVolume);
2647
2648   CAMLlocal2 (rv, connv);
2649   virStorageVolPtr vol = Volume_val (volv);
2650   virConnectPtr conn = Connect_volv (volv);
2651   virStoragePoolPtr r;
2652
2653   NONBLOCKING (r = virStoragePoolLookupByVolume (vol));
2654   CHECK_ERROR (!r, conn, "virStoragePoolLookupByVolume");
2655
2656   connv = Field (volv, 1);
2657   rv = Val_pool (r, connv);
2658
2659   CAMLreturn (rv);
2660 #endif
2661 }
2662
2663 #include "libvirt_c_epilogue.c"
2664
2665 /* EOF */