8d519448ee8669863c7d35029771e0a78a27f537
[ocaml-libvirt.git] / libvirt / libvirt_c.c
1 /* !!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!!
2  *
3  * THIS FILE IS AUTOMATICALLY GENERATED BY 'generator.pl'.
4  *
5  * Any changes you make to this file may be overwritten.
6  */
7
8 /* OCaml bindings for libvirt.
9  * (C) Copyright 2007-2015 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  * with the OCaml linking exception described in ../COPYING.LIB.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21  * Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public
24  * License along with this library; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
26  */
27
28 #include "config.h"
29
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33
34 #include <libvirt/libvirt.h>
35 #include <libvirt/virterror.h>
36
37 #include <caml/config.h>
38 #include <caml/alloc.h>
39 #include <caml/callback.h>
40 #include <caml/custom.h>
41 #include <caml/fail.h>
42 #include <caml/memory.h>
43 #include <caml/misc.h>
44 #include <caml/mlvalues.h>
45 #include <caml/signals.h>
46
47 #include "libvirt_c_prologue.c"
48
49 #include "libvirt_c_oneoffs.c"
50
51 /* Automatically generated binding for virConnectClose.
52  * In generator.pl this function has signature "conn : free".
53  */
54
55 CAMLprim value
56 ocaml_libvirt_connect_close (value connv)
57 {
58   CAMLparam1 (connv);
59
60   virConnectPtr conn = Connect_val (connv);
61   int r;
62
63   NONBLOCKING (r = virConnectClose (conn));
64   CHECK_ERROR (r == -1, "virConnectClose");
65
66   /* So that we don't double-free in the finalizer: */
67   Connect_val (connv) = NULL;
68
69   CAMLreturn (Val_unit);
70 }
71
72 /* Automatically generated binding for virConnectGetHostname.
73  * In generator.pl this function has signature "conn : string".
74  */
75
76 CAMLprim value
77 ocaml_libvirt_connect_get_hostname (value connv)
78 {
79   CAMLparam1 (connv);
80
81   CAMLlocal1 (rv);
82   virConnectPtr conn = Connect_val (connv);
83   char *r;
84
85   NONBLOCKING (r = virConnectGetHostname (conn));
86   CHECK_ERROR (!r, "virConnectGetHostname");
87
88   rv = caml_copy_string (r);
89   free (r);
90   CAMLreturn (rv);
91 }
92
93 /* Automatically generated binding for virConnectGetURI.
94  * In generator.pl this function has signature "conn : string".
95  */
96
97 CAMLprim value
98 ocaml_libvirt_connect_get_uri (value connv)
99 {
100   CAMLparam1 (connv);
101
102   CAMLlocal1 (rv);
103   virConnectPtr conn = Connect_val (connv);
104   char *r;
105
106   NONBLOCKING (r = virConnectGetURI (conn));
107   CHECK_ERROR (!r, "virConnectGetURI");
108
109   rv = caml_copy_string (r);
110   free (r);
111   CAMLreturn (rv);
112 }
113
114 /* Automatically generated binding for virConnectGetType.
115  * In generator.pl this function has signature "conn : static string".
116  */
117
118 CAMLprim value
119 ocaml_libvirt_connect_get_type (value connv)
120 {
121   CAMLparam1 (connv);
122
123   CAMLlocal1 (rv);
124   virConnectPtr conn = Connect_val (connv);
125   const char *r;
126
127   NONBLOCKING (r = virConnectGetType (conn));
128   CHECK_ERROR (!r, "virConnectGetType");
129
130   rv = caml_copy_string (r);
131   CAMLreturn (rv);
132 }
133
134 /* Automatically generated binding for virConnectNumOfDomains.
135  * In generator.pl this function has signature "conn : int".
136  */
137
138 CAMLprim value
139 ocaml_libvirt_connect_num_of_domains (value connv)
140 {
141   CAMLparam1 (connv);
142
143   virConnectPtr conn = Connect_val (connv);
144   int r;
145
146   NONBLOCKING (r = virConnectNumOfDomains (conn));
147   CHECK_ERROR (r == -1, "virConnectNumOfDomains");
148
149   CAMLreturn (Val_int (r));
150 }
151
152 /* Automatically generated binding for virConnectListDomains.
153  * In generator.pl this function has signature "conn, int : int array".
154  */
155
156 CAMLprim value
157 ocaml_libvirt_connect_list_domains (value connv, value iv)
158 {
159   CAMLparam2 (connv, iv);
160
161   CAMLlocal1 (rv);
162   virConnectPtr conn = Connect_val (connv);
163   int i = Int_val (iv);
164   int ids[i], r;
165
166   /* Some libvirt List* functions still throw exceptions if i == 0,
167    * so catch that and return an empty array directly.  This changes
168    * the semantics slightly (masking other failures) but it's
169    * unlikely anyone will care.  RWMJ 2008/06/10
170    */
171   if (i == 0) {
172     rv = caml_alloc (0, 0);
173     CAMLreturn (rv);
174   }
175
176   NONBLOCKING (r = virConnectListDomains (conn, ids, i));
177   CHECK_ERROR (r == -1, "virConnectListDomains");
178
179   rv = caml_alloc (r, 0);
180   for (i = 0; i < r; ++i)
181     Store_field (rv, i, Val_int (ids[i]));
182
183   CAMLreturn (rv);
184 }
185
186 /* Automatically generated binding for virConnectNumOfDefinedDomains.
187  * In generator.pl this function has signature "conn : int".
188  */
189
190 CAMLprim value
191 ocaml_libvirt_connect_num_of_defined_domains (value connv)
192 {
193   CAMLparam1 (connv);
194
195   virConnectPtr conn = Connect_val (connv);
196   int r;
197
198   NONBLOCKING (r = virConnectNumOfDefinedDomains (conn));
199   CHECK_ERROR (r == -1, "virConnectNumOfDefinedDomains");
200
201   CAMLreturn (Val_int (r));
202 }
203
204 /* Automatically generated binding for virConnectListDefinedDomains.
205  * In generator.pl this function has signature "conn, int : string array".
206  */
207
208 CAMLprim value
209 ocaml_libvirt_connect_list_defined_domains (value connv, value iv)
210 {
211   CAMLparam2 (connv, iv);
212
213   CAMLlocal2 (rv, strv);
214   virConnectPtr conn = Connect_val (connv);
215   int i = Int_val (iv);
216   char *names[i];
217   int r;
218
219   /* Some libvirt List* functions still throw exceptions if i == 0,
220    * so catch that and return an empty array directly.  This changes
221    * the semantics slightly (masking other failures) but it's
222    * unlikely anyone will care.  RWMJ 2008/06/10
223    */
224   if (i == 0) {
225     rv = caml_alloc (0, 0);
226     CAMLreturn (rv);
227   }
228
229   NONBLOCKING (r = virConnectListDefinedDomains (conn, names, i));
230   CHECK_ERROR (r == -1, "virConnectListDefinedDomains");
231
232   rv = caml_alloc (r, 0);
233   for (i = 0; i < r; ++i) {
234     strv = caml_copy_string (names[i]);
235     Store_field (rv, i, strv);
236     free (names[i]);
237   }
238
239   CAMLreturn (rv);
240 }
241
242 /* Automatically generated binding for virConnectNumOfNetworks.
243  * In generator.pl this function has signature "conn : int".
244  */
245
246 CAMLprim value
247 ocaml_libvirt_connect_num_of_networks (value connv)
248 {
249   CAMLparam1 (connv);
250
251   virConnectPtr conn = Connect_val (connv);
252   int r;
253
254   NONBLOCKING (r = virConnectNumOfNetworks (conn));
255   CHECK_ERROR (r == -1, "virConnectNumOfNetworks");
256
257   CAMLreturn (Val_int (r));
258 }
259
260 /* Automatically generated binding for virConnectListNetworks.
261  * In generator.pl this function has signature "conn, int : string array".
262  */
263
264 CAMLprim value
265 ocaml_libvirt_connect_list_networks (value connv, value iv)
266 {
267   CAMLparam2 (connv, iv);
268
269   CAMLlocal2 (rv, strv);
270   virConnectPtr conn = Connect_val (connv);
271   int i = Int_val (iv);
272   char *names[i];
273   int r;
274
275   /* Some libvirt List* functions still throw exceptions if i == 0,
276    * so catch that and return an empty array directly.  This changes
277    * the semantics slightly (masking other failures) but it's
278    * unlikely anyone will care.  RWMJ 2008/06/10
279    */
280   if (i == 0) {
281     rv = caml_alloc (0, 0);
282     CAMLreturn (rv);
283   }
284
285   NONBLOCKING (r = virConnectListNetworks (conn, names, i));
286   CHECK_ERROR (r == -1, "virConnectListNetworks");
287
288   rv = caml_alloc (r, 0);
289   for (i = 0; i < r; ++i) {
290     strv = caml_copy_string (names[i]);
291     Store_field (rv, i, strv);
292     free (names[i]);
293   }
294
295   CAMLreturn (rv);
296 }
297
298 /* Automatically generated binding for virConnectNumOfDefinedNetworks.
299  * In generator.pl this function has signature "conn : int".
300  */
301
302 CAMLprim value
303 ocaml_libvirt_connect_num_of_defined_networks (value connv)
304 {
305   CAMLparam1 (connv);
306
307   virConnectPtr conn = Connect_val (connv);
308   int r;
309
310   NONBLOCKING (r = virConnectNumOfDefinedNetworks (conn));
311   CHECK_ERROR (r == -1, "virConnectNumOfDefinedNetworks");
312
313   CAMLreturn (Val_int (r));
314 }
315
316 /* Automatically generated binding for virConnectListDefinedNetworks.
317  * In generator.pl this function has signature "conn, int : string array".
318  */
319
320 CAMLprim value
321 ocaml_libvirt_connect_list_defined_networks (value connv, value iv)
322 {
323   CAMLparam2 (connv, iv);
324
325   CAMLlocal2 (rv, strv);
326   virConnectPtr conn = Connect_val (connv);
327   int i = Int_val (iv);
328   char *names[i];
329   int r;
330
331   /* Some libvirt List* functions still throw exceptions if i == 0,
332    * so catch that and return an empty array directly.  This changes
333    * the semantics slightly (masking other failures) but it's
334    * unlikely anyone will care.  RWMJ 2008/06/10
335    */
336   if (i == 0) {
337     rv = caml_alloc (0, 0);
338     CAMLreturn (rv);
339   }
340
341   NONBLOCKING (r = virConnectListDefinedNetworks (conn, names, i));
342   CHECK_ERROR (r == -1, "virConnectListDefinedNetworks");
343
344   rv = caml_alloc (r, 0);
345   for (i = 0; i < r; ++i) {
346     strv = caml_copy_string (names[i]);
347     Store_field (rv, i, strv);
348     free (names[i]);
349   }
350
351   CAMLreturn (rv);
352 }
353
354 /* Automatically generated binding for virConnectNumOfStoragePools.
355  * In generator.pl this function has signature "conn : int".
356  */
357
358 CAMLprim value
359 ocaml_libvirt_connect_num_of_storage_pools (value connv)
360 {
361   CAMLparam1 (connv);
362
363   virConnectPtr conn = Connect_val (connv);
364   int r;
365
366   NONBLOCKING (r = virConnectNumOfStoragePools (conn));
367   CHECK_ERROR (r == -1, "virConnectNumOfStoragePools");
368
369   CAMLreturn (Val_int (r));
370 }
371
372 /* Automatically generated binding for virConnectListStoragePools.
373  * In generator.pl this function has signature "conn, int : string array".
374  */
375
376 CAMLprim value
377 ocaml_libvirt_connect_list_storage_pools (value connv, value iv)
378 {
379   CAMLparam2 (connv, iv);
380
381   CAMLlocal2 (rv, strv);
382   virConnectPtr conn = Connect_val (connv);
383   int i = Int_val (iv);
384   char *names[i];
385   int r;
386
387   /* Some libvirt List* functions still throw exceptions if i == 0,
388    * so catch that and return an empty array directly.  This changes
389    * the semantics slightly (masking other failures) but it's
390    * unlikely anyone will care.  RWMJ 2008/06/10
391    */
392   if (i == 0) {
393     rv = caml_alloc (0, 0);
394     CAMLreturn (rv);
395   }
396
397   NONBLOCKING (r = virConnectListStoragePools (conn, names, i));
398   CHECK_ERROR (r == -1, "virConnectListStoragePools");
399
400   rv = caml_alloc (r, 0);
401   for (i = 0; i < r; ++i) {
402     strv = caml_copy_string (names[i]);
403     Store_field (rv, i, strv);
404     free (names[i]);
405   }
406
407   CAMLreturn (rv);
408 }
409
410 /* Automatically generated binding for virConnectNumOfDefinedStoragePools.
411  * In generator.pl this function has signature "conn : int".
412  */
413
414 CAMLprim value
415 ocaml_libvirt_connect_num_of_defined_storage_pools (value connv)
416 {
417   CAMLparam1 (connv);
418
419   virConnectPtr conn = Connect_val (connv);
420   int r;
421
422   NONBLOCKING (r = virConnectNumOfDefinedStoragePools (conn));
423   CHECK_ERROR (r == -1, "virConnectNumOfDefinedStoragePools");
424
425   CAMLreturn (Val_int (r));
426 }
427
428 /* Automatically generated binding for virConnectListDefinedStoragePools.
429  * In generator.pl this function has signature "conn, int : string array".
430  */
431
432 CAMLprim value
433 ocaml_libvirt_connect_list_defined_storage_pools (value connv, value iv)
434 {
435   CAMLparam2 (connv, iv);
436
437   CAMLlocal2 (rv, strv);
438   virConnectPtr conn = Connect_val (connv);
439   int i = Int_val (iv);
440   char *names[i];
441   int r;
442
443   /* Some libvirt List* functions still throw exceptions if i == 0,
444    * so catch that and return an empty array directly.  This changes
445    * the semantics slightly (masking other failures) but it's
446    * unlikely anyone will care.  RWMJ 2008/06/10
447    */
448   if (i == 0) {
449     rv = caml_alloc (0, 0);
450     CAMLreturn (rv);
451   }
452
453   NONBLOCKING (r = virConnectListDefinedStoragePools (conn, names, i));
454   CHECK_ERROR (r == -1, "virConnectListDefinedStoragePools");
455
456   rv = caml_alloc (r, 0);
457   for (i = 0; i < r; ++i) {
458     strv = caml_copy_string (names[i]);
459     Store_field (rv, i, strv);
460     free (names[i]);
461   }
462
463   CAMLreturn (rv);
464 }
465
466 /* Automatically generated binding for virConnectGetCapabilities.
467  * In generator.pl this function has signature "conn : string".
468  */
469
470 CAMLprim value
471 ocaml_libvirt_connect_get_capabilities (value connv)
472 {
473   CAMLparam1 (connv);
474
475   CAMLlocal1 (rv);
476   virConnectPtr conn = Connect_val (connv);
477   char *r;
478
479   NONBLOCKING (r = virConnectGetCapabilities (conn));
480   CHECK_ERROR (!r, "virConnectGetCapabilities");
481
482   rv = caml_copy_string (r);
483   free (r);
484   CAMLreturn (rv);
485 }
486
487 /* Automatically generated binding for virConnectDomainEventDeregisterAny.
488  * In generator.pl this function has signature "conn, int : unit".
489  */
490
491 CAMLprim value
492 ocaml_libvirt_connect_domain_event_deregister_any (value connv, value iv)
493 {
494   CAMLparam2 (connv, iv);
495
496   virConnectPtr conn = Connect_val (connv);
497   int i = Int_val (iv);
498   int r;
499
500   NONBLOCKING (r = virConnectDomainEventDeregisterAny (conn, i));
501   CHECK_ERROR (r == -1, "virConnectDomainEventDeregisterAny");
502
503   CAMLreturn (Val_unit);
504 }
505
506 /* Automatically generated binding for virDomainCreateLinux.
507  * In generator.pl this function has signature "conn, string, 0U : dom".
508  */
509
510 CAMLprim value
511 ocaml_libvirt_domain_create_linux (value connv, value strv)
512 {
513   CAMLparam2 (connv, strv);
514
515   CAMLlocal1 (rv);
516   virConnectPtr conn = Connect_val (connv);
517   char *str = String_val (strv);
518   virDomainPtr r;
519
520   NONBLOCKING (r = virDomainCreateLinux (conn, str, 0));
521   CHECK_ERROR (!r, "virDomainCreateLinux");
522
523   rv = Val_domain (r, connv);
524
525   CAMLreturn (rv);
526 }
527
528 /* Automatically generated binding for virDomainCreateXML.
529  * In generator.pl this function has signature "conn, string, unsigned : dom".
530  */
531
532 CAMLprim value
533 ocaml_libvirt_domain_create_xml (value connv, value strv, value uv)
534 {
535   CAMLparam3 (connv, strv, uv);
536
537   CAMLlocal1 (rv);
538   virConnectPtr conn = Connect_val (connv);
539   char *str = String_val (strv);
540   unsigned int u = Int_val (uv);
541   virDomainPtr r;
542
543   NONBLOCKING (r = virDomainCreateXML (conn, str, u));
544   CHECK_ERROR (!r, "virDomainCreateXML");
545
546   rv = Val_domain (r, connv);
547
548   CAMLreturn (rv);
549 }
550
551 /* Automatically generated binding for virDomainFree.
552  * In generator.pl this function has signature "dom : free".
553  */
554
555 CAMLprim value
556 ocaml_libvirt_domain_free (value domv)
557 {
558   CAMLparam1 (domv);
559
560   virDomainPtr dom = Domain_val (domv);
561   int r;
562
563   NONBLOCKING (r = virDomainFree (dom));
564   CHECK_ERROR (r == -1, "virDomainFree");
565
566   /* So that we don't double-free in the finalizer: */
567   Domain_val (domv) = NULL;
568
569   CAMLreturn (Val_unit);
570 }
571
572 /* Automatically generated binding for virDomainDestroy.
573  * In generator.pl this function has signature "dom : free".
574  */
575
576 CAMLprim value
577 ocaml_libvirt_domain_destroy (value domv)
578 {
579   CAMLparam1 (domv);
580
581   virDomainPtr dom = Domain_val (domv);
582   int r;
583
584   NONBLOCKING (r = virDomainDestroy (dom));
585   CHECK_ERROR (r == -1, "virDomainDestroy");
586
587   /* So that we don't double-free in the finalizer: */
588   Domain_val (domv) = NULL;
589
590   CAMLreturn (Val_unit);
591 }
592
593 /* Automatically generated binding for virDomainLookupByName.
594  * In generator.pl this function has signature "conn, string : dom".
595  */
596
597 CAMLprim value
598 ocaml_libvirt_domain_lookup_by_name (value connv, value strv)
599 {
600   CAMLparam2 (connv, strv);
601
602   CAMLlocal1 (rv);
603   virConnectPtr conn = Connect_val (connv);
604   char *str = String_val (strv);
605   virDomainPtr r;
606
607   NONBLOCKING (r = virDomainLookupByName (conn, str));
608   CHECK_ERROR (!r, "virDomainLookupByName");
609
610   rv = Val_domain (r, connv);
611
612   CAMLreturn (rv);
613 }
614
615 /* Automatically generated binding for virDomainLookupByID.
616  * In generator.pl this function has signature "conn, int : dom".
617  */
618
619 CAMLprim value
620 ocaml_libvirt_domain_lookup_by_id (value connv, value iv)
621 {
622   CAMLparam2 (connv, iv);
623
624   CAMLlocal1 (rv);
625   virConnectPtr conn = Connect_val (connv);
626   int i = Int_val (iv);
627   virDomainPtr r;
628
629   NONBLOCKING (r = virDomainLookupByID (conn, i));
630   CHECK_ERROR (!r, "virDomainLookupByID");
631
632   rv = Val_domain (r, connv);
633
634   CAMLreturn (rv);
635 }
636
637 /* Automatically generated binding for virDomainLookupByUUID.
638  * In generator.pl this function has signature "conn, uuid : dom".
639  */
640
641 CAMLprim value
642 ocaml_libvirt_domain_lookup_by_uuid (value connv, value uuidv)
643 {
644   CAMLparam2 (connv, uuidv);
645
646   CAMLlocal1 (rv);
647   virConnectPtr conn = Connect_val (connv);
648   unsigned char *uuid = (unsigned char *) String_val (uuidv);
649   virDomainPtr r;
650
651   NONBLOCKING (r = virDomainLookupByUUID (conn, uuid));
652   CHECK_ERROR (!r, "virDomainLookupByUUID");
653
654   rv = Val_domain (r, connv);
655
656   CAMLreturn (rv);
657 }
658
659 /* Automatically generated binding for virDomainLookupByUUIDString.
660  * In generator.pl this function has signature "conn, string : dom".
661  */
662
663 CAMLprim value
664 ocaml_libvirt_domain_lookup_by_uuid_string (value connv, value strv)
665 {
666   CAMLparam2 (connv, strv);
667
668   CAMLlocal1 (rv);
669   virConnectPtr conn = Connect_val (connv);
670   char *str = String_val (strv);
671   virDomainPtr r;
672
673   NONBLOCKING (r = virDomainLookupByUUIDString (conn, str));
674   CHECK_ERROR (!r, "virDomainLookupByUUIDString");
675
676   rv = Val_domain (r, connv);
677
678   CAMLreturn (rv);
679 }
680
681 /* Automatically generated binding for virDomainGetName.
682  * In generator.pl this function has signature "dom : static string".
683  */
684
685 CAMLprim value
686 ocaml_libvirt_domain_get_name (value domv)
687 {
688   CAMLparam1 (domv);
689
690   CAMLlocal1 (rv);
691   virDomainPtr dom = Domain_val (domv);
692   const char *r;
693
694   NONBLOCKING (r = virDomainGetName (dom));
695   CHECK_ERROR (!r, "virDomainGetName");
696
697   rv = caml_copy_string (r);
698   CAMLreturn (rv);
699 }
700
701 /* Automatically generated binding for virDomainGetOSType.
702  * In generator.pl this function has signature "dom : string".
703  */
704
705 CAMLprim value
706 ocaml_libvirt_domain_get_os_type (value domv)
707 {
708   CAMLparam1 (domv);
709
710   CAMLlocal1 (rv);
711   virDomainPtr dom = Domain_val (domv);
712   char *r;
713
714   NONBLOCKING (r = virDomainGetOSType (dom));
715   CHECK_ERROR (!r, "virDomainGetOSType");
716
717   rv = caml_copy_string (r);
718   free (r);
719   CAMLreturn (rv);
720 }
721
722 /* Automatically generated binding for virDomainGetXMLDesc.
723  * In generator.pl this function has signature "dom, 0 : string".
724  */
725
726 CAMLprim value
727 ocaml_libvirt_domain_get_xml_desc (value domv)
728 {
729   CAMLparam1 (domv);
730
731   CAMLlocal1 (rv);
732   virDomainPtr dom = Domain_val (domv);
733   char *r;
734
735   NONBLOCKING (r = virDomainGetXMLDesc (dom, 0));
736   CHECK_ERROR (!r, "virDomainGetXMLDesc");
737
738   rv = caml_copy_string (r);
739   free (r);
740   CAMLreturn (rv);
741 }
742
743 /* Automatically generated binding for virDomainGetUUID.
744  * In generator.pl this function has signature "dom : uuid".
745  */
746
747 CAMLprim value
748 ocaml_libvirt_domain_get_uuid (value domv)
749 {
750   CAMLparam1 (domv);
751
752   CAMLlocal1 (rv);
753   virDomainPtr dom = Domain_val (domv);
754   unsigned char uuid[VIR_UUID_BUFLEN];
755   int r;
756
757   NONBLOCKING (r = virDomainGetUUID (dom, uuid));
758   CHECK_ERROR (r == -1, "virDomainGetUUID");
759
760   /* UUIDs are byte arrays with a fixed length. */
761   rv = caml_alloc_string (VIR_UUID_BUFLEN);
762   memcpy (String_val (rv), uuid, VIR_UUID_BUFLEN);
763   CAMLreturn (rv);
764 }
765
766 /* Automatically generated binding for virDomainGetUUIDString.
767  * In generator.pl this function has signature "dom : uuid string".
768  */
769
770 CAMLprim value
771 ocaml_libvirt_domain_get_uuid_string (value domv)
772 {
773   CAMLparam1 (domv);
774
775   CAMLlocal1 (rv);
776   virDomainPtr dom = Domain_val (domv);
777   char uuid[VIR_UUID_STRING_BUFLEN];
778   int r;
779
780   NONBLOCKING (r = virDomainGetUUIDString (dom, uuid));
781   CHECK_ERROR (r == -1, "virDomainGetUUIDString");
782
783   rv = caml_copy_string (uuid);
784   CAMLreturn (rv);
785 }
786
787 /* Automatically generated binding for virDomainGetMaxVcpus.
788  * In generator.pl this function has signature "dom : int".
789  */
790
791 CAMLprim value
792 ocaml_libvirt_domain_get_max_vcpus (value domv)
793 {
794   CAMLparam1 (domv);
795
796   virDomainPtr dom = Domain_val (domv);
797   int r;
798
799   NONBLOCKING (r = virDomainGetMaxVcpus (dom));
800   CHECK_ERROR (r == -1, "virDomainGetMaxVcpus");
801
802   CAMLreturn (Val_int (r));
803 }
804
805 /* Automatically generated binding for virDomainSave.
806  * In generator.pl this function has signature "dom, string : unit".
807  */
808
809 CAMLprim value
810 ocaml_libvirt_domain_save (value domv, value strv)
811 {
812   CAMLparam2 (domv, strv);
813
814   virDomainPtr dom = Domain_val (domv);
815   char *str = String_val (strv);
816   int r;
817
818   NONBLOCKING (r = virDomainSave (dom, str));
819   CHECK_ERROR (r == -1, "virDomainSave");
820
821   CAMLreturn (Val_unit);
822 }
823
824 /* Automatically generated binding for virDomainRestore.
825  * In generator.pl this function has signature "conn, string : unit".
826  */
827
828 CAMLprim value
829 ocaml_libvirt_domain_restore (value connv, value strv)
830 {
831   CAMLparam2 (connv, strv);
832
833   virConnectPtr conn = Connect_val (connv);
834   char *str = String_val (strv);
835   int r;
836
837   NONBLOCKING (r = virDomainRestore (conn, str));
838   CHECK_ERROR (r == -1, "virDomainRestore");
839
840   CAMLreturn (Val_unit);
841 }
842
843 /* Automatically generated binding for virDomainCoreDump.
844  * In generator.pl this function has signature "dom, string, 0 : unit".
845  */
846
847 CAMLprim value
848 ocaml_libvirt_domain_core_dump (value domv, value strv)
849 {
850   CAMLparam2 (domv, strv);
851
852   CAMLlocal1 (rv);
853   virDomainPtr dom = Domain_val (domv);
854   char *str = String_val (strv);
855   int r;
856
857   NONBLOCKING (r = virDomainCoreDump (dom, str, 0));
858   CHECK_ERROR (!r, "virDomainCoreDump");
859
860   CAMLreturn (Val_unit);
861 }
862
863 /* Automatically generated binding for virDomainSuspend.
864  * In generator.pl this function has signature "dom : unit".
865  */
866
867 CAMLprim value
868 ocaml_libvirt_domain_suspend (value domv)
869 {
870   CAMLparam1 (domv);
871
872   virDomainPtr dom = Domain_val (domv);
873   int r;
874
875   NONBLOCKING (r = virDomainSuspend (dom));
876   CHECK_ERROR (r == -1, "virDomainSuspend");
877
878   CAMLreturn (Val_unit);
879 }
880
881 /* Automatically generated binding for virDomainResume.
882  * In generator.pl this function has signature "dom : unit".
883  */
884
885 CAMLprim value
886 ocaml_libvirt_domain_resume (value domv)
887 {
888   CAMLparam1 (domv);
889
890   virDomainPtr dom = Domain_val (domv);
891   int r;
892
893   NONBLOCKING (r = virDomainResume (dom));
894   CHECK_ERROR (r == -1, "virDomainResume");
895
896   CAMLreturn (Val_unit);
897 }
898
899 /* Automatically generated binding for virDomainShutdown.
900  * In generator.pl this function has signature "dom : unit".
901  */
902
903 CAMLprim value
904 ocaml_libvirt_domain_shutdown (value domv)
905 {
906   CAMLparam1 (domv);
907
908   virDomainPtr dom = Domain_val (domv);
909   int r;
910
911   NONBLOCKING (r = virDomainShutdown (dom));
912   CHECK_ERROR (r == -1, "virDomainShutdown");
913
914   CAMLreturn (Val_unit);
915 }
916
917 /* Automatically generated binding for virDomainReboot.
918  * In generator.pl this function has signature "dom, 0 : unit".
919  */
920
921 CAMLprim value
922 ocaml_libvirt_domain_reboot (value domv)
923 {
924   CAMLparam1 (domv);
925
926   virDomainPtr dom = Domain_val (domv);
927   int r;
928
929   NONBLOCKING (r = virDomainReboot (dom, 0));
930   CHECK_ERROR (r == -1, "virDomainReboot");
931
932   CAMLreturn (Val_unit);
933 }
934
935 /* Automatically generated binding for virDomainDefineXML.
936  * In generator.pl this function has signature "conn, string : dom".
937  */
938
939 CAMLprim value
940 ocaml_libvirt_domain_define_xml (value connv, value strv)
941 {
942   CAMLparam2 (connv, strv);
943
944   CAMLlocal1 (rv);
945   virConnectPtr conn = Connect_val (connv);
946   char *str = String_val (strv);
947   virDomainPtr r;
948
949   NONBLOCKING (r = virDomainDefineXML (conn, str));
950   CHECK_ERROR (!r, "virDomainDefineXML");
951
952   rv = Val_domain (r, connv);
953
954   CAMLreturn (rv);
955 }
956
957 /* Automatically generated binding for virDomainUndefine.
958  * In generator.pl this function has signature "dom : unit".
959  */
960
961 CAMLprim value
962 ocaml_libvirt_domain_undefine (value domv)
963 {
964   CAMLparam1 (domv);
965
966   virDomainPtr dom = Domain_val (domv);
967   int r;
968
969   NONBLOCKING (r = virDomainUndefine (dom));
970   CHECK_ERROR (r == -1, "virDomainUndefine");
971
972   CAMLreturn (Val_unit);
973 }
974
975 /* Automatically generated binding for virDomainCreate.
976  * In generator.pl this function has signature "dom : unit".
977  */
978
979 CAMLprim value
980 ocaml_libvirt_domain_create (value domv)
981 {
982   CAMLparam1 (domv);
983
984   virDomainPtr dom = Domain_val (domv);
985   int r;
986
987   NONBLOCKING (r = virDomainCreate (dom));
988   CHECK_ERROR (r == -1, "virDomainCreate");
989
990   CAMLreturn (Val_unit);
991 }
992
993 /* Automatically generated binding for virDomainAttachDevice.
994  * In generator.pl this function has signature "dom, string : unit".
995  */
996
997 CAMLprim value
998 ocaml_libvirt_domain_attach_device (value domv, value strv)
999 {
1000   CAMLparam2 (domv, strv);
1001
1002   virDomainPtr dom = Domain_val (domv);
1003   char *str = String_val (strv);
1004   int r;
1005
1006   NONBLOCKING (r = virDomainAttachDevice (dom, str));
1007   CHECK_ERROR (r == -1, "virDomainAttachDevice");
1008
1009   CAMLreturn (Val_unit);
1010 }
1011
1012 /* Automatically generated binding for virDomainDetachDevice.
1013  * In generator.pl this function has signature "dom, string : unit".
1014  */
1015
1016 CAMLprim value
1017 ocaml_libvirt_domain_detach_device (value domv, value strv)
1018 {
1019   CAMLparam2 (domv, strv);
1020
1021   virDomainPtr dom = Domain_val (domv);
1022   char *str = String_val (strv);
1023   int r;
1024
1025   NONBLOCKING (r = virDomainDetachDevice (dom, str));
1026   CHECK_ERROR (r == -1, "virDomainDetachDevice");
1027
1028   CAMLreturn (Val_unit);
1029 }
1030
1031 /* Automatically generated binding for virDomainGetAutostart.
1032  * In generator.pl this function has signature "dom : bool".
1033  */
1034
1035 CAMLprim value
1036 ocaml_libvirt_domain_get_autostart (value domv)
1037 {
1038   CAMLparam1 (domv);
1039
1040   virDomainPtr dom = Domain_val (domv);
1041   int r, b;
1042
1043   NONBLOCKING (r = virDomainGetAutostart (dom, &b));
1044   CHECK_ERROR (r == -1, "virDomainGetAutostart");
1045
1046   CAMLreturn (b ? Val_true : Val_false);
1047 }
1048
1049 /* Automatically generated binding for virDomainSetAutostart.
1050  * In generator.pl this function has signature "dom, bool : unit".
1051  */
1052
1053 CAMLprim value
1054 ocaml_libvirt_domain_set_autostart (value domv, value bv)
1055 {
1056   CAMLparam2 (domv, bv);
1057
1058   virDomainPtr dom = Domain_val (domv);
1059   int r, b;
1060
1061   b = bv == Val_true ? 1 : 0;
1062
1063   NONBLOCKING (r = virDomainSetAutostart (dom, b));
1064   CHECK_ERROR (r == -1, "virDomainSetAutostart");
1065
1066   CAMLreturn (Val_unit);
1067 }
1068
1069 /* Automatically generated binding for virNetworkFree.
1070  * In generator.pl this function has signature "net : free".
1071  */
1072
1073 CAMLprim value
1074 ocaml_libvirt_network_free (value netv)
1075 {
1076   CAMLparam1 (netv);
1077
1078   virNetworkPtr net = Network_val (netv);
1079   int r;
1080
1081   NONBLOCKING (r = virNetworkFree (net));
1082   CHECK_ERROR (r == -1, "virNetworkFree");
1083
1084   /* So that we don't double-free in the finalizer: */
1085   Network_val (netv) = NULL;
1086
1087   CAMLreturn (Val_unit);
1088 }
1089
1090 /* Automatically generated binding for virNetworkDestroy.
1091  * In generator.pl this function has signature "net : free".
1092  */
1093
1094 CAMLprim value
1095 ocaml_libvirt_network_destroy (value netv)
1096 {
1097   CAMLparam1 (netv);
1098
1099   virNetworkPtr net = Network_val (netv);
1100   int r;
1101
1102   NONBLOCKING (r = virNetworkDestroy (net));
1103   CHECK_ERROR (r == -1, "virNetworkDestroy");
1104
1105   /* So that we don't double-free in the finalizer: */
1106   Network_val (netv) = NULL;
1107
1108   CAMLreturn (Val_unit);
1109 }
1110
1111 /* Automatically generated binding for virNetworkLookupByName.
1112  * In generator.pl this function has signature "conn, string : net".
1113  */
1114
1115 CAMLprim value
1116 ocaml_libvirt_network_lookup_by_name (value connv, value strv)
1117 {
1118   CAMLparam2 (connv, strv);
1119
1120   CAMLlocal1 (rv);
1121   virConnectPtr conn = Connect_val (connv);
1122   char *str = String_val (strv);
1123   virNetworkPtr r;
1124
1125   NONBLOCKING (r = virNetworkLookupByName (conn, str));
1126   CHECK_ERROR (!r, "virNetworkLookupByName");
1127
1128   rv = Val_network (r, connv);
1129
1130   CAMLreturn (rv);
1131 }
1132
1133 /* Automatically generated binding for virNetworkLookupByUUID.
1134  * In generator.pl this function has signature "conn, uuid : net".
1135  */
1136
1137 CAMLprim value
1138 ocaml_libvirt_network_lookup_by_uuid (value connv, value uuidv)
1139 {
1140   CAMLparam2 (connv, uuidv);
1141
1142   CAMLlocal1 (rv);
1143   virConnectPtr conn = Connect_val (connv);
1144   unsigned char *uuid = (unsigned char *) String_val (uuidv);
1145   virNetworkPtr r;
1146
1147   NONBLOCKING (r = virNetworkLookupByUUID (conn, uuid));
1148   CHECK_ERROR (!r, "virNetworkLookupByUUID");
1149
1150   rv = Val_network (r, connv);
1151
1152   CAMLreturn (rv);
1153 }
1154
1155 /* Automatically generated binding for virNetworkLookupByUUIDString.
1156  * In generator.pl this function has signature "conn, string : net".
1157  */
1158
1159 CAMLprim value
1160 ocaml_libvirt_network_lookup_by_uuid_string (value connv, value strv)
1161 {
1162   CAMLparam2 (connv, strv);
1163
1164   CAMLlocal1 (rv);
1165   virConnectPtr conn = Connect_val (connv);
1166   char *str = String_val (strv);
1167   virNetworkPtr r;
1168
1169   NONBLOCKING (r = virNetworkLookupByUUIDString (conn, str));
1170   CHECK_ERROR (!r, "virNetworkLookupByUUIDString");
1171
1172   rv = Val_network (r, connv);
1173
1174   CAMLreturn (rv);
1175 }
1176
1177 /* Automatically generated binding for virNetworkGetName.
1178  * In generator.pl this function has signature "net : static string".
1179  */
1180
1181 CAMLprim value
1182 ocaml_libvirt_network_get_name (value netv)
1183 {
1184   CAMLparam1 (netv);
1185
1186   CAMLlocal1 (rv);
1187   virNetworkPtr net = Network_val (netv);
1188   const char *r;
1189
1190   NONBLOCKING (r = virNetworkGetName (net));
1191   CHECK_ERROR (!r, "virNetworkGetName");
1192
1193   rv = caml_copy_string (r);
1194   CAMLreturn (rv);
1195 }
1196
1197 /* Automatically generated binding for virNetworkGetXMLDesc.
1198  * In generator.pl this function has signature "net, 0 : string".
1199  */
1200
1201 CAMLprim value
1202 ocaml_libvirt_network_get_xml_desc (value netv)
1203 {
1204   CAMLparam1 (netv);
1205
1206   CAMLlocal1 (rv);
1207   virNetworkPtr net = Network_val (netv);
1208   char *r;
1209
1210   NONBLOCKING (r = virNetworkGetXMLDesc (net, 0));
1211   CHECK_ERROR (!r, "virNetworkGetXMLDesc");
1212
1213   rv = caml_copy_string (r);
1214   free (r);
1215   CAMLreturn (rv);
1216 }
1217
1218 /* Automatically generated binding for virNetworkGetBridgeName.
1219  * In generator.pl this function has signature "net : string".
1220  */
1221
1222 CAMLprim value
1223 ocaml_libvirt_network_get_bridge_name (value netv)
1224 {
1225   CAMLparam1 (netv);
1226
1227   CAMLlocal1 (rv);
1228   virNetworkPtr net = Network_val (netv);
1229   char *r;
1230
1231   NONBLOCKING (r = virNetworkGetBridgeName (net));
1232   CHECK_ERROR (!r, "virNetworkGetBridgeName");
1233
1234   rv = caml_copy_string (r);
1235   free (r);
1236   CAMLreturn (rv);
1237 }
1238
1239 /* Automatically generated binding for virNetworkGetUUID.
1240  * In generator.pl this function has signature "net : uuid".
1241  */
1242
1243 CAMLprim value
1244 ocaml_libvirt_network_get_uuid (value netv)
1245 {
1246   CAMLparam1 (netv);
1247
1248   CAMLlocal1 (rv);
1249   virNetworkPtr net = Network_val (netv);
1250   unsigned char uuid[VIR_UUID_BUFLEN];
1251   int r;
1252
1253   NONBLOCKING (r = virNetworkGetUUID (net, uuid));
1254   CHECK_ERROR (r == -1, "virNetworkGetUUID");
1255
1256   /* UUIDs are byte arrays with a fixed length. */
1257   rv = caml_alloc_string (VIR_UUID_BUFLEN);
1258   memcpy (String_val (rv), uuid, VIR_UUID_BUFLEN);
1259   CAMLreturn (rv);
1260 }
1261
1262 /* Automatically generated binding for virNetworkGetUUIDString.
1263  * In generator.pl this function has signature "net : uuid string".
1264  */
1265
1266 CAMLprim value
1267 ocaml_libvirt_network_get_uuid_string (value netv)
1268 {
1269   CAMLparam1 (netv);
1270
1271   CAMLlocal1 (rv);
1272   virNetworkPtr net = Network_val (netv);
1273   char uuid[VIR_UUID_STRING_BUFLEN];
1274   int r;
1275
1276   NONBLOCKING (r = virNetworkGetUUIDString (net, uuid));
1277   CHECK_ERROR (r == -1, "virNetworkGetUUIDString");
1278
1279   rv = caml_copy_string (uuid);
1280   CAMLreturn (rv);
1281 }
1282
1283 /* Automatically generated binding for virNetworkUndefine.
1284  * In generator.pl this function has signature "net : unit".
1285  */
1286
1287 CAMLprim value
1288 ocaml_libvirt_network_undefine (value netv)
1289 {
1290   CAMLparam1 (netv);
1291
1292   virNetworkPtr net = Network_val (netv);
1293   int r;
1294
1295   NONBLOCKING (r = virNetworkUndefine (net));
1296   CHECK_ERROR (r == -1, "virNetworkUndefine");
1297
1298   CAMLreturn (Val_unit);
1299 }
1300
1301 /* Automatically generated binding for virNetworkCreateXML.
1302  * In generator.pl this function has signature "conn, string : net".
1303  */
1304
1305 CAMLprim value
1306 ocaml_libvirt_network_create_xml (value connv, value strv)
1307 {
1308   CAMLparam2 (connv, strv);
1309
1310   CAMLlocal1 (rv);
1311   virConnectPtr conn = Connect_val (connv);
1312   char *str = String_val (strv);
1313   virNetworkPtr r;
1314
1315   NONBLOCKING (r = virNetworkCreateXML (conn, str));
1316   CHECK_ERROR (!r, "virNetworkCreateXML");
1317
1318   rv = Val_network (r, connv);
1319
1320   CAMLreturn (rv);
1321 }
1322
1323 /* Automatically generated binding for virNetworkDefineXML.
1324  * In generator.pl this function has signature "conn, string : net".
1325  */
1326
1327 CAMLprim value
1328 ocaml_libvirt_network_define_xml (value connv, value strv)
1329 {
1330   CAMLparam2 (connv, strv);
1331
1332   CAMLlocal1 (rv);
1333   virConnectPtr conn = Connect_val (connv);
1334   char *str = String_val (strv);
1335   virNetworkPtr r;
1336
1337   NONBLOCKING (r = virNetworkDefineXML (conn, str));
1338   CHECK_ERROR (!r, "virNetworkDefineXML");
1339
1340   rv = Val_network (r, connv);
1341
1342   CAMLreturn (rv);
1343 }
1344
1345 /* Automatically generated binding for virNetworkCreate.
1346  * In generator.pl this function has signature "net : unit".
1347  */
1348
1349 CAMLprim value
1350 ocaml_libvirt_network_create (value netv)
1351 {
1352   CAMLparam1 (netv);
1353
1354   virNetworkPtr net = Network_val (netv);
1355   int r;
1356
1357   NONBLOCKING (r = virNetworkCreate (net));
1358   CHECK_ERROR (r == -1, "virNetworkCreate");
1359
1360   CAMLreturn (Val_unit);
1361 }
1362
1363 /* Automatically generated binding for virNetworkGetAutostart.
1364  * In generator.pl this function has signature "net : bool".
1365  */
1366
1367 CAMLprim value
1368 ocaml_libvirt_network_get_autostart (value netv)
1369 {
1370   CAMLparam1 (netv);
1371
1372   virNetworkPtr net = Network_val (netv);
1373   int r, b;
1374
1375   NONBLOCKING (r = virNetworkGetAutostart (net, &b));
1376   CHECK_ERROR (r == -1, "virNetworkGetAutostart");
1377
1378   CAMLreturn (b ? Val_true : Val_false);
1379 }
1380
1381 /* Automatically generated binding for virNetworkSetAutostart.
1382  * In generator.pl this function has signature "net, bool : unit".
1383  */
1384
1385 CAMLprim value
1386 ocaml_libvirt_network_set_autostart (value netv, value bv)
1387 {
1388   CAMLparam2 (netv, bv);
1389
1390   virNetworkPtr net = Network_val (netv);
1391   int r, b;
1392
1393   b = bv == Val_true ? 1 : 0;
1394
1395   NONBLOCKING (r = virNetworkSetAutostart (net, b));
1396   CHECK_ERROR (r == -1, "virNetworkSetAutostart");
1397
1398   CAMLreturn (Val_unit);
1399 }
1400
1401 /* Automatically generated binding for virStoragePoolFree.
1402  * In generator.pl this function has signature "pool : free".
1403  */
1404
1405 CAMLprim value
1406 ocaml_libvirt_storage_pool_free (value poolv)
1407 {
1408   CAMLparam1 (poolv);
1409
1410   virStoragePoolPtr pool = Pool_val (poolv);
1411   int r;
1412
1413   NONBLOCKING (r = virStoragePoolFree (pool));
1414   CHECK_ERROR (r == -1, "virStoragePoolFree");
1415
1416   /* So that we don't double-free in the finalizer: */
1417   Pool_val (poolv) = NULL;
1418
1419   CAMLreturn (Val_unit);
1420 }
1421
1422 /* Automatically generated binding for virStoragePoolDestroy.
1423  * In generator.pl this function has signature "pool : free".
1424  */
1425
1426 CAMLprim value
1427 ocaml_libvirt_storage_pool_destroy (value poolv)
1428 {
1429   CAMLparam1 (poolv);
1430
1431   virStoragePoolPtr pool = Pool_val (poolv);
1432   int r;
1433
1434   NONBLOCKING (r = virStoragePoolDestroy (pool));
1435   CHECK_ERROR (r == -1, "virStoragePoolDestroy");
1436
1437   /* So that we don't double-free in the finalizer: */
1438   Pool_val (poolv) = NULL;
1439
1440   CAMLreturn (Val_unit);
1441 }
1442
1443 /* Automatically generated binding for virStoragePoolLookupByName.
1444  * In generator.pl this function has signature "conn, string : pool".
1445  */
1446
1447 CAMLprim value
1448 ocaml_libvirt_storage_pool_lookup_by_name (value connv, value strv)
1449 {
1450   CAMLparam2 (connv, strv);
1451
1452   CAMLlocal1 (rv);
1453   virConnectPtr conn = Connect_val (connv);
1454   char *str = String_val (strv);
1455   virStoragePoolPtr r;
1456
1457   NONBLOCKING (r = virStoragePoolLookupByName (conn, str));
1458   CHECK_ERROR (!r, "virStoragePoolLookupByName");
1459
1460   rv = Val_pool (r, connv);
1461
1462   CAMLreturn (rv);
1463 }
1464
1465 /* Automatically generated binding for virStoragePoolLookupByUUID.
1466  * In generator.pl this function has signature "conn, uuid : pool".
1467  */
1468
1469 CAMLprim value
1470 ocaml_libvirt_storage_pool_lookup_by_uuid (value connv, value uuidv)
1471 {
1472   CAMLparam2 (connv, uuidv);
1473
1474   CAMLlocal1 (rv);
1475   virConnectPtr conn = Connect_val (connv);
1476   unsigned char *uuid = (unsigned char *) String_val (uuidv);
1477   virStoragePoolPtr r;
1478
1479   NONBLOCKING (r = virStoragePoolLookupByUUID (conn, uuid));
1480   CHECK_ERROR (!r, "virStoragePoolLookupByUUID");
1481
1482   rv = Val_pool (r, connv);
1483
1484   CAMLreturn (rv);
1485 }
1486
1487 /* Automatically generated binding for virStoragePoolLookupByUUIDString.
1488  * In generator.pl this function has signature "conn, string : pool".
1489  */
1490
1491 CAMLprim value
1492 ocaml_libvirt_storage_pool_lookup_by_uuid_string (value connv, value strv)
1493 {
1494   CAMLparam2 (connv, strv);
1495
1496   CAMLlocal1 (rv);
1497   virConnectPtr conn = Connect_val (connv);
1498   char *str = String_val (strv);
1499   virStoragePoolPtr r;
1500
1501   NONBLOCKING (r = virStoragePoolLookupByUUIDString (conn, str));
1502   CHECK_ERROR (!r, "virStoragePoolLookupByUUIDString");
1503
1504   rv = Val_pool (r, connv);
1505
1506   CAMLreturn (rv);
1507 }
1508
1509 /* Automatically generated binding for virStoragePoolGetName.
1510  * In generator.pl this function has signature "pool : static string".
1511  */
1512
1513 CAMLprim value
1514 ocaml_libvirt_storage_pool_get_name (value poolv)
1515 {
1516   CAMLparam1 (poolv);
1517
1518   CAMLlocal1 (rv);
1519   virStoragePoolPtr pool = Pool_val (poolv);
1520   const char *r;
1521
1522   NONBLOCKING (r = virStoragePoolGetName (pool));
1523   CHECK_ERROR (!r, "virStoragePoolGetName");
1524
1525   rv = caml_copy_string (r);
1526   CAMLreturn (rv);
1527 }
1528
1529 /* Automatically generated binding for virStoragePoolGetXMLDesc.
1530  * In generator.pl this function has signature "pool, 0U : string".
1531  */
1532
1533 CAMLprim value
1534 ocaml_libvirt_storage_pool_get_xml_desc (value poolv)
1535 {
1536   CAMLparam1 (poolv);
1537
1538   CAMLlocal1 (rv);
1539   virStoragePoolPtr pool = Pool_val (poolv);
1540   char *r;
1541
1542   NONBLOCKING (r = virStoragePoolGetXMLDesc (pool, 0));
1543   CHECK_ERROR (!r, "virStoragePoolGetXMLDesc");
1544
1545   rv = caml_copy_string (r);
1546   free (r);
1547   CAMLreturn (rv);
1548 }
1549
1550 /* Automatically generated binding for virStoragePoolGetUUID.
1551  * In generator.pl this function has signature "pool : uuid".
1552  */
1553
1554 CAMLprim value
1555 ocaml_libvirt_storage_pool_get_uuid (value poolv)
1556 {
1557   CAMLparam1 (poolv);
1558
1559   CAMLlocal1 (rv);
1560   virStoragePoolPtr pool = Pool_val (poolv);
1561   unsigned char uuid[VIR_UUID_BUFLEN];
1562   int r;
1563
1564   NONBLOCKING (r = virStoragePoolGetUUID (pool, uuid));
1565   CHECK_ERROR (r == -1, "virStoragePoolGetUUID");
1566
1567   /* UUIDs are byte arrays with a fixed length. */
1568   rv = caml_alloc_string (VIR_UUID_BUFLEN);
1569   memcpy (String_val (rv), uuid, VIR_UUID_BUFLEN);
1570   CAMLreturn (rv);
1571 }
1572
1573 /* Automatically generated binding for virStoragePoolGetUUIDString.
1574  * In generator.pl this function has signature "pool : uuid string".
1575  */
1576
1577 CAMLprim value
1578 ocaml_libvirt_storage_pool_get_uuid_string (value poolv)
1579 {
1580   CAMLparam1 (poolv);
1581
1582   CAMLlocal1 (rv);
1583   virStoragePoolPtr pool = Pool_val (poolv);
1584   char uuid[VIR_UUID_STRING_BUFLEN];
1585   int r;
1586
1587   NONBLOCKING (r = virStoragePoolGetUUIDString (pool, uuid));
1588   CHECK_ERROR (r == -1, "virStoragePoolGetUUIDString");
1589
1590   rv = caml_copy_string (uuid);
1591   CAMLreturn (rv);
1592 }
1593
1594 /* Automatically generated binding for virStoragePoolCreateXML.
1595  * In generator.pl this function has signature "conn, string, 0U : pool".
1596  */
1597
1598 CAMLprim value
1599 ocaml_libvirt_storage_pool_create_xml (value connv, value strv)
1600 {
1601   CAMLparam2 (connv, strv);
1602
1603   CAMLlocal1 (rv);
1604   virConnectPtr conn = Connect_val (connv);
1605   char *str = String_val (strv);
1606   virStoragePoolPtr r;
1607
1608   NONBLOCKING (r = virStoragePoolCreateXML (conn, str, 0));
1609   CHECK_ERROR (!r, "virStoragePoolCreateXML");
1610
1611   rv = Val_pool (r, connv);
1612
1613   CAMLreturn (rv);
1614 }
1615
1616 /* Automatically generated binding for virStoragePoolDefineXML.
1617  * In generator.pl this function has signature "conn, string, 0U : pool".
1618  */
1619
1620 CAMLprim value
1621 ocaml_libvirt_storage_pool_define_xml (value connv, value strv)
1622 {
1623   CAMLparam2 (connv, strv);
1624
1625   CAMLlocal1 (rv);
1626   virConnectPtr conn = Connect_val (connv);
1627   char *str = String_val (strv);
1628   virStoragePoolPtr r;
1629
1630   NONBLOCKING (r = virStoragePoolDefineXML (conn, str, 0));
1631   CHECK_ERROR (!r, "virStoragePoolDefineXML");
1632
1633   rv = Val_pool (r, connv);
1634
1635   CAMLreturn (rv);
1636 }
1637
1638 /* Automatically generated binding for virStoragePoolBuild.
1639  * In generator.pl this function has signature "pool, uint : unit".
1640  */
1641
1642 CAMLprim value
1643 ocaml_libvirt_storage_pool_build (value poolv, value iv)
1644 {
1645   CAMLparam2 (poolv, iv);
1646
1647   virStoragePoolPtr pool = Pool_val (poolv);
1648   unsigned int i = Int_val (iv);
1649   int r;
1650
1651   NONBLOCKING (r = virStoragePoolBuild (pool, i));
1652   CHECK_ERROR (r == -1, "virStoragePoolBuild");
1653
1654   CAMLreturn (Val_unit);
1655 }
1656
1657 /* Automatically generated binding for virStoragePoolUndefine.
1658  * In generator.pl this function has signature "pool : unit".
1659  */
1660
1661 CAMLprim value
1662 ocaml_libvirt_storage_pool_undefine (value poolv)
1663 {
1664   CAMLparam1 (poolv);
1665
1666   virStoragePoolPtr pool = Pool_val (poolv);
1667   int r;
1668
1669   NONBLOCKING (r = virStoragePoolUndefine (pool));
1670   CHECK_ERROR (r == -1, "virStoragePoolUndefine");
1671
1672   CAMLreturn (Val_unit);
1673 }
1674
1675 /* Automatically generated binding for virStoragePoolCreate.
1676  * In generator.pl this function has signature "pool, 0U : unit".
1677  */
1678
1679 CAMLprim value
1680 ocaml_libvirt_storage_pool_create (value poolv)
1681 {
1682   CAMLparam1 (poolv);
1683
1684   virStoragePoolPtr pool = Pool_val (poolv);
1685   int r;
1686
1687   NONBLOCKING (r = virStoragePoolCreate (pool, 0));
1688   CHECK_ERROR (r == -1, "virStoragePoolCreate");
1689
1690   CAMLreturn (Val_unit);
1691 }
1692
1693 /* Automatically generated binding for virStoragePoolDelete.
1694  * In generator.pl this function has signature "pool, uint : unit".
1695  */
1696
1697 CAMLprim value
1698 ocaml_libvirt_storage_pool_delete (value poolv, value iv)
1699 {
1700   CAMLparam2 (poolv, iv);
1701
1702   virStoragePoolPtr pool = Pool_val (poolv);
1703   unsigned int i = Int_val (iv);
1704   int r;
1705
1706   NONBLOCKING (r = virStoragePoolDelete (pool, i));
1707   CHECK_ERROR (r == -1, "virStoragePoolDelete");
1708
1709   CAMLreturn (Val_unit);
1710 }
1711
1712 /* Automatically generated binding for virStoragePoolRefresh.
1713  * In generator.pl this function has signature "pool, 0U : unit".
1714  */
1715
1716 CAMLprim value
1717 ocaml_libvirt_storage_pool_refresh (value poolv)
1718 {
1719   CAMLparam1 (poolv);
1720
1721   virStoragePoolPtr pool = Pool_val (poolv);
1722   int r;
1723
1724   NONBLOCKING (r = virStoragePoolRefresh (pool, 0));
1725   CHECK_ERROR (r == -1, "virStoragePoolRefresh");
1726
1727   CAMLreturn (Val_unit);
1728 }
1729
1730 /* Automatically generated binding for virStoragePoolGetAutostart.
1731  * In generator.pl this function has signature "pool : bool".
1732  */
1733
1734 CAMLprim value
1735 ocaml_libvirt_storage_pool_get_autostart (value poolv)
1736 {
1737   CAMLparam1 (poolv);
1738
1739   virStoragePoolPtr pool = Pool_val (poolv);
1740   int r, b;
1741
1742   NONBLOCKING (r = virStoragePoolGetAutostart (pool, &b));
1743   CHECK_ERROR (r == -1, "virStoragePoolGetAutostart");
1744
1745   CAMLreturn (b ? Val_true : Val_false);
1746 }
1747
1748 /* Automatically generated binding for virStoragePoolSetAutostart.
1749  * In generator.pl this function has signature "pool, bool : unit".
1750  */
1751
1752 CAMLprim value
1753 ocaml_libvirt_storage_pool_set_autostart (value poolv, value bv)
1754 {
1755   CAMLparam2 (poolv, bv);
1756
1757   virStoragePoolPtr pool = Pool_val (poolv);
1758   int r, b;
1759
1760   b = bv == Val_true ? 1 : 0;
1761
1762   NONBLOCKING (r = virStoragePoolSetAutostart (pool, b));
1763   CHECK_ERROR (r == -1, "virStoragePoolSetAutostart");
1764
1765   CAMLreturn (Val_unit);
1766 }
1767
1768 /* Automatically generated binding for virStoragePoolNumOfVolumes.
1769  * In generator.pl this function has signature "pool : int".
1770  */
1771
1772 CAMLprim value
1773 ocaml_libvirt_storage_pool_num_of_volumes (value poolv)
1774 {
1775   CAMLparam1 (poolv);
1776
1777   virStoragePoolPtr pool = Pool_val (poolv);
1778   int r;
1779
1780   NONBLOCKING (r = virStoragePoolNumOfVolumes (pool));
1781   CHECK_ERROR (r == -1, "virStoragePoolNumOfVolumes");
1782
1783   CAMLreturn (Val_int (r));
1784 }
1785
1786 /* Automatically generated binding for virStoragePoolListVolumes.
1787  * In generator.pl this function has signature "pool, int : string array".
1788  */
1789
1790 CAMLprim value
1791 ocaml_libvirt_storage_pool_list_volumes (value poolv, value iv)
1792 {
1793   CAMLparam2 (poolv, iv);
1794
1795   CAMLlocal2 (rv, strv);
1796   virStoragePoolPtr pool = Pool_val (poolv);
1797   int i = Int_val (iv);
1798   char *names[i];
1799   int r;
1800
1801   /* Some libvirt List* functions still throw exceptions if i == 0,
1802    * so catch that and return an empty array directly.  This changes
1803    * the semantics slightly (masking other failures) but it's
1804    * unlikely anyone will care.  RWMJ 2008/06/10
1805    */
1806   if (i == 0) {
1807     rv = caml_alloc (0, 0);
1808     CAMLreturn (rv);
1809   }
1810
1811   NONBLOCKING (r = virStoragePoolListVolumes (pool, names, i));
1812   CHECK_ERROR (r == -1, "virStoragePoolListVolumes");
1813
1814   rv = caml_alloc (r, 0);
1815   for (i = 0; i < r; ++i) {
1816     strv = caml_copy_string (names[i]);
1817     Store_field (rv, i, strv);
1818     free (names[i]);
1819   }
1820
1821   CAMLreturn (rv);
1822 }
1823
1824 /* Automatically generated binding for virStorageVolFree.
1825  * In generator.pl this function has signature "vol : free".
1826  */
1827
1828 CAMLprim value
1829 ocaml_libvirt_storage_vol_free (value volv)
1830 {
1831   CAMLparam1 (volv);
1832
1833   virStorageVolPtr vol = Volume_val (volv);
1834   int r;
1835
1836   NONBLOCKING (r = virStorageVolFree (vol));
1837   CHECK_ERROR (r == -1, "virStorageVolFree");
1838
1839   /* So that we don't double-free in the finalizer: */
1840   Volume_val (volv) = NULL;
1841
1842   CAMLreturn (Val_unit);
1843 }
1844
1845 /* Automatically generated binding for virStorageVolDelete.
1846  * In generator.pl this function has signature "vol, uint : unit".
1847  */
1848
1849 CAMLprim value
1850 ocaml_libvirt_storage_vol_delete (value volv, value iv)
1851 {
1852   CAMLparam2 (volv, iv);
1853
1854   virStorageVolPtr vol = Volume_val (volv);
1855   unsigned int i = Int_val (iv);
1856   int r;
1857
1858   NONBLOCKING (r = virStorageVolDelete (vol, i));
1859   CHECK_ERROR (r == -1, "virStorageVolDelete");
1860
1861   CAMLreturn (Val_unit);
1862 }
1863
1864 /* Automatically generated binding for virStorageVolLookupByName.
1865  * In generator.pl this function has signature "pool, string : vol from pool".
1866  */
1867
1868 CAMLprim value
1869 ocaml_libvirt_storage_vol_lookup_by_name (value poolv, value strv)
1870 {
1871   CAMLparam2 (poolv, strv);
1872
1873   CAMLlocal2 (rv, connv);
1874   virStoragePoolPtr pool = Pool_val (poolv);
1875   char *str = String_val (strv);
1876   virStorageVolPtr r;
1877
1878   NONBLOCKING (r = virStorageVolLookupByName (pool, str));
1879   CHECK_ERROR (!r, "virStorageVolLookupByName");
1880
1881   connv = Field (poolv, 1);
1882   rv = Val_volume (r, connv);
1883
1884   CAMLreturn (rv);
1885 }
1886
1887 /* Automatically generated binding for virStorageVolLookupByKey.
1888  * In generator.pl this function has signature "conn, string : vol".
1889  */
1890
1891 CAMLprim value
1892 ocaml_libvirt_storage_vol_lookup_by_key (value connv, value strv)
1893 {
1894   CAMLparam2 (connv, strv);
1895
1896   CAMLlocal1 (rv);
1897   virConnectPtr conn = Connect_val (connv);
1898   char *str = String_val (strv);
1899   virStorageVolPtr r;
1900
1901   NONBLOCKING (r = virStorageVolLookupByKey (conn, str));
1902   CHECK_ERROR (!r, "virStorageVolLookupByKey");
1903
1904   rv = Val_volume (r, connv);
1905
1906   CAMLreturn (rv);
1907 }
1908
1909 /* Automatically generated binding for virStorageVolLookupByPath.
1910  * In generator.pl this function has signature "conn, string : vol".
1911  */
1912
1913 CAMLprim value
1914 ocaml_libvirt_storage_vol_lookup_by_path (value connv, value strv)
1915 {
1916   CAMLparam2 (connv, strv);
1917
1918   CAMLlocal1 (rv);
1919   virConnectPtr conn = Connect_val (connv);
1920   char *str = String_val (strv);
1921   virStorageVolPtr r;
1922
1923   NONBLOCKING (r = virStorageVolLookupByPath (conn, str));
1924   CHECK_ERROR (!r, "virStorageVolLookupByPath");
1925
1926   rv = Val_volume (r, connv);
1927
1928   CAMLreturn (rv);
1929 }
1930
1931 /* Automatically generated binding for virStorageVolCreateXML.
1932  * In generator.pl this function has signature "pool, string, 0U : vol from pool".
1933  */
1934
1935 CAMLprim value
1936 ocaml_libvirt_storage_vol_create_xml (value poolv, value strv)
1937 {
1938   CAMLparam2 (poolv, strv);
1939
1940   CAMLlocal2 (rv, connv);
1941   virStoragePoolPtr pool = Pool_val (poolv);
1942   char *str = String_val (strv);
1943   virStorageVolPtr r;
1944
1945   NONBLOCKING (r = virStorageVolCreateXML (pool, str, 0));
1946   CHECK_ERROR (!r, "virStorageVolCreateXML");
1947
1948   connv = Field (poolv, 1);
1949   rv = Val_volume (r, connv);
1950
1951   CAMLreturn (rv);
1952 }
1953
1954 /* Automatically generated binding for virStorageVolGetXMLDesc.
1955  * In generator.pl this function has signature "vol, 0U : string".
1956  */
1957
1958 CAMLprim value
1959 ocaml_libvirt_storage_vol_get_xml_desc (value volv)
1960 {
1961   CAMLparam1 (volv);
1962
1963   CAMLlocal1 (rv);
1964   virStorageVolPtr vol = Volume_val (volv);
1965   char *r;
1966
1967   NONBLOCKING (r = virStorageVolGetXMLDesc (vol, 0));
1968   CHECK_ERROR (!r, "virStorageVolGetXMLDesc");
1969
1970   rv = caml_copy_string (r);
1971   free (r);
1972   CAMLreturn (rv);
1973 }
1974
1975 /* Automatically generated binding for virStorageVolGetPath.
1976  * In generator.pl this function has signature "vol : string".
1977  */
1978
1979 CAMLprim value
1980 ocaml_libvirt_storage_vol_get_path (value volv)
1981 {
1982   CAMLparam1 (volv);
1983
1984   CAMLlocal1 (rv);
1985   virStorageVolPtr vol = Volume_val (volv);
1986   char *r;
1987
1988   NONBLOCKING (r = virStorageVolGetPath (vol));
1989   CHECK_ERROR (!r, "virStorageVolGetPath");
1990
1991   rv = caml_copy_string (r);
1992   free (r);
1993   CAMLreturn (rv);
1994 }
1995
1996 /* Automatically generated binding for virStorageVolGetKey.
1997  * In generator.pl this function has signature "vol : static string".
1998  */
1999
2000 CAMLprim value
2001 ocaml_libvirt_storage_vol_get_key (value volv)
2002 {
2003   CAMLparam1 (volv);
2004
2005   CAMLlocal1 (rv);
2006   virStorageVolPtr vol = Volume_val (volv);
2007   const char *r;
2008
2009   NONBLOCKING (r = virStorageVolGetKey (vol));
2010   CHECK_ERROR (!r, "virStorageVolGetKey");
2011
2012   rv = caml_copy_string (r);
2013   CAMLreturn (rv);
2014 }
2015
2016 /* Automatically generated binding for virStorageVolGetName.
2017  * In generator.pl this function has signature "vol : static string".
2018  */
2019
2020 CAMLprim value
2021 ocaml_libvirt_storage_vol_get_name (value volv)
2022 {
2023   CAMLparam1 (volv);
2024
2025   CAMLlocal1 (rv);
2026   virStorageVolPtr vol = Volume_val (volv);
2027   const char *r;
2028
2029   NONBLOCKING (r = virStorageVolGetName (vol));
2030   CHECK_ERROR (!r, "virStorageVolGetName");
2031
2032   rv = caml_copy_string (r);
2033   CAMLreturn (rv);
2034 }
2035
2036 /* Automatically generated binding for virStoragePoolLookupByVolume.
2037  * In generator.pl this function has signature "vol : pool from vol".
2038  */
2039
2040 CAMLprim value
2041 ocaml_libvirt_storage_pool_lookup_by_volume (value volv)
2042 {
2043   CAMLparam1 (volv);
2044
2045   CAMLlocal2 (rv, connv);
2046   virStorageVolPtr vol = Volume_val (volv);
2047   virStoragePoolPtr r;
2048
2049   NONBLOCKING (r = virStoragePoolLookupByVolume (vol));
2050   CHECK_ERROR (!r, "virStoragePoolLookupByVolume");
2051
2052   connv = Field (volv, 1);
2053   rv = Val_pool (r, connv);
2054
2055   CAMLreturn (rv);
2056 }
2057
2058 #include "libvirt_c_epilogue.c"
2059
2060 /* EOF */