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