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