Documentation updates.
[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 #ifdef HAVE_WEAK_SYMBOLS
51 #ifdef HAVE_VIRCONNECTGETHOSTNAME
52 extern char *virConnectGetHostname (virConnectPtr conn) __attribute__((weak));
53 #endif
54 #endif
55
56 CAMLprim value
57 ocaml_libvirt_connect_get_hostname (value connv)
58 {
59   CAMLparam1 (connv);
60 #ifndef HAVE_VIRCONNECTGETHOSTNAME
61   /* Symbol virConnectGetHostname not found at compile time. */
62   not_supported ("virConnectGetHostname");
63   /* Suppresses a compiler warning. */
64   (void) caml__frame;
65 #else
66   /* Check that the symbol virConnectGetHostname
67    * is in runtime version of libvirt.
68    */
69   WEAK_SYMBOL_CHECK (virConnectGetHostname);
70
71   CAMLlocal1 (rv);
72   virConnectPtr conn = Connect_val (connv);
73   char *r;
74
75   NONBLOCKING (r = virConnectGetHostname (conn));
76   CHECK_ERROR (!r, conn, "virConnectGetHostname");
77
78   rv = caml_copy_string (r);
79   free (r);
80   CAMLreturn (rv);
81 #endif
82 }
83
84 #ifdef HAVE_WEAK_SYMBOLS
85 #ifdef HAVE_VIRCONNECTGETURI
86 extern char *virConnectGetURI (virConnectPtr conn) __attribute__((weak));
87 #endif
88 #endif
89
90 CAMLprim value
91 ocaml_libvirt_connect_get_uri (value connv)
92 {
93   CAMLparam1 (connv);
94 #ifndef HAVE_VIRCONNECTGETURI
95   /* Symbol virConnectGetURI not found at compile time. */
96   not_supported ("virConnectGetURI");
97   /* Suppresses a compiler warning. */
98   (void) caml__frame;
99 #else
100   /* Check that the symbol virConnectGetURI
101    * is in runtime version of libvirt.
102    */
103   WEAK_SYMBOL_CHECK (virConnectGetURI);
104
105   CAMLlocal1 (rv);
106   virConnectPtr conn = Connect_val (connv);
107   char *r;
108
109   NONBLOCKING (r = virConnectGetURI (conn));
110   CHECK_ERROR (!r, conn, "virConnectGetURI");
111
112   rv = caml_copy_string (r);
113   free (r);
114   CAMLreturn (rv);
115 #endif
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, conn, "virConnectGetType");
129
130   rv = caml_copy_string (r);
131   CAMLreturn (rv);
132 }
133
134 CAMLprim value
135 ocaml_libvirt_connect_num_of_domains (value connv)
136 {
137   CAMLparam1 (connv);
138
139   virConnectPtr conn = Connect_val (connv);
140   int r;
141
142   NONBLOCKING (r = virConnectNumOfDomains (conn));
143   CHECK_ERROR (r == -1, conn, "virConnectNumOfDomains");
144
145   CAMLreturn (Val_int (r));
146 }
147
148 CAMLprim value
149 ocaml_libvirt_connect_list_domains (value connv, value iv)
150 {
151   CAMLparam2 (connv, iv);
152
153   CAMLlocal1 (rv);
154   virConnectPtr conn = Connect_val (connv);
155   int i = Int_val (iv);
156   int ids[i], r;
157
158   NONBLOCKING (r = virConnectListDomains (conn, ids, i));
159   CHECK_ERROR (r == -1, conn, "virConnectListDomains");
160
161   rv = caml_alloc (r, 0);
162   for (i = 0; i < r; ++i)
163     Store_field (rv, i, Val_int (ids[i]));
164
165   CAMLreturn (rv);
166 }
167
168 CAMLprim value
169 ocaml_libvirt_connect_num_of_defined_domains (value connv)
170 {
171   CAMLparam1 (connv);
172
173   virConnectPtr conn = Connect_val (connv);
174   int r;
175
176   NONBLOCKING (r = virConnectNumOfDefinedDomains (conn));
177   CHECK_ERROR (r == -1, conn, "virConnectNumOfDefinedDomains");
178
179   CAMLreturn (Val_int (r));
180 }
181
182 CAMLprim value
183 ocaml_libvirt_connect_list_defined_domains (value connv, value iv)
184 {
185   CAMLparam2 (connv, iv);
186
187   CAMLlocal2 (rv, strv);
188   virConnectPtr conn = Connect_val (connv);
189   int i = Int_val (iv);
190   char *names[i];
191   int r;
192
193   NONBLOCKING (r = virConnectListDefinedDomains (conn, names, i));
194   CHECK_ERROR (r == -1, conn, "virConnectListDefinedDomains");
195
196   rv = caml_alloc (r, 0);
197   for (i = 0; i < r; ++i) {
198     strv = caml_copy_string (names[i]);
199     Store_field (rv, i, strv);
200     free (names[i]);
201   }
202
203   CAMLreturn (rv);
204 }
205
206 CAMLprim value
207 ocaml_libvirt_connect_num_of_networks (value connv)
208 {
209   CAMLparam1 (connv);
210
211   virConnectPtr conn = Connect_val (connv);
212   int r;
213
214   NONBLOCKING (r = virConnectNumOfNetworks (conn));
215   CHECK_ERROR (r == -1, conn, "virConnectNumOfNetworks");
216
217   CAMLreturn (Val_int (r));
218 }
219
220 CAMLprim value
221 ocaml_libvirt_connect_list_networks (value connv, value iv)
222 {
223   CAMLparam2 (connv, iv);
224
225   CAMLlocal2 (rv, strv);
226   virConnectPtr conn = Connect_val (connv);
227   int i = Int_val (iv);
228   char *names[i];
229   int r;
230
231   NONBLOCKING (r = virConnectListNetworks (conn, names, i));
232   CHECK_ERROR (r == -1, conn, "virConnectListNetworks");
233
234   rv = caml_alloc (r, 0);
235   for (i = 0; i < r; ++i) {
236     strv = caml_copy_string (names[i]);
237     Store_field (rv, i, strv);
238     free (names[i]);
239   }
240
241   CAMLreturn (rv);
242 }
243
244 CAMLprim value
245 ocaml_libvirt_connect_num_of_defined_networks (value connv)
246 {
247   CAMLparam1 (connv);
248
249   virConnectPtr conn = Connect_val (connv);
250   int r;
251
252   NONBLOCKING (r = virConnectNumOfDefinedNetworks (conn));
253   CHECK_ERROR (r == -1, conn, "virConnectNumOfDefinedNetworks");
254
255   CAMLreturn (Val_int (r));
256 }
257
258 CAMLprim value
259 ocaml_libvirt_connect_list_defined_networks (value connv, value iv)
260 {
261   CAMLparam2 (connv, iv);
262
263   CAMLlocal2 (rv, strv);
264   virConnectPtr conn = Connect_val (connv);
265   int i = Int_val (iv);
266   char *names[i];
267   int r;
268
269   NONBLOCKING (r = virConnectListDefinedNetworks (conn, names, i));
270   CHECK_ERROR (r == -1, conn, "virConnectListDefinedNetworks");
271
272   rv = caml_alloc (r, 0);
273   for (i = 0; i < r; ++i) {
274     strv = caml_copy_string (names[i]);
275     Store_field (rv, i, strv);
276     free (names[i]);
277   }
278
279   CAMLreturn (rv);
280 }
281
282 #ifdef HAVE_WEAK_SYMBOLS
283 #ifdef HAVE_VIRCONNECTNUMOFSTORAGEPOOLS
284 extern int virConnectNumOfStoragePools (virConnectPtr conn) __attribute__((weak));
285 #endif
286 #endif
287
288 CAMLprim value
289 ocaml_libvirt_connect_num_of_storage_pools (value connv)
290 {
291   CAMLparam1 (connv);
292 #ifndef HAVE_VIRCONNECTNUMOFSTORAGEPOOLS
293   /* Symbol virConnectNumOfStoragePools not found at compile time. */
294   not_supported ("virConnectNumOfStoragePools");
295   /* Suppresses a compiler warning. */
296   (void) caml__frame;
297 #else
298   /* Check that the symbol virConnectNumOfStoragePools
299    * is in runtime version of libvirt.
300    */
301   WEAK_SYMBOL_CHECK (virConnectNumOfStoragePools);
302
303   virConnectPtr conn = Connect_val (connv);
304   int r;
305
306   NONBLOCKING (r = virConnectNumOfStoragePools (conn));
307   CHECK_ERROR (r == -1, conn, "virConnectNumOfStoragePools");
308
309   CAMLreturn (Val_int (r));
310 #endif
311 }
312
313 #ifdef HAVE_WEAK_SYMBOLS
314 #ifdef HAVE_VIRCONNECTLISTSTORAGEPOOLS
315 extern int virConnectListStoragePools (virConnectPtr conn, char **const names, int maxnames) __attribute__((weak));
316 #endif
317 #endif
318
319 CAMLprim value
320 ocaml_libvirt_connect_list_storage_pools (value connv, value iv)
321 {
322   CAMLparam2 (connv, iv);
323 #ifndef HAVE_VIRCONNECTLISTSTORAGEPOOLS
324   /* Symbol virConnectListStoragePools not found at compile time. */
325   not_supported ("virConnectListStoragePools");
326   /* Suppresses a compiler warning. */
327   (void) caml__frame;
328 #else
329   /* Check that the symbol virConnectListStoragePools
330    * is in runtime version of libvirt.
331    */
332   WEAK_SYMBOL_CHECK (virConnectListStoragePools);
333
334   CAMLlocal2 (rv, strv);
335   virConnectPtr conn = Connect_val (connv);
336   int i = Int_val (iv);
337   char *names[i];
338   int r;
339
340   NONBLOCKING (r = virConnectListStoragePools (conn, names, i));
341   CHECK_ERROR (r == -1, conn, "virConnectListStoragePools");
342
343   rv = caml_alloc (r, 0);
344   for (i = 0; i < r; ++i) {
345     strv = caml_copy_string (names[i]);
346     Store_field (rv, i, strv);
347     free (names[i]);
348   }
349
350   CAMLreturn (rv);
351 #endif
352 }
353
354 #ifdef HAVE_WEAK_SYMBOLS
355 #ifdef HAVE_VIRCONNECTNUMOFDEFINEDSTORAGEPOOLS
356 extern int virConnectNumOfDefinedStoragePools (virConnectPtr conn) __attribute__((weak));
357 #endif
358 #endif
359
360 CAMLprim value
361 ocaml_libvirt_connect_num_of_defined_storage_pools (value connv)
362 {
363   CAMLparam1 (connv);
364 #ifndef HAVE_VIRCONNECTNUMOFDEFINEDSTORAGEPOOLS
365   /* Symbol virConnectNumOfDefinedStoragePools not found at compile time. */
366   not_supported ("virConnectNumOfDefinedStoragePools");
367   /* Suppresses a compiler warning. */
368   (void) caml__frame;
369 #else
370   /* Check that the symbol virConnectNumOfDefinedStoragePools
371    * is in runtime version of libvirt.
372    */
373   WEAK_SYMBOL_CHECK (virConnectNumOfDefinedStoragePools);
374
375   virConnectPtr conn = Connect_val (connv);
376   int r;
377
378   NONBLOCKING (r = virConnectNumOfDefinedStoragePools (conn));
379   CHECK_ERROR (r == -1, conn, "virConnectNumOfDefinedStoragePools");
380
381   CAMLreturn (Val_int (r));
382 #endif
383 }
384
385 #ifdef HAVE_WEAK_SYMBOLS
386 #ifdef HAVE_VIRCONNECTLISTDEFINEDSTORAGEPOOLS
387 extern int virConnectListDefinedStoragePools (virConnectPtr conn, char **const names, int maxnames) __attribute__((weak));
388 #endif
389 #endif
390
391 CAMLprim value
392 ocaml_libvirt_connect_list_defined_storage_pools (value connv, value iv)
393 {
394   CAMLparam2 (connv, iv);
395 #ifndef HAVE_VIRCONNECTLISTDEFINEDSTORAGEPOOLS
396   /* Symbol virConnectListDefinedStoragePools not found at compile time. */
397   not_supported ("virConnectListDefinedStoragePools");
398   /* Suppresses a compiler warning. */
399   (void) caml__frame;
400 #else
401   /* Check that the symbol virConnectListDefinedStoragePools
402    * is in runtime version of libvirt.
403    */
404   WEAK_SYMBOL_CHECK (virConnectListDefinedStoragePools);
405
406   CAMLlocal2 (rv, strv);
407   virConnectPtr conn = Connect_val (connv);
408   int i = Int_val (iv);
409   char *names[i];
410   int r;
411
412   NONBLOCKING (r = virConnectListDefinedStoragePools (conn, names, i));
413   CHECK_ERROR (r == -1, conn, "virConnectListDefinedStoragePools");
414
415   rv = caml_alloc (r, 0);
416   for (i = 0; i < r; ++i) {
417     strv = caml_copy_string (names[i]);
418     Store_field (rv, i, strv);
419     free (names[i]);
420   }
421
422   CAMLreturn (rv);
423 #endif
424 }
425
426 CAMLprim value
427 ocaml_libvirt_connect_get_capabilities (value connv)
428 {
429   CAMLparam1 (connv);
430
431   CAMLlocal1 (rv);
432   virConnectPtr conn = Connect_val (connv);
433   char *r;
434
435   NONBLOCKING (r = virConnectGetCapabilities (conn));
436   CHECK_ERROR (!r, conn, "virConnectGetCapabilities");
437
438   rv = caml_copy_string (r);
439   free (r);
440   CAMLreturn (rv);
441 }
442
443 CAMLprim value
444 ocaml_libvirt_domain_lookup_by_name (value connv, value strv)
445 {
446   CAMLparam2 (connv, strv);
447
448   CAMLlocal1 (rv);
449   virConnectPtr conn = Connect_val (connv);
450   char *str = String_val (strv);
451   virDomainPtr r;
452
453   NONBLOCKING (r = virDomainLookupByName (conn, str));
454   CHECK_ERROR (!r, conn, "virDomainLookupByName");
455
456   rv = Val_domain (r, connv);
457
458   CAMLreturn (rv);
459 }
460
461 CAMLprim value
462 ocaml_libvirt_domain_lookup_by_uuid_string (value connv, value strv)
463 {
464   CAMLparam2 (connv, strv);
465
466   CAMLlocal1 (rv);
467   virConnectPtr conn = Connect_val (connv);
468   char *str = String_val (strv);
469   virDomainPtr r;
470
471   NONBLOCKING (r = virDomainLookupByUUIDString (conn, str));
472   CHECK_ERROR (!r, conn, "virDomainLookupByUUIDString");
473
474   rv = Val_domain (r, connv);
475
476   CAMLreturn (rv);
477 }
478
479 CAMLprim value
480 ocaml_libvirt_domain_get_name (value domv)
481 {
482   CAMLparam1 (domv);
483
484   CAMLlocal1 (rv);
485   virDomainPtr dom = Domain_val (domv);
486   virConnectPtr conn = Connect_domv (domv);
487   const char *r;
488
489   NONBLOCKING (r = virDomainGetName (dom));
490   CHECK_ERROR (!r, conn, "virDomainGetName");
491
492   rv = caml_copy_string (r);
493   CAMLreturn (rv);
494 }
495
496 CAMLprim value
497 ocaml_libvirt_domain_get_os_type (value domv)
498 {
499   CAMLparam1 (domv);
500
501   CAMLlocal1 (rv);
502   virDomainPtr dom = Domain_val (domv);
503   virConnectPtr conn = Connect_domv (domv);
504   char *r;
505
506   NONBLOCKING (r = virDomainGetOSType (dom));
507   CHECK_ERROR (!r, conn, "virDomainGetOSType");
508
509   rv = caml_copy_string (r);
510   free (r);
511   CAMLreturn (rv);
512 }
513
514 CAMLprim value
515 ocaml_libvirt_domain_get_xml_desc (value domv)
516 {
517   CAMLparam1 (domv);
518
519   CAMLlocal1 (rv);
520   virDomainPtr dom = Domain_val (domv);
521   virConnectPtr conn = Connect_domv (domv);
522   char *r;
523
524   NONBLOCKING (r = virDomainGetXMLDesc (dom, 0));
525   CHECK_ERROR (!r, conn, "virDomainGetXMLDesc");
526
527   rv = caml_copy_string (r);
528   free (r);
529   CAMLreturn (rv);
530 }
531
532 CAMLprim value
533 ocaml_libvirt_domain_get_uuid (value domv)
534 {
535   CAMLparam1 (domv);
536
537   CAMLlocal1 (rv);
538   virDomainPtr dom = Domain_val (domv);
539   virConnectPtr conn = Connect_domv (domv);
540   unsigned char uuid[VIR_UUID_BUFLEN];
541   int r;
542
543   NONBLOCKING (r = virDomainGetUUID (dom, uuid));
544   CHECK_ERROR (r == -1, conn, "virDomainGetUUID");
545
546   rv = caml_copy_string ((char *) uuid);
547   CAMLreturn (rv);
548 }
549
550 CAMLprim value
551 ocaml_libvirt_domain_get_uuid_string (value domv)
552 {
553   CAMLparam1 (domv);
554
555   CAMLlocal1 (rv);
556   virDomainPtr dom = Domain_val (domv);
557   virConnectPtr conn = Connect_domv (domv);
558   char uuid[VIR_UUID_STRING_BUFLEN];
559   int r;
560
561   NONBLOCKING (r = virDomainGetUUIDString (dom, uuid));
562   CHECK_ERROR (r == -1, conn, "virDomainGetUUIDString");
563
564   rv = caml_copy_string (uuid);
565   CAMLreturn (rv);
566 }
567
568 CAMLprim value
569 ocaml_libvirt_domain_suspend (value domv)
570 {
571   CAMLparam1 (domv);
572
573   virDomainPtr dom = Domain_val (domv);
574   virConnectPtr conn = Connect_domv (domv);
575   int r;
576
577   NONBLOCKING (r = virDomainSuspend (dom));
578   CHECK_ERROR (r == -1, conn, "virDomainSuspend");
579
580   CAMLreturn (Val_unit);
581 }
582
583 CAMLprim value
584 ocaml_libvirt_domain_resume (value domv)
585 {
586   CAMLparam1 (domv);
587
588   virDomainPtr dom = Domain_val (domv);
589   virConnectPtr conn = Connect_domv (domv);
590   int r;
591
592   NONBLOCKING (r = virDomainResume (dom));
593   CHECK_ERROR (r == -1, conn, "virDomainResume");
594
595   CAMLreturn (Val_unit);
596 }
597
598 CAMLprim value
599 ocaml_libvirt_domain_shutdown (value domv)
600 {
601   CAMLparam1 (domv);
602
603   virDomainPtr dom = Domain_val (domv);
604   virConnectPtr conn = Connect_domv (domv);
605   int r;
606
607   NONBLOCKING (r = virDomainShutdown (dom));
608   CHECK_ERROR (r == -1, conn, "virDomainShutdown");
609
610   CAMLreturn (Val_unit);
611 }
612
613 CAMLprim value
614 ocaml_libvirt_domain_reboot (value domv)
615 {
616   CAMLparam1 (domv);
617
618   virDomainPtr dom = Domain_val (domv);
619   virConnectPtr conn = Connect_domv (domv);
620   int r;
621
622   NONBLOCKING (r = virDomainReboot (dom, 0));
623   CHECK_ERROR (r == -1, conn, "virDomainReboot");
624
625   CAMLreturn (Val_unit);
626 }
627
628 CAMLprim value
629 ocaml_libvirt_domain_undefine (value domv)
630 {
631   CAMLparam1 (domv);
632
633   virDomainPtr dom = Domain_val (domv);
634   virConnectPtr conn = Connect_domv (domv);
635   int r;
636
637   NONBLOCKING (r = virDomainUndefine (dom));
638   CHECK_ERROR (r == -1, conn, "virDomainUndefine");
639
640   CAMLreturn (Val_unit);
641 }
642
643 CAMLprim value
644 ocaml_libvirt_domain_create (value domv)
645 {
646   CAMLparam1 (domv);
647
648   virDomainPtr dom = Domain_val (domv);
649   virConnectPtr conn = Connect_domv (domv);
650   int r;
651
652   NONBLOCKING (r = virDomainCreate (dom));
653   CHECK_ERROR (r == -1, conn, "virDomainCreate");
654
655   CAMLreturn (Val_unit);
656 }
657
658 CAMLprim value
659 ocaml_libvirt_domain_get_autostart (value domv)
660 {
661   CAMLparam1 (domv);
662
663   virDomainPtr dom = Domain_val (domv);
664   virConnectPtr conn = Connect_domv (domv);
665   int r, b;
666
667   NONBLOCKING (r = virDomainGetAutostart (dom, &b));
668   CHECK_ERROR (r == -1, conn, "virDomainGetAutostart");
669
670   CAMLreturn (b ? Val_true : Val_false);
671 }
672
673 CAMLprim value
674 ocaml_libvirt_domain_set_autostart (value domv, value bv)
675 {
676   CAMLparam2 (domv, bv);
677
678   virDomainPtr dom = Domain_val (domv);
679   virConnectPtr conn = Connect_domv (domv);
680   int r, b;
681
682   b = bv == Val_true ? 1 : 0;
683
684   NONBLOCKING (r = virDomainSetAutostart (dom, b));
685   CHECK_ERROR (r == -1, conn, "virDomainSetAutostart");
686
687   CAMLreturn (Val_unit);
688 }
689
690 CAMLprim value
691 ocaml_libvirt_network_lookup_by_name (value connv, value strv)
692 {
693   CAMLparam2 (connv, strv);
694
695   CAMLlocal1 (rv);
696   virConnectPtr conn = Connect_val (connv);
697   char *str = String_val (strv);
698   virNetworkPtr r;
699
700   NONBLOCKING (r = virNetworkLookupByName (conn, str));
701   CHECK_ERROR (!r, conn, "virNetworkLookupByName");
702
703   rv = Val_network (r, connv);
704
705   CAMLreturn (rv);
706 }
707
708 CAMLprim value
709 ocaml_libvirt_network_lookup_by_uuid_string (value connv, value strv)
710 {
711   CAMLparam2 (connv, strv);
712
713   CAMLlocal1 (rv);
714   virConnectPtr conn = Connect_val (connv);
715   char *str = String_val (strv);
716   virNetworkPtr r;
717
718   NONBLOCKING (r = virNetworkLookupByUUIDString (conn, str));
719   CHECK_ERROR (!r, conn, "virNetworkLookupByUUIDString");
720
721   rv = Val_network (r, connv);
722
723   CAMLreturn (rv);
724 }
725
726 CAMLprim value
727 ocaml_libvirt_network_get_name (value netv)
728 {
729   CAMLparam1 (netv);
730
731   CAMLlocal1 (rv);
732   virNetworkPtr net = Network_val (netv);
733   virConnectPtr conn = Connect_netv (netv);
734   const char *r;
735
736   NONBLOCKING (r = virNetworkGetName (net));
737   CHECK_ERROR (!r, conn, "virNetworkGetName");
738
739   rv = caml_copy_string (r);
740   CAMLreturn (rv);
741 }
742
743 CAMLprim value
744 ocaml_libvirt_network_get_xml_desc (value netv)
745 {
746   CAMLparam1 (netv);
747
748   CAMLlocal1 (rv);
749   virNetworkPtr net = Network_val (netv);
750   virConnectPtr conn = Connect_netv (netv);
751   char *r;
752
753   NONBLOCKING (r = virNetworkGetXMLDesc (net, 0));
754   CHECK_ERROR (!r, conn, "virNetworkGetXMLDesc");
755
756   rv = caml_copy_string (r);
757   free (r);
758   CAMLreturn (rv);
759 }
760
761 CAMLprim value
762 ocaml_libvirt_network_get_bridge_name (value netv)
763 {
764   CAMLparam1 (netv);
765
766   CAMLlocal1 (rv);
767   virNetworkPtr net = Network_val (netv);
768   virConnectPtr conn = Connect_netv (netv);
769   char *r;
770
771   NONBLOCKING (r = virNetworkGetBridgeName (net));
772   CHECK_ERROR (!r, conn, "virNetworkGetBridgeName");
773
774   rv = caml_copy_string (r);
775   free (r);
776   CAMLreturn (rv);
777 }
778
779 CAMLprim value
780 ocaml_libvirt_network_get_uuid (value netv)
781 {
782   CAMLparam1 (netv);
783
784   CAMLlocal1 (rv);
785   virNetworkPtr net = Network_val (netv);
786   virConnectPtr conn = Connect_netv (netv);
787   unsigned char uuid[VIR_UUID_BUFLEN];
788   int r;
789
790   NONBLOCKING (r = virNetworkGetUUID (net, uuid));
791   CHECK_ERROR (r == -1, conn, "virNetworkGetUUID");
792
793   rv = caml_copy_string ((char *) uuid);
794   CAMLreturn (rv);
795 }
796
797 CAMLprim value
798 ocaml_libvirt_network_get_uuid_string (value netv)
799 {
800   CAMLparam1 (netv);
801
802   CAMLlocal1 (rv);
803   virNetworkPtr net = Network_val (netv);
804   virConnectPtr conn = Connect_netv (netv);
805   char uuid[VIR_UUID_STRING_BUFLEN];
806   int r;
807
808   NONBLOCKING (r = virNetworkGetUUIDString (net, uuid));
809   CHECK_ERROR (r == -1, conn, "virNetworkGetUUIDString");
810
811   rv = caml_copy_string (uuid);
812   CAMLreturn (rv);
813 }
814
815 CAMLprim value
816 ocaml_libvirt_network_undefine (value netv)
817 {
818   CAMLparam1 (netv);
819
820   virNetworkPtr net = Network_val (netv);
821   virConnectPtr conn = Connect_netv (netv);
822   int r;
823
824   NONBLOCKING (r = virNetworkUndefine (net));
825   CHECK_ERROR (r == -1, conn, "virNetworkUndefine");
826
827   CAMLreturn (Val_unit);
828 }
829
830 CAMLprim value
831 ocaml_libvirt_network_create (value netv)
832 {
833   CAMLparam1 (netv);
834
835   virNetworkPtr net = Network_val (netv);
836   virConnectPtr conn = Connect_netv (netv);
837   int r;
838
839   NONBLOCKING (r = virNetworkCreate (net));
840   CHECK_ERROR (r == -1, conn, "virNetworkCreate");
841
842   CAMLreturn (Val_unit);
843 }
844
845 CAMLprim value
846 ocaml_libvirt_network_get_autostart (value netv)
847 {
848   CAMLparam1 (netv);
849
850   virNetworkPtr net = Network_val (netv);
851   virConnectPtr conn = Connect_netv (netv);
852   int r, b;
853
854   NONBLOCKING (r = virNetworkGetAutostart (net, &b));
855   CHECK_ERROR (r == -1, conn, "virNetworkGetAutostart");
856
857   CAMLreturn (b ? Val_true : Val_false);
858 }
859
860 CAMLprim value
861 ocaml_libvirt_network_set_autostart (value netv, value bv)
862 {
863   CAMLparam2 (netv, bv);
864
865   virNetworkPtr net = Network_val (netv);
866   virConnectPtr conn = Connect_netv (netv);
867   int r, b;
868
869   b = bv == Val_true ? 1 : 0;
870
871   NONBLOCKING (r = virNetworkSetAutostart (net, b));
872   CHECK_ERROR (r == -1, conn, "virNetworkSetAutostart");
873
874   CAMLreturn (Val_unit);
875 }
876
877 #ifdef HAVE_WEAK_SYMBOLS
878 #ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYNAME
879 extern virStoragePoolPtr virStoragePoolLookupByName (virConnectPtr conn, const char *str) __attribute__((weak));
880 #endif
881 #endif
882
883 CAMLprim value
884 ocaml_libvirt_storage_pool_lookup_by_name (value connv, value strv)
885 {
886   CAMLparam2 (connv, strv);
887 #ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYNAME
888   /* Symbol virStoragePoolLookupByName not found at compile time. */
889   not_supported ("virStoragePoolLookupByName");
890   /* Suppresses a compiler warning. */
891   (void) caml__frame;
892 #else
893   /* Check that the symbol virStoragePoolLookupByName
894    * is in runtime version of libvirt.
895    */
896   WEAK_SYMBOL_CHECK (virStoragePoolLookupByName);
897
898   CAMLlocal1 (rv);
899   virConnectPtr conn = Connect_val (connv);
900   char *str = String_val (strv);
901   virStoragePoolPtr r;
902
903   NONBLOCKING (r = virStoragePoolLookupByName (conn, str));
904   CHECK_ERROR (!r, conn, "virStoragePoolLookupByName");
905
906   rv = Val_pool (r, connv);
907
908   CAMLreturn (rv);
909 #endif
910 }
911
912 #ifdef HAVE_WEAK_SYMBOLS
913 #ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYUUIDSTRING
914 extern virStoragePoolPtr virStoragePoolLookupByUUIDString (virConnectPtr conn, const char *str) __attribute__((weak));
915 #endif
916 #endif
917
918 CAMLprim value
919 ocaml_libvirt_storage_pool_lookup_by_uuid_string (value connv, value strv)
920 {
921   CAMLparam2 (connv, strv);
922 #ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYUUIDSTRING
923   /* Symbol virStoragePoolLookupByUUIDString not found at compile time. */
924   not_supported ("virStoragePoolLookupByUUIDString");
925   /* Suppresses a compiler warning. */
926   (void) caml__frame;
927 #else
928   /* Check that the symbol virStoragePoolLookupByUUIDString
929    * is in runtime version of libvirt.
930    */
931   WEAK_SYMBOL_CHECK (virStoragePoolLookupByUUIDString);
932
933   CAMLlocal1 (rv);
934   virConnectPtr conn = Connect_val (connv);
935   char *str = String_val (strv);
936   virStoragePoolPtr r;
937
938   NONBLOCKING (r = virStoragePoolLookupByUUIDString (conn, str));
939   CHECK_ERROR (!r, conn, "virStoragePoolLookupByUUIDString");
940
941   rv = Val_pool (r, connv);
942
943   CAMLreturn (rv);
944 #endif
945 }
946
947 #ifdef HAVE_WEAK_SYMBOLS
948 #ifdef HAVE_VIRSTORAGEPOOLGETNAME
949 extern const char *virStoragePoolGetName (virStoragePoolPtr pool) __attribute__((weak));
950 #endif
951 #endif
952
953 CAMLprim value
954 ocaml_libvirt_storage_pool_get_name (value poolv)
955 {
956   CAMLparam1 (poolv);
957 #ifndef HAVE_VIRSTORAGEPOOLGETNAME
958   /* Symbol virStoragePoolGetName not found at compile time. */
959   not_supported ("virStoragePoolGetName");
960   /* Suppresses a compiler warning. */
961   (void) caml__frame;
962 #else
963   /* Check that the symbol virStoragePoolGetName
964    * is in runtime version of libvirt.
965    */
966   WEAK_SYMBOL_CHECK (virStoragePoolGetName);
967
968   CAMLlocal1 (rv);
969   virStoragePoolPtr pool = Pool_val (poolv);
970   virConnectPtr conn = Connect_polv (poolv);
971   const char *r;
972
973   NONBLOCKING (r = virStoragePoolGetName (pool));
974   CHECK_ERROR (!r, conn, "virStoragePoolGetName");
975
976   rv = caml_copy_string (r);
977   CAMLreturn (rv);
978 #endif
979 }
980
981 #ifdef HAVE_WEAK_SYMBOLS
982 #ifdef HAVE_VIRSTORAGEPOOLGETXMLDESC
983 extern char *virStoragePoolGetXMLDesc (virStoragePoolPtr pool,  int flags) __attribute__((weak));
984 #endif
985 #endif
986
987 CAMLprim value
988 ocaml_libvirt_storage_pool_get_xml_desc (value poolv)
989 {
990   CAMLparam1 (poolv);
991 #ifndef HAVE_VIRSTORAGEPOOLGETXMLDESC
992   /* Symbol virStoragePoolGetXMLDesc not found at compile time. */
993   not_supported ("virStoragePoolGetXMLDesc");
994   /* Suppresses a compiler warning. */
995   (void) caml__frame;
996 #else
997   /* Check that the symbol virStoragePoolGetXMLDesc
998    * is in runtime version of libvirt.
999    */
1000   WEAK_SYMBOL_CHECK (virStoragePoolGetXMLDesc);
1001
1002   CAMLlocal1 (rv);
1003   virStoragePoolPtr pool = Pool_val (poolv);
1004   virConnectPtr conn = Connect_polv (poolv);
1005   char *r;
1006
1007   NONBLOCKING (r = virStoragePoolGetXMLDesc (pool, 0));
1008   CHECK_ERROR (!r, conn, "virStoragePoolGetXMLDesc");
1009
1010   rv = caml_copy_string (r);
1011   free (r);
1012   CAMLreturn (rv);
1013 #endif
1014 }
1015
1016 #ifdef HAVE_WEAK_SYMBOLS
1017 #ifdef HAVE_VIRSTORAGEPOOLGETUUID
1018 extern int virStoragePoolGetUUID (virStoragePoolPtr pool, unsigned char *) __attribute__((weak));
1019 #endif
1020 #endif
1021
1022 CAMLprim value
1023 ocaml_libvirt_storage_pool_get_uuid (value poolv)
1024 {
1025   CAMLparam1 (poolv);
1026 #ifndef HAVE_VIRSTORAGEPOOLGETUUID
1027   /* Symbol virStoragePoolGetUUID not found at compile time. */
1028   not_supported ("virStoragePoolGetUUID");
1029   /* Suppresses a compiler warning. */
1030   (void) caml__frame;
1031 #else
1032   /* Check that the symbol virStoragePoolGetUUID
1033    * is in runtime version of libvirt.
1034    */
1035   WEAK_SYMBOL_CHECK (virStoragePoolGetUUID);
1036
1037   CAMLlocal1 (rv);
1038   virStoragePoolPtr pool = Pool_val (poolv);
1039   virConnectPtr conn = Connect_polv (poolv);
1040   unsigned char uuid[VIR_UUID_BUFLEN];
1041   int r;
1042
1043   NONBLOCKING (r = virStoragePoolGetUUID (pool, uuid));
1044   CHECK_ERROR (r == -1, conn, "virStoragePoolGetUUID");
1045
1046   rv = caml_copy_string ((char *) uuid);
1047   CAMLreturn (rv);
1048 #endif
1049 }
1050
1051 #ifdef HAVE_WEAK_SYMBOLS
1052 #ifdef HAVE_VIRSTORAGEPOOLGETUUIDSTRING
1053 extern int virStoragePoolGetUUIDString (virStoragePoolPtr pool, char *) __attribute__((weak));
1054 #endif
1055 #endif
1056
1057 CAMLprim value
1058 ocaml_libvirt_storage_pool_get_uuid_string (value poolv)
1059 {
1060   CAMLparam1 (poolv);
1061 #ifndef HAVE_VIRSTORAGEPOOLGETUUIDSTRING
1062   /* Symbol virStoragePoolGetUUIDString not found at compile time. */
1063   not_supported ("virStoragePoolGetUUIDString");
1064   /* Suppresses a compiler warning. */
1065   (void) caml__frame;
1066 #else
1067   /* Check that the symbol virStoragePoolGetUUIDString
1068    * is in runtime version of libvirt.
1069    */
1070   WEAK_SYMBOL_CHECK (virStoragePoolGetUUIDString);
1071
1072   CAMLlocal1 (rv);
1073   virStoragePoolPtr pool = Pool_val (poolv);
1074   virConnectPtr conn = Connect_polv (poolv);
1075   char uuid[VIR_UUID_STRING_BUFLEN];
1076   int r;
1077
1078   NONBLOCKING (r = virStoragePoolGetUUIDString (pool, uuid));
1079   CHECK_ERROR (r == -1, conn, "virStoragePoolGetUUIDString");
1080
1081   rv = caml_copy_string (uuid);
1082   CAMLreturn (rv);
1083 #endif
1084 }
1085
1086 #ifdef HAVE_WEAK_SYMBOLS
1087 #ifdef HAVE_VIRSTORAGEPOOLUNDEFINE
1088 extern int virStoragePoolUndefine (virStoragePoolPtr pool) __attribute__((weak));
1089 #endif
1090 #endif
1091
1092 CAMLprim value
1093 ocaml_libvirt_storage_pool_undefine (value poolv)
1094 {
1095   CAMLparam1 (poolv);
1096 #ifndef HAVE_VIRSTORAGEPOOLUNDEFINE
1097   /* Symbol virStoragePoolUndefine not found at compile time. */
1098   not_supported ("virStoragePoolUndefine");
1099   /* Suppresses a compiler warning. */
1100   (void) caml__frame;
1101 #else
1102   /* Check that the symbol virStoragePoolUndefine
1103    * is in runtime version of libvirt.
1104    */
1105   WEAK_SYMBOL_CHECK (virStoragePoolUndefine);
1106
1107   virStoragePoolPtr pool = Pool_val (poolv);
1108   virConnectPtr conn = Connect_polv (poolv);
1109   int r;
1110
1111   NONBLOCKING (r = virStoragePoolUndefine (pool));
1112   CHECK_ERROR (r == -1, conn, "virStoragePoolUndefine");
1113
1114   CAMLreturn (Val_unit);
1115 #endif
1116 }
1117
1118 #ifdef HAVE_WEAK_SYMBOLS
1119 #ifdef HAVE_VIRSTORAGEPOOLCREATE
1120 extern int virStoragePoolCreate (virStoragePoolPtr pool) __attribute__((weak));
1121 #endif
1122 #endif
1123
1124 CAMLprim value
1125 ocaml_libvirt_storage_pool_create (value poolv)
1126 {
1127   CAMLparam1 (poolv);
1128 #ifndef HAVE_VIRSTORAGEPOOLCREATE
1129   /* Symbol virStoragePoolCreate not found at compile time. */
1130   not_supported ("virStoragePoolCreate");
1131   /* Suppresses a compiler warning. */
1132   (void) caml__frame;
1133 #else
1134   /* Check that the symbol virStoragePoolCreate
1135    * is in runtime version of libvirt.
1136    */
1137   WEAK_SYMBOL_CHECK (virStoragePoolCreate);
1138
1139   virStoragePoolPtr pool = Pool_val (poolv);
1140   virConnectPtr conn = Connect_polv (poolv);
1141   int r;
1142
1143   NONBLOCKING (r = virStoragePoolCreate (pool));
1144   CHECK_ERROR (r == -1, conn, "virStoragePoolCreate");
1145
1146   CAMLreturn (Val_unit);
1147 #endif
1148 }
1149
1150 #ifdef HAVE_WEAK_SYMBOLS
1151 #ifdef HAVE_VIRSTORAGEPOOLSHUTDOWN
1152 extern int virStoragePoolShutdown (virStoragePoolPtr pool) __attribute__((weak));
1153 #endif
1154 #endif
1155
1156 CAMLprim value
1157 ocaml_libvirt_storage_pool_shutdown (value poolv)
1158 {
1159   CAMLparam1 (poolv);
1160 #ifndef HAVE_VIRSTORAGEPOOLSHUTDOWN
1161   /* Symbol virStoragePoolShutdown not found at compile time. */
1162   not_supported ("virStoragePoolShutdown");
1163   /* Suppresses a compiler warning. */
1164   (void) caml__frame;
1165 #else
1166   /* Check that the symbol virStoragePoolShutdown
1167    * is in runtime version of libvirt.
1168    */
1169   WEAK_SYMBOL_CHECK (virStoragePoolShutdown);
1170
1171   virStoragePoolPtr pool = Pool_val (poolv);
1172   virConnectPtr conn = Connect_polv (poolv);
1173   int r;
1174
1175   NONBLOCKING (r = virStoragePoolShutdown (pool));
1176   CHECK_ERROR (r == -1, conn, "virStoragePoolShutdown");
1177
1178   CAMLreturn (Val_unit);
1179 #endif
1180 }
1181
1182 #ifdef HAVE_WEAK_SYMBOLS
1183 #ifdef HAVE_VIRSTORAGEPOOLREFRESH
1184 extern int virStoragePoolRefresh (virStoragePoolPtr pool, unsigned  int flags) __attribute__((weak));
1185 #endif
1186 #endif
1187
1188 CAMLprim value
1189 ocaml_libvirt_storage_pool_refresh (value poolv)
1190 {
1191   CAMLparam1 (poolv);
1192 #ifndef HAVE_VIRSTORAGEPOOLREFRESH
1193   /* Symbol virStoragePoolRefresh not found at compile time. */
1194   not_supported ("virStoragePoolRefresh");
1195   /* Suppresses a compiler warning. */
1196   (void) caml__frame;
1197 #else
1198   /* Check that the symbol virStoragePoolRefresh
1199    * is in runtime version of libvirt.
1200    */
1201   WEAK_SYMBOL_CHECK (virStoragePoolRefresh);
1202
1203   virStoragePoolPtr pool = Pool_val (poolv);
1204   virConnectPtr conn = Connect_polv (poolv);
1205   int r;
1206
1207   NONBLOCKING (r = virStoragePoolRefresh (pool, 0));
1208   CHECK_ERROR (r == -1, conn, "virStoragePoolRefresh");
1209
1210   CAMLreturn (Val_unit);
1211 #endif
1212 }
1213
1214 #ifdef HAVE_WEAK_SYMBOLS
1215 #ifdef HAVE_VIRSTORAGEPOOLGETAUTOSTART
1216 extern int virStoragePoolGetAutostart (virStoragePoolPtr pool, int *r) __attribute__((weak));
1217 #endif
1218 #endif
1219
1220 CAMLprim value
1221 ocaml_libvirt_storage_pool_get_autostart (value poolv)
1222 {
1223   CAMLparam1 (poolv);
1224 #ifndef HAVE_VIRSTORAGEPOOLGETAUTOSTART
1225   /* Symbol virStoragePoolGetAutostart not found at compile time. */
1226   not_supported ("virStoragePoolGetAutostart");
1227   /* Suppresses a compiler warning. */
1228   (void) caml__frame;
1229 #else
1230   /* Check that the symbol virStoragePoolGetAutostart
1231    * is in runtime version of libvirt.
1232    */
1233   WEAK_SYMBOL_CHECK (virStoragePoolGetAutostart);
1234
1235   virStoragePoolPtr pool = Pool_val (poolv);
1236   virConnectPtr conn = Connect_polv (poolv);
1237   int r, b;
1238
1239   NONBLOCKING (r = virStoragePoolGetAutostart (pool, &b));
1240   CHECK_ERROR (r == -1, conn, "virStoragePoolGetAutostart");
1241
1242   CAMLreturn (b ? Val_true : Val_false);
1243 #endif
1244 }
1245
1246 #ifdef HAVE_WEAK_SYMBOLS
1247 #ifdef HAVE_VIRSTORAGEPOOLSETAUTOSTART
1248 extern int virStoragePoolSetAutostart (virStoragePoolPtr pool, int b) __attribute__((weak));
1249 #endif
1250 #endif
1251
1252 CAMLprim value
1253 ocaml_libvirt_storage_pool_set_autostart (value poolv, value bv)
1254 {
1255   CAMLparam2 (poolv, bv);
1256 #ifndef HAVE_VIRSTORAGEPOOLSETAUTOSTART
1257   /* Symbol virStoragePoolSetAutostart not found at compile time. */
1258   not_supported ("virStoragePoolSetAutostart");
1259   /* Suppresses a compiler warning. */
1260   (void) caml__frame;
1261 #else
1262   /* Check that the symbol virStoragePoolSetAutostart
1263    * is in runtime version of libvirt.
1264    */
1265   WEAK_SYMBOL_CHECK (virStoragePoolSetAutostart);
1266
1267   virStoragePoolPtr pool = Pool_val (poolv);
1268   virConnectPtr conn = Connect_polv (poolv);
1269   int r, b;
1270
1271   b = bv == Val_true ? 1 : 0;
1272
1273   NONBLOCKING (r = virStoragePoolSetAutostart (pool, b));
1274   CHECK_ERROR (r == -1, conn, "virStoragePoolSetAutostart");
1275
1276   CAMLreturn (Val_unit);
1277 #endif
1278 }
1279
1280 #ifdef HAVE_WEAK_SYMBOLS
1281 #ifdef HAVE_VIRSTORAGEVOLLOOKUPBYKEY
1282 extern virStorageVolPtr virStorageVolLookupByKey (virConnectPtr conn, const char *str) __attribute__((weak));
1283 #endif
1284 #endif
1285
1286 CAMLprim value
1287 ocaml_libvirt_storage_vol_lookup_by_key (value connv, value strv)
1288 {
1289   CAMLparam2 (connv, strv);
1290 #ifndef HAVE_VIRSTORAGEVOLLOOKUPBYKEY
1291   /* Symbol virStorageVolLookupByKey not found at compile time. */
1292   not_supported ("virStorageVolLookupByKey");
1293   /* Suppresses a compiler warning. */
1294   (void) caml__frame;
1295 #else
1296   /* Check that the symbol virStorageVolLookupByKey
1297    * is in runtime version of libvirt.
1298    */
1299   WEAK_SYMBOL_CHECK (virStorageVolLookupByKey);
1300
1301   CAMLlocal1 (rv);
1302   virConnectPtr conn = Connect_val (connv);
1303   char *str = String_val (strv);
1304   virStorageVolPtr r;
1305
1306   NONBLOCKING (r = virStorageVolLookupByKey (conn, str));
1307   CHECK_ERROR (!r, conn, "virStorageVolLookupByKey");
1308
1309   rv = Val_volume (r, connv);
1310
1311   CAMLreturn (rv);
1312 #endif
1313 }
1314
1315 #ifdef HAVE_WEAK_SYMBOLS
1316 #ifdef HAVE_VIRSTORAGEVOLLOOKUPBYPATH
1317 extern virStorageVolPtr virStorageVolLookupByPath (virConnectPtr conn, const char *str) __attribute__((weak));
1318 #endif
1319 #endif
1320
1321 CAMLprim value
1322 ocaml_libvirt_storage_vol_lookup_by_path (value connv, value strv)
1323 {
1324   CAMLparam2 (connv, strv);
1325 #ifndef HAVE_VIRSTORAGEVOLLOOKUPBYPATH
1326   /* Symbol virStorageVolLookupByPath not found at compile time. */
1327   not_supported ("virStorageVolLookupByPath");
1328   /* Suppresses a compiler warning. */
1329   (void) caml__frame;
1330 #else
1331   /* Check that the symbol virStorageVolLookupByPath
1332    * is in runtime version of libvirt.
1333    */
1334   WEAK_SYMBOL_CHECK (virStorageVolLookupByPath);
1335
1336   CAMLlocal1 (rv);
1337   virConnectPtr conn = Connect_val (connv);
1338   char *str = String_val (strv);
1339   virStorageVolPtr r;
1340
1341   NONBLOCKING (r = virStorageVolLookupByPath (conn, str));
1342   CHECK_ERROR (!r, conn, "virStorageVolLookupByPath");
1343
1344   rv = Val_volume (r, connv);
1345
1346   CAMLreturn (rv);
1347 #endif
1348 }
1349
1350 #ifdef HAVE_WEAK_SYMBOLS
1351 #ifdef HAVE_VIRSTORAGEVOLGETXMLDESC
1352 extern char *virStorageVolGetXMLDesc (virStorageVolPtr vol,  int flags) __attribute__((weak));
1353 #endif
1354 #endif
1355
1356 CAMLprim value
1357 ocaml_libvirt_storage_vol_get_xml_desc (value volv)
1358 {
1359   CAMLparam1 (volv);
1360 #ifndef HAVE_VIRSTORAGEVOLGETXMLDESC
1361   /* Symbol virStorageVolGetXMLDesc not found at compile time. */
1362   not_supported ("virStorageVolGetXMLDesc");
1363   /* Suppresses a compiler warning. */
1364   (void) caml__frame;
1365 #else
1366   /* Check that the symbol virStorageVolGetXMLDesc
1367    * is in runtime version of libvirt.
1368    */
1369   WEAK_SYMBOL_CHECK (virStorageVolGetXMLDesc);
1370
1371   CAMLlocal1 (rv);
1372   virStorageVolPtr vol = Volume_val (volv);
1373   virConnectPtr conn = Connect_volv (volv);
1374   char *r;
1375
1376   NONBLOCKING (r = virStorageVolGetXMLDesc (vol, 0));
1377   CHECK_ERROR (!r, conn, "virStorageVolGetXMLDesc");
1378
1379   rv = caml_copy_string (r);
1380   free (r);
1381   CAMLreturn (rv);
1382 #endif
1383 }
1384
1385 #ifdef HAVE_WEAK_SYMBOLS
1386 #ifdef HAVE_VIRSTORAGEVOLGETPATH
1387 extern char *virStorageVolGetPath (virStorageVolPtr vol) __attribute__((weak));
1388 #endif
1389 #endif
1390
1391 CAMLprim value
1392 ocaml_libvirt_storage_vol_get_path (value volv)
1393 {
1394   CAMLparam1 (volv);
1395 #ifndef HAVE_VIRSTORAGEVOLGETPATH
1396   /* Symbol virStorageVolGetPath not found at compile time. */
1397   not_supported ("virStorageVolGetPath");
1398   /* Suppresses a compiler warning. */
1399   (void) caml__frame;
1400 #else
1401   /* Check that the symbol virStorageVolGetPath
1402    * is in runtime version of libvirt.
1403    */
1404   WEAK_SYMBOL_CHECK (virStorageVolGetPath);
1405
1406   CAMLlocal1 (rv);
1407   virStorageVolPtr vol = Volume_val (volv);
1408   virConnectPtr conn = Connect_volv (volv);
1409   char *r;
1410
1411   NONBLOCKING (r = virStorageVolGetPath (vol));
1412   CHECK_ERROR (!r, conn, "virStorageVolGetPath");
1413
1414   rv = caml_copy_string (r);
1415   free (r);
1416   CAMLreturn (rv);
1417 #endif
1418 }
1419
1420 #ifdef HAVE_WEAK_SYMBOLS
1421 #ifdef HAVE_VIRSTORAGEVOLGETKEY
1422 extern const char *virStorageVolGetKey (virStorageVolPtr vol) __attribute__((weak));
1423 #endif
1424 #endif
1425
1426 CAMLprim value
1427 ocaml_libvirt_storage_vol_get_key (value volv)
1428 {
1429   CAMLparam1 (volv);
1430 #ifndef HAVE_VIRSTORAGEVOLGETKEY
1431   /* Symbol virStorageVolGetKey not found at compile time. */
1432   not_supported ("virStorageVolGetKey");
1433   /* Suppresses a compiler warning. */
1434   (void) caml__frame;
1435 #else
1436   /* Check that the symbol virStorageVolGetKey
1437    * is in runtime version of libvirt.
1438    */
1439   WEAK_SYMBOL_CHECK (virStorageVolGetKey);
1440
1441   CAMLlocal1 (rv);
1442   virStorageVolPtr vol = Volume_val (volv);
1443   virConnectPtr conn = Connect_volv (volv);
1444   const char *r;
1445
1446   NONBLOCKING (r = virStorageVolGetKey (vol));
1447   CHECK_ERROR (!r, conn, "virStorageVolGetKey");
1448
1449   rv = caml_copy_string (r);
1450   CAMLreturn (rv);
1451 #endif
1452 }
1453
1454 #ifdef HAVE_WEAK_SYMBOLS
1455 #ifdef HAVE_VIRSTORAGEVOLGETNAME
1456 extern const char *virStorageVolGetName (virStorageVolPtr vol) __attribute__((weak));
1457 #endif
1458 #endif
1459
1460 CAMLprim value
1461 ocaml_libvirt_storage_vol_get_name (value volv)
1462 {
1463   CAMLparam1 (volv);
1464 #ifndef HAVE_VIRSTORAGEVOLGETNAME
1465   /* Symbol virStorageVolGetName not found at compile time. */
1466   not_supported ("virStorageVolGetName");
1467   /* Suppresses a compiler warning. */
1468   (void) caml__frame;
1469 #else
1470   /* Check that the symbol virStorageVolGetName
1471    * is in runtime version of libvirt.
1472    */
1473   WEAK_SYMBOL_CHECK (virStorageVolGetName);
1474
1475   CAMLlocal1 (rv);
1476   virStorageVolPtr vol = Volume_val (volv);
1477   virConnectPtr conn = Connect_volv (volv);
1478   const char *r;
1479
1480   NONBLOCKING (r = virStorageVolGetName (vol));
1481   CHECK_ERROR (!r, conn, "virStorageVolGetName");
1482
1483   rv = caml_copy_string (r);
1484   CAMLreturn (rv);
1485 #endif
1486 }
1487
1488 /* The following functions are unimplemented and always fail.
1489  * See generator.pl '@unimplemented'
1490  */
1491
1492 CAMLprim value
1493 ocaml_libvirt_domain_create_job ()
1494 {
1495   failwith ("ocaml_libvirt_domain_create_job is unimplemented");
1496 }
1497
1498 CAMLprim value
1499 ocaml_libvirt_domain_core_dump_job ()
1500 {
1501   failwith ("ocaml_libvirt_domain_core_dump_job is unimplemented");
1502 }
1503
1504 CAMLprim value
1505 ocaml_libvirt_domain_restore_job ()
1506 {
1507   failwith ("ocaml_libvirt_domain_restore_job is unimplemented");
1508 }
1509
1510 CAMLprim value
1511 ocaml_libvirt_domain_save_job ()
1512 {
1513   failwith ("ocaml_libvirt_domain_save_job is unimplemented");
1514 }
1515
1516 CAMLprim value
1517 ocaml_libvirt_connect_create_linux_job ()
1518 {
1519   failwith ("ocaml_libvirt_connect_create_linux_job is unimplemented");
1520 }
1521
1522 CAMLprim value
1523 ocaml_libvirt_network_create_job ()
1524 {
1525   failwith ("ocaml_libvirt_network_create_job is unimplemented");
1526 }
1527
1528 CAMLprim value
1529 ocaml_libvirt_network_create_xml_job ()
1530 {
1531   failwith ("ocaml_libvirt_network_create_xml_job is unimplemented");
1532 }
1533
1534 CAMLprim value
1535 ocaml_libvirt_storage_pool_get_info ()
1536 {
1537   failwith ("ocaml_libvirt_storage_pool_get_info is unimplemented");
1538 }
1539
1540 CAMLprim value
1541 ocaml_libvirt_storage_pool_free ()
1542 {
1543   failwith ("ocaml_libvirt_storage_pool_free is unimplemented");
1544 }
1545
1546 CAMLprim value
1547 ocaml_libvirt_storage_pool_destroy ()
1548 {
1549   failwith ("ocaml_libvirt_storage_pool_destroy is unimplemented");
1550 }
1551
1552 CAMLprim value
1553 ocaml_libvirt_storage_pool_define_xml ()
1554 {
1555   failwith ("ocaml_libvirt_storage_pool_define_xml is unimplemented");
1556 }
1557
1558 CAMLprim value
1559 ocaml_libvirt_storage_pool_create_xml ()
1560 {
1561   failwith ("ocaml_libvirt_storage_pool_create_xml is unimplemented");
1562 }
1563
1564 CAMLprim value
1565 ocaml_libvirt_storage_pool_lookup_by_uuid ()
1566 {
1567   failwith ("ocaml_libvirt_storage_pool_lookup_by_uuid is unimplemented");
1568 }
1569
1570 CAMLprim value
1571 ocaml_libvirt_storage_vol_lookup_by_name ()
1572 {
1573   failwith ("ocaml_libvirt_storage_vol_lookup_by_name is unimplemented");
1574 }
1575
1576 CAMLprim value
1577 ocaml_libvirt_storage_vol_free ()
1578 {
1579   failwith ("ocaml_libvirt_storage_vol_free is unimplemented");
1580 }
1581
1582 CAMLprim value
1583 ocaml_libvirt_storage_vol_destroy ()
1584 {
1585   failwith ("ocaml_libvirt_storage_vol_destroy is unimplemented");
1586 }
1587
1588 CAMLprim value
1589 ocaml_libvirt_storage_vol_create_xml ()
1590 {
1591   failwith ("ocaml_libvirt_storage_vol_create_xml is unimplemented");
1592 }
1593
1594 CAMLprim value
1595 ocaml_libvirt_storage_vol_get_info ()
1596 {
1597   failwith ("ocaml_libvirt_storage_vol_get_info is unimplemented");
1598 }
1599
1600 CAMLprim value
1601 ocaml_libvirt_pool_of_volume ()
1602 {
1603   failwith ("ocaml_libvirt_pool_of_volume is unimplemented");
1604 }
1605
1606 CAMLprim value
1607 ocaml_libvirt_job_cancel ()
1608 {
1609   failwith ("ocaml_libvirt_job_cancel is unimplemented");
1610 }
1611
1612 CAMLprim value
1613 ocaml_libvirt_job_get_network ()
1614 {
1615   failwith ("ocaml_libvirt_job_get_network is unimplemented");
1616 }
1617
1618 CAMLprim value
1619 ocaml_libvirt_job_get_domain ()
1620 {
1621   failwith ("ocaml_libvirt_job_get_domain is unimplemented");
1622 }
1623
1624 CAMLprim value
1625 ocaml_libvirt_job_get_info ()
1626 {
1627   failwith ("ocaml_libvirt_job_get_info is unimplemented");
1628 }
1629
1630 #include "libvirt_c_epilogue.c"
1631
1632 /* EOF */