1 /* !!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!!
3 * THIS FILE IS AUTOMATICALLY GENERATED BY 'generator.pl'.
5 * Any changes you make to this file may be overwritten.
8 /* OCaml bindings for libvirt.
9 * (C) Copyright 2007-2008 Richard W.M. Jones, Red Hat Inc.
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.
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.
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
33 #include <libvirt/libvirt.h>
34 #include <libvirt/virterror.h>
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>
46 #include "libvirt_c_prologue.c"
48 #include "libvirt_c_oneoffs.c"
51 ocaml_libvirt_connect_close (value connv)
55 virConnectPtr conn = Connect_val (connv);
58 NONBLOCKING (r = virConnectClose (conn));
59 CHECK_ERROR (r == -1, conn, "virConnectClose");
61 /* So that we don't double-free in the finalizer: */
62 Connect_val (connv) = NULL;
64 CAMLreturn (Val_unit);
67 #ifdef HAVE_WEAK_SYMBOLS
68 #ifdef HAVE_VIRCONNECTGETHOSTNAME
69 extern char *virConnectGetHostname (virConnectPtr conn) __attribute__((weak));
74 ocaml_libvirt_connect_get_hostname (value connv)
77 #ifndef HAVE_VIRCONNECTGETHOSTNAME
78 /* Symbol virConnectGetHostname not found at compile time. */
79 not_supported ("virConnectGetHostname");
80 /* Suppresses a compiler warning. */
83 /* Check that the symbol virConnectGetHostname
84 * is in runtime version of libvirt.
86 WEAK_SYMBOL_CHECK (virConnectGetHostname);
89 virConnectPtr conn = Connect_val (connv);
92 NONBLOCKING (r = virConnectGetHostname (conn));
93 CHECK_ERROR (!r, conn, "virConnectGetHostname");
95 rv = caml_copy_string (r);
101 #ifdef HAVE_WEAK_SYMBOLS
102 #ifdef HAVE_VIRCONNECTGETURI
103 extern char *virConnectGetURI (virConnectPtr conn) __attribute__((weak));
108 ocaml_libvirt_connect_get_uri (value connv)
111 #ifndef HAVE_VIRCONNECTGETURI
112 /* Symbol virConnectGetURI not found at compile time. */
113 not_supported ("virConnectGetURI");
114 /* Suppresses a compiler warning. */
117 /* Check that the symbol virConnectGetURI
118 * is in runtime version of libvirt.
120 WEAK_SYMBOL_CHECK (virConnectGetURI);
123 virConnectPtr conn = Connect_val (connv);
126 NONBLOCKING (r = virConnectGetURI (conn));
127 CHECK_ERROR (!r, conn, "virConnectGetURI");
129 rv = caml_copy_string (r);
136 ocaml_libvirt_connect_get_type (value connv)
141 virConnectPtr conn = Connect_val (connv);
144 NONBLOCKING (r = virConnectGetType (conn));
145 CHECK_ERROR (!r, conn, "virConnectGetType");
147 rv = caml_copy_string (r);
152 ocaml_libvirt_connect_num_of_domains (value connv)
156 virConnectPtr conn = Connect_val (connv);
159 NONBLOCKING (r = virConnectNumOfDomains (conn));
160 CHECK_ERROR (r == -1, conn, "virConnectNumOfDomains");
162 CAMLreturn (Val_int (r));
166 ocaml_libvirt_connect_list_domains (value connv, value iv)
168 CAMLparam2 (connv, iv);
171 virConnectPtr conn = Connect_val (connv);
172 int i = Int_val (iv);
175 NONBLOCKING (r = virConnectListDomains (conn, ids, i));
176 CHECK_ERROR (r == -1, conn, "virConnectListDomains");
178 rv = caml_alloc (r, 0);
179 for (i = 0; i < r; ++i)
180 Store_field (rv, i, Val_int (ids[i]));
186 ocaml_libvirt_connect_num_of_defined_domains (value connv)
190 virConnectPtr conn = Connect_val (connv);
193 NONBLOCKING (r = virConnectNumOfDefinedDomains (conn));
194 CHECK_ERROR (r == -1, conn, "virConnectNumOfDefinedDomains");
196 CAMLreturn (Val_int (r));
200 ocaml_libvirt_connect_list_defined_domains (value connv, value iv)
202 CAMLparam2 (connv, iv);
204 CAMLlocal2 (rv, strv);
205 virConnectPtr conn = Connect_val (connv);
206 int i = Int_val (iv);
210 NONBLOCKING (r = virConnectListDefinedDomains (conn, names, i));
211 CHECK_ERROR (r == -1, conn, "virConnectListDefinedDomains");
213 rv = caml_alloc (r, 0);
214 for (i = 0; i < r; ++i) {
215 strv = caml_copy_string (names[i]);
216 Store_field (rv, i, strv);
224 ocaml_libvirt_connect_num_of_networks (value connv)
228 virConnectPtr conn = Connect_val (connv);
231 NONBLOCKING (r = virConnectNumOfNetworks (conn));
232 CHECK_ERROR (r == -1, conn, "virConnectNumOfNetworks");
234 CAMLreturn (Val_int (r));
238 ocaml_libvirt_connect_list_networks (value connv, value iv)
240 CAMLparam2 (connv, iv);
242 CAMLlocal2 (rv, strv);
243 virConnectPtr conn = Connect_val (connv);
244 int i = Int_val (iv);
248 NONBLOCKING (r = virConnectListNetworks (conn, names, i));
249 CHECK_ERROR (r == -1, conn, "virConnectListNetworks");
251 rv = caml_alloc (r, 0);
252 for (i = 0; i < r; ++i) {
253 strv = caml_copy_string (names[i]);
254 Store_field (rv, i, strv);
262 ocaml_libvirt_connect_num_of_defined_networks (value connv)
266 virConnectPtr conn = Connect_val (connv);
269 NONBLOCKING (r = virConnectNumOfDefinedNetworks (conn));
270 CHECK_ERROR (r == -1, conn, "virConnectNumOfDefinedNetworks");
272 CAMLreturn (Val_int (r));
276 ocaml_libvirt_connect_list_defined_networks (value connv, value iv)
278 CAMLparam2 (connv, iv);
280 CAMLlocal2 (rv, strv);
281 virConnectPtr conn = Connect_val (connv);
282 int i = Int_val (iv);
286 NONBLOCKING (r = virConnectListDefinedNetworks (conn, names, i));
287 CHECK_ERROR (r == -1, conn, "virConnectListDefinedNetworks");
289 rv = caml_alloc (r, 0);
290 for (i = 0; i < r; ++i) {
291 strv = caml_copy_string (names[i]);
292 Store_field (rv, i, strv);
299 #ifdef HAVE_WEAK_SYMBOLS
300 #ifdef HAVE_VIRCONNECTNUMOFSTORAGEPOOLS
301 extern int virConnectNumOfStoragePools (virConnectPtr conn) __attribute__((weak));
306 ocaml_libvirt_connect_num_of_storage_pools (value connv)
309 #ifndef HAVE_VIRCONNECTNUMOFSTORAGEPOOLS
310 /* Symbol virConnectNumOfStoragePools not found at compile time. */
311 not_supported ("virConnectNumOfStoragePools");
312 /* Suppresses a compiler warning. */
315 /* Check that the symbol virConnectNumOfStoragePools
316 * is in runtime version of libvirt.
318 WEAK_SYMBOL_CHECK (virConnectNumOfStoragePools);
320 virConnectPtr conn = Connect_val (connv);
323 NONBLOCKING (r = virConnectNumOfStoragePools (conn));
324 CHECK_ERROR (r == -1, conn, "virConnectNumOfStoragePools");
326 CAMLreturn (Val_int (r));
330 #ifdef HAVE_WEAK_SYMBOLS
331 #ifdef HAVE_VIRCONNECTLISTSTORAGEPOOLS
332 extern int virConnectListStoragePools (virConnectPtr conn, char **const names, int maxnames) __attribute__((weak));
337 ocaml_libvirt_connect_list_storage_pools (value connv, value iv)
339 CAMLparam2 (connv, iv);
340 #ifndef HAVE_VIRCONNECTLISTSTORAGEPOOLS
341 /* Symbol virConnectListStoragePools not found at compile time. */
342 not_supported ("virConnectListStoragePools");
343 /* Suppresses a compiler warning. */
346 /* Check that the symbol virConnectListStoragePools
347 * is in runtime version of libvirt.
349 WEAK_SYMBOL_CHECK (virConnectListStoragePools);
351 CAMLlocal2 (rv, strv);
352 virConnectPtr conn = Connect_val (connv);
353 int i = Int_val (iv);
357 NONBLOCKING (r = virConnectListStoragePools (conn, names, i));
358 CHECK_ERROR (r == -1, conn, "virConnectListStoragePools");
360 rv = caml_alloc (r, 0);
361 for (i = 0; i < r; ++i) {
362 strv = caml_copy_string (names[i]);
363 Store_field (rv, i, strv);
371 #ifdef HAVE_WEAK_SYMBOLS
372 #ifdef HAVE_VIRCONNECTNUMOFDEFINEDSTORAGEPOOLS
373 extern int virConnectNumOfDefinedStoragePools (virConnectPtr conn) __attribute__((weak));
378 ocaml_libvirt_connect_num_of_defined_storage_pools (value connv)
381 #ifndef HAVE_VIRCONNECTNUMOFDEFINEDSTORAGEPOOLS
382 /* Symbol virConnectNumOfDefinedStoragePools not found at compile time. */
383 not_supported ("virConnectNumOfDefinedStoragePools");
384 /* Suppresses a compiler warning. */
387 /* Check that the symbol virConnectNumOfDefinedStoragePools
388 * is in runtime version of libvirt.
390 WEAK_SYMBOL_CHECK (virConnectNumOfDefinedStoragePools);
392 virConnectPtr conn = Connect_val (connv);
395 NONBLOCKING (r = virConnectNumOfDefinedStoragePools (conn));
396 CHECK_ERROR (r == -1, conn, "virConnectNumOfDefinedStoragePools");
398 CAMLreturn (Val_int (r));
402 #ifdef HAVE_WEAK_SYMBOLS
403 #ifdef HAVE_VIRCONNECTLISTDEFINEDSTORAGEPOOLS
404 extern int virConnectListDefinedStoragePools (virConnectPtr conn, char **const names, int maxnames) __attribute__((weak));
409 ocaml_libvirt_connect_list_defined_storage_pools (value connv, value iv)
411 CAMLparam2 (connv, iv);
412 #ifndef HAVE_VIRCONNECTLISTDEFINEDSTORAGEPOOLS
413 /* Symbol virConnectListDefinedStoragePools not found at compile time. */
414 not_supported ("virConnectListDefinedStoragePools");
415 /* Suppresses a compiler warning. */
418 /* Check that the symbol virConnectListDefinedStoragePools
419 * is in runtime version of libvirt.
421 WEAK_SYMBOL_CHECK (virConnectListDefinedStoragePools);
423 CAMLlocal2 (rv, strv);
424 virConnectPtr conn = Connect_val (connv);
425 int i = Int_val (iv);
429 NONBLOCKING (r = virConnectListDefinedStoragePools (conn, names, i));
430 CHECK_ERROR (r == -1, conn, "virConnectListDefinedStoragePools");
432 rv = caml_alloc (r, 0);
433 for (i = 0; i < r; ++i) {
434 strv = caml_copy_string (names[i]);
435 Store_field (rv, i, strv);
444 ocaml_libvirt_connect_get_capabilities (value connv)
449 virConnectPtr conn = Connect_val (connv);
452 NONBLOCKING (r = virConnectGetCapabilities (conn));
453 CHECK_ERROR (!r, conn, "virConnectGetCapabilities");
455 rv = caml_copy_string (r);
461 ocaml_libvirt_domain_create_linux (value connv, value strv)
463 CAMLparam2 (connv, strv);
466 virConnectPtr conn = Connect_val (connv);
467 char *str = String_val (strv);
470 NONBLOCKING (r = virDomainCreateLinux (conn, str, 0));
471 CHECK_ERROR (!r, conn, "virDomainCreateLinux");
473 rv = Val_domain (r, connv);
479 ocaml_libvirt_domain_create_linux_job (value connv, value strv)
481 CAMLparam2 (connv, strv);
484 virConnectPtr conn = Connect_val (connv);
485 char *str = String_val (strv);
488 NONBLOCKING (r = virDomainCreateLinuxJob (conn, str, 0));
489 CHECK_ERROR (!r, conn, "virDomainCreateLinuxJob");
491 rv = Val_job (r, connv);
497 ocaml_libvirt_domain_free (value domv)
501 virDomainPtr dom = Domain_val (domv);
502 virConnectPtr conn = Connect_domv (domv);
505 NONBLOCKING (r = virDomainFree (dom));
506 CHECK_ERROR (r == -1, conn, "virDomainFree");
508 /* So that we don't double-free in the finalizer: */
509 Domain_val (domv) = NULL;
511 CAMLreturn (Val_unit);
515 ocaml_libvirt_domain_destroy (value domv)
519 virDomainPtr dom = Domain_val (domv);
520 virConnectPtr conn = Connect_domv (domv);
523 NONBLOCKING (r = virDomainDestroy (dom));
524 CHECK_ERROR (r == -1, conn, "virDomainDestroy");
526 /* So that we don't double-free in the finalizer: */
527 Domain_val (domv) = NULL;
529 CAMLreturn (Val_unit);
533 ocaml_libvirt_domain_lookup_by_name (value connv, value strv)
535 CAMLparam2 (connv, strv);
538 virConnectPtr conn = Connect_val (connv);
539 char *str = String_val (strv);
542 NONBLOCKING (r = virDomainLookupByName (conn, str));
543 CHECK_ERROR (!r, conn, "virDomainLookupByName");
545 rv = Val_domain (r, connv);
551 ocaml_libvirt_domain_lookup_by_id (value connv, value iv)
553 CAMLparam2 (connv, iv);
556 virConnectPtr conn = Connect_val (connv);
557 int i = Int_val (iv);
560 NONBLOCKING (r = virDomainLookupByID (conn, i));
561 CHECK_ERROR (!r, conn, "virDomainLookupByID");
563 rv = Val_domain (r, connv);
569 ocaml_libvirt_domain_lookup_by_uuid (value connv, value uuidv)
571 CAMLparam2 (connv, uuidv);
574 virConnectPtr conn = Connect_val (connv);
575 unsigned char *uuid = (unsigned char *) String_val (uuidv);
578 NONBLOCKING (r = virDomainLookupByUUID (conn, uuid));
579 CHECK_ERROR (!r, conn, "virDomainLookupByUUID");
581 rv = Val_domain (r, connv);
587 ocaml_libvirt_domain_lookup_by_uuid_string (value connv, value strv)
589 CAMLparam2 (connv, strv);
592 virConnectPtr conn = Connect_val (connv);
593 char *str = String_val (strv);
596 NONBLOCKING (r = virDomainLookupByUUIDString (conn, str));
597 CHECK_ERROR (!r, conn, "virDomainLookupByUUIDString");
599 rv = Val_domain (r, connv);
605 ocaml_libvirt_domain_get_name (value domv)
610 virDomainPtr dom = Domain_val (domv);
611 virConnectPtr conn = Connect_domv (domv);
614 NONBLOCKING (r = virDomainGetName (dom));
615 CHECK_ERROR (!r, conn, "virDomainGetName");
617 rv = caml_copy_string (r);
622 ocaml_libvirt_domain_get_os_type (value domv)
627 virDomainPtr dom = Domain_val (domv);
628 virConnectPtr conn = Connect_domv (domv);
631 NONBLOCKING (r = virDomainGetOSType (dom));
632 CHECK_ERROR (!r, conn, "virDomainGetOSType");
634 rv = caml_copy_string (r);
640 ocaml_libvirt_domain_get_xml_desc (value domv)
645 virDomainPtr dom = Domain_val (domv);
646 virConnectPtr conn = Connect_domv (domv);
649 NONBLOCKING (r = virDomainGetXMLDesc (dom, 0));
650 CHECK_ERROR (!r, conn, "virDomainGetXMLDesc");
652 rv = caml_copy_string (r);
658 ocaml_libvirt_domain_get_uuid (value domv)
663 virDomainPtr dom = Domain_val (domv);
664 virConnectPtr conn = Connect_domv (domv);
665 unsigned char uuid[VIR_UUID_BUFLEN];
668 NONBLOCKING (r = virDomainGetUUID (dom, uuid));
669 CHECK_ERROR (r == -1, conn, "virDomainGetUUID");
671 rv = caml_copy_string ((char *) uuid);
676 ocaml_libvirt_domain_get_uuid_string (value domv)
681 virDomainPtr dom = Domain_val (domv);
682 virConnectPtr conn = Connect_domv (domv);
683 char uuid[VIR_UUID_STRING_BUFLEN];
686 NONBLOCKING (r = virDomainGetUUIDString (dom, uuid));
687 CHECK_ERROR (r == -1, conn, "virDomainGetUUIDString");
689 rv = caml_copy_string (uuid);
694 ocaml_libvirt_domain_get_max_vcpus (value domv)
698 virDomainPtr dom = Domain_val (domv);
699 virConnectPtr conn = Connect_domv (domv);
702 NONBLOCKING (r = virDomainGetMaxVcpus (dom));
703 CHECK_ERROR (r == -1, conn, "virDomainGetMaxVcpus");
705 CAMLreturn (Val_int (r));
709 ocaml_libvirt_domain_save (value domv, value strv)
711 CAMLparam2 (domv, strv);
714 virDomainPtr dom = Domain_val (domv);
715 virConnectPtr conn = Connect_domv (domv);
716 char *str = String_val (strv);
719 NONBLOCKING (r = virDomainSave (dom, str));
720 CHECK_ERROR (r == -1, conn, "virDomainSave");
722 CAMLreturn (Val_unit);
726 ocaml_libvirt_domain_save_job (value domv, value strv)
728 CAMLparam2 (domv, strv);
730 CAMLlocal2 (rv, connv);
731 virDomainPtr dom = Domain_val (domv);
732 virConnectPtr conn = Connect_domv (domv);
733 char *str = String_val (strv);
736 NONBLOCKING (r = virDomainSaveJob (dom, str));
737 CHECK_ERROR (!r, conn, "virDomainSaveJob");
739 connv = Field (domv, 1);
740 rv = Val_job (r, connv);
746 ocaml_libvirt_domain_restore (value connv, value strv)
748 CAMLparam2 (connv, strv);
751 virConnectPtr conn = Connect_val (connv);
752 char *str = String_val (strv);
755 NONBLOCKING (r = virDomainRestore (conn, str));
756 CHECK_ERROR (r == -1, conn, "virDomainRestore");
758 CAMLreturn (Val_unit);
762 ocaml_libvirt_domain_restore_job (value connv, value strv)
764 CAMLparam2 (connv, strv);
767 virConnectPtr conn = Connect_val (connv);
768 char *str = String_val (strv);
771 NONBLOCKING (r = virDomainRestoreJob (conn, str));
772 CHECK_ERROR (!r, conn, "virDomainRestoreJob");
774 rv = Val_job (r, connv);
780 ocaml_libvirt_domain_core_dump (value domv, value strv)
782 CAMLparam2 (domv, strv);
785 virDomainPtr dom = Domain_val (domv);
786 virConnectPtr conn = Connect_domv (domv);
787 char *str = String_val (strv);
790 NONBLOCKING (r = virDomainCoreDump (dom, str, 0));
791 CHECK_ERROR (!r, conn, "virDomainCoreDump");
793 CAMLreturn (Val_unit);
797 ocaml_libvirt_domain_core_dump_job (value domv, value strv)
799 CAMLparam2 (domv, strv);
801 CAMLlocal2 (rv, connv);
802 virDomainPtr dom = Domain_val (domv);
803 virConnectPtr conn = Connect_domv (domv);
804 char *str = String_val (strv);
807 NONBLOCKING (r = virDomainCoreDumpJob (dom, str, 0));
808 CHECK_ERROR (!r, conn, "virDomainCoreDumpJob");
810 connv = Field (domv, 1);
811 rv = Val_job (r, connv);
817 ocaml_libvirt_domain_suspend (value domv)
821 virDomainPtr dom = Domain_val (domv);
822 virConnectPtr conn = Connect_domv (domv);
825 NONBLOCKING (r = virDomainSuspend (dom));
826 CHECK_ERROR (r == -1, conn, "virDomainSuspend");
828 CAMLreturn (Val_unit);
832 ocaml_libvirt_domain_resume (value domv)
836 virDomainPtr dom = Domain_val (domv);
837 virConnectPtr conn = Connect_domv (domv);
840 NONBLOCKING (r = virDomainResume (dom));
841 CHECK_ERROR (r == -1, conn, "virDomainResume");
843 CAMLreturn (Val_unit);
847 ocaml_libvirt_domain_shutdown (value domv)
851 virDomainPtr dom = Domain_val (domv);
852 virConnectPtr conn = Connect_domv (domv);
855 NONBLOCKING (r = virDomainShutdown (dom));
856 CHECK_ERROR (r == -1, conn, "virDomainShutdown");
858 CAMLreturn (Val_unit);
862 ocaml_libvirt_domain_reboot (value domv)
866 virDomainPtr dom = Domain_val (domv);
867 virConnectPtr conn = Connect_domv (domv);
870 NONBLOCKING (r = virDomainReboot (dom, 0));
871 CHECK_ERROR (r == -1, conn, "virDomainReboot");
873 CAMLreturn (Val_unit);
877 ocaml_libvirt_domain_define_xml (value connv, value strv)
879 CAMLparam2 (connv, strv);
882 virConnectPtr conn = Connect_val (connv);
883 char *str = String_val (strv);
886 NONBLOCKING (r = virDomainDefineXML (conn, str));
887 CHECK_ERROR (!r, conn, "virDomainDefineXML");
889 rv = Val_domain (r, connv);
895 ocaml_libvirt_domain_undefine (value domv)
899 virDomainPtr dom = Domain_val (domv);
900 virConnectPtr conn = Connect_domv (domv);
903 NONBLOCKING (r = virDomainUndefine (dom));
904 CHECK_ERROR (r == -1, conn, "virDomainUndefine");
906 CAMLreturn (Val_unit);
910 ocaml_libvirt_domain_create (value domv)
914 virDomainPtr dom = Domain_val (domv);
915 virConnectPtr conn = Connect_domv (domv);
918 NONBLOCKING (r = virDomainCreate (dom));
919 CHECK_ERROR (r == -1, conn, "virDomainCreate");
921 CAMLreturn (Val_unit);
925 ocaml_libvirt_domain_create_job (value domv)
929 CAMLlocal2 (rv, connv);
930 virDomainPtr dom = Domain_val (domv);
931 virConnectPtr conn = Connect_domv (domv);
934 NONBLOCKING (r = virDomainCreateJob (dom, 0));
935 CHECK_ERROR (!r, conn, "virDomainCreateJob");
937 connv = Field (domv, 1);
938 rv = Val_job (r, connv);
944 ocaml_libvirt_domain_attach_device (value domv, value strv)
946 CAMLparam2 (domv, strv);
949 virDomainPtr dom = Domain_val (domv);
950 virConnectPtr conn = Connect_domv (domv);
951 char *str = String_val (strv);
954 NONBLOCKING (r = virDomainAttachDevice (dom, str));
955 CHECK_ERROR (r == -1, conn, "virDomainAttachDevice");
957 CAMLreturn (Val_unit);
961 ocaml_libvirt_domain_detach_device (value domv, value strv)
963 CAMLparam2 (domv, strv);
966 virDomainPtr dom = Domain_val (domv);
967 virConnectPtr conn = Connect_domv (domv);
968 char *str = String_val (strv);
971 NONBLOCKING (r = virDomainDetachDevice (dom, str));
972 CHECK_ERROR (r == -1, conn, "virDomainDetachDevice");
974 CAMLreturn (Val_unit);
978 ocaml_libvirt_domain_get_autostart (value domv)
982 virDomainPtr dom = Domain_val (domv);
983 virConnectPtr conn = Connect_domv (domv);
986 NONBLOCKING (r = virDomainGetAutostart (dom, &b));
987 CHECK_ERROR (r == -1, conn, "virDomainGetAutostart");
989 CAMLreturn (b ? Val_true : Val_false);
993 ocaml_libvirt_domain_set_autostart (value domv, value bv)
995 CAMLparam2 (domv, bv);
997 virDomainPtr dom = Domain_val (domv);
998 virConnectPtr conn = Connect_domv (domv);
1001 b = bv == Val_true ? 1 : 0;
1003 NONBLOCKING (r = virDomainSetAutostart (dom, b));
1004 CHECK_ERROR (r == -1, conn, "virDomainSetAutostart");
1006 CAMLreturn (Val_unit);
1010 ocaml_libvirt_network_free (value netv)
1014 virNetworkPtr net = Network_val (netv);
1015 virConnectPtr conn = Connect_netv (netv);
1018 NONBLOCKING (r = virNetworkFree (net));
1019 CHECK_ERROR (r == -1, conn, "virNetworkFree");
1021 /* So that we don't double-free in the finalizer: */
1022 Network_val (netv) = NULL;
1024 CAMLreturn (Val_unit);
1028 ocaml_libvirt_network_destroy (value netv)
1032 virNetworkPtr net = Network_val (netv);
1033 virConnectPtr conn = Connect_netv (netv);
1036 NONBLOCKING (r = virNetworkDestroy (net));
1037 CHECK_ERROR (r == -1, conn, "virNetworkDestroy");
1039 /* So that we don't double-free in the finalizer: */
1040 Network_val (netv) = NULL;
1042 CAMLreturn (Val_unit);
1046 ocaml_libvirt_network_lookup_by_name (value connv, value strv)
1048 CAMLparam2 (connv, strv);
1051 virConnectPtr conn = Connect_val (connv);
1052 char *str = String_val (strv);
1055 NONBLOCKING (r = virNetworkLookupByName (conn, str));
1056 CHECK_ERROR (!r, conn, "virNetworkLookupByName");
1058 rv = Val_network (r, connv);
1064 ocaml_libvirt_network_lookup_by_uuid (value connv, value uuidv)
1066 CAMLparam2 (connv, uuidv);
1069 virConnectPtr conn = Connect_val (connv);
1070 unsigned char *uuid = (unsigned char *) String_val (uuidv);
1073 NONBLOCKING (r = virNetworkLookupByUUID (conn, uuid));
1074 CHECK_ERROR (!r, conn, "virNetworkLookupByUUID");
1076 rv = Val_network (r, connv);
1082 ocaml_libvirt_network_lookup_by_uuid_string (value connv, value strv)
1084 CAMLparam2 (connv, strv);
1087 virConnectPtr conn = Connect_val (connv);
1088 char *str = String_val (strv);
1091 NONBLOCKING (r = virNetworkLookupByUUIDString (conn, str));
1092 CHECK_ERROR (!r, conn, "virNetworkLookupByUUIDString");
1094 rv = Val_network (r, connv);
1100 ocaml_libvirt_network_get_name (value netv)
1105 virNetworkPtr net = Network_val (netv);
1106 virConnectPtr conn = Connect_netv (netv);
1109 NONBLOCKING (r = virNetworkGetName (net));
1110 CHECK_ERROR (!r, conn, "virNetworkGetName");
1112 rv = caml_copy_string (r);
1117 ocaml_libvirt_network_get_xml_desc (value netv)
1122 virNetworkPtr net = Network_val (netv);
1123 virConnectPtr conn = Connect_netv (netv);
1126 NONBLOCKING (r = virNetworkGetXMLDesc (net, 0));
1127 CHECK_ERROR (!r, conn, "virNetworkGetXMLDesc");
1129 rv = caml_copy_string (r);
1135 ocaml_libvirt_network_get_bridge_name (value netv)
1140 virNetworkPtr net = Network_val (netv);
1141 virConnectPtr conn = Connect_netv (netv);
1144 NONBLOCKING (r = virNetworkGetBridgeName (net));
1145 CHECK_ERROR (!r, conn, "virNetworkGetBridgeName");
1147 rv = caml_copy_string (r);
1153 ocaml_libvirt_network_get_uuid (value netv)
1158 virNetworkPtr net = Network_val (netv);
1159 virConnectPtr conn = Connect_netv (netv);
1160 unsigned char uuid[VIR_UUID_BUFLEN];
1163 NONBLOCKING (r = virNetworkGetUUID (net, uuid));
1164 CHECK_ERROR (r == -1, conn, "virNetworkGetUUID");
1166 rv = caml_copy_string ((char *) uuid);
1171 ocaml_libvirt_network_get_uuid_string (value netv)
1176 virNetworkPtr net = Network_val (netv);
1177 virConnectPtr conn = Connect_netv (netv);
1178 char uuid[VIR_UUID_STRING_BUFLEN];
1181 NONBLOCKING (r = virNetworkGetUUIDString (net, uuid));
1182 CHECK_ERROR (r == -1, conn, "virNetworkGetUUIDString");
1184 rv = caml_copy_string (uuid);
1189 ocaml_libvirt_network_undefine (value netv)
1193 virNetworkPtr net = Network_val (netv);
1194 virConnectPtr conn = Connect_netv (netv);
1197 NONBLOCKING (r = virNetworkUndefine (net));
1198 CHECK_ERROR (r == -1, conn, "virNetworkUndefine");
1200 CAMLreturn (Val_unit);
1204 ocaml_libvirt_network_create_xml (value connv, value strv)
1206 CAMLparam2 (connv, strv);
1209 virConnectPtr conn = Connect_val (connv);
1210 char *str = String_val (strv);
1213 NONBLOCKING (r = virNetworkCreateXML (conn, str));
1214 CHECK_ERROR (!r, conn, "virNetworkCreateXML");
1216 rv = Val_network (r, connv);
1222 ocaml_libvirt_network_create_xml_job (value connv, value strv)
1224 CAMLparam2 (connv, strv);
1227 virConnectPtr conn = Connect_val (connv);
1228 char *str = String_val (strv);
1231 NONBLOCKING (r = virNetworkCreateXMLJob (conn, str));
1232 CHECK_ERROR (!r, conn, "virNetworkCreateXMLJob");
1234 rv = Val_job (r, connv);
1240 ocaml_libvirt_network_define_xml (value connv, value strv)
1242 CAMLparam2 (connv, strv);
1245 virConnectPtr conn = Connect_val (connv);
1246 char *str = String_val (strv);
1249 NONBLOCKING (r = virNetworkDefineXML (conn, str));
1250 CHECK_ERROR (!r, conn, "virNetworkDefineXML");
1252 rv = Val_network (r, connv);
1258 ocaml_libvirt_network_create (value netv)
1262 virNetworkPtr net = Network_val (netv);
1263 virConnectPtr conn = Connect_netv (netv);
1266 NONBLOCKING (r = virNetworkCreate (net));
1267 CHECK_ERROR (r == -1, conn, "virNetworkCreate");
1269 CAMLreturn (Val_unit);
1273 ocaml_libvirt_network_create_job (value netv)
1277 CAMLlocal2 (rv, connv);
1278 virNetworkPtr net = Network_val (netv);
1279 virConnectPtr conn = Connect_netv (netv);
1282 NONBLOCKING (r = virNetworkCreateJob (net));
1283 CHECK_ERROR (!r, conn, "virNetworkCreateJob");
1285 connv = Field (netv, 1);
1286 rv = Val_job (r, connv);
1292 ocaml_libvirt_network_get_autostart (value netv)
1296 virNetworkPtr net = Network_val (netv);
1297 virConnectPtr conn = Connect_netv (netv);
1300 NONBLOCKING (r = virNetworkGetAutostart (net, &b));
1301 CHECK_ERROR (r == -1, conn, "virNetworkGetAutostart");
1303 CAMLreturn (b ? Val_true : Val_false);
1307 ocaml_libvirt_network_set_autostart (value netv, value bv)
1309 CAMLparam2 (netv, bv);
1311 virNetworkPtr net = Network_val (netv);
1312 virConnectPtr conn = Connect_netv (netv);
1315 b = bv == Val_true ? 1 : 0;
1317 NONBLOCKING (r = virNetworkSetAutostart (net, b));
1318 CHECK_ERROR (r == -1, conn, "virNetworkSetAutostart");
1320 CAMLreturn (Val_unit);
1323 #ifdef HAVE_WEAK_SYMBOLS
1324 #ifdef HAVE_VIRSTORAGEPOOLFREE
1325 extern int virStoragePoolFree (virStoragePoolPtr pool) __attribute__((weak));
1330 ocaml_libvirt_storage_pool_free (value poolv)
1333 #ifndef HAVE_VIRSTORAGEPOOLFREE
1334 /* Symbol virStoragePoolFree not found at compile time. */
1335 not_supported ("virStoragePoolFree");
1336 /* Suppresses a compiler warning. */
1339 /* Check that the symbol virStoragePoolFree
1340 * is in runtime version of libvirt.
1342 WEAK_SYMBOL_CHECK (virStoragePoolFree);
1344 virStoragePoolPtr pool = Pool_val (poolv);
1345 virConnectPtr conn = Connect_polv (poolv);
1348 NONBLOCKING (r = virStoragePoolFree (pool));
1349 CHECK_ERROR (r == -1, conn, "virStoragePoolFree");
1351 /* So that we don't double-free in the finalizer: */
1352 Pool_val (poolv) = NULL;
1354 CAMLreturn (Val_unit);
1358 #ifdef HAVE_WEAK_SYMBOLS
1359 #ifdef HAVE_VIRSTORAGEPOOLDESTROY
1360 extern int virStoragePoolDestroy (virStoragePoolPtr pool) __attribute__((weak));
1365 ocaml_libvirt_storage_pool_destroy (value poolv)
1368 #ifndef HAVE_VIRSTORAGEPOOLDESTROY
1369 /* Symbol virStoragePoolDestroy not found at compile time. */
1370 not_supported ("virStoragePoolDestroy");
1371 /* Suppresses a compiler warning. */
1374 /* Check that the symbol virStoragePoolDestroy
1375 * is in runtime version of libvirt.
1377 WEAK_SYMBOL_CHECK (virStoragePoolDestroy);
1379 virStoragePoolPtr pool = Pool_val (poolv);
1380 virConnectPtr conn = Connect_polv (poolv);
1383 NONBLOCKING (r = virStoragePoolDestroy (pool));
1384 CHECK_ERROR (r == -1, conn, "virStoragePoolDestroy");
1386 /* So that we don't double-free in the finalizer: */
1387 Pool_val (poolv) = NULL;
1389 CAMLreturn (Val_unit);
1393 #ifdef HAVE_WEAK_SYMBOLS
1394 #ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYNAME
1395 extern virStoragePoolPtr virStoragePoolLookupByName (virConnectPtr conn, const char *str) __attribute__((weak));
1400 ocaml_libvirt_storage_pool_lookup_by_name (value connv, value strv)
1402 CAMLparam2 (connv, strv);
1403 #ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYNAME
1404 /* Symbol virStoragePoolLookupByName not found at compile time. */
1405 not_supported ("virStoragePoolLookupByName");
1406 /* Suppresses a compiler warning. */
1409 /* Check that the symbol virStoragePoolLookupByName
1410 * is in runtime version of libvirt.
1412 WEAK_SYMBOL_CHECK (virStoragePoolLookupByName);
1415 virConnectPtr conn = Connect_val (connv);
1416 char *str = String_val (strv);
1417 virStoragePoolPtr r;
1419 NONBLOCKING (r = virStoragePoolLookupByName (conn, str));
1420 CHECK_ERROR (!r, conn, "virStoragePoolLookupByName");
1422 rv = Val_pool (r, connv);
1428 #ifdef HAVE_WEAK_SYMBOLS
1429 #ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYUUID
1430 extern virStoragePoolPtr virStoragePoolLookupByUUID (virConnectPtr conn, const unsigned char *str) __attribute__((weak));
1435 ocaml_libvirt_storage_pool_lookup_by_uuid (value connv, value uuidv)
1437 CAMLparam2 (connv, uuidv);
1438 #ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYUUID
1439 /* Symbol virStoragePoolLookupByUUID not found at compile time. */
1440 not_supported ("virStoragePoolLookupByUUID");
1441 /* Suppresses a compiler warning. */
1444 /* Check that the symbol virStoragePoolLookupByUUID
1445 * is in runtime version of libvirt.
1447 WEAK_SYMBOL_CHECK (virStoragePoolLookupByUUID);
1450 virConnectPtr conn = Connect_val (connv);
1451 unsigned char *uuid = (unsigned char *) String_val (uuidv);
1452 virStoragePoolPtr r;
1454 NONBLOCKING (r = virStoragePoolLookupByUUID (conn, uuid));
1455 CHECK_ERROR (!r, conn, "virStoragePoolLookupByUUID");
1457 rv = Val_pool (r, connv);
1463 #ifdef HAVE_WEAK_SYMBOLS
1464 #ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYUUIDSTRING
1465 extern virStoragePoolPtr virStoragePoolLookupByUUIDString (virConnectPtr conn, const char *str) __attribute__((weak));
1470 ocaml_libvirt_storage_pool_lookup_by_uuid_string (value connv, value strv)
1472 CAMLparam2 (connv, strv);
1473 #ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYUUIDSTRING
1474 /* Symbol virStoragePoolLookupByUUIDString not found at compile time. */
1475 not_supported ("virStoragePoolLookupByUUIDString");
1476 /* Suppresses a compiler warning. */
1479 /* Check that the symbol virStoragePoolLookupByUUIDString
1480 * is in runtime version of libvirt.
1482 WEAK_SYMBOL_CHECK (virStoragePoolLookupByUUIDString);
1485 virConnectPtr conn = Connect_val (connv);
1486 char *str = String_val (strv);
1487 virStoragePoolPtr r;
1489 NONBLOCKING (r = virStoragePoolLookupByUUIDString (conn, str));
1490 CHECK_ERROR (!r, conn, "virStoragePoolLookupByUUIDString");
1492 rv = Val_pool (r, connv);
1498 #ifdef HAVE_WEAK_SYMBOLS
1499 #ifdef HAVE_VIRSTORAGEPOOLGETNAME
1500 extern const char *virStoragePoolGetName (virStoragePoolPtr pool) __attribute__((weak));
1505 ocaml_libvirt_storage_pool_get_name (value poolv)
1508 #ifndef HAVE_VIRSTORAGEPOOLGETNAME
1509 /* Symbol virStoragePoolGetName not found at compile time. */
1510 not_supported ("virStoragePoolGetName");
1511 /* Suppresses a compiler warning. */
1514 /* Check that the symbol virStoragePoolGetName
1515 * is in runtime version of libvirt.
1517 WEAK_SYMBOL_CHECK (virStoragePoolGetName);
1520 virStoragePoolPtr pool = Pool_val (poolv);
1521 virConnectPtr conn = Connect_polv (poolv);
1524 NONBLOCKING (r = virStoragePoolGetName (pool));
1525 CHECK_ERROR (!r, conn, "virStoragePoolGetName");
1527 rv = caml_copy_string (r);
1532 #ifdef HAVE_WEAK_SYMBOLS
1533 #ifdef HAVE_VIRSTORAGEPOOLGETXMLDESC
1534 extern char *virStoragePoolGetXMLDesc (virStoragePoolPtr pool, int flags) __attribute__((weak));
1539 ocaml_libvirt_storage_pool_get_xml_desc (value poolv)
1542 #ifndef HAVE_VIRSTORAGEPOOLGETXMLDESC
1543 /* Symbol virStoragePoolGetXMLDesc not found at compile time. */
1544 not_supported ("virStoragePoolGetXMLDesc");
1545 /* Suppresses a compiler warning. */
1548 /* Check that the symbol virStoragePoolGetXMLDesc
1549 * is in runtime version of libvirt.
1551 WEAK_SYMBOL_CHECK (virStoragePoolGetXMLDesc);
1554 virStoragePoolPtr pool = Pool_val (poolv);
1555 virConnectPtr conn = Connect_polv (poolv);
1558 NONBLOCKING (r = virStoragePoolGetXMLDesc (pool, 0));
1559 CHECK_ERROR (!r, conn, "virStoragePoolGetXMLDesc");
1561 rv = caml_copy_string (r);
1567 #ifdef HAVE_WEAK_SYMBOLS
1568 #ifdef HAVE_VIRSTORAGEPOOLGETUUID
1569 extern int virStoragePoolGetUUID (virStoragePoolPtr pool, unsigned char *) __attribute__((weak));
1574 ocaml_libvirt_storage_pool_get_uuid (value poolv)
1577 #ifndef HAVE_VIRSTORAGEPOOLGETUUID
1578 /* Symbol virStoragePoolGetUUID not found at compile time. */
1579 not_supported ("virStoragePoolGetUUID");
1580 /* Suppresses a compiler warning. */
1583 /* Check that the symbol virStoragePoolGetUUID
1584 * is in runtime version of libvirt.
1586 WEAK_SYMBOL_CHECK (virStoragePoolGetUUID);
1589 virStoragePoolPtr pool = Pool_val (poolv);
1590 virConnectPtr conn = Connect_polv (poolv);
1591 unsigned char uuid[VIR_UUID_BUFLEN];
1594 NONBLOCKING (r = virStoragePoolGetUUID (pool, uuid));
1595 CHECK_ERROR (r == -1, conn, "virStoragePoolGetUUID");
1597 rv = caml_copy_string ((char *) uuid);
1602 #ifdef HAVE_WEAK_SYMBOLS
1603 #ifdef HAVE_VIRSTORAGEPOOLGETUUIDSTRING
1604 extern int virStoragePoolGetUUIDString (virStoragePoolPtr pool, char *) __attribute__((weak));
1609 ocaml_libvirt_storage_pool_get_uuid_string (value poolv)
1612 #ifndef HAVE_VIRSTORAGEPOOLGETUUIDSTRING
1613 /* Symbol virStoragePoolGetUUIDString not found at compile time. */
1614 not_supported ("virStoragePoolGetUUIDString");
1615 /* Suppresses a compiler warning. */
1618 /* Check that the symbol virStoragePoolGetUUIDString
1619 * is in runtime version of libvirt.
1621 WEAK_SYMBOL_CHECK (virStoragePoolGetUUIDString);
1624 virStoragePoolPtr pool = Pool_val (poolv);
1625 virConnectPtr conn = Connect_polv (poolv);
1626 char uuid[VIR_UUID_STRING_BUFLEN];
1629 NONBLOCKING (r = virStoragePoolGetUUIDString (pool, uuid));
1630 CHECK_ERROR (r == -1, conn, "virStoragePoolGetUUIDString");
1632 rv = caml_copy_string (uuid);
1637 #ifdef HAVE_WEAK_SYMBOLS
1638 #ifdef HAVE_VIRSTORAGEPOOLCREATEXML
1639 extern virStoragePoolPtr virStoragePoolCreateXML (virConnectPtr conn, const char *str) __attribute__((weak));
1644 ocaml_libvirt_storage_pool_create_xml (value connv, value strv)
1646 CAMLparam2 (connv, strv);
1647 #ifndef HAVE_VIRSTORAGEPOOLCREATEXML
1648 /* Symbol virStoragePoolCreateXML not found at compile time. */
1649 not_supported ("virStoragePoolCreateXML");
1650 /* Suppresses a compiler warning. */
1653 /* Check that the symbol virStoragePoolCreateXML
1654 * is in runtime version of libvirt.
1656 WEAK_SYMBOL_CHECK (virStoragePoolCreateXML);
1659 virConnectPtr conn = Connect_val (connv);
1660 char *str = String_val (strv);
1661 virStoragePoolPtr r;
1663 NONBLOCKING (r = virStoragePoolCreateXML (conn, str));
1664 CHECK_ERROR (!r, conn, "virStoragePoolCreateXML");
1666 rv = Val_pool (r, connv);
1672 #ifdef HAVE_WEAK_SYMBOLS
1673 #ifdef HAVE_VIRSTORAGEPOOLDEFINEXML
1674 extern virStoragePoolPtr virStoragePoolDefineXML (virConnectPtr conn, const char *str) __attribute__((weak));
1679 ocaml_libvirt_storage_pool_define_xml (value connv, value strv)
1681 CAMLparam2 (connv, strv);
1682 #ifndef HAVE_VIRSTORAGEPOOLDEFINEXML
1683 /* Symbol virStoragePoolDefineXML not found at compile time. */
1684 not_supported ("virStoragePoolDefineXML");
1685 /* Suppresses a compiler warning. */
1688 /* Check that the symbol virStoragePoolDefineXML
1689 * is in runtime version of libvirt.
1691 WEAK_SYMBOL_CHECK (virStoragePoolDefineXML);
1694 virConnectPtr conn = Connect_val (connv);
1695 char *str = String_val (strv);
1696 virStoragePoolPtr r;
1698 NONBLOCKING (r = virStoragePoolDefineXML (conn, str));
1699 CHECK_ERROR (!r, conn, "virStoragePoolDefineXML");
1701 rv = Val_pool (r, connv);
1707 #ifdef HAVE_WEAK_SYMBOLS
1708 #ifdef HAVE_VIRSTORAGEPOOLUNDEFINE
1709 extern int virStoragePoolUndefine (virStoragePoolPtr pool) __attribute__((weak));
1714 ocaml_libvirt_storage_pool_undefine (value poolv)
1717 #ifndef HAVE_VIRSTORAGEPOOLUNDEFINE
1718 /* Symbol virStoragePoolUndefine not found at compile time. */
1719 not_supported ("virStoragePoolUndefine");
1720 /* Suppresses a compiler warning. */
1723 /* Check that the symbol virStoragePoolUndefine
1724 * is in runtime version of libvirt.
1726 WEAK_SYMBOL_CHECK (virStoragePoolUndefine);
1728 virStoragePoolPtr pool = Pool_val (poolv);
1729 virConnectPtr conn = Connect_polv (poolv);
1732 NONBLOCKING (r = virStoragePoolUndefine (pool));
1733 CHECK_ERROR (r == -1, conn, "virStoragePoolUndefine");
1735 CAMLreturn (Val_unit);
1739 #ifdef HAVE_WEAK_SYMBOLS
1740 #ifdef HAVE_VIRSTORAGEPOOLCREATE
1741 extern int virStoragePoolCreate (virStoragePoolPtr pool) __attribute__((weak));
1746 ocaml_libvirt_storage_pool_create (value poolv)
1749 #ifndef HAVE_VIRSTORAGEPOOLCREATE
1750 /* Symbol virStoragePoolCreate not found at compile time. */
1751 not_supported ("virStoragePoolCreate");
1752 /* Suppresses a compiler warning. */
1755 /* Check that the symbol virStoragePoolCreate
1756 * is in runtime version of libvirt.
1758 WEAK_SYMBOL_CHECK (virStoragePoolCreate);
1760 virStoragePoolPtr pool = Pool_val (poolv);
1761 virConnectPtr conn = Connect_polv (poolv);
1764 NONBLOCKING (r = virStoragePoolCreate (pool));
1765 CHECK_ERROR (r == -1, conn, "virStoragePoolCreate");
1767 CAMLreturn (Val_unit);
1771 #ifdef HAVE_WEAK_SYMBOLS
1772 #ifdef HAVE_VIRSTORAGEPOOLSHUTDOWN
1773 extern int virStoragePoolShutdown (virStoragePoolPtr pool) __attribute__((weak));
1778 ocaml_libvirt_storage_pool_shutdown (value poolv)
1781 #ifndef HAVE_VIRSTORAGEPOOLSHUTDOWN
1782 /* Symbol virStoragePoolShutdown not found at compile time. */
1783 not_supported ("virStoragePoolShutdown");
1784 /* Suppresses a compiler warning. */
1787 /* Check that the symbol virStoragePoolShutdown
1788 * is in runtime version of libvirt.
1790 WEAK_SYMBOL_CHECK (virStoragePoolShutdown);
1792 virStoragePoolPtr pool = Pool_val (poolv);
1793 virConnectPtr conn = Connect_polv (poolv);
1796 NONBLOCKING (r = virStoragePoolShutdown (pool));
1797 CHECK_ERROR (r == -1, conn, "virStoragePoolShutdown");
1799 CAMLreturn (Val_unit);
1803 #ifdef HAVE_WEAK_SYMBOLS
1804 #ifdef HAVE_VIRSTORAGEPOOLREFRESH
1805 extern int virStoragePoolRefresh (virStoragePoolPtr pool, unsigned int flags) __attribute__((weak));
1810 ocaml_libvirt_storage_pool_refresh (value poolv)
1813 #ifndef HAVE_VIRSTORAGEPOOLREFRESH
1814 /* Symbol virStoragePoolRefresh not found at compile time. */
1815 not_supported ("virStoragePoolRefresh");
1816 /* Suppresses a compiler warning. */
1819 /* Check that the symbol virStoragePoolRefresh
1820 * is in runtime version of libvirt.
1822 WEAK_SYMBOL_CHECK (virStoragePoolRefresh);
1824 virStoragePoolPtr pool = Pool_val (poolv);
1825 virConnectPtr conn = Connect_polv (poolv);
1828 NONBLOCKING (r = virStoragePoolRefresh (pool, 0));
1829 CHECK_ERROR (r == -1, conn, "virStoragePoolRefresh");
1831 CAMLreturn (Val_unit);
1835 #ifdef HAVE_WEAK_SYMBOLS
1836 #ifdef HAVE_VIRSTORAGEPOOLGETAUTOSTART
1837 extern int virStoragePoolGetAutostart (virStoragePoolPtr pool, int *r) __attribute__((weak));
1842 ocaml_libvirt_storage_pool_get_autostart (value poolv)
1845 #ifndef HAVE_VIRSTORAGEPOOLGETAUTOSTART
1846 /* Symbol virStoragePoolGetAutostart not found at compile time. */
1847 not_supported ("virStoragePoolGetAutostart");
1848 /* Suppresses a compiler warning. */
1851 /* Check that the symbol virStoragePoolGetAutostart
1852 * is in runtime version of libvirt.
1854 WEAK_SYMBOL_CHECK (virStoragePoolGetAutostart);
1856 virStoragePoolPtr pool = Pool_val (poolv);
1857 virConnectPtr conn = Connect_polv (poolv);
1860 NONBLOCKING (r = virStoragePoolGetAutostart (pool, &b));
1861 CHECK_ERROR (r == -1, conn, "virStoragePoolGetAutostart");
1863 CAMLreturn (b ? Val_true : Val_false);
1867 #ifdef HAVE_WEAK_SYMBOLS
1868 #ifdef HAVE_VIRSTORAGEPOOLSETAUTOSTART
1869 extern int virStoragePoolSetAutostart (virStoragePoolPtr pool, int b) __attribute__((weak));
1874 ocaml_libvirt_storage_pool_set_autostart (value poolv, value bv)
1876 CAMLparam2 (poolv, bv);
1877 #ifndef HAVE_VIRSTORAGEPOOLSETAUTOSTART
1878 /* Symbol virStoragePoolSetAutostart not found at compile time. */
1879 not_supported ("virStoragePoolSetAutostart");
1880 /* Suppresses a compiler warning. */
1883 /* Check that the symbol virStoragePoolSetAutostart
1884 * is in runtime version of libvirt.
1886 WEAK_SYMBOL_CHECK (virStoragePoolSetAutostart);
1888 virStoragePoolPtr pool = Pool_val (poolv);
1889 virConnectPtr conn = Connect_polv (poolv);
1892 b = bv == Val_true ? 1 : 0;
1894 NONBLOCKING (r = virStoragePoolSetAutostart (pool, b));
1895 CHECK_ERROR (r == -1, conn, "virStoragePoolSetAutostart");
1897 CAMLreturn (Val_unit);
1901 #ifdef HAVE_WEAK_SYMBOLS
1902 #ifdef HAVE_VIRSTORAGEVOLFREE
1903 extern int virStorageVolFree (virStorageVolPtr vol) __attribute__((weak));
1908 ocaml_libvirt_storage_vol_free (value volv)
1911 #ifndef HAVE_VIRSTORAGEVOLFREE
1912 /* Symbol virStorageVolFree not found at compile time. */
1913 not_supported ("virStorageVolFree");
1914 /* Suppresses a compiler warning. */
1917 /* Check that the symbol virStorageVolFree
1918 * is in runtime version of libvirt.
1920 WEAK_SYMBOL_CHECK (virStorageVolFree);
1922 virStorageVolPtr vol = Volume_val (volv);
1923 virConnectPtr conn = Connect_volv (volv);
1926 NONBLOCKING (r = virStorageVolFree (vol));
1927 CHECK_ERROR (r == -1, conn, "virStorageVolFree");
1929 /* So that we don't double-free in the finalizer: */
1930 Volume_val (volv) = NULL;
1932 CAMLreturn (Val_unit);
1936 #ifdef HAVE_WEAK_SYMBOLS
1937 #ifdef HAVE_VIRSTORAGEVOLDESTROY
1938 extern int virStorageVolDestroy (virStorageVolPtr vol) __attribute__((weak));
1943 ocaml_libvirt_storage_vol_destroy (value volv)
1946 #ifndef HAVE_VIRSTORAGEVOLDESTROY
1947 /* Symbol virStorageVolDestroy not found at compile time. */
1948 not_supported ("virStorageVolDestroy");
1949 /* Suppresses a compiler warning. */
1952 /* Check that the symbol virStorageVolDestroy
1953 * is in runtime version of libvirt.
1955 WEAK_SYMBOL_CHECK (virStorageVolDestroy);
1957 virStorageVolPtr vol = Volume_val (volv);
1958 virConnectPtr conn = Connect_volv (volv);
1961 NONBLOCKING (r = virStorageVolDestroy (vol));
1962 CHECK_ERROR (r == -1, conn, "virStorageVolDestroy");
1964 /* So that we don't double-free in the finalizer: */
1965 Volume_val (volv) = NULL;
1967 CAMLreturn (Val_unit);
1971 #ifdef HAVE_WEAK_SYMBOLS
1972 #ifdef HAVE_VIRSTORAGEVOLLOOKUPBYKEY
1973 extern virStorageVolPtr virStorageVolLookupByKey (virConnectPtr conn, const char *str) __attribute__((weak));
1978 ocaml_libvirt_storage_vol_lookup_by_key (value connv, value strv)
1980 CAMLparam2 (connv, strv);
1981 #ifndef HAVE_VIRSTORAGEVOLLOOKUPBYKEY
1982 /* Symbol virStorageVolLookupByKey not found at compile time. */
1983 not_supported ("virStorageVolLookupByKey");
1984 /* Suppresses a compiler warning. */
1987 /* Check that the symbol virStorageVolLookupByKey
1988 * is in runtime version of libvirt.
1990 WEAK_SYMBOL_CHECK (virStorageVolLookupByKey);
1993 virConnectPtr conn = Connect_val (connv);
1994 char *str = String_val (strv);
1997 NONBLOCKING (r = virStorageVolLookupByKey (conn, str));
1998 CHECK_ERROR (!r, conn, "virStorageVolLookupByKey");
2000 rv = Val_volume (r, connv);
2006 #ifdef HAVE_WEAK_SYMBOLS
2007 #ifdef HAVE_VIRSTORAGEVOLLOOKUPBYPATH
2008 extern virStorageVolPtr virStorageVolLookupByPath (virConnectPtr conn, const char *str) __attribute__((weak));
2013 ocaml_libvirt_storage_vol_lookup_by_path (value connv, value strv)
2015 CAMLparam2 (connv, strv);
2016 #ifndef HAVE_VIRSTORAGEVOLLOOKUPBYPATH
2017 /* Symbol virStorageVolLookupByPath not found at compile time. */
2018 not_supported ("virStorageVolLookupByPath");
2019 /* Suppresses a compiler warning. */
2022 /* Check that the symbol virStorageVolLookupByPath
2023 * is in runtime version of libvirt.
2025 WEAK_SYMBOL_CHECK (virStorageVolLookupByPath);
2028 virConnectPtr conn = Connect_val (connv);
2029 char *str = String_val (strv);
2032 NONBLOCKING (r = virStorageVolLookupByPath (conn, str));
2033 CHECK_ERROR (!r, conn, "virStorageVolLookupByPath");
2035 rv = Val_volume (r, connv);
2041 #ifdef HAVE_WEAK_SYMBOLS
2042 #ifdef HAVE_VIRSTORAGEVOLGETXMLDESC
2043 extern char *virStorageVolGetXMLDesc (virStorageVolPtr vol, int flags) __attribute__((weak));
2048 ocaml_libvirt_storage_vol_get_xml_desc (value volv)
2051 #ifndef HAVE_VIRSTORAGEVOLGETXMLDESC
2052 /* Symbol virStorageVolGetXMLDesc not found at compile time. */
2053 not_supported ("virStorageVolGetXMLDesc");
2054 /* Suppresses a compiler warning. */
2057 /* Check that the symbol virStorageVolGetXMLDesc
2058 * is in runtime version of libvirt.
2060 WEAK_SYMBOL_CHECK (virStorageVolGetXMLDesc);
2063 virStorageVolPtr vol = Volume_val (volv);
2064 virConnectPtr conn = Connect_volv (volv);
2067 NONBLOCKING (r = virStorageVolGetXMLDesc (vol, 0));
2068 CHECK_ERROR (!r, conn, "virStorageVolGetXMLDesc");
2070 rv = caml_copy_string (r);
2076 #ifdef HAVE_WEAK_SYMBOLS
2077 #ifdef HAVE_VIRSTORAGEVOLGETPATH
2078 extern char *virStorageVolGetPath (virStorageVolPtr vol) __attribute__((weak));
2083 ocaml_libvirt_storage_vol_get_path (value volv)
2086 #ifndef HAVE_VIRSTORAGEVOLGETPATH
2087 /* Symbol virStorageVolGetPath not found at compile time. */
2088 not_supported ("virStorageVolGetPath");
2089 /* Suppresses a compiler warning. */
2092 /* Check that the symbol virStorageVolGetPath
2093 * is in runtime version of libvirt.
2095 WEAK_SYMBOL_CHECK (virStorageVolGetPath);
2098 virStorageVolPtr vol = Volume_val (volv);
2099 virConnectPtr conn = Connect_volv (volv);
2102 NONBLOCKING (r = virStorageVolGetPath (vol));
2103 CHECK_ERROR (!r, conn, "virStorageVolGetPath");
2105 rv = caml_copy_string (r);
2111 #ifdef HAVE_WEAK_SYMBOLS
2112 #ifdef HAVE_VIRSTORAGEVOLGETKEY
2113 extern const char *virStorageVolGetKey (virStorageVolPtr vol) __attribute__((weak));
2118 ocaml_libvirt_storage_vol_get_key (value volv)
2121 #ifndef HAVE_VIRSTORAGEVOLGETKEY
2122 /* Symbol virStorageVolGetKey not found at compile time. */
2123 not_supported ("virStorageVolGetKey");
2124 /* Suppresses a compiler warning. */
2127 /* Check that the symbol virStorageVolGetKey
2128 * is in runtime version of libvirt.
2130 WEAK_SYMBOL_CHECK (virStorageVolGetKey);
2133 virStorageVolPtr vol = Volume_val (volv);
2134 virConnectPtr conn = Connect_volv (volv);
2137 NONBLOCKING (r = virStorageVolGetKey (vol));
2138 CHECK_ERROR (!r, conn, "virStorageVolGetKey");
2140 rv = caml_copy_string (r);
2145 #ifdef HAVE_WEAK_SYMBOLS
2146 #ifdef HAVE_VIRSTORAGEVOLGETNAME
2147 extern const char *virStorageVolGetName (virStorageVolPtr vol) __attribute__((weak));
2152 ocaml_libvirt_storage_vol_get_name (value volv)
2155 #ifndef HAVE_VIRSTORAGEVOLGETNAME
2156 /* Symbol virStorageVolGetName not found at compile time. */
2157 not_supported ("virStorageVolGetName");
2158 /* Suppresses a compiler warning. */
2161 /* Check that the symbol virStorageVolGetName
2162 * is in runtime version of libvirt.
2164 WEAK_SYMBOL_CHECK (virStorageVolGetName);
2167 virStorageVolPtr vol = Volume_val (volv);
2168 virConnectPtr conn = Connect_volv (volv);
2171 NONBLOCKING (r = virStorageVolGetName (vol));
2172 CHECK_ERROR (!r, conn, "virStorageVolGetName");
2174 rv = caml_copy_string (r);
2179 #ifdef HAVE_WEAK_SYMBOLS
2180 #ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYVOLUME
2181 extern virStoragePoolPtr virStoragePoolLookupByVolume (virStorageVolPtr vol) __attribute__((weak));
2186 ocaml_libvirt_storage_pool_lookup_by_volume (value volv)
2189 #ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYVOLUME
2190 /* Symbol virStoragePoolLookupByVolume not found at compile time. */
2191 not_supported ("virStoragePoolLookupByVolume");
2192 /* Suppresses a compiler warning. */
2195 /* Check that the symbol virStoragePoolLookupByVolume
2196 * is in runtime version of libvirt.
2198 WEAK_SYMBOL_CHECK (virStoragePoolLookupByVolume);
2200 CAMLlocal2 (rv, connv);
2201 virStorageVolPtr vol = Volume_val (volv);
2202 virConnectPtr conn = Connect_volv (volv);
2203 virStoragePoolPtr r;
2205 NONBLOCKING (r = virStoragePoolLookupByVolume (vol));
2206 CHECK_ERROR (!r, conn, "virStoragePoolLookupByVolume");
2208 connv = Field (volv, 1);
2209 rv = Val_pool (r, connv);
2215 #ifdef HAVE_WEAK_SYMBOLS
2216 #ifdef HAVE_VIRJOBFREE
2217 extern int virJobFree (virJobPtr job) __attribute__((weak));
2222 ocaml_libvirt_job_free (value jobv)
2225 #ifndef HAVE_VIRJOBFREE
2226 /* Symbol virJobFree not found at compile time. */
2227 not_supported ("virJobFree");
2228 /* Suppresses a compiler warning. */
2231 /* Check that the symbol virJobFree
2232 * is in runtime version of libvirt.
2234 WEAK_SYMBOL_CHECK (virJobFree);
2236 virJobPtr job = Job_val (jobv);
2237 virConnectPtr conn = Connect_jobv (jobv);
2240 NONBLOCKING (r = virJobFree (job));
2241 CHECK_ERROR (r == -1, conn, "virJobFree");
2243 /* So that we don't double-free in the finalizer: */
2244 Job_val (jobv) = NULL;
2246 CAMLreturn (Val_unit);
2250 #ifdef HAVE_WEAK_SYMBOLS
2251 #ifdef HAVE_VIRJOBCANCEL
2252 extern int virJobCancel (virJobPtr job) __attribute__((weak));
2257 ocaml_libvirt_job_cancel (value jobv)
2260 #ifndef HAVE_VIRJOBCANCEL
2261 /* Symbol virJobCancel not found at compile time. */
2262 not_supported ("virJobCancel");
2263 /* Suppresses a compiler warning. */
2266 /* Check that the symbol virJobCancel
2267 * is in runtime version of libvirt.
2269 WEAK_SYMBOL_CHECK (virJobCancel);
2271 virJobPtr job = Job_val (jobv);
2272 virConnectPtr conn = Connect_jobv (jobv);
2275 NONBLOCKING (r = virJobCancel (job));
2276 CHECK_ERROR (r == -1, conn, "virJobCancel");
2278 CAMLreturn (Val_unit);
2282 #ifdef HAVE_WEAK_SYMBOLS
2283 #ifdef HAVE_VIRJOBGETNETWORK
2284 extern virNetworkPtr virJobGetNetwork (virJobPtr job) __attribute__((weak));
2289 ocaml_libvirt_job_get_network (value jobv)
2292 #ifndef HAVE_VIRJOBGETNETWORK
2293 /* Symbol virJobGetNetwork not found at compile time. */
2294 not_supported ("virJobGetNetwork");
2295 /* Suppresses a compiler warning. */
2298 /* Check that the symbol virJobGetNetwork
2299 * is in runtime version of libvirt.
2301 WEAK_SYMBOL_CHECK (virJobGetNetwork);
2303 CAMLlocal2 (rv, connv);
2304 virJobPtr job = Job_val (jobv);
2305 virConnectPtr conn = Connect_jobv (jobv);
2308 NONBLOCKING (r = virJobGetNetwork (job));
2309 CHECK_ERROR (!r, conn, "virJobGetNetwork");
2311 connv = Field (jobv, 1);
2312 rv = Val_network (r, connv);
2318 #ifdef HAVE_WEAK_SYMBOLS
2319 #ifdef HAVE_VIRJOBGETDOMAIN
2320 extern virDomainPtr virJobGetDomain (virJobPtr job) __attribute__((weak));
2325 ocaml_libvirt_job_get_domain (value jobv)
2328 #ifndef HAVE_VIRJOBGETDOMAIN
2329 /* Symbol virJobGetDomain not found at compile time. */
2330 not_supported ("virJobGetDomain");
2331 /* Suppresses a compiler warning. */
2334 /* Check that the symbol virJobGetDomain
2335 * is in runtime version of libvirt.
2337 WEAK_SYMBOL_CHECK (virJobGetDomain);
2339 CAMLlocal2 (rv, connv);
2340 virJobPtr job = Job_val (jobv);
2341 virConnectPtr conn = Connect_jobv (jobv);
2344 NONBLOCKING (r = virJobGetDomain (job));
2345 CHECK_ERROR (!r, conn, "virJobGetDomain");
2347 connv = Field (jobv, 1);
2348 rv = Val_domain (r, connv);
2354 /* The following functions are unimplemented and always fail.
2355 * See generator.pl '@unimplemented'
2359 ocaml_libvirt_storage_pool_get_info ()
2361 failwith ("ocaml_libvirt_storage_pool_get_info is unimplemented");
2365 ocaml_libvirt_storage_vol_lookup_by_name ()
2367 failwith ("ocaml_libvirt_storage_vol_lookup_by_name is unimplemented");
2371 ocaml_libvirt_storage_vol_create_xml ()
2373 failwith ("ocaml_libvirt_storage_vol_create_xml is unimplemented");
2377 ocaml_libvirt_storage_vol_get_info ()
2379 failwith ("ocaml_libvirt_storage_vol_get_info is unimplemented");
2383 ocaml_libvirt_job_get_info ()
2385 failwith ("ocaml_libvirt_job_get_info is unimplemented");
2388 #include "libvirt_c_epilogue.c"