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