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