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