6be1d0da8d6e78049b3ce8d55fcbe0cca48b1e8e
[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 virDomainCreateLinuxJob.
606  * In generator.pl this function has signature "conn, string, 0U : job".
607  */
608
609 #ifdef HAVE_WEAK_SYMBOLS
610 #ifdef HAVE_VIRDOMAINCREATELINUXJOB
611 extern virJobPtr virDomainCreateLinuxJob (virConnectPtr conn, const char *str, unsigned int flags) __attribute__((weak));
612 #endif
613 #endif
614
615 CAMLprim value
616 ocaml_libvirt_domain_create_linux_job (value connv, value strv)
617 {
618   CAMLparam2 (connv, strv);
619 #ifndef HAVE_VIRDOMAINCREATELINUXJOB
620   /* Symbol virDomainCreateLinuxJob not found at compile time. */
621   not_supported ("virDomainCreateLinuxJob");
622   CAMLnoreturn;
623 #else
624   /* Check that the symbol virDomainCreateLinuxJob
625    * is in runtime version of libvirt.
626    */
627   WEAK_SYMBOL_CHECK (virDomainCreateLinuxJob);
628
629   CAMLlocal1 (rv);
630   virConnectPtr conn = Connect_val (connv);
631   char *str = String_val (strv);
632   virJobPtr r;
633
634   NONBLOCKING (r = virDomainCreateLinuxJob (conn, str, 0));
635   CHECK_ERROR (!r, conn, "virDomainCreateLinuxJob");
636
637   rv = Val_job (r, connv);
638
639   CAMLreturn (rv);
640 #endif
641 }
642
643 /* Automatically generated binding for virDomainFree.
644  * In generator.pl this function has signature "dom : free".
645  */
646
647 CAMLprim value
648 ocaml_libvirt_domain_free (value domv)
649 {
650   CAMLparam1 (domv);
651
652   virDomainPtr dom = Domain_val (domv);
653   virConnectPtr conn = Connect_domv (domv);
654   int r;
655
656   NONBLOCKING (r = virDomainFree (dom));
657   CHECK_ERROR (r == -1, conn, "virDomainFree");
658
659   /* So that we don't double-free in the finalizer: */
660   Domain_val (domv) = NULL;
661
662   CAMLreturn (Val_unit);
663 }
664
665 /* Automatically generated binding for virDomainDestroy.
666  * In generator.pl this function has signature "dom : free".
667  */
668
669 CAMLprim value
670 ocaml_libvirt_domain_destroy (value domv)
671 {
672   CAMLparam1 (domv);
673
674   virDomainPtr dom = Domain_val (domv);
675   virConnectPtr conn = Connect_domv (domv);
676   int r;
677
678   NONBLOCKING (r = virDomainDestroy (dom));
679   CHECK_ERROR (r == -1, conn, "virDomainDestroy");
680
681   /* So that we don't double-free in the finalizer: */
682   Domain_val (domv) = NULL;
683
684   CAMLreturn (Val_unit);
685 }
686
687 /* Automatically generated binding for virDomainLookupByName.
688  * In generator.pl this function has signature "conn, string : dom".
689  */
690
691 CAMLprim value
692 ocaml_libvirt_domain_lookup_by_name (value connv, value strv)
693 {
694   CAMLparam2 (connv, strv);
695
696   CAMLlocal1 (rv);
697   virConnectPtr conn = Connect_val (connv);
698   char *str = String_val (strv);
699   virDomainPtr r;
700
701   NONBLOCKING (r = virDomainLookupByName (conn, str));
702   CHECK_ERROR (!r, conn, "virDomainLookupByName");
703
704   rv = Val_domain (r, connv);
705
706   CAMLreturn (rv);
707 }
708
709 /* Automatically generated binding for virDomainLookupByID.
710  * In generator.pl this function has signature "conn, int : dom".
711  */
712
713 CAMLprim value
714 ocaml_libvirt_domain_lookup_by_id (value connv, value iv)
715 {
716   CAMLparam2 (connv, iv);
717
718   CAMLlocal1 (rv);
719   virConnectPtr conn = Connect_val (connv);
720   int i = Int_val (iv);
721   virDomainPtr r;
722
723   NONBLOCKING (r = virDomainLookupByID (conn, i));
724   CHECK_ERROR (!r, conn, "virDomainLookupByID");
725
726   rv = Val_domain (r, connv);
727
728   CAMLreturn (rv);
729 }
730
731 /* Automatically generated binding for virDomainLookupByUUID.
732  * In generator.pl this function has signature "conn, uuid : dom".
733  */
734
735 CAMLprim value
736 ocaml_libvirt_domain_lookup_by_uuid (value connv, value uuidv)
737 {
738   CAMLparam2 (connv, uuidv);
739
740   CAMLlocal1 (rv);
741   virConnectPtr conn = Connect_val (connv);
742   unsigned char *uuid = (unsigned char *) String_val (uuidv);
743   virDomainPtr r;
744
745   NONBLOCKING (r = virDomainLookupByUUID (conn, uuid));
746   CHECK_ERROR (!r, conn, "virDomainLookupByUUID");
747
748   rv = Val_domain (r, connv);
749
750   CAMLreturn (rv);
751 }
752
753 /* Automatically generated binding for virDomainLookupByUUIDString.
754  * In generator.pl this function has signature "conn, string : dom".
755  */
756
757 CAMLprim value
758 ocaml_libvirt_domain_lookup_by_uuid_string (value connv, value strv)
759 {
760   CAMLparam2 (connv, strv);
761
762   CAMLlocal1 (rv);
763   virConnectPtr conn = Connect_val (connv);
764   char *str = String_val (strv);
765   virDomainPtr r;
766
767   NONBLOCKING (r = virDomainLookupByUUIDString (conn, str));
768   CHECK_ERROR (!r, conn, "virDomainLookupByUUIDString");
769
770   rv = Val_domain (r, connv);
771
772   CAMLreturn (rv);
773 }
774
775 /* Automatically generated binding for virDomainGetName.
776  * In generator.pl this function has signature "dom : static string".
777  */
778
779 CAMLprim value
780 ocaml_libvirt_domain_get_name (value domv)
781 {
782   CAMLparam1 (domv);
783
784   CAMLlocal1 (rv);
785   virDomainPtr dom = Domain_val (domv);
786   virConnectPtr conn = Connect_domv (domv);
787   const char *r;
788
789   NONBLOCKING (r = virDomainGetName (dom));
790   CHECK_ERROR (!r, conn, "virDomainGetName");
791
792   rv = caml_copy_string (r);
793   CAMLreturn (rv);
794 }
795
796 /* Automatically generated binding for virDomainGetOSType.
797  * In generator.pl this function has signature "dom : string".
798  */
799
800 CAMLprim value
801 ocaml_libvirt_domain_get_os_type (value domv)
802 {
803   CAMLparam1 (domv);
804
805   CAMLlocal1 (rv);
806   virDomainPtr dom = Domain_val (domv);
807   virConnectPtr conn = Connect_domv (domv);
808   char *r;
809
810   NONBLOCKING (r = virDomainGetOSType (dom));
811   CHECK_ERROR (!r, conn, "virDomainGetOSType");
812
813   rv = caml_copy_string (r);
814   free (r);
815   CAMLreturn (rv);
816 }
817
818 /* Automatically generated binding for virDomainGetXMLDesc.
819  * In generator.pl this function has signature "dom, 0 : string".
820  */
821
822 CAMLprim value
823 ocaml_libvirt_domain_get_xml_desc (value domv)
824 {
825   CAMLparam1 (domv);
826
827   CAMLlocal1 (rv);
828   virDomainPtr dom = Domain_val (domv);
829   virConnectPtr conn = Connect_domv (domv);
830   char *r;
831
832   NONBLOCKING (r = virDomainGetXMLDesc (dom, 0));
833   CHECK_ERROR (!r, conn, "virDomainGetXMLDesc");
834
835   rv = caml_copy_string (r);
836   free (r);
837   CAMLreturn (rv);
838 }
839
840 /* Automatically generated binding for virDomainGetUUID.
841  * In generator.pl this function has signature "dom : uuid".
842  */
843
844 CAMLprim value
845 ocaml_libvirt_domain_get_uuid (value domv)
846 {
847   CAMLparam1 (domv);
848
849   CAMLlocal1 (rv);
850   virDomainPtr dom = Domain_val (domv);
851   virConnectPtr conn = Connect_domv (domv);
852   unsigned char uuid[VIR_UUID_BUFLEN];
853   int r;
854
855   NONBLOCKING (r = virDomainGetUUID (dom, uuid));
856   CHECK_ERROR (r == -1, conn, "virDomainGetUUID");
857
858   /* UUIDs are byte arrays with a fixed length. */
859   rv = caml_alloc_string (VIR_UUID_BUFLEN);
860   memcpy (String_val (rv), uuid, VIR_UUID_BUFLEN);
861   CAMLreturn (rv);
862 }
863
864 /* Automatically generated binding for virDomainGetUUIDString.
865  * In generator.pl this function has signature "dom : uuid string".
866  */
867
868 CAMLprim value
869 ocaml_libvirt_domain_get_uuid_string (value domv)
870 {
871   CAMLparam1 (domv);
872
873   CAMLlocal1 (rv);
874   virDomainPtr dom = Domain_val (domv);
875   virConnectPtr conn = Connect_domv (domv);
876   char uuid[VIR_UUID_STRING_BUFLEN];
877   int r;
878
879   NONBLOCKING (r = virDomainGetUUIDString (dom, uuid));
880   CHECK_ERROR (r == -1, conn, "virDomainGetUUIDString");
881
882   rv = caml_copy_string (uuid);
883   CAMLreturn (rv);
884 }
885
886 /* Automatically generated binding for virDomainGetMaxVcpus.
887  * In generator.pl this function has signature "dom : int".
888  */
889
890 CAMLprim value
891 ocaml_libvirt_domain_get_max_vcpus (value domv)
892 {
893   CAMLparam1 (domv);
894
895   virDomainPtr dom = Domain_val (domv);
896   virConnectPtr conn = Connect_domv (domv);
897   int r;
898
899   NONBLOCKING (r = virDomainGetMaxVcpus (dom));
900   CHECK_ERROR (r == -1, conn, "virDomainGetMaxVcpus");
901
902   CAMLreturn (Val_int (r));
903 }
904
905 /* Automatically generated binding for virDomainSave.
906  * In generator.pl this function has signature "dom, string : unit".
907  */
908
909 CAMLprim value
910 ocaml_libvirt_domain_save (value domv, value strv)
911 {
912   CAMLparam2 (domv, strv);
913
914   virDomainPtr dom = Domain_val (domv);
915   virConnectPtr conn = Connect_domv (domv);
916   char *str = String_val (strv);
917   int r;
918
919   NONBLOCKING (r = virDomainSave (dom, str));
920   CHECK_ERROR (r == -1, conn, "virDomainSave");
921
922   CAMLreturn (Val_unit);
923 }
924
925 /* Automatically generated binding for virDomainSaveJob.
926  * In generator.pl this function has signature "dom, string : job from dom".
927  */
928
929 #ifdef HAVE_WEAK_SYMBOLS
930 #ifdef HAVE_VIRDOMAINSAVEJOB
931 extern virJobPtr virDomainSaveJob (virDomainPtr dom, const char *str) __attribute__((weak));
932 #endif
933 #endif
934
935 CAMLprim value
936 ocaml_libvirt_domain_save_job (value domv, value strv)
937 {
938   CAMLparam2 (domv, strv);
939 #ifndef HAVE_VIRDOMAINSAVEJOB
940   /* Symbol virDomainSaveJob not found at compile time. */
941   not_supported ("virDomainSaveJob");
942   CAMLnoreturn;
943 #else
944   /* Check that the symbol virDomainSaveJob
945    * is in runtime version of libvirt.
946    */
947   WEAK_SYMBOL_CHECK (virDomainSaveJob);
948
949   CAMLlocal2 (rv, connv);
950   virDomainPtr dom = Domain_val (domv);
951   virConnectPtr conn = Connect_domv (domv);
952   char *str = String_val (strv);
953   virJobPtr r;
954
955   NONBLOCKING (r = virDomainSaveJob (dom, str));
956   CHECK_ERROR (!r, conn, "virDomainSaveJob");
957
958   connv = Field (domv, 1);
959   rv = Val_job (r, connv);
960
961   CAMLreturn (rv);
962 #endif
963 }
964
965 /* Automatically generated binding for virDomainRestore.
966  * In generator.pl this function has signature "conn, string : unit".
967  */
968
969 CAMLprim value
970 ocaml_libvirt_domain_restore (value connv, value strv)
971 {
972   CAMLparam2 (connv, strv);
973
974   virConnectPtr conn = Connect_val (connv);
975   char *str = String_val (strv);
976   int r;
977
978   NONBLOCKING (r = virDomainRestore (conn, str));
979   CHECK_ERROR (r == -1, conn, "virDomainRestore");
980
981   CAMLreturn (Val_unit);
982 }
983
984 /* Automatically generated binding for virDomainRestoreJob.
985  * In generator.pl this function has signature "conn, string : job".
986  */
987
988 #ifdef HAVE_WEAK_SYMBOLS
989 #ifdef HAVE_VIRDOMAINRESTOREJOB
990 extern virJobPtr virDomainRestoreJob (virConnectPtr conn, const char *str) __attribute__((weak));
991 #endif
992 #endif
993
994 CAMLprim value
995 ocaml_libvirt_domain_restore_job (value connv, value strv)
996 {
997   CAMLparam2 (connv, strv);
998 #ifndef HAVE_VIRDOMAINRESTOREJOB
999   /* Symbol virDomainRestoreJob not found at compile time. */
1000   not_supported ("virDomainRestoreJob");
1001   CAMLnoreturn;
1002 #else
1003   /* Check that the symbol virDomainRestoreJob
1004    * is in runtime version of libvirt.
1005    */
1006   WEAK_SYMBOL_CHECK (virDomainRestoreJob);
1007
1008   CAMLlocal1 (rv);
1009   virConnectPtr conn = Connect_val (connv);
1010   char *str = String_val (strv);
1011   virJobPtr r;
1012
1013   NONBLOCKING (r = virDomainRestoreJob (conn, str));
1014   CHECK_ERROR (!r, conn, "virDomainRestoreJob");
1015
1016   rv = Val_job (r, connv);
1017
1018   CAMLreturn (rv);
1019 #endif
1020 }
1021
1022 /* Automatically generated binding for virDomainCoreDump.
1023  * In generator.pl this function has signature "dom, string, 0 : unit".
1024  */
1025
1026 CAMLprim value
1027 ocaml_libvirt_domain_core_dump (value domv, value strv)
1028 {
1029   CAMLparam2 (domv, strv);
1030
1031   CAMLlocal1 (rv);
1032   virDomainPtr dom = Domain_val (domv);
1033   virConnectPtr conn = Connect_domv (domv);
1034   char *str = String_val (strv);
1035   int r;
1036
1037   NONBLOCKING (r = virDomainCoreDump (dom, str, 0));
1038   CHECK_ERROR (!r, conn, "virDomainCoreDump");
1039
1040   CAMLreturn (Val_unit);
1041 }
1042
1043 /* Automatically generated binding for virDomainCoreDumpJob.
1044  * In generator.pl this function has signature "dom, string, 0 : job from dom".
1045  */
1046
1047 #ifdef HAVE_WEAK_SYMBOLS
1048 #ifdef HAVE_VIRDOMAINCOREDUMPJOB
1049 extern virJobPtr virDomainCoreDumpJob (virDomainPtr dom, const char *str,  int flags) __attribute__((weak));
1050 #endif
1051 #endif
1052
1053 CAMLprim value
1054 ocaml_libvirt_domain_core_dump_job (value domv, value strv)
1055 {
1056   CAMLparam2 (domv, strv);
1057 #ifndef HAVE_VIRDOMAINCOREDUMPJOB
1058   /* Symbol virDomainCoreDumpJob not found at compile time. */
1059   not_supported ("virDomainCoreDumpJob");
1060   CAMLnoreturn;
1061 #else
1062   /* Check that the symbol virDomainCoreDumpJob
1063    * is in runtime version of libvirt.
1064    */
1065   WEAK_SYMBOL_CHECK (virDomainCoreDumpJob);
1066
1067   CAMLlocal2 (rv, connv);
1068   virDomainPtr dom = Domain_val (domv);
1069   virConnectPtr conn = Connect_domv (domv);
1070   char *str = String_val (strv);
1071   virJobPtr r;
1072
1073   NONBLOCKING (r = virDomainCoreDumpJob (dom, str, 0));
1074   CHECK_ERROR (!r, conn, "virDomainCoreDumpJob");
1075
1076   connv = Field (domv, 1);
1077   rv = Val_job (r, connv);
1078
1079   CAMLreturn (rv);
1080 #endif
1081 }
1082
1083 /* Automatically generated binding for virDomainSuspend.
1084  * In generator.pl this function has signature "dom : unit".
1085  */
1086
1087 CAMLprim value
1088 ocaml_libvirt_domain_suspend (value domv)
1089 {
1090   CAMLparam1 (domv);
1091
1092   virDomainPtr dom = Domain_val (domv);
1093   virConnectPtr conn = Connect_domv (domv);
1094   int r;
1095
1096   NONBLOCKING (r = virDomainSuspend (dom));
1097   CHECK_ERROR (r == -1, conn, "virDomainSuspend");
1098
1099   CAMLreturn (Val_unit);
1100 }
1101
1102 /* Automatically generated binding for virDomainResume.
1103  * In generator.pl this function has signature "dom : unit".
1104  */
1105
1106 CAMLprim value
1107 ocaml_libvirt_domain_resume (value domv)
1108 {
1109   CAMLparam1 (domv);
1110
1111   virDomainPtr dom = Domain_val (domv);
1112   virConnectPtr conn = Connect_domv (domv);
1113   int r;
1114
1115   NONBLOCKING (r = virDomainResume (dom));
1116   CHECK_ERROR (r == -1, conn, "virDomainResume");
1117
1118   CAMLreturn (Val_unit);
1119 }
1120
1121 /* Automatically generated binding for virDomainShutdown.
1122  * In generator.pl this function has signature "dom : unit".
1123  */
1124
1125 CAMLprim value
1126 ocaml_libvirt_domain_shutdown (value domv)
1127 {
1128   CAMLparam1 (domv);
1129
1130   virDomainPtr dom = Domain_val (domv);
1131   virConnectPtr conn = Connect_domv (domv);
1132   int r;
1133
1134   NONBLOCKING (r = virDomainShutdown (dom));
1135   CHECK_ERROR (r == -1, conn, "virDomainShutdown");
1136
1137   CAMLreturn (Val_unit);
1138 }
1139
1140 /* Automatically generated binding for virDomainReboot.
1141  * In generator.pl this function has signature "dom, 0 : unit".
1142  */
1143
1144 CAMLprim value
1145 ocaml_libvirt_domain_reboot (value domv)
1146 {
1147   CAMLparam1 (domv);
1148
1149   virDomainPtr dom = Domain_val (domv);
1150   virConnectPtr conn = Connect_domv (domv);
1151   int r;
1152
1153   NONBLOCKING (r = virDomainReboot (dom, 0));
1154   CHECK_ERROR (r == -1, conn, "virDomainReboot");
1155
1156   CAMLreturn (Val_unit);
1157 }
1158
1159 /* Automatically generated binding for virDomainDefineXML.
1160  * In generator.pl this function has signature "conn, string : dom".
1161  */
1162
1163 CAMLprim value
1164 ocaml_libvirt_domain_define_xml (value connv, value strv)
1165 {
1166   CAMLparam2 (connv, strv);
1167
1168   CAMLlocal1 (rv);
1169   virConnectPtr conn = Connect_val (connv);
1170   char *str = String_val (strv);
1171   virDomainPtr r;
1172
1173   NONBLOCKING (r = virDomainDefineXML (conn, str));
1174   CHECK_ERROR (!r, conn, "virDomainDefineXML");
1175
1176   rv = Val_domain (r, connv);
1177
1178   CAMLreturn (rv);
1179 }
1180
1181 /* Automatically generated binding for virDomainUndefine.
1182  * In generator.pl this function has signature "dom : unit".
1183  */
1184
1185 CAMLprim value
1186 ocaml_libvirt_domain_undefine (value domv)
1187 {
1188   CAMLparam1 (domv);
1189
1190   virDomainPtr dom = Domain_val (domv);
1191   virConnectPtr conn = Connect_domv (domv);
1192   int r;
1193
1194   NONBLOCKING (r = virDomainUndefine (dom));
1195   CHECK_ERROR (r == -1, conn, "virDomainUndefine");
1196
1197   CAMLreturn (Val_unit);
1198 }
1199
1200 /* Automatically generated binding for virDomainCreate.
1201  * In generator.pl this function has signature "dom : unit".
1202  */
1203
1204 CAMLprim value
1205 ocaml_libvirt_domain_create (value domv)
1206 {
1207   CAMLparam1 (domv);
1208
1209   virDomainPtr dom = Domain_val (domv);
1210   virConnectPtr conn = Connect_domv (domv);
1211   int r;
1212
1213   NONBLOCKING (r = virDomainCreate (dom));
1214   CHECK_ERROR (r == -1, conn, "virDomainCreate");
1215
1216   CAMLreturn (Val_unit);
1217 }
1218
1219 /* Automatically generated binding for virDomainCreateJob.
1220  * In generator.pl this function has signature "dom, 0U : job from dom".
1221  */
1222
1223 #ifdef HAVE_WEAK_SYMBOLS
1224 #ifdef HAVE_VIRDOMAINCREATEJOB
1225 extern virJobPtr virDomainCreateJob (virDomainPtr dom, unsigned  int flags) __attribute__((weak));
1226 #endif
1227 #endif
1228
1229 CAMLprim value
1230 ocaml_libvirt_domain_create_job (value domv)
1231 {
1232   CAMLparam1 (domv);
1233 #ifndef HAVE_VIRDOMAINCREATEJOB
1234   /* Symbol virDomainCreateJob not found at compile time. */
1235   not_supported ("virDomainCreateJob");
1236   CAMLnoreturn;
1237 #else
1238   /* Check that the symbol virDomainCreateJob
1239    * is in runtime version of libvirt.
1240    */
1241   WEAK_SYMBOL_CHECK (virDomainCreateJob);
1242
1243   CAMLlocal2 (rv, connv);
1244   virDomainPtr dom = Domain_val (domv);
1245   virConnectPtr conn = Connect_domv (domv);
1246   virJobPtr r;
1247
1248   NONBLOCKING (r = virDomainCreateJob (dom, 0));
1249   CHECK_ERROR (!r, conn, "virDomainCreateJob");
1250
1251   connv = Field (domv, 1);
1252   rv = Val_job (r, connv);
1253
1254   CAMLreturn (rv);
1255 #endif
1256 }
1257
1258 /* Automatically generated binding for virDomainAttachDevice.
1259  * In generator.pl this function has signature "dom, string : unit".
1260  */
1261
1262 CAMLprim value
1263 ocaml_libvirt_domain_attach_device (value domv, value strv)
1264 {
1265   CAMLparam2 (domv, strv);
1266
1267   virDomainPtr dom = Domain_val (domv);
1268   virConnectPtr conn = Connect_domv (domv);
1269   char *str = String_val (strv);
1270   int r;
1271
1272   NONBLOCKING (r = virDomainAttachDevice (dom, str));
1273   CHECK_ERROR (r == -1, conn, "virDomainAttachDevice");
1274
1275   CAMLreturn (Val_unit);
1276 }
1277
1278 /* Automatically generated binding for virDomainDetachDevice.
1279  * In generator.pl this function has signature "dom, string : unit".
1280  */
1281
1282 CAMLprim value
1283 ocaml_libvirt_domain_detach_device (value domv, value strv)
1284 {
1285   CAMLparam2 (domv, strv);
1286
1287   virDomainPtr dom = Domain_val (domv);
1288   virConnectPtr conn = Connect_domv (domv);
1289   char *str = String_val (strv);
1290   int r;
1291
1292   NONBLOCKING (r = virDomainDetachDevice (dom, str));
1293   CHECK_ERROR (r == -1, conn, "virDomainDetachDevice");
1294
1295   CAMLreturn (Val_unit);
1296 }
1297
1298 /* Automatically generated binding for virDomainGetAutostart.
1299  * In generator.pl this function has signature "dom : bool".
1300  */
1301
1302 CAMLprim value
1303 ocaml_libvirt_domain_get_autostart (value domv)
1304 {
1305   CAMLparam1 (domv);
1306
1307   virDomainPtr dom = Domain_val (domv);
1308   virConnectPtr conn = Connect_domv (domv);
1309   int r, b;
1310
1311   NONBLOCKING (r = virDomainGetAutostart (dom, &b));
1312   CHECK_ERROR (r == -1, conn, "virDomainGetAutostart");
1313
1314   CAMLreturn (b ? Val_true : Val_false);
1315 }
1316
1317 /* Automatically generated binding for virDomainSetAutostart.
1318  * In generator.pl this function has signature "dom, bool : unit".
1319  */
1320
1321 CAMLprim value
1322 ocaml_libvirt_domain_set_autostart (value domv, value bv)
1323 {
1324   CAMLparam2 (domv, bv);
1325
1326   virDomainPtr dom = Domain_val (domv);
1327   virConnectPtr conn = Connect_domv (domv);
1328   int r, b;
1329
1330   b = bv == Val_true ? 1 : 0;
1331
1332   NONBLOCKING (r = virDomainSetAutostart (dom, b));
1333   CHECK_ERROR (r == -1, conn, "virDomainSetAutostart");
1334
1335   CAMLreturn (Val_unit);
1336 }
1337
1338 /* Automatically generated binding for virNetworkFree.
1339  * In generator.pl this function has signature "net : free".
1340  */
1341
1342 CAMLprim value
1343 ocaml_libvirt_network_free (value netv)
1344 {
1345   CAMLparam1 (netv);
1346
1347   virNetworkPtr net = Network_val (netv);
1348   virConnectPtr conn = Connect_netv (netv);
1349   int r;
1350
1351   NONBLOCKING (r = virNetworkFree (net));
1352   CHECK_ERROR (r == -1, conn, "virNetworkFree");
1353
1354   /* So that we don't double-free in the finalizer: */
1355   Network_val (netv) = NULL;
1356
1357   CAMLreturn (Val_unit);
1358 }
1359
1360 /* Automatically generated binding for virNetworkDestroy.
1361  * In generator.pl this function has signature "net : free".
1362  */
1363
1364 CAMLprim value
1365 ocaml_libvirt_network_destroy (value netv)
1366 {
1367   CAMLparam1 (netv);
1368
1369   virNetworkPtr net = Network_val (netv);
1370   virConnectPtr conn = Connect_netv (netv);
1371   int r;
1372
1373   NONBLOCKING (r = virNetworkDestroy (net));
1374   CHECK_ERROR (r == -1, conn, "virNetworkDestroy");
1375
1376   /* So that we don't double-free in the finalizer: */
1377   Network_val (netv) = NULL;
1378
1379   CAMLreturn (Val_unit);
1380 }
1381
1382 /* Automatically generated binding for virNetworkLookupByName.
1383  * In generator.pl this function has signature "conn, string : net".
1384  */
1385
1386 CAMLprim value
1387 ocaml_libvirt_network_lookup_by_name (value connv, value strv)
1388 {
1389   CAMLparam2 (connv, strv);
1390
1391   CAMLlocal1 (rv);
1392   virConnectPtr conn = Connect_val (connv);
1393   char *str = String_val (strv);
1394   virNetworkPtr r;
1395
1396   NONBLOCKING (r = virNetworkLookupByName (conn, str));
1397   CHECK_ERROR (!r, conn, "virNetworkLookupByName");
1398
1399   rv = Val_network (r, connv);
1400
1401   CAMLreturn (rv);
1402 }
1403
1404 /* Automatically generated binding for virNetworkLookupByUUID.
1405  * In generator.pl this function has signature "conn, uuid : net".
1406  */
1407
1408 CAMLprim value
1409 ocaml_libvirt_network_lookup_by_uuid (value connv, value uuidv)
1410 {
1411   CAMLparam2 (connv, uuidv);
1412
1413   CAMLlocal1 (rv);
1414   virConnectPtr conn = Connect_val (connv);
1415   unsigned char *uuid = (unsigned char *) String_val (uuidv);
1416   virNetworkPtr r;
1417
1418   NONBLOCKING (r = virNetworkLookupByUUID (conn, uuid));
1419   CHECK_ERROR (!r, conn, "virNetworkLookupByUUID");
1420
1421   rv = Val_network (r, connv);
1422
1423   CAMLreturn (rv);
1424 }
1425
1426 /* Automatically generated binding for virNetworkLookupByUUIDString.
1427  * In generator.pl this function has signature "conn, string : net".
1428  */
1429
1430 CAMLprim value
1431 ocaml_libvirt_network_lookup_by_uuid_string (value connv, value strv)
1432 {
1433   CAMLparam2 (connv, strv);
1434
1435   CAMLlocal1 (rv);
1436   virConnectPtr conn = Connect_val (connv);
1437   char *str = String_val (strv);
1438   virNetworkPtr r;
1439
1440   NONBLOCKING (r = virNetworkLookupByUUIDString (conn, str));
1441   CHECK_ERROR (!r, conn, "virNetworkLookupByUUIDString");
1442
1443   rv = Val_network (r, connv);
1444
1445   CAMLreturn (rv);
1446 }
1447
1448 /* Automatically generated binding for virNetworkGetName.
1449  * In generator.pl this function has signature "net : static string".
1450  */
1451
1452 CAMLprim value
1453 ocaml_libvirt_network_get_name (value netv)
1454 {
1455   CAMLparam1 (netv);
1456
1457   CAMLlocal1 (rv);
1458   virNetworkPtr net = Network_val (netv);
1459   virConnectPtr conn = Connect_netv (netv);
1460   const char *r;
1461
1462   NONBLOCKING (r = virNetworkGetName (net));
1463   CHECK_ERROR (!r, conn, "virNetworkGetName");
1464
1465   rv = caml_copy_string (r);
1466   CAMLreturn (rv);
1467 }
1468
1469 /* Automatically generated binding for virNetworkGetXMLDesc.
1470  * In generator.pl this function has signature "net, 0 : string".
1471  */
1472
1473 CAMLprim value
1474 ocaml_libvirt_network_get_xml_desc (value netv)
1475 {
1476   CAMLparam1 (netv);
1477
1478   CAMLlocal1 (rv);
1479   virNetworkPtr net = Network_val (netv);
1480   virConnectPtr conn = Connect_netv (netv);
1481   char *r;
1482
1483   NONBLOCKING (r = virNetworkGetXMLDesc (net, 0));
1484   CHECK_ERROR (!r, conn, "virNetworkGetXMLDesc");
1485
1486   rv = caml_copy_string (r);
1487   free (r);
1488   CAMLreturn (rv);
1489 }
1490
1491 /* Automatically generated binding for virNetworkGetBridgeName.
1492  * In generator.pl this function has signature "net : string".
1493  */
1494
1495 CAMLprim value
1496 ocaml_libvirt_network_get_bridge_name (value netv)
1497 {
1498   CAMLparam1 (netv);
1499
1500   CAMLlocal1 (rv);
1501   virNetworkPtr net = Network_val (netv);
1502   virConnectPtr conn = Connect_netv (netv);
1503   char *r;
1504
1505   NONBLOCKING (r = virNetworkGetBridgeName (net));
1506   CHECK_ERROR (!r, conn, "virNetworkGetBridgeName");
1507
1508   rv = caml_copy_string (r);
1509   free (r);
1510   CAMLreturn (rv);
1511 }
1512
1513 /* Automatically generated binding for virNetworkGetUUID.
1514  * In generator.pl this function has signature "net : uuid".
1515  */
1516
1517 CAMLprim value
1518 ocaml_libvirt_network_get_uuid (value netv)
1519 {
1520   CAMLparam1 (netv);
1521
1522   CAMLlocal1 (rv);
1523   virNetworkPtr net = Network_val (netv);
1524   virConnectPtr conn = Connect_netv (netv);
1525   unsigned char uuid[VIR_UUID_BUFLEN];
1526   int r;
1527
1528   NONBLOCKING (r = virNetworkGetUUID (net, uuid));
1529   CHECK_ERROR (r == -1, conn, "virNetworkGetUUID");
1530
1531   /* UUIDs are byte arrays with a fixed length. */
1532   rv = caml_alloc_string (VIR_UUID_BUFLEN);
1533   memcpy (String_val (rv), uuid, VIR_UUID_BUFLEN);
1534   CAMLreturn (rv);
1535 }
1536
1537 /* Automatically generated binding for virNetworkGetUUIDString.
1538  * In generator.pl this function has signature "net : uuid string".
1539  */
1540
1541 CAMLprim value
1542 ocaml_libvirt_network_get_uuid_string (value netv)
1543 {
1544   CAMLparam1 (netv);
1545
1546   CAMLlocal1 (rv);
1547   virNetworkPtr net = Network_val (netv);
1548   virConnectPtr conn = Connect_netv (netv);
1549   char uuid[VIR_UUID_STRING_BUFLEN];
1550   int r;
1551
1552   NONBLOCKING (r = virNetworkGetUUIDString (net, uuid));
1553   CHECK_ERROR (r == -1, conn, "virNetworkGetUUIDString");
1554
1555   rv = caml_copy_string (uuid);
1556   CAMLreturn (rv);
1557 }
1558
1559 /* Automatically generated binding for virNetworkUndefine.
1560  * In generator.pl this function has signature "net : unit".
1561  */
1562
1563 CAMLprim value
1564 ocaml_libvirt_network_undefine (value netv)
1565 {
1566   CAMLparam1 (netv);
1567
1568   virNetworkPtr net = Network_val (netv);
1569   virConnectPtr conn = Connect_netv (netv);
1570   int r;
1571
1572   NONBLOCKING (r = virNetworkUndefine (net));
1573   CHECK_ERROR (r == -1, conn, "virNetworkUndefine");
1574
1575   CAMLreturn (Val_unit);
1576 }
1577
1578 /* Automatically generated binding for virNetworkCreateXML.
1579  * In generator.pl this function has signature "conn, string : net".
1580  */
1581
1582 CAMLprim value
1583 ocaml_libvirt_network_create_xml (value connv, value strv)
1584 {
1585   CAMLparam2 (connv, strv);
1586
1587   CAMLlocal1 (rv);
1588   virConnectPtr conn = Connect_val (connv);
1589   char *str = String_val (strv);
1590   virNetworkPtr r;
1591
1592   NONBLOCKING (r = virNetworkCreateXML (conn, str));
1593   CHECK_ERROR (!r, conn, "virNetworkCreateXML");
1594
1595   rv = Val_network (r, connv);
1596
1597   CAMLreturn (rv);
1598 }
1599
1600 /* Automatically generated binding for virNetworkCreateXMLJob.
1601  * In generator.pl this function has signature "conn, string : job".
1602  */
1603
1604 #ifdef HAVE_WEAK_SYMBOLS
1605 #ifdef HAVE_VIRNETWORKCREATEXMLJOB
1606 extern virJobPtr virNetworkCreateXMLJob (virConnectPtr conn, const char *str) __attribute__((weak));
1607 #endif
1608 #endif
1609
1610 CAMLprim value
1611 ocaml_libvirt_network_create_xml_job (value connv, value strv)
1612 {
1613   CAMLparam2 (connv, strv);
1614 #ifndef HAVE_VIRNETWORKCREATEXMLJOB
1615   /* Symbol virNetworkCreateXMLJob not found at compile time. */
1616   not_supported ("virNetworkCreateXMLJob");
1617   CAMLnoreturn;
1618 #else
1619   /* Check that the symbol virNetworkCreateXMLJob
1620    * is in runtime version of libvirt.
1621    */
1622   WEAK_SYMBOL_CHECK (virNetworkCreateXMLJob);
1623
1624   CAMLlocal1 (rv);
1625   virConnectPtr conn = Connect_val (connv);
1626   char *str = String_val (strv);
1627   virJobPtr r;
1628
1629   NONBLOCKING (r = virNetworkCreateXMLJob (conn, str));
1630   CHECK_ERROR (!r, conn, "virNetworkCreateXMLJob");
1631
1632   rv = Val_job (r, connv);
1633
1634   CAMLreturn (rv);
1635 #endif
1636 }
1637
1638 /* Automatically generated binding for virNetworkDefineXML.
1639  * In generator.pl this function has signature "conn, string : net".
1640  */
1641
1642 CAMLprim value
1643 ocaml_libvirt_network_define_xml (value connv, value strv)
1644 {
1645   CAMLparam2 (connv, strv);
1646
1647   CAMLlocal1 (rv);
1648   virConnectPtr conn = Connect_val (connv);
1649   char *str = String_val (strv);
1650   virNetworkPtr r;
1651
1652   NONBLOCKING (r = virNetworkDefineXML (conn, str));
1653   CHECK_ERROR (!r, conn, "virNetworkDefineXML");
1654
1655   rv = Val_network (r, connv);
1656
1657   CAMLreturn (rv);
1658 }
1659
1660 /* Automatically generated binding for virNetworkCreate.
1661  * In generator.pl this function has signature "net : unit".
1662  */
1663
1664 CAMLprim value
1665 ocaml_libvirt_network_create (value netv)
1666 {
1667   CAMLparam1 (netv);
1668
1669   virNetworkPtr net = Network_val (netv);
1670   virConnectPtr conn = Connect_netv (netv);
1671   int r;
1672
1673   NONBLOCKING (r = virNetworkCreate (net));
1674   CHECK_ERROR (r == -1, conn, "virNetworkCreate");
1675
1676   CAMLreturn (Val_unit);
1677 }
1678
1679 /* Automatically generated binding for virNetworkCreateJob.
1680  * In generator.pl this function has signature "net : job from net".
1681  */
1682
1683 #ifdef HAVE_WEAK_SYMBOLS
1684 #ifdef HAVE_VIRNETWORKCREATEJOB
1685 extern virJobPtr virNetworkCreateJob (virNetworkPtr net) __attribute__((weak));
1686 #endif
1687 #endif
1688
1689 CAMLprim value
1690 ocaml_libvirt_network_create_job (value netv)
1691 {
1692   CAMLparam1 (netv);
1693 #ifndef HAVE_VIRNETWORKCREATEJOB
1694   /* Symbol virNetworkCreateJob not found at compile time. */
1695   not_supported ("virNetworkCreateJob");
1696   CAMLnoreturn;
1697 #else
1698   /* Check that the symbol virNetworkCreateJob
1699    * is in runtime version of libvirt.
1700    */
1701   WEAK_SYMBOL_CHECK (virNetworkCreateJob);
1702
1703   CAMLlocal2 (rv, connv);
1704   virNetworkPtr net = Network_val (netv);
1705   virConnectPtr conn = Connect_netv (netv);
1706   virJobPtr r;
1707
1708   NONBLOCKING (r = virNetworkCreateJob (net));
1709   CHECK_ERROR (!r, conn, "virNetworkCreateJob");
1710
1711   connv = Field (netv, 1);
1712   rv = Val_job (r, connv);
1713
1714   CAMLreturn (rv);
1715 #endif
1716 }
1717
1718 /* Automatically generated binding for virNetworkGetAutostart.
1719  * In generator.pl this function has signature "net : bool".
1720  */
1721
1722 CAMLprim value
1723 ocaml_libvirt_network_get_autostart (value netv)
1724 {
1725   CAMLparam1 (netv);
1726
1727   virNetworkPtr net = Network_val (netv);
1728   virConnectPtr conn = Connect_netv (netv);
1729   int r, b;
1730
1731   NONBLOCKING (r = virNetworkGetAutostart (net, &b));
1732   CHECK_ERROR (r == -1, conn, "virNetworkGetAutostart");
1733
1734   CAMLreturn (b ? Val_true : Val_false);
1735 }
1736
1737 /* Automatically generated binding for virNetworkSetAutostart.
1738  * In generator.pl this function has signature "net, bool : unit".
1739  */
1740
1741 CAMLprim value
1742 ocaml_libvirt_network_set_autostart (value netv, value bv)
1743 {
1744   CAMLparam2 (netv, bv);
1745
1746   virNetworkPtr net = Network_val (netv);
1747   virConnectPtr conn = Connect_netv (netv);
1748   int r, b;
1749
1750   b = bv == Val_true ? 1 : 0;
1751
1752   NONBLOCKING (r = virNetworkSetAutostart (net, b));
1753   CHECK_ERROR (r == -1, conn, "virNetworkSetAutostart");
1754
1755   CAMLreturn (Val_unit);
1756 }
1757
1758 /* Automatically generated binding for virStoragePoolFree.
1759  * In generator.pl this function has signature "pool : free".
1760  */
1761
1762 #ifdef HAVE_WEAK_SYMBOLS
1763 #ifdef HAVE_VIRSTORAGEPOOLFREE
1764 extern int virStoragePoolFree (virStoragePoolPtr pool) __attribute__((weak));
1765 #endif
1766 #endif
1767
1768 CAMLprim value
1769 ocaml_libvirt_storage_pool_free (value poolv)
1770 {
1771   CAMLparam1 (poolv);
1772 #ifndef HAVE_VIRSTORAGEPOOLFREE
1773   /* Symbol virStoragePoolFree not found at compile time. */
1774   not_supported ("virStoragePoolFree");
1775   CAMLnoreturn;
1776 #else
1777   /* Check that the symbol virStoragePoolFree
1778    * is in runtime version of libvirt.
1779    */
1780   WEAK_SYMBOL_CHECK (virStoragePoolFree);
1781
1782   virStoragePoolPtr pool = Pool_val (poolv);
1783   virConnectPtr conn = Connect_polv (poolv);
1784   int r;
1785
1786   NONBLOCKING (r = virStoragePoolFree (pool));
1787   CHECK_ERROR (r == -1, conn, "virStoragePoolFree");
1788
1789   /* So that we don't double-free in the finalizer: */
1790   Pool_val (poolv) = NULL;
1791
1792   CAMLreturn (Val_unit);
1793 #endif
1794 }
1795
1796 /* Automatically generated binding for virStoragePoolDestroy.
1797  * In generator.pl this function has signature "pool : free".
1798  */
1799
1800 #ifdef HAVE_WEAK_SYMBOLS
1801 #ifdef HAVE_VIRSTORAGEPOOLDESTROY
1802 extern int virStoragePoolDestroy (virStoragePoolPtr pool) __attribute__((weak));
1803 #endif
1804 #endif
1805
1806 CAMLprim value
1807 ocaml_libvirt_storage_pool_destroy (value poolv)
1808 {
1809   CAMLparam1 (poolv);
1810 #ifndef HAVE_VIRSTORAGEPOOLDESTROY
1811   /* Symbol virStoragePoolDestroy not found at compile time. */
1812   not_supported ("virStoragePoolDestroy");
1813   CAMLnoreturn;
1814 #else
1815   /* Check that the symbol virStoragePoolDestroy
1816    * is in runtime version of libvirt.
1817    */
1818   WEAK_SYMBOL_CHECK (virStoragePoolDestroy);
1819
1820   virStoragePoolPtr pool = Pool_val (poolv);
1821   virConnectPtr conn = Connect_polv (poolv);
1822   int r;
1823
1824   NONBLOCKING (r = virStoragePoolDestroy (pool));
1825   CHECK_ERROR (r == -1, conn, "virStoragePoolDestroy");
1826
1827   /* So that we don't double-free in the finalizer: */
1828   Pool_val (poolv) = NULL;
1829
1830   CAMLreturn (Val_unit);
1831 #endif
1832 }
1833
1834 /* Automatically generated binding for virStoragePoolLookupByName.
1835  * In generator.pl this function has signature "conn, string : pool".
1836  */
1837
1838 #ifdef HAVE_WEAK_SYMBOLS
1839 #ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYNAME
1840 extern virStoragePoolPtr virStoragePoolLookupByName (virConnectPtr conn, const char *str) __attribute__((weak));
1841 #endif
1842 #endif
1843
1844 CAMLprim value
1845 ocaml_libvirt_storage_pool_lookup_by_name (value connv, value strv)
1846 {
1847   CAMLparam2 (connv, strv);
1848 #ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYNAME
1849   /* Symbol virStoragePoolLookupByName not found at compile time. */
1850   not_supported ("virStoragePoolLookupByName");
1851   CAMLnoreturn;
1852 #else
1853   /* Check that the symbol virStoragePoolLookupByName
1854    * is in runtime version of libvirt.
1855    */
1856   WEAK_SYMBOL_CHECK (virStoragePoolLookupByName);
1857
1858   CAMLlocal1 (rv);
1859   virConnectPtr conn = Connect_val (connv);
1860   char *str = String_val (strv);
1861   virStoragePoolPtr r;
1862
1863   NONBLOCKING (r = virStoragePoolLookupByName (conn, str));
1864   CHECK_ERROR (!r, conn, "virStoragePoolLookupByName");
1865
1866   rv = Val_pool (r, connv);
1867
1868   CAMLreturn (rv);
1869 #endif
1870 }
1871
1872 /* Automatically generated binding for virStoragePoolLookupByUUID.
1873  * In generator.pl this function has signature "conn, uuid : pool".
1874  */
1875
1876 #ifdef HAVE_WEAK_SYMBOLS
1877 #ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYUUID
1878 extern virStoragePoolPtr virStoragePoolLookupByUUID (virConnectPtr conn, const unsigned char *str) __attribute__((weak));
1879 #endif
1880 #endif
1881
1882 CAMLprim value
1883 ocaml_libvirt_storage_pool_lookup_by_uuid (value connv, value uuidv)
1884 {
1885   CAMLparam2 (connv, uuidv);
1886 #ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYUUID
1887   /* Symbol virStoragePoolLookupByUUID not found at compile time. */
1888   not_supported ("virStoragePoolLookupByUUID");
1889   CAMLnoreturn;
1890 #else
1891   /* Check that the symbol virStoragePoolLookupByUUID
1892    * is in runtime version of libvirt.
1893    */
1894   WEAK_SYMBOL_CHECK (virStoragePoolLookupByUUID);
1895
1896   CAMLlocal1 (rv);
1897   virConnectPtr conn = Connect_val (connv);
1898   unsigned char *uuid = (unsigned char *) String_val (uuidv);
1899   virStoragePoolPtr r;
1900
1901   NONBLOCKING (r = virStoragePoolLookupByUUID (conn, uuid));
1902   CHECK_ERROR (!r, conn, "virStoragePoolLookupByUUID");
1903
1904   rv = Val_pool (r, connv);
1905
1906   CAMLreturn (rv);
1907 #endif
1908 }
1909
1910 /* Automatically generated binding for virStoragePoolLookupByUUIDString.
1911  * In generator.pl this function has signature "conn, string : pool".
1912  */
1913
1914 #ifdef HAVE_WEAK_SYMBOLS
1915 #ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYUUIDSTRING
1916 extern virStoragePoolPtr virStoragePoolLookupByUUIDString (virConnectPtr conn, const char *str) __attribute__((weak));
1917 #endif
1918 #endif
1919
1920 CAMLprim value
1921 ocaml_libvirt_storage_pool_lookup_by_uuid_string (value connv, value strv)
1922 {
1923   CAMLparam2 (connv, strv);
1924 #ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYUUIDSTRING
1925   /* Symbol virStoragePoolLookupByUUIDString not found at compile time. */
1926   not_supported ("virStoragePoolLookupByUUIDString");
1927   CAMLnoreturn;
1928 #else
1929   /* Check that the symbol virStoragePoolLookupByUUIDString
1930    * is in runtime version of libvirt.
1931    */
1932   WEAK_SYMBOL_CHECK (virStoragePoolLookupByUUIDString);
1933
1934   CAMLlocal1 (rv);
1935   virConnectPtr conn = Connect_val (connv);
1936   char *str = String_val (strv);
1937   virStoragePoolPtr r;
1938
1939   NONBLOCKING (r = virStoragePoolLookupByUUIDString (conn, str));
1940   CHECK_ERROR (!r, conn, "virStoragePoolLookupByUUIDString");
1941
1942   rv = Val_pool (r, connv);
1943
1944   CAMLreturn (rv);
1945 #endif
1946 }
1947
1948 /* Automatically generated binding for virStoragePoolGetName.
1949  * In generator.pl this function has signature "pool : static string".
1950  */
1951
1952 #ifdef HAVE_WEAK_SYMBOLS
1953 #ifdef HAVE_VIRSTORAGEPOOLGETNAME
1954 extern const char *virStoragePoolGetName (virStoragePoolPtr pool) __attribute__((weak));
1955 #endif
1956 #endif
1957
1958 CAMLprim value
1959 ocaml_libvirt_storage_pool_get_name (value poolv)
1960 {
1961   CAMLparam1 (poolv);
1962 #ifndef HAVE_VIRSTORAGEPOOLGETNAME
1963   /* Symbol virStoragePoolGetName not found at compile time. */
1964   not_supported ("virStoragePoolGetName");
1965   CAMLnoreturn;
1966 #else
1967   /* Check that the symbol virStoragePoolGetName
1968    * is in runtime version of libvirt.
1969    */
1970   WEAK_SYMBOL_CHECK (virStoragePoolGetName);
1971
1972   CAMLlocal1 (rv);
1973   virStoragePoolPtr pool = Pool_val (poolv);
1974   virConnectPtr conn = Connect_polv (poolv);
1975   const char *r;
1976
1977   NONBLOCKING (r = virStoragePoolGetName (pool));
1978   CHECK_ERROR (!r, conn, "virStoragePoolGetName");
1979
1980   rv = caml_copy_string (r);
1981   CAMLreturn (rv);
1982 #endif
1983 }
1984
1985 /* Automatically generated binding for virStoragePoolGetXMLDesc.
1986  * In generator.pl this function has signature "pool, 0U : string".
1987  */
1988
1989 #ifdef HAVE_WEAK_SYMBOLS
1990 #ifdef HAVE_VIRSTORAGEPOOLGETXMLDESC
1991 extern char *virStoragePoolGetXMLDesc (virStoragePoolPtr pool, unsigned  int flags) __attribute__((weak));
1992 #endif
1993 #endif
1994
1995 CAMLprim value
1996 ocaml_libvirt_storage_pool_get_xml_desc (value poolv)
1997 {
1998   CAMLparam1 (poolv);
1999 #ifndef HAVE_VIRSTORAGEPOOLGETXMLDESC
2000   /* Symbol virStoragePoolGetXMLDesc not found at compile time. */
2001   not_supported ("virStoragePoolGetXMLDesc");
2002   CAMLnoreturn;
2003 #else
2004   /* Check that the symbol virStoragePoolGetXMLDesc
2005    * is in runtime version of libvirt.
2006    */
2007   WEAK_SYMBOL_CHECK (virStoragePoolGetXMLDesc);
2008
2009   CAMLlocal1 (rv);
2010   virStoragePoolPtr pool = Pool_val (poolv);
2011   virConnectPtr conn = Connect_polv (poolv);
2012   char *r;
2013
2014   NONBLOCKING (r = virStoragePoolGetXMLDesc (pool, 0));
2015   CHECK_ERROR (!r, conn, "virStoragePoolGetXMLDesc");
2016
2017   rv = caml_copy_string (r);
2018   free (r);
2019   CAMLreturn (rv);
2020 #endif
2021 }
2022
2023 /* Automatically generated binding for virStoragePoolGetUUID.
2024  * In generator.pl this function has signature "pool : uuid".
2025  */
2026
2027 #ifdef HAVE_WEAK_SYMBOLS
2028 #ifdef HAVE_VIRSTORAGEPOOLGETUUID
2029 extern int virStoragePoolGetUUID (virStoragePoolPtr pool, unsigned char *) __attribute__((weak));
2030 #endif
2031 #endif
2032
2033 CAMLprim value
2034 ocaml_libvirt_storage_pool_get_uuid (value poolv)
2035 {
2036   CAMLparam1 (poolv);
2037 #ifndef HAVE_VIRSTORAGEPOOLGETUUID
2038   /* Symbol virStoragePoolGetUUID not found at compile time. */
2039   not_supported ("virStoragePoolGetUUID");
2040   CAMLnoreturn;
2041 #else
2042   /* Check that the symbol virStoragePoolGetUUID
2043    * is in runtime version of libvirt.
2044    */
2045   WEAK_SYMBOL_CHECK (virStoragePoolGetUUID);
2046
2047   CAMLlocal1 (rv);
2048   virStoragePoolPtr pool = Pool_val (poolv);
2049   virConnectPtr conn = Connect_polv (poolv);
2050   unsigned char uuid[VIR_UUID_BUFLEN];
2051   int r;
2052
2053   NONBLOCKING (r = virStoragePoolGetUUID (pool, uuid));
2054   CHECK_ERROR (r == -1, conn, "virStoragePoolGetUUID");
2055
2056   /* UUIDs are byte arrays with a fixed length. */
2057   rv = caml_alloc_string (VIR_UUID_BUFLEN);
2058   memcpy (String_val (rv), uuid, VIR_UUID_BUFLEN);
2059   CAMLreturn (rv);
2060 #endif
2061 }
2062
2063 /* Automatically generated binding for virStoragePoolGetUUIDString.
2064  * In generator.pl this function has signature "pool : uuid string".
2065  */
2066
2067 #ifdef HAVE_WEAK_SYMBOLS
2068 #ifdef HAVE_VIRSTORAGEPOOLGETUUIDSTRING
2069 extern int virStoragePoolGetUUIDString (virStoragePoolPtr pool, char *) __attribute__((weak));
2070 #endif
2071 #endif
2072
2073 CAMLprim value
2074 ocaml_libvirt_storage_pool_get_uuid_string (value poolv)
2075 {
2076   CAMLparam1 (poolv);
2077 #ifndef HAVE_VIRSTORAGEPOOLGETUUIDSTRING
2078   /* Symbol virStoragePoolGetUUIDString not found at compile time. */
2079   not_supported ("virStoragePoolGetUUIDString");
2080   CAMLnoreturn;
2081 #else
2082   /* Check that the symbol virStoragePoolGetUUIDString
2083    * is in runtime version of libvirt.
2084    */
2085   WEAK_SYMBOL_CHECK (virStoragePoolGetUUIDString);
2086
2087   CAMLlocal1 (rv);
2088   virStoragePoolPtr pool = Pool_val (poolv);
2089   virConnectPtr conn = Connect_polv (poolv);
2090   char uuid[VIR_UUID_STRING_BUFLEN];
2091   int r;
2092
2093   NONBLOCKING (r = virStoragePoolGetUUIDString (pool, uuid));
2094   CHECK_ERROR (r == -1, conn, "virStoragePoolGetUUIDString");
2095
2096   rv = caml_copy_string (uuid);
2097   CAMLreturn (rv);
2098 #endif
2099 }
2100
2101 /* Automatically generated binding for virStoragePoolCreateXML.
2102  * In generator.pl this function has signature "conn, string, 0U : pool".
2103  */
2104
2105 #ifdef HAVE_WEAK_SYMBOLS
2106 #ifdef HAVE_VIRSTORAGEPOOLCREATEXML
2107 extern virStoragePoolPtr virStoragePoolCreateXML (virConnectPtr conn, const char *str, unsigned int flags) __attribute__((weak));
2108 #endif
2109 #endif
2110
2111 CAMLprim value
2112 ocaml_libvirt_storage_pool_create_xml (value connv, value strv)
2113 {
2114   CAMLparam2 (connv, strv);
2115 #ifndef HAVE_VIRSTORAGEPOOLCREATEXML
2116   /* Symbol virStoragePoolCreateXML not found at compile time. */
2117   not_supported ("virStoragePoolCreateXML");
2118   CAMLnoreturn;
2119 #else
2120   /* Check that the symbol virStoragePoolCreateXML
2121    * is in runtime version of libvirt.
2122    */
2123   WEAK_SYMBOL_CHECK (virStoragePoolCreateXML);
2124
2125   CAMLlocal1 (rv);
2126   virConnectPtr conn = Connect_val (connv);
2127   char *str = String_val (strv);
2128   virStoragePoolPtr r;
2129
2130   NONBLOCKING (r = virStoragePoolCreateXML (conn, str, 0));
2131   CHECK_ERROR (!r, conn, "virStoragePoolCreateXML");
2132
2133   rv = Val_pool (r, connv);
2134
2135   CAMLreturn (rv);
2136 #endif
2137 }
2138
2139 /* Automatically generated binding for virStoragePoolDefineXML.
2140  * In generator.pl this function has signature "conn, string, 0U : pool".
2141  */
2142
2143 #ifdef HAVE_WEAK_SYMBOLS
2144 #ifdef HAVE_VIRSTORAGEPOOLDEFINEXML
2145 extern virStoragePoolPtr virStoragePoolDefineXML (virConnectPtr conn, const char *str, unsigned int flags) __attribute__((weak));
2146 #endif
2147 #endif
2148
2149 CAMLprim value
2150 ocaml_libvirt_storage_pool_define_xml (value connv, value strv)
2151 {
2152   CAMLparam2 (connv, strv);
2153 #ifndef HAVE_VIRSTORAGEPOOLDEFINEXML
2154   /* Symbol virStoragePoolDefineXML not found at compile time. */
2155   not_supported ("virStoragePoolDefineXML");
2156   CAMLnoreturn;
2157 #else
2158   /* Check that the symbol virStoragePoolDefineXML
2159    * is in runtime version of libvirt.
2160    */
2161   WEAK_SYMBOL_CHECK (virStoragePoolDefineXML);
2162
2163   CAMLlocal1 (rv);
2164   virConnectPtr conn = Connect_val (connv);
2165   char *str = String_val (strv);
2166   virStoragePoolPtr r;
2167
2168   NONBLOCKING (r = virStoragePoolDefineXML (conn, str, 0));
2169   CHECK_ERROR (!r, conn, "virStoragePoolDefineXML");
2170
2171   rv = Val_pool (r, connv);
2172
2173   CAMLreturn (rv);
2174 #endif
2175 }
2176
2177 /* Automatically generated binding for virStoragePoolBuild.
2178  * In generator.pl this function has signature "pool, uint : unit".
2179  */
2180
2181 #ifdef HAVE_WEAK_SYMBOLS
2182 #ifdef HAVE_VIRSTORAGEPOOLBUILD
2183 extern int virStoragePoolBuild (virStoragePoolPtr pool, unsigned int i) __attribute__((weak));
2184 #endif
2185 #endif
2186
2187 CAMLprim value
2188 ocaml_libvirt_storage_pool_build (value poolv, value iv)
2189 {
2190   CAMLparam2 (poolv, iv);
2191 #ifndef HAVE_VIRSTORAGEPOOLBUILD
2192   /* Symbol virStoragePoolBuild not found at compile time. */
2193   not_supported ("virStoragePoolBuild");
2194   CAMLnoreturn;
2195 #else
2196   /* Check that the symbol virStoragePoolBuild
2197    * is in runtime version of libvirt.
2198    */
2199   WEAK_SYMBOL_CHECK (virStoragePoolBuild);
2200
2201   virStoragePoolPtr pool = Pool_val (poolv);
2202   virConnectPtr conn = Connect_polv (poolv);
2203   unsigned int i = Int_val (iv);
2204   int r;
2205
2206   NONBLOCKING (r = virStoragePoolBuild (pool, i));
2207   CHECK_ERROR (!r, conn, "virStoragePoolBuild");
2208
2209   CAMLreturn (Val_unit);
2210 #endif
2211 }
2212
2213 /* Automatically generated binding for virStoragePoolUndefine.
2214  * In generator.pl this function has signature "pool : unit".
2215  */
2216
2217 #ifdef HAVE_WEAK_SYMBOLS
2218 #ifdef HAVE_VIRSTORAGEPOOLUNDEFINE
2219 extern int virStoragePoolUndefine (virStoragePoolPtr pool) __attribute__((weak));
2220 #endif
2221 #endif
2222
2223 CAMLprim value
2224 ocaml_libvirt_storage_pool_undefine (value poolv)
2225 {
2226   CAMLparam1 (poolv);
2227 #ifndef HAVE_VIRSTORAGEPOOLUNDEFINE
2228   /* Symbol virStoragePoolUndefine not found at compile time. */
2229   not_supported ("virStoragePoolUndefine");
2230   CAMLnoreturn;
2231 #else
2232   /* Check that the symbol virStoragePoolUndefine
2233    * is in runtime version of libvirt.
2234    */
2235   WEAK_SYMBOL_CHECK (virStoragePoolUndefine);
2236
2237   virStoragePoolPtr pool = Pool_val (poolv);
2238   virConnectPtr conn = Connect_polv (poolv);
2239   int r;
2240
2241   NONBLOCKING (r = virStoragePoolUndefine (pool));
2242   CHECK_ERROR (r == -1, conn, "virStoragePoolUndefine");
2243
2244   CAMLreturn (Val_unit);
2245 #endif
2246 }
2247
2248 /* Automatically generated binding for virStoragePoolCreate.
2249  * In generator.pl this function has signature "pool, 0U : unit".
2250  */
2251
2252 #ifdef HAVE_WEAK_SYMBOLS
2253 #ifdef HAVE_VIRSTORAGEPOOLCREATE
2254 extern int virStoragePoolCreate (virStoragePoolPtr pool, unsigned  int flags) __attribute__((weak));
2255 #endif
2256 #endif
2257
2258 CAMLprim value
2259 ocaml_libvirt_storage_pool_create (value poolv)
2260 {
2261   CAMLparam1 (poolv);
2262 #ifndef HAVE_VIRSTORAGEPOOLCREATE
2263   /* Symbol virStoragePoolCreate not found at compile time. */
2264   not_supported ("virStoragePoolCreate");
2265   CAMLnoreturn;
2266 #else
2267   /* Check that the symbol virStoragePoolCreate
2268    * is in runtime version of libvirt.
2269    */
2270   WEAK_SYMBOL_CHECK (virStoragePoolCreate);
2271
2272   virStoragePoolPtr pool = Pool_val (poolv);
2273   virConnectPtr conn = Connect_polv (poolv);
2274   int r;
2275
2276   NONBLOCKING (r = virStoragePoolCreate (pool, 0));
2277   CHECK_ERROR (r == -1, conn, "virStoragePoolCreate");
2278
2279   CAMLreturn (Val_unit);
2280 #endif
2281 }
2282
2283 /* Automatically generated binding for virStoragePoolDelete.
2284  * In generator.pl this function has signature "pool, uint : unit".
2285  */
2286
2287 #ifdef HAVE_WEAK_SYMBOLS
2288 #ifdef HAVE_VIRSTORAGEPOOLDELETE
2289 extern int virStoragePoolDelete (virStoragePoolPtr pool, unsigned int i) __attribute__((weak));
2290 #endif
2291 #endif
2292
2293 CAMLprim value
2294 ocaml_libvirt_storage_pool_delete (value poolv, value iv)
2295 {
2296   CAMLparam2 (poolv, iv);
2297 #ifndef HAVE_VIRSTORAGEPOOLDELETE
2298   /* Symbol virStoragePoolDelete not found at compile time. */
2299   not_supported ("virStoragePoolDelete");
2300   CAMLnoreturn;
2301 #else
2302   /* Check that the symbol virStoragePoolDelete
2303    * is in runtime version of libvirt.
2304    */
2305   WEAK_SYMBOL_CHECK (virStoragePoolDelete);
2306
2307   virStoragePoolPtr pool = Pool_val (poolv);
2308   virConnectPtr conn = Connect_polv (poolv);
2309   unsigned int i = Int_val (iv);
2310   int r;
2311
2312   NONBLOCKING (r = virStoragePoolDelete (pool, i));
2313   CHECK_ERROR (!r, conn, "virStoragePoolDelete");
2314
2315   CAMLreturn (Val_unit);
2316 #endif
2317 }
2318
2319 /* Automatically generated binding for virStoragePoolRefresh.
2320  * In generator.pl this function has signature "pool, 0U : unit".
2321  */
2322
2323 #ifdef HAVE_WEAK_SYMBOLS
2324 #ifdef HAVE_VIRSTORAGEPOOLREFRESH
2325 extern int virStoragePoolRefresh (virStoragePoolPtr pool, unsigned  int flags) __attribute__((weak));
2326 #endif
2327 #endif
2328
2329 CAMLprim value
2330 ocaml_libvirt_storage_pool_refresh (value poolv)
2331 {
2332   CAMLparam1 (poolv);
2333 #ifndef HAVE_VIRSTORAGEPOOLREFRESH
2334   /* Symbol virStoragePoolRefresh not found at compile time. */
2335   not_supported ("virStoragePoolRefresh");
2336   CAMLnoreturn;
2337 #else
2338   /* Check that the symbol virStoragePoolRefresh
2339    * is in runtime version of libvirt.
2340    */
2341   WEAK_SYMBOL_CHECK (virStoragePoolRefresh);
2342
2343   virStoragePoolPtr pool = Pool_val (poolv);
2344   virConnectPtr conn = Connect_polv (poolv);
2345   int r;
2346
2347   NONBLOCKING (r = virStoragePoolRefresh (pool, 0));
2348   CHECK_ERROR (r == -1, conn, "virStoragePoolRefresh");
2349
2350   CAMLreturn (Val_unit);
2351 #endif
2352 }
2353
2354 /* Automatically generated binding for virStoragePoolGetAutostart.
2355  * In generator.pl this function has signature "pool : bool".
2356  */
2357
2358 #ifdef HAVE_WEAK_SYMBOLS
2359 #ifdef HAVE_VIRSTORAGEPOOLGETAUTOSTART
2360 extern int virStoragePoolGetAutostart (virStoragePoolPtr pool, int *r) __attribute__((weak));
2361 #endif
2362 #endif
2363
2364 CAMLprim value
2365 ocaml_libvirt_storage_pool_get_autostart (value poolv)
2366 {
2367   CAMLparam1 (poolv);
2368 #ifndef HAVE_VIRSTORAGEPOOLGETAUTOSTART
2369   /* Symbol virStoragePoolGetAutostart not found at compile time. */
2370   not_supported ("virStoragePoolGetAutostart");
2371   CAMLnoreturn;
2372 #else
2373   /* Check that the symbol virStoragePoolGetAutostart
2374    * is in runtime version of libvirt.
2375    */
2376   WEAK_SYMBOL_CHECK (virStoragePoolGetAutostart);
2377
2378   virStoragePoolPtr pool = Pool_val (poolv);
2379   virConnectPtr conn = Connect_polv (poolv);
2380   int r, b;
2381
2382   NONBLOCKING (r = virStoragePoolGetAutostart (pool, &b));
2383   CHECK_ERROR (r == -1, conn, "virStoragePoolGetAutostart");
2384
2385   CAMLreturn (b ? Val_true : Val_false);
2386 #endif
2387 }
2388
2389 /* Automatically generated binding for virStoragePoolSetAutostart.
2390  * In generator.pl this function has signature "pool, bool : unit".
2391  */
2392
2393 #ifdef HAVE_WEAK_SYMBOLS
2394 #ifdef HAVE_VIRSTORAGEPOOLSETAUTOSTART
2395 extern int virStoragePoolSetAutostart (virStoragePoolPtr pool, int b) __attribute__((weak));
2396 #endif
2397 #endif
2398
2399 CAMLprim value
2400 ocaml_libvirt_storage_pool_set_autostart (value poolv, value bv)
2401 {
2402   CAMLparam2 (poolv, bv);
2403 #ifndef HAVE_VIRSTORAGEPOOLSETAUTOSTART
2404   /* Symbol virStoragePoolSetAutostart not found at compile time. */
2405   not_supported ("virStoragePoolSetAutostart");
2406   CAMLnoreturn;
2407 #else
2408   /* Check that the symbol virStoragePoolSetAutostart
2409    * is in runtime version of libvirt.
2410    */
2411   WEAK_SYMBOL_CHECK (virStoragePoolSetAutostart);
2412
2413   virStoragePoolPtr pool = Pool_val (poolv);
2414   virConnectPtr conn = Connect_polv (poolv);
2415   int r, b;
2416
2417   b = bv == Val_true ? 1 : 0;
2418
2419   NONBLOCKING (r = virStoragePoolSetAutostart (pool, b));
2420   CHECK_ERROR (r == -1, conn, "virStoragePoolSetAutostart");
2421
2422   CAMLreturn (Val_unit);
2423 #endif
2424 }
2425
2426 /* Automatically generated binding for virStoragePoolNumOfVolumes.
2427  * In generator.pl this function has signature "pool : int".
2428  */
2429
2430 #ifdef HAVE_WEAK_SYMBOLS
2431 #ifdef HAVE_VIRSTORAGEPOOLNUMOFVOLUMES
2432 extern int virStoragePoolNumOfVolumes (virStoragePoolPtr pool) __attribute__((weak));
2433 #endif
2434 #endif
2435
2436 CAMLprim value
2437 ocaml_libvirt_storage_pool_num_of_volumes (value poolv)
2438 {
2439   CAMLparam1 (poolv);
2440 #ifndef HAVE_VIRSTORAGEPOOLNUMOFVOLUMES
2441   /* Symbol virStoragePoolNumOfVolumes not found at compile time. */
2442   not_supported ("virStoragePoolNumOfVolumes");
2443   CAMLnoreturn;
2444 #else
2445   /* Check that the symbol virStoragePoolNumOfVolumes
2446    * is in runtime version of libvirt.
2447    */
2448   WEAK_SYMBOL_CHECK (virStoragePoolNumOfVolumes);
2449
2450   virStoragePoolPtr pool = Pool_val (poolv);
2451   virConnectPtr conn = Connect_polv (poolv);
2452   int r;
2453
2454   NONBLOCKING (r = virStoragePoolNumOfVolumes (pool));
2455   CHECK_ERROR (r == -1, conn, "virStoragePoolNumOfVolumes");
2456
2457   CAMLreturn (Val_int (r));
2458 #endif
2459 }
2460
2461 /* Automatically generated binding for virStoragePoolListVolumes.
2462  * In generator.pl this function has signature "pool, int : string array".
2463  */
2464
2465 #ifdef HAVE_WEAK_SYMBOLS
2466 #ifdef HAVE_VIRSTORAGEPOOLLISTVOLUMES
2467 extern int virStoragePoolListVolumes (virStoragePoolPtr pool, char **const names, int maxnames) __attribute__((weak));
2468 #endif
2469 #endif
2470
2471 CAMLprim value
2472 ocaml_libvirt_storage_pool_list_volumes (value poolv, value iv)
2473 {
2474   CAMLparam2 (poolv, iv);
2475 #ifndef HAVE_VIRSTORAGEPOOLLISTVOLUMES
2476   /* Symbol virStoragePoolListVolumes not found at compile time. */
2477   not_supported ("virStoragePoolListVolumes");
2478   CAMLnoreturn;
2479 #else
2480   /* Check that the symbol virStoragePoolListVolumes
2481    * is in runtime version of libvirt.
2482    */
2483   WEAK_SYMBOL_CHECK (virStoragePoolListVolumes);
2484
2485   CAMLlocal2 (rv, strv);
2486   virStoragePoolPtr pool = Pool_val (poolv);
2487   virConnectPtr conn = Connect_polv (poolv);
2488   int i = Int_val (iv);
2489   char *names[i];
2490   int r;
2491
2492   /* Some libvirt List* functions still throw exceptions if i == 0,
2493    * so catch that and return an empty array directly.  This changes
2494    * the semantics slightly (masking other failures) but it's
2495    * unlikely anyone will care.  RWMJ 2008/06/10
2496    */
2497   if (i == 0) {
2498     rv = caml_alloc (0, 0);
2499     CAMLreturn (rv);
2500   }
2501
2502   NONBLOCKING (r = virStoragePoolListVolumes (pool, names, i));
2503   CHECK_ERROR (r == -1, conn, "virStoragePoolListVolumes");
2504
2505   rv = caml_alloc (r, 0);
2506   for (i = 0; i < r; ++i) {
2507     strv = caml_copy_string (names[i]);
2508     Store_field (rv, i, strv);
2509     free (names[i]);
2510   }
2511
2512   CAMLreturn (rv);
2513 #endif
2514 }
2515
2516 /* Automatically generated binding for virStorageVolFree.
2517  * In generator.pl this function has signature "vol : free".
2518  */
2519
2520 #ifdef HAVE_WEAK_SYMBOLS
2521 #ifdef HAVE_VIRSTORAGEVOLFREE
2522 extern int virStorageVolFree (virStorageVolPtr vol) __attribute__((weak));
2523 #endif
2524 #endif
2525
2526 CAMLprim value
2527 ocaml_libvirt_storage_vol_free (value volv)
2528 {
2529   CAMLparam1 (volv);
2530 #ifndef HAVE_VIRSTORAGEVOLFREE
2531   /* Symbol virStorageVolFree not found at compile time. */
2532   not_supported ("virStorageVolFree");
2533   CAMLnoreturn;
2534 #else
2535   /* Check that the symbol virStorageVolFree
2536    * is in runtime version of libvirt.
2537    */
2538   WEAK_SYMBOL_CHECK (virStorageVolFree);
2539
2540   virStorageVolPtr vol = Volume_val (volv);
2541   virConnectPtr conn = Connect_volv (volv);
2542   int r;
2543
2544   NONBLOCKING (r = virStorageVolFree (vol));
2545   CHECK_ERROR (r == -1, conn, "virStorageVolFree");
2546
2547   /* So that we don't double-free in the finalizer: */
2548   Volume_val (volv) = NULL;
2549
2550   CAMLreturn (Val_unit);
2551 #endif
2552 }
2553
2554 /* Automatically generated binding for virStorageVolDelete.
2555  * In generator.pl this function has signature "vol, uint : unit".
2556  */
2557
2558 #ifdef HAVE_WEAK_SYMBOLS
2559 #ifdef HAVE_VIRSTORAGEVOLDELETE
2560 extern int virStorageVolDelete (virStorageVolPtr vol, unsigned int i) __attribute__((weak));
2561 #endif
2562 #endif
2563
2564 CAMLprim value
2565 ocaml_libvirt_storage_vol_delete (value volv, value iv)
2566 {
2567   CAMLparam2 (volv, iv);
2568 #ifndef HAVE_VIRSTORAGEVOLDELETE
2569   /* Symbol virStorageVolDelete not found at compile time. */
2570   not_supported ("virStorageVolDelete");
2571   CAMLnoreturn;
2572 #else
2573   /* Check that the symbol virStorageVolDelete
2574    * is in runtime version of libvirt.
2575    */
2576   WEAK_SYMBOL_CHECK (virStorageVolDelete);
2577
2578   virStorageVolPtr vol = Volume_val (volv);
2579   virConnectPtr conn = Connect_volv (volv);
2580   unsigned int i = Int_val (iv);
2581   int r;
2582
2583   NONBLOCKING (r = virStorageVolDelete (vol, i));
2584   CHECK_ERROR (!r, conn, "virStorageVolDelete");
2585
2586   CAMLreturn (Val_unit);
2587 #endif
2588 }
2589
2590 /* Automatically generated binding for virStorageVolLookupByName.
2591  * In generator.pl this function has signature "pool, string : vol from pool".
2592  */
2593
2594 #ifdef HAVE_WEAK_SYMBOLS
2595 #ifdef HAVE_VIRSTORAGEVOLLOOKUPBYNAME
2596 extern virStorageVolPtr virStorageVolLookupByName (virStoragePoolPtr pool, const char *str) __attribute__((weak));
2597 #endif
2598 #endif
2599
2600 CAMLprim value
2601 ocaml_libvirt_storage_vol_lookup_by_name (value poolv, value strv)
2602 {
2603   CAMLparam2 (poolv, strv);
2604 #ifndef HAVE_VIRSTORAGEVOLLOOKUPBYNAME
2605   /* Symbol virStorageVolLookupByName not found at compile time. */
2606   not_supported ("virStorageVolLookupByName");
2607   CAMLnoreturn;
2608 #else
2609   /* Check that the symbol virStorageVolLookupByName
2610    * is in runtime version of libvirt.
2611    */
2612   WEAK_SYMBOL_CHECK (virStorageVolLookupByName);
2613
2614   CAMLlocal2 (rv, connv);
2615   virStoragePoolPtr pool = Pool_val (poolv);
2616   virConnectPtr conn = Connect_polv (poolv);
2617   char *str = String_val (strv);
2618   virStorageVolPtr r;
2619
2620   NONBLOCKING (r = virStorageVolLookupByName (pool, str));
2621   CHECK_ERROR (!r, conn, "virStorageVolLookupByName");
2622
2623   connv = Field (poolv, 1);
2624   rv = Val_volume (r, connv);
2625
2626   CAMLreturn (rv);
2627 #endif
2628 }
2629
2630 /* Automatically generated binding for virStorageVolLookupByKey.
2631  * In generator.pl this function has signature "conn, string : vol".
2632  */
2633
2634 #ifdef HAVE_WEAK_SYMBOLS
2635 #ifdef HAVE_VIRSTORAGEVOLLOOKUPBYKEY
2636 extern virStorageVolPtr virStorageVolLookupByKey (virConnectPtr conn, const char *str) __attribute__((weak));
2637 #endif
2638 #endif
2639
2640 CAMLprim value
2641 ocaml_libvirt_storage_vol_lookup_by_key (value connv, value strv)
2642 {
2643   CAMLparam2 (connv, strv);
2644 #ifndef HAVE_VIRSTORAGEVOLLOOKUPBYKEY
2645   /* Symbol virStorageVolLookupByKey not found at compile time. */
2646   not_supported ("virStorageVolLookupByKey");
2647   CAMLnoreturn;
2648 #else
2649   /* Check that the symbol virStorageVolLookupByKey
2650    * is in runtime version of libvirt.
2651    */
2652   WEAK_SYMBOL_CHECK (virStorageVolLookupByKey);
2653
2654   CAMLlocal1 (rv);
2655   virConnectPtr conn = Connect_val (connv);
2656   char *str = String_val (strv);
2657   virStorageVolPtr r;
2658
2659   NONBLOCKING (r = virStorageVolLookupByKey (conn, str));
2660   CHECK_ERROR (!r, conn, "virStorageVolLookupByKey");
2661
2662   rv = Val_volume (r, connv);
2663
2664   CAMLreturn (rv);
2665 #endif
2666 }
2667
2668 /* Automatically generated binding for virStorageVolLookupByPath.
2669  * In generator.pl this function has signature "conn, string : vol".
2670  */
2671
2672 #ifdef HAVE_WEAK_SYMBOLS
2673 #ifdef HAVE_VIRSTORAGEVOLLOOKUPBYPATH
2674 extern virStorageVolPtr virStorageVolLookupByPath (virConnectPtr conn, const char *str) __attribute__((weak));
2675 #endif
2676 #endif
2677
2678 CAMLprim value
2679 ocaml_libvirt_storage_vol_lookup_by_path (value connv, value strv)
2680 {
2681   CAMLparam2 (connv, strv);
2682 #ifndef HAVE_VIRSTORAGEVOLLOOKUPBYPATH
2683   /* Symbol virStorageVolLookupByPath not found at compile time. */
2684   not_supported ("virStorageVolLookupByPath");
2685   CAMLnoreturn;
2686 #else
2687   /* Check that the symbol virStorageVolLookupByPath
2688    * is in runtime version of libvirt.
2689    */
2690   WEAK_SYMBOL_CHECK (virStorageVolLookupByPath);
2691
2692   CAMLlocal1 (rv);
2693   virConnectPtr conn = Connect_val (connv);
2694   char *str = String_val (strv);
2695   virStorageVolPtr r;
2696
2697   NONBLOCKING (r = virStorageVolLookupByPath (conn, str));
2698   CHECK_ERROR (!r, conn, "virStorageVolLookupByPath");
2699
2700   rv = Val_volume (r, connv);
2701
2702   CAMLreturn (rv);
2703 #endif
2704 }
2705
2706 /* Automatically generated binding for virStorageVolCreateXML.
2707  * In generator.pl this function has signature "pool, string, 0U : vol from pool".
2708  */
2709
2710 #ifdef HAVE_WEAK_SYMBOLS
2711 #ifdef HAVE_VIRSTORAGEVOLCREATEXML
2712 extern virStorageVolPtr virStorageVolCreateXML (virStoragePoolPtr pool, const char *str, unsigned  int flags) __attribute__((weak));
2713 #endif
2714 #endif
2715
2716 CAMLprim value
2717 ocaml_libvirt_storage_vol_create_xml (value poolv, value strv)
2718 {
2719   CAMLparam2 (poolv, strv);
2720 #ifndef HAVE_VIRSTORAGEVOLCREATEXML
2721   /* Symbol virStorageVolCreateXML not found at compile time. */
2722   not_supported ("virStorageVolCreateXML");
2723   CAMLnoreturn;
2724 #else
2725   /* Check that the symbol virStorageVolCreateXML
2726    * is in runtime version of libvirt.
2727    */
2728   WEAK_SYMBOL_CHECK (virStorageVolCreateXML);
2729
2730   CAMLlocal2 (rv, connv);
2731   virStoragePoolPtr pool = Pool_val (poolv);
2732   virConnectPtr conn = Connect_polv (poolv);
2733   char *str = String_val (strv);
2734   virStorageVolPtr r;
2735
2736   NONBLOCKING (r = virStorageVolCreateXML (pool, str, 0));
2737   CHECK_ERROR (!r, conn, "virStorageVolCreateXML");
2738
2739   connv = Field (poolv, 1);
2740   rv = Val_volume (r, connv);
2741
2742   CAMLreturn (rv);
2743 #endif
2744 }
2745
2746 /* Automatically generated binding for virStorageVolGetXMLDesc.
2747  * In generator.pl this function has signature "vol, 0U : string".
2748  */
2749
2750 #ifdef HAVE_WEAK_SYMBOLS
2751 #ifdef HAVE_VIRSTORAGEVOLGETXMLDESC
2752 extern char *virStorageVolGetXMLDesc (virStorageVolPtr vol, unsigned  int flags) __attribute__((weak));
2753 #endif
2754 #endif
2755
2756 CAMLprim value
2757 ocaml_libvirt_storage_vol_get_xml_desc (value volv)
2758 {
2759   CAMLparam1 (volv);
2760 #ifndef HAVE_VIRSTORAGEVOLGETXMLDESC
2761   /* Symbol virStorageVolGetXMLDesc not found at compile time. */
2762   not_supported ("virStorageVolGetXMLDesc");
2763   CAMLnoreturn;
2764 #else
2765   /* Check that the symbol virStorageVolGetXMLDesc
2766    * is in runtime version of libvirt.
2767    */
2768   WEAK_SYMBOL_CHECK (virStorageVolGetXMLDesc);
2769
2770   CAMLlocal1 (rv);
2771   virStorageVolPtr vol = Volume_val (volv);
2772   virConnectPtr conn = Connect_volv (volv);
2773   char *r;
2774
2775   NONBLOCKING (r = virStorageVolGetXMLDesc (vol, 0));
2776   CHECK_ERROR (!r, conn, "virStorageVolGetXMLDesc");
2777
2778   rv = caml_copy_string (r);
2779   free (r);
2780   CAMLreturn (rv);
2781 #endif
2782 }
2783
2784 /* Automatically generated binding for virStorageVolGetPath.
2785  * In generator.pl this function has signature "vol : string".
2786  */
2787
2788 #ifdef HAVE_WEAK_SYMBOLS
2789 #ifdef HAVE_VIRSTORAGEVOLGETPATH
2790 extern char *virStorageVolGetPath (virStorageVolPtr vol) __attribute__((weak));
2791 #endif
2792 #endif
2793
2794 CAMLprim value
2795 ocaml_libvirt_storage_vol_get_path (value volv)
2796 {
2797   CAMLparam1 (volv);
2798 #ifndef HAVE_VIRSTORAGEVOLGETPATH
2799   /* Symbol virStorageVolGetPath not found at compile time. */
2800   not_supported ("virStorageVolGetPath");
2801   CAMLnoreturn;
2802 #else
2803   /* Check that the symbol virStorageVolGetPath
2804    * is in runtime version of libvirt.
2805    */
2806   WEAK_SYMBOL_CHECK (virStorageVolGetPath);
2807
2808   CAMLlocal1 (rv);
2809   virStorageVolPtr vol = Volume_val (volv);
2810   virConnectPtr conn = Connect_volv (volv);
2811   char *r;
2812
2813   NONBLOCKING (r = virStorageVolGetPath (vol));
2814   CHECK_ERROR (!r, conn, "virStorageVolGetPath");
2815
2816   rv = caml_copy_string (r);
2817   free (r);
2818   CAMLreturn (rv);
2819 #endif
2820 }
2821
2822 /* Automatically generated binding for virStorageVolGetKey.
2823  * In generator.pl this function has signature "vol : static string".
2824  */
2825
2826 #ifdef HAVE_WEAK_SYMBOLS
2827 #ifdef HAVE_VIRSTORAGEVOLGETKEY
2828 extern const char *virStorageVolGetKey (virStorageVolPtr vol) __attribute__((weak));
2829 #endif
2830 #endif
2831
2832 CAMLprim value
2833 ocaml_libvirt_storage_vol_get_key (value volv)
2834 {
2835   CAMLparam1 (volv);
2836 #ifndef HAVE_VIRSTORAGEVOLGETKEY
2837   /* Symbol virStorageVolGetKey not found at compile time. */
2838   not_supported ("virStorageVolGetKey");
2839   CAMLnoreturn;
2840 #else
2841   /* Check that the symbol virStorageVolGetKey
2842    * is in runtime version of libvirt.
2843    */
2844   WEAK_SYMBOL_CHECK (virStorageVolGetKey);
2845
2846   CAMLlocal1 (rv);
2847   virStorageVolPtr vol = Volume_val (volv);
2848   virConnectPtr conn = Connect_volv (volv);
2849   const char *r;
2850
2851   NONBLOCKING (r = virStorageVolGetKey (vol));
2852   CHECK_ERROR (!r, conn, "virStorageVolGetKey");
2853
2854   rv = caml_copy_string (r);
2855   CAMLreturn (rv);
2856 #endif
2857 }
2858
2859 /* Automatically generated binding for virStorageVolGetName.
2860  * In generator.pl this function has signature "vol : static string".
2861  */
2862
2863 #ifdef HAVE_WEAK_SYMBOLS
2864 #ifdef HAVE_VIRSTORAGEVOLGETNAME
2865 extern const char *virStorageVolGetName (virStorageVolPtr vol) __attribute__((weak));
2866 #endif
2867 #endif
2868
2869 CAMLprim value
2870 ocaml_libvirt_storage_vol_get_name (value volv)
2871 {
2872   CAMLparam1 (volv);
2873 #ifndef HAVE_VIRSTORAGEVOLGETNAME
2874   /* Symbol virStorageVolGetName not found at compile time. */
2875   not_supported ("virStorageVolGetName");
2876   CAMLnoreturn;
2877 #else
2878   /* Check that the symbol virStorageVolGetName
2879    * is in runtime version of libvirt.
2880    */
2881   WEAK_SYMBOL_CHECK (virStorageVolGetName);
2882
2883   CAMLlocal1 (rv);
2884   virStorageVolPtr vol = Volume_val (volv);
2885   virConnectPtr conn = Connect_volv (volv);
2886   const char *r;
2887
2888   NONBLOCKING (r = virStorageVolGetName (vol));
2889   CHECK_ERROR (!r, conn, "virStorageVolGetName");
2890
2891   rv = caml_copy_string (r);
2892   CAMLreturn (rv);
2893 #endif
2894 }
2895
2896 /* Automatically generated binding for virStoragePoolLookupByVolume.
2897  * In generator.pl this function has signature "vol : pool from vol".
2898  */
2899
2900 #ifdef HAVE_WEAK_SYMBOLS
2901 #ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYVOLUME
2902 extern virStoragePoolPtr virStoragePoolLookupByVolume (virStorageVolPtr vol) __attribute__((weak));
2903 #endif
2904 #endif
2905
2906 CAMLprim value
2907 ocaml_libvirt_storage_pool_lookup_by_volume (value volv)
2908 {
2909   CAMLparam1 (volv);
2910 #ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYVOLUME
2911   /* Symbol virStoragePoolLookupByVolume not found at compile time. */
2912   not_supported ("virStoragePoolLookupByVolume");
2913   CAMLnoreturn;
2914 #else
2915   /* Check that the symbol virStoragePoolLookupByVolume
2916    * is in runtime version of libvirt.
2917    */
2918   WEAK_SYMBOL_CHECK (virStoragePoolLookupByVolume);
2919
2920   CAMLlocal2 (rv, connv);
2921   virStorageVolPtr vol = Volume_val (volv);
2922   virConnectPtr conn = Connect_volv (volv);
2923   virStoragePoolPtr r;
2924
2925   NONBLOCKING (r = virStoragePoolLookupByVolume (vol));
2926   CHECK_ERROR (!r, conn, "virStoragePoolLookupByVolume");
2927
2928   connv = Field (volv, 1);
2929   rv = Val_pool (r, connv);
2930
2931   CAMLreturn (rv);
2932 #endif
2933 }
2934
2935 /* Automatically generated binding for virJobFree.
2936  * In generator.pl this function has signature "job : free".
2937  */
2938
2939 #ifdef HAVE_WEAK_SYMBOLS
2940 #ifdef HAVE_VIRJOBFREE
2941 extern int virJobFree (virJobPtr job) __attribute__((weak));
2942 #endif
2943 #endif
2944
2945 CAMLprim value
2946 ocaml_libvirt_job_free (value jobv)
2947 {
2948   CAMLparam1 (jobv);
2949 #ifndef HAVE_VIRJOBFREE
2950   /* Symbol virJobFree not found at compile time. */
2951   not_supported ("virJobFree");
2952   CAMLnoreturn;
2953 #else
2954   /* Check that the symbol virJobFree
2955    * is in runtime version of libvirt.
2956    */
2957   WEAK_SYMBOL_CHECK (virJobFree);
2958
2959   virJobPtr job = Job_val (jobv);
2960   virConnectPtr conn = Connect_jobv (jobv);
2961   int r;
2962
2963   NONBLOCKING (r = virJobFree (job));
2964   CHECK_ERROR (r == -1, conn, "virJobFree");
2965
2966   /* So that we don't double-free in the finalizer: */
2967   Job_val (jobv) = NULL;
2968
2969   CAMLreturn (Val_unit);
2970 #endif
2971 }
2972
2973 /* Automatically generated binding for virJobCancel.
2974  * In generator.pl this function has signature "job : unit".
2975  */
2976
2977 #ifdef HAVE_WEAK_SYMBOLS
2978 #ifdef HAVE_VIRJOBCANCEL
2979 extern int virJobCancel (virJobPtr job) __attribute__((weak));
2980 #endif
2981 #endif
2982
2983 CAMLprim value
2984 ocaml_libvirt_job_cancel (value jobv)
2985 {
2986   CAMLparam1 (jobv);
2987 #ifndef HAVE_VIRJOBCANCEL
2988   /* Symbol virJobCancel not found at compile time. */
2989   not_supported ("virJobCancel");
2990   CAMLnoreturn;
2991 #else
2992   /* Check that the symbol virJobCancel
2993    * is in runtime version of libvirt.
2994    */
2995   WEAK_SYMBOL_CHECK (virJobCancel);
2996
2997   virJobPtr job = Job_val (jobv);
2998   virConnectPtr conn = Connect_jobv (jobv);
2999   int r;
3000
3001   NONBLOCKING (r = virJobCancel (job));
3002   CHECK_ERROR (r == -1, conn, "virJobCancel");
3003
3004   CAMLreturn (Val_unit);
3005 #endif
3006 }
3007
3008 /* Automatically generated binding for virJobGetNetwork.
3009  * In generator.pl this function has signature "job : net from job".
3010  */
3011
3012 #ifdef HAVE_WEAK_SYMBOLS
3013 #ifdef HAVE_VIRJOBGETNETWORK
3014 extern virNetworkPtr virJobGetNetwork (virJobPtr job) __attribute__((weak));
3015 #endif
3016 #endif
3017
3018 CAMLprim value
3019 ocaml_libvirt_job_get_network (value jobv)
3020 {
3021   CAMLparam1 (jobv);
3022 #ifndef HAVE_VIRJOBGETNETWORK
3023   /* Symbol virJobGetNetwork not found at compile time. */
3024   not_supported ("virJobGetNetwork");
3025   CAMLnoreturn;
3026 #else
3027   /* Check that the symbol virJobGetNetwork
3028    * is in runtime version of libvirt.
3029    */
3030   WEAK_SYMBOL_CHECK (virJobGetNetwork);
3031
3032   CAMLlocal2 (rv, connv);
3033   virJobPtr job = Job_val (jobv);
3034   virConnectPtr conn = Connect_jobv (jobv);
3035   virNetworkPtr r;
3036
3037   NONBLOCKING (r = virJobGetNetwork (job));
3038   CHECK_ERROR (!r, conn, "virJobGetNetwork");
3039
3040   connv = Field (jobv, 1);
3041   rv = Val_network (r, connv);
3042
3043   CAMLreturn (rv);
3044 #endif
3045 }
3046
3047 /* Automatically generated binding for virJobGetDomain.
3048  * In generator.pl this function has signature "job : dom from job".
3049  */
3050
3051 #ifdef HAVE_WEAK_SYMBOLS
3052 #ifdef HAVE_VIRJOBGETDOMAIN
3053 extern virDomainPtr virJobGetDomain (virJobPtr job) __attribute__((weak));
3054 #endif
3055 #endif
3056
3057 CAMLprim value
3058 ocaml_libvirt_job_get_domain (value jobv)
3059 {
3060   CAMLparam1 (jobv);
3061 #ifndef HAVE_VIRJOBGETDOMAIN
3062   /* Symbol virJobGetDomain not found at compile time. */
3063   not_supported ("virJobGetDomain");
3064   CAMLnoreturn;
3065 #else
3066   /* Check that the symbol virJobGetDomain
3067    * is in runtime version of libvirt.
3068    */
3069   WEAK_SYMBOL_CHECK (virJobGetDomain);
3070
3071   CAMLlocal2 (rv, connv);
3072   virJobPtr job = Job_val (jobv);
3073   virConnectPtr conn = Connect_jobv (jobv);
3074   virDomainPtr r;
3075
3076   NONBLOCKING (r = virJobGetDomain (job));
3077   CHECK_ERROR (!r, conn, "virJobGetDomain");
3078
3079   connv = Field (jobv, 1);
3080   rv = Val_domain (r, connv);
3081
3082   CAMLreturn (rv);
3083 #endif
3084 }
3085
3086 #include "libvirt_c_epilogue.c"
3087
3088 /* EOF */