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);
478 #ifdef HAVE_WEAK_SYMBOLS
479 #ifdef HAVE_VIRDOMAINCREATELINUXJOB
480 extern virJobPtr virDomainCreateLinuxJob (virConnectPtr conn, const char *str, unsigned int flags) __attribute__((weak));
485 ocaml_libvirt_domain_create_linux_job (value connv, value strv)
487 CAMLparam2 (connv, strv);
488 #ifndef HAVE_VIRDOMAINCREATELINUXJOB
489 /* Symbol virDomainCreateLinuxJob not found at compile time. */
490 not_supported ("virDomainCreateLinuxJob");
491 /* Suppresses a compiler warning. */
494 /* Check that the symbol virDomainCreateLinuxJob
495 * is in runtime version of libvirt.
497 WEAK_SYMBOL_CHECK (virDomainCreateLinuxJob);
500 virConnectPtr conn = Connect_val (connv);
501 char *str = String_val (strv);
504 NONBLOCKING (r = virDomainCreateLinuxJob (conn, str, 0));
505 CHECK_ERROR (!r, conn, "virDomainCreateLinuxJob");
507 rv = Val_job (r, connv);
514 ocaml_libvirt_domain_free (value domv)
518 virDomainPtr dom = Domain_val (domv);
519 virConnectPtr conn = Connect_domv (domv);
522 NONBLOCKING (r = virDomainFree (dom));
523 CHECK_ERROR (r == -1, conn, "virDomainFree");
525 /* So that we don't double-free in the finalizer: */
526 Domain_val (domv) = NULL;
528 CAMLreturn (Val_unit);
532 ocaml_libvirt_domain_destroy (value domv)
536 virDomainPtr dom = Domain_val (domv);
537 virConnectPtr conn = Connect_domv (domv);
540 NONBLOCKING (r = virDomainDestroy (dom));
541 CHECK_ERROR (r == -1, conn, "virDomainDestroy");
543 /* So that we don't double-free in the finalizer: */
544 Domain_val (domv) = NULL;
546 CAMLreturn (Val_unit);
550 ocaml_libvirt_domain_lookup_by_name (value connv, value strv)
552 CAMLparam2 (connv, strv);
555 virConnectPtr conn = Connect_val (connv);
556 char *str = String_val (strv);
559 NONBLOCKING (r = virDomainLookupByName (conn, str));
560 CHECK_ERROR (!r, conn, "virDomainLookupByName");
562 rv = Val_domain (r, connv);
568 ocaml_libvirt_domain_lookup_by_id (value connv, value iv)
570 CAMLparam2 (connv, iv);
573 virConnectPtr conn = Connect_val (connv);
574 int i = Int_val (iv);
577 NONBLOCKING (r = virDomainLookupByID (conn, i));
578 CHECK_ERROR (!r, conn, "virDomainLookupByID");
580 rv = Val_domain (r, connv);
586 ocaml_libvirt_domain_lookup_by_uuid (value connv, value uuidv)
588 CAMLparam2 (connv, uuidv);
591 virConnectPtr conn = Connect_val (connv);
592 unsigned char *uuid = (unsigned char *) String_val (uuidv);
595 NONBLOCKING (r = virDomainLookupByUUID (conn, uuid));
596 CHECK_ERROR (!r, conn, "virDomainLookupByUUID");
598 rv = Val_domain (r, connv);
604 ocaml_libvirt_domain_lookup_by_uuid_string (value connv, value strv)
606 CAMLparam2 (connv, strv);
609 virConnectPtr conn = Connect_val (connv);
610 char *str = String_val (strv);
613 NONBLOCKING (r = virDomainLookupByUUIDString (conn, str));
614 CHECK_ERROR (!r, conn, "virDomainLookupByUUIDString");
616 rv = Val_domain (r, connv);
622 ocaml_libvirt_domain_get_name (value domv)
627 virDomainPtr dom = Domain_val (domv);
628 virConnectPtr conn = Connect_domv (domv);
631 NONBLOCKING (r = virDomainGetName (dom));
632 CHECK_ERROR (!r, conn, "virDomainGetName");
634 rv = caml_copy_string (r);
639 ocaml_libvirt_domain_get_os_type (value domv)
644 virDomainPtr dom = Domain_val (domv);
645 virConnectPtr conn = Connect_domv (domv);
648 NONBLOCKING (r = virDomainGetOSType (dom));
649 CHECK_ERROR (!r, conn, "virDomainGetOSType");
651 rv = caml_copy_string (r);
657 ocaml_libvirt_domain_get_xml_desc (value domv)
662 virDomainPtr dom = Domain_val (domv);
663 virConnectPtr conn = Connect_domv (domv);
666 NONBLOCKING (r = virDomainGetXMLDesc (dom, 0));
667 CHECK_ERROR (!r, conn, "virDomainGetXMLDesc");
669 rv = caml_copy_string (r);
675 ocaml_libvirt_domain_get_uuid (value domv)
680 virDomainPtr dom = Domain_val (domv);
681 virConnectPtr conn = Connect_domv (domv);
682 unsigned char uuid[VIR_UUID_BUFLEN];
685 NONBLOCKING (r = virDomainGetUUID (dom, uuid));
686 CHECK_ERROR (r == -1, conn, "virDomainGetUUID");
688 rv = caml_copy_string ((char *) uuid);
693 ocaml_libvirt_domain_get_uuid_string (value domv)
698 virDomainPtr dom = Domain_val (domv);
699 virConnectPtr conn = Connect_domv (domv);
700 char uuid[VIR_UUID_STRING_BUFLEN];
703 NONBLOCKING (r = virDomainGetUUIDString (dom, uuid));
704 CHECK_ERROR (r == -1, conn, "virDomainGetUUIDString");
706 rv = caml_copy_string (uuid);
711 ocaml_libvirt_domain_get_max_vcpus (value domv)
715 virDomainPtr dom = Domain_val (domv);
716 virConnectPtr conn = Connect_domv (domv);
719 NONBLOCKING (r = virDomainGetMaxVcpus (dom));
720 CHECK_ERROR (r == -1, conn, "virDomainGetMaxVcpus");
722 CAMLreturn (Val_int (r));
726 ocaml_libvirt_domain_save (value domv, value strv)
728 CAMLparam2 (domv, strv);
731 virDomainPtr dom = Domain_val (domv);
732 virConnectPtr conn = Connect_domv (domv);
733 char *str = String_val (strv);
736 NONBLOCKING (r = virDomainSave (dom, str));
737 CHECK_ERROR (r == -1, conn, "virDomainSave");
739 CAMLreturn (Val_unit);
742 #ifdef HAVE_WEAK_SYMBOLS
743 #ifdef HAVE_VIRDOMAINSAVEJOB
744 extern virJobPtr virDomainSaveJob (virDomainPtr dom, const char *str) __attribute__((weak));
749 ocaml_libvirt_domain_save_job (value domv, value strv)
751 CAMLparam2 (domv, strv);
752 #ifndef HAVE_VIRDOMAINSAVEJOB
753 /* Symbol virDomainSaveJob not found at compile time. */
754 not_supported ("virDomainSaveJob");
755 /* Suppresses a compiler warning. */
758 /* Check that the symbol virDomainSaveJob
759 * is in runtime version of libvirt.
761 WEAK_SYMBOL_CHECK (virDomainSaveJob);
763 CAMLlocal2 (rv, connv);
764 virDomainPtr dom = Domain_val (domv);
765 virConnectPtr conn = Connect_domv (domv);
766 char *str = String_val (strv);
769 NONBLOCKING (r = virDomainSaveJob (dom, str));
770 CHECK_ERROR (!r, conn, "virDomainSaveJob");
772 connv = Field (domv, 1);
773 rv = Val_job (r, connv);
780 ocaml_libvirt_domain_restore (value connv, value strv)
782 CAMLparam2 (connv, strv);
785 virConnectPtr conn = Connect_val (connv);
786 char *str = String_val (strv);
789 NONBLOCKING (r = virDomainRestore (conn, str));
790 CHECK_ERROR (r == -1, conn, "virDomainRestore");
792 CAMLreturn (Val_unit);
795 #ifdef HAVE_WEAK_SYMBOLS
796 #ifdef HAVE_VIRDOMAINRESTOREJOB
797 extern virJobPtr virDomainRestoreJob (virConnectPtr conn, const char *str) __attribute__((weak));
802 ocaml_libvirt_domain_restore_job (value connv, value strv)
804 CAMLparam2 (connv, strv);
805 #ifndef HAVE_VIRDOMAINRESTOREJOB
806 /* Symbol virDomainRestoreJob not found at compile time. */
807 not_supported ("virDomainRestoreJob");
808 /* Suppresses a compiler warning. */
811 /* Check that the symbol virDomainRestoreJob
812 * is in runtime version of libvirt.
814 WEAK_SYMBOL_CHECK (virDomainRestoreJob);
817 virConnectPtr conn = Connect_val (connv);
818 char *str = String_val (strv);
821 NONBLOCKING (r = virDomainRestoreJob (conn, str));
822 CHECK_ERROR (!r, conn, "virDomainRestoreJob");
824 rv = Val_job (r, connv);
831 ocaml_libvirt_domain_core_dump (value domv, value strv)
833 CAMLparam2 (domv, strv);
836 virDomainPtr dom = Domain_val (domv);
837 virConnectPtr conn = Connect_domv (domv);
838 char *str = String_val (strv);
841 NONBLOCKING (r = virDomainCoreDump (dom, str, 0));
842 CHECK_ERROR (!r, conn, "virDomainCoreDump");
844 CAMLreturn (Val_unit);
847 #ifdef HAVE_WEAK_SYMBOLS
848 #ifdef HAVE_VIRDOMAINCOREDUMPJOB
849 extern virJobPtr virDomainCoreDumpJob (virDomainPtr dom, const char *str, int flags) __attribute__((weak));
854 ocaml_libvirt_domain_core_dump_job (value domv, value strv)
856 CAMLparam2 (domv, strv);
857 #ifndef HAVE_VIRDOMAINCOREDUMPJOB
858 /* Symbol virDomainCoreDumpJob not found at compile time. */
859 not_supported ("virDomainCoreDumpJob");
860 /* Suppresses a compiler warning. */
863 /* Check that the symbol virDomainCoreDumpJob
864 * is in runtime version of libvirt.
866 WEAK_SYMBOL_CHECK (virDomainCoreDumpJob);
868 CAMLlocal2 (rv, connv);
869 virDomainPtr dom = Domain_val (domv);
870 virConnectPtr conn = Connect_domv (domv);
871 char *str = String_val (strv);
874 NONBLOCKING (r = virDomainCoreDumpJob (dom, str, 0));
875 CHECK_ERROR (!r, conn, "virDomainCoreDumpJob");
877 connv = Field (domv, 1);
878 rv = Val_job (r, connv);
885 ocaml_libvirt_domain_suspend (value domv)
889 virDomainPtr dom = Domain_val (domv);
890 virConnectPtr conn = Connect_domv (domv);
893 NONBLOCKING (r = virDomainSuspend (dom));
894 CHECK_ERROR (r == -1, conn, "virDomainSuspend");
896 CAMLreturn (Val_unit);
900 ocaml_libvirt_domain_resume (value domv)
904 virDomainPtr dom = Domain_val (domv);
905 virConnectPtr conn = Connect_domv (domv);
908 NONBLOCKING (r = virDomainResume (dom));
909 CHECK_ERROR (r == -1, conn, "virDomainResume");
911 CAMLreturn (Val_unit);
915 ocaml_libvirt_domain_shutdown (value domv)
919 virDomainPtr dom = Domain_val (domv);
920 virConnectPtr conn = Connect_domv (domv);
923 NONBLOCKING (r = virDomainShutdown (dom));
924 CHECK_ERROR (r == -1, conn, "virDomainShutdown");
926 CAMLreturn (Val_unit);
930 ocaml_libvirt_domain_reboot (value domv)
934 virDomainPtr dom = Domain_val (domv);
935 virConnectPtr conn = Connect_domv (domv);
938 NONBLOCKING (r = virDomainReboot (dom, 0));
939 CHECK_ERROR (r == -1, conn, "virDomainReboot");
941 CAMLreturn (Val_unit);
945 ocaml_libvirt_domain_define_xml (value connv, value strv)
947 CAMLparam2 (connv, strv);
950 virConnectPtr conn = Connect_val (connv);
951 char *str = String_val (strv);
954 NONBLOCKING (r = virDomainDefineXML (conn, str));
955 CHECK_ERROR (!r, conn, "virDomainDefineXML");
957 rv = Val_domain (r, connv);
963 ocaml_libvirt_domain_undefine (value domv)
967 virDomainPtr dom = Domain_val (domv);
968 virConnectPtr conn = Connect_domv (domv);
971 NONBLOCKING (r = virDomainUndefine (dom));
972 CHECK_ERROR (r == -1, conn, "virDomainUndefine");
974 CAMLreturn (Val_unit);
978 ocaml_libvirt_domain_create (value domv)
982 virDomainPtr dom = Domain_val (domv);
983 virConnectPtr conn = Connect_domv (domv);
986 NONBLOCKING (r = virDomainCreate (dom));
987 CHECK_ERROR (r == -1, conn, "virDomainCreate");
989 CAMLreturn (Val_unit);
992 #ifdef HAVE_WEAK_SYMBOLS
993 #ifdef HAVE_VIRDOMAINCREATEJOB
994 extern virJobPtr virDomainCreateJob (virDomainPtr dom, unsigned int flags) __attribute__((weak));
999 ocaml_libvirt_domain_create_job (value domv)
1002 #ifndef HAVE_VIRDOMAINCREATEJOB
1003 /* Symbol virDomainCreateJob not found at compile time. */
1004 not_supported ("virDomainCreateJob");
1005 /* Suppresses a compiler warning. */
1008 /* Check that the symbol virDomainCreateJob
1009 * is in runtime version of libvirt.
1011 WEAK_SYMBOL_CHECK (virDomainCreateJob);
1013 CAMLlocal2 (rv, connv);
1014 virDomainPtr dom = Domain_val (domv);
1015 virConnectPtr conn = Connect_domv (domv);
1018 NONBLOCKING (r = virDomainCreateJob (dom, 0));
1019 CHECK_ERROR (!r, conn, "virDomainCreateJob");
1021 connv = Field (domv, 1);
1022 rv = Val_job (r, connv);
1029 ocaml_libvirt_domain_attach_device (value domv, value strv)
1031 CAMLparam2 (domv, strv);
1034 virDomainPtr dom = Domain_val (domv);
1035 virConnectPtr conn = Connect_domv (domv);
1036 char *str = String_val (strv);
1039 NONBLOCKING (r = virDomainAttachDevice (dom, str));
1040 CHECK_ERROR (r == -1, conn, "virDomainAttachDevice");
1042 CAMLreturn (Val_unit);
1046 ocaml_libvirt_domain_detach_device (value domv, value strv)
1048 CAMLparam2 (domv, strv);
1051 virDomainPtr dom = Domain_val (domv);
1052 virConnectPtr conn = Connect_domv (domv);
1053 char *str = String_val (strv);
1056 NONBLOCKING (r = virDomainDetachDevice (dom, str));
1057 CHECK_ERROR (r == -1, conn, "virDomainDetachDevice");
1059 CAMLreturn (Val_unit);
1063 ocaml_libvirt_domain_get_autostart (value domv)
1067 virDomainPtr dom = Domain_val (domv);
1068 virConnectPtr conn = Connect_domv (domv);
1071 NONBLOCKING (r = virDomainGetAutostart (dom, &b));
1072 CHECK_ERROR (r == -1, conn, "virDomainGetAutostart");
1074 CAMLreturn (b ? Val_true : Val_false);
1078 ocaml_libvirt_domain_set_autostart (value domv, value bv)
1080 CAMLparam2 (domv, bv);
1082 virDomainPtr dom = Domain_val (domv);
1083 virConnectPtr conn = Connect_domv (domv);
1086 b = bv == Val_true ? 1 : 0;
1088 NONBLOCKING (r = virDomainSetAutostart (dom, b));
1089 CHECK_ERROR (r == -1, conn, "virDomainSetAutostart");
1091 CAMLreturn (Val_unit);
1095 ocaml_libvirt_network_free (value netv)
1099 virNetworkPtr net = Network_val (netv);
1100 virConnectPtr conn = Connect_netv (netv);
1103 NONBLOCKING (r = virNetworkFree (net));
1104 CHECK_ERROR (r == -1, conn, "virNetworkFree");
1106 /* So that we don't double-free in the finalizer: */
1107 Network_val (netv) = NULL;
1109 CAMLreturn (Val_unit);
1113 ocaml_libvirt_network_destroy (value netv)
1117 virNetworkPtr net = Network_val (netv);
1118 virConnectPtr conn = Connect_netv (netv);
1121 NONBLOCKING (r = virNetworkDestroy (net));
1122 CHECK_ERROR (r == -1, conn, "virNetworkDestroy");
1124 /* So that we don't double-free in the finalizer: */
1125 Network_val (netv) = NULL;
1127 CAMLreturn (Val_unit);
1131 ocaml_libvirt_network_lookup_by_name (value connv, value strv)
1133 CAMLparam2 (connv, strv);
1136 virConnectPtr conn = Connect_val (connv);
1137 char *str = String_val (strv);
1140 NONBLOCKING (r = virNetworkLookupByName (conn, str));
1141 CHECK_ERROR (!r, conn, "virNetworkLookupByName");
1143 rv = Val_network (r, connv);
1149 ocaml_libvirt_network_lookup_by_uuid (value connv, value uuidv)
1151 CAMLparam2 (connv, uuidv);
1154 virConnectPtr conn = Connect_val (connv);
1155 unsigned char *uuid = (unsigned char *) String_val (uuidv);
1158 NONBLOCKING (r = virNetworkLookupByUUID (conn, uuid));
1159 CHECK_ERROR (!r, conn, "virNetworkLookupByUUID");
1161 rv = Val_network (r, connv);
1167 ocaml_libvirt_network_lookup_by_uuid_string (value connv, value strv)
1169 CAMLparam2 (connv, strv);
1172 virConnectPtr conn = Connect_val (connv);
1173 char *str = String_val (strv);
1176 NONBLOCKING (r = virNetworkLookupByUUIDString (conn, str));
1177 CHECK_ERROR (!r, conn, "virNetworkLookupByUUIDString");
1179 rv = Val_network (r, connv);
1185 ocaml_libvirt_network_get_name (value netv)
1190 virNetworkPtr net = Network_val (netv);
1191 virConnectPtr conn = Connect_netv (netv);
1194 NONBLOCKING (r = virNetworkGetName (net));
1195 CHECK_ERROR (!r, conn, "virNetworkGetName");
1197 rv = caml_copy_string (r);
1202 ocaml_libvirt_network_get_xml_desc (value netv)
1207 virNetworkPtr net = Network_val (netv);
1208 virConnectPtr conn = Connect_netv (netv);
1211 NONBLOCKING (r = virNetworkGetXMLDesc (net, 0));
1212 CHECK_ERROR (!r, conn, "virNetworkGetXMLDesc");
1214 rv = caml_copy_string (r);
1220 ocaml_libvirt_network_get_bridge_name (value netv)
1225 virNetworkPtr net = Network_val (netv);
1226 virConnectPtr conn = Connect_netv (netv);
1229 NONBLOCKING (r = virNetworkGetBridgeName (net));
1230 CHECK_ERROR (!r, conn, "virNetworkGetBridgeName");
1232 rv = caml_copy_string (r);
1238 ocaml_libvirt_network_get_uuid (value netv)
1243 virNetworkPtr net = Network_val (netv);
1244 virConnectPtr conn = Connect_netv (netv);
1245 unsigned char uuid[VIR_UUID_BUFLEN];
1248 NONBLOCKING (r = virNetworkGetUUID (net, uuid));
1249 CHECK_ERROR (r == -1, conn, "virNetworkGetUUID");
1251 rv = caml_copy_string ((char *) uuid);
1256 ocaml_libvirt_network_get_uuid_string (value netv)
1261 virNetworkPtr net = Network_val (netv);
1262 virConnectPtr conn = Connect_netv (netv);
1263 char uuid[VIR_UUID_STRING_BUFLEN];
1266 NONBLOCKING (r = virNetworkGetUUIDString (net, uuid));
1267 CHECK_ERROR (r == -1, conn, "virNetworkGetUUIDString");
1269 rv = caml_copy_string (uuid);
1274 ocaml_libvirt_network_undefine (value netv)
1278 virNetworkPtr net = Network_val (netv);
1279 virConnectPtr conn = Connect_netv (netv);
1282 NONBLOCKING (r = virNetworkUndefine (net));
1283 CHECK_ERROR (r == -1, conn, "virNetworkUndefine");
1285 CAMLreturn (Val_unit);
1289 ocaml_libvirt_network_create_xml (value connv, value strv)
1291 CAMLparam2 (connv, strv);
1294 virConnectPtr conn = Connect_val (connv);
1295 char *str = String_val (strv);
1298 NONBLOCKING (r = virNetworkCreateXML (conn, str));
1299 CHECK_ERROR (!r, conn, "virNetworkCreateXML");
1301 rv = Val_network (r, connv);
1306 #ifdef HAVE_WEAK_SYMBOLS
1307 #ifdef HAVE_VIRNETWORKCREATEXMLJOB
1308 extern virJobPtr virNetworkCreateXMLJob (virConnectPtr conn, const char *str) __attribute__((weak));
1313 ocaml_libvirt_network_create_xml_job (value connv, value strv)
1315 CAMLparam2 (connv, strv);
1316 #ifndef HAVE_VIRNETWORKCREATEXMLJOB
1317 /* Symbol virNetworkCreateXMLJob not found at compile time. */
1318 not_supported ("virNetworkCreateXMLJob");
1319 /* Suppresses a compiler warning. */
1322 /* Check that the symbol virNetworkCreateXMLJob
1323 * is in runtime version of libvirt.
1325 WEAK_SYMBOL_CHECK (virNetworkCreateXMLJob);
1328 virConnectPtr conn = Connect_val (connv);
1329 char *str = String_val (strv);
1332 NONBLOCKING (r = virNetworkCreateXMLJob (conn, str));
1333 CHECK_ERROR (!r, conn, "virNetworkCreateXMLJob");
1335 rv = Val_job (r, connv);
1342 ocaml_libvirt_network_define_xml (value connv, value strv)
1344 CAMLparam2 (connv, strv);
1347 virConnectPtr conn = Connect_val (connv);
1348 char *str = String_val (strv);
1351 NONBLOCKING (r = virNetworkDefineXML (conn, str));
1352 CHECK_ERROR (!r, conn, "virNetworkDefineXML");
1354 rv = Val_network (r, connv);
1360 ocaml_libvirt_network_create (value netv)
1364 virNetworkPtr net = Network_val (netv);
1365 virConnectPtr conn = Connect_netv (netv);
1368 NONBLOCKING (r = virNetworkCreate (net));
1369 CHECK_ERROR (r == -1, conn, "virNetworkCreate");
1371 CAMLreturn (Val_unit);
1374 #ifdef HAVE_WEAK_SYMBOLS
1375 #ifdef HAVE_VIRNETWORKCREATEJOB
1376 extern virJobPtr virNetworkCreateJob (virNetworkPtr net) __attribute__((weak));
1381 ocaml_libvirt_network_create_job (value netv)
1384 #ifndef HAVE_VIRNETWORKCREATEJOB
1385 /* Symbol virNetworkCreateJob not found at compile time. */
1386 not_supported ("virNetworkCreateJob");
1387 /* Suppresses a compiler warning. */
1390 /* Check that the symbol virNetworkCreateJob
1391 * is in runtime version of libvirt.
1393 WEAK_SYMBOL_CHECK (virNetworkCreateJob);
1395 CAMLlocal2 (rv, connv);
1396 virNetworkPtr net = Network_val (netv);
1397 virConnectPtr conn = Connect_netv (netv);
1400 NONBLOCKING (r = virNetworkCreateJob (net));
1401 CHECK_ERROR (!r, conn, "virNetworkCreateJob");
1403 connv = Field (netv, 1);
1404 rv = Val_job (r, connv);
1411 ocaml_libvirt_network_get_autostart (value netv)
1415 virNetworkPtr net = Network_val (netv);
1416 virConnectPtr conn = Connect_netv (netv);
1419 NONBLOCKING (r = virNetworkGetAutostart (net, &b));
1420 CHECK_ERROR (r == -1, conn, "virNetworkGetAutostart");
1422 CAMLreturn (b ? Val_true : Val_false);
1426 ocaml_libvirt_network_set_autostart (value netv, value bv)
1428 CAMLparam2 (netv, bv);
1430 virNetworkPtr net = Network_val (netv);
1431 virConnectPtr conn = Connect_netv (netv);
1434 b = bv == Val_true ? 1 : 0;
1436 NONBLOCKING (r = virNetworkSetAutostart (net, b));
1437 CHECK_ERROR (r == -1, conn, "virNetworkSetAutostart");
1439 CAMLreturn (Val_unit);
1442 #ifdef HAVE_WEAK_SYMBOLS
1443 #ifdef HAVE_VIRSTORAGEPOOLFREE
1444 extern int virStoragePoolFree (virStoragePoolPtr pool) __attribute__((weak));
1449 ocaml_libvirt_storage_pool_free (value poolv)
1452 #ifndef HAVE_VIRSTORAGEPOOLFREE
1453 /* Symbol virStoragePoolFree not found at compile time. */
1454 not_supported ("virStoragePoolFree");
1455 /* Suppresses a compiler warning. */
1458 /* Check that the symbol virStoragePoolFree
1459 * is in runtime version of libvirt.
1461 WEAK_SYMBOL_CHECK (virStoragePoolFree);
1463 virStoragePoolPtr pool = Pool_val (poolv);
1464 virConnectPtr conn = Connect_polv (poolv);
1467 NONBLOCKING (r = virStoragePoolFree (pool));
1468 CHECK_ERROR (r == -1, conn, "virStoragePoolFree");
1470 /* So that we don't double-free in the finalizer: */
1471 Pool_val (poolv) = NULL;
1473 CAMLreturn (Val_unit);
1477 #ifdef HAVE_WEAK_SYMBOLS
1478 #ifdef HAVE_VIRSTORAGEPOOLDESTROY
1479 extern int virStoragePoolDestroy (virStoragePoolPtr pool) __attribute__((weak));
1484 ocaml_libvirt_storage_pool_destroy (value poolv)
1487 #ifndef HAVE_VIRSTORAGEPOOLDESTROY
1488 /* Symbol virStoragePoolDestroy not found at compile time. */
1489 not_supported ("virStoragePoolDestroy");
1490 /* Suppresses a compiler warning. */
1493 /* Check that the symbol virStoragePoolDestroy
1494 * is in runtime version of libvirt.
1496 WEAK_SYMBOL_CHECK (virStoragePoolDestroy);
1498 virStoragePoolPtr pool = Pool_val (poolv);
1499 virConnectPtr conn = Connect_polv (poolv);
1502 NONBLOCKING (r = virStoragePoolDestroy (pool));
1503 CHECK_ERROR (r == -1, conn, "virStoragePoolDestroy");
1505 /* So that we don't double-free in the finalizer: */
1506 Pool_val (poolv) = NULL;
1508 CAMLreturn (Val_unit);
1512 #ifdef HAVE_WEAK_SYMBOLS
1513 #ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYNAME
1514 extern virStoragePoolPtr virStoragePoolLookupByName (virConnectPtr conn, const char *str) __attribute__((weak));
1519 ocaml_libvirt_storage_pool_lookup_by_name (value connv, value strv)
1521 CAMLparam2 (connv, strv);
1522 #ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYNAME
1523 /* Symbol virStoragePoolLookupByName not found at compile time. */
1524 not_supported ("virStoragePoolLookupByName");
1525 /* Suppresses a compiler warning. */
1528 /* Check that the symbol virStoragePoolLookupByName
1529 * is in runtime version of libvirt.
1531 WEAK_SYMBOL_CHECK (virStoragePoolLookupByName);
1534 virConnectPtr conn = Connect_val (connv);
1535 char *str = String_val (strv);
1536 virStoragePoolPtr r;
1538 NONBLOCKING (r = virStoragePoolLookupByName (conn, str));
1539 CHECK_ERROR (!r, conn, "virStoragePoolLookupByName");
1541 rv = Val_pool (r, connv);
1547 #ifdef HAVE_WEAK_SYMBOLS
1548 #ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYUUID
1549 extern virStoragePoolPtr virStoragePoolLookupByUUID (virConnectPtr conn, const unsigned char *str) __attribute__((weak));
1554 ocaml_libvirt_storage_pool_lookup_by_uuid (value connv, value uuidv)
1556 CAMLparam2 (connv, uuidv);
1557 #ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYUUID
1558 /* Symbol virStoragePoolLookupByUUID not found at compile time. */
1559 not_supported ("virStoragePoolLookupByUUID");
1560 /* Suppresses a compiler warning. */
1563 /* Check that the symbol virStoragePoolLookupByUUID
1564 * is in runtime version of libvirt.
1566 WEAK_SYMBOL_CHECK (virStoragePoolLookupByUUID);
1569 virConnectPtr conn = Connect_val (connv);
1570 unsigned char *uuid = (unsigned char *) String_val (uuidv);
1571 virStoragePoolPtr r;
1573 NONBLOCKING (r = virStoragePoolLookupByUUID (conn, uuid));
1574 CHECK_ERROR (!r, conn, "virStoragePoolLookupByUUID");
1576 rv = Val_pool (r, connv);
1582 #ifdef HAVE_WEAK_SYMBOLS
1583 #ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYUUIDSTRING
1584 extern virStoragePoolPtr virStoragePoolLookupByUUIDString (virConnectPtr conn, const char *str) __attribute__((weak));
1589 ocaml_libvirt_storage_pool_lookup_by_uuid_string (value connv, value strv)
1591 CAMLparam2 (connv, strv);
1592 #ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYUUIDSTRING
1593 /* Symbol virStoragePoolLookupByUUIDString not found at compile time. */
1594 not_supported ("virStoragePoolLookupByUUIDString");
1595 /* Suppresses a compiler warning. */
1598 /* Check that the symbol virStoragePoolLookupByUUIDString
1599 * is in runtime version of libvirt.
1601 WEAK_SYMBOL_CHECK (virStoragePoolLookupByUUIDString);
1604 virConnectPtr conn = Connect_val (connv);
1605 char *str = String_val (strv);
1606 virStoragePoolPtr r;
1608 NONBLOCKING (r = virStoragePoolLookupByUUIDString (conn, str));
1609 CHECK_ERROR (!r, conn, "virStoragePoolLookupByUUIDString");
1611 rv = Val_pool (r, connv);
1617 #ifdef HAVE_WEAK_SYMBOLS
1618 #ifdef HAVE_VIRSTORAGEPOOLGETNAME
1619 extern const char *virStoragePoolGetName (virStoragePoolPtr pool) __attribute__((weak));
1624 ocaml_libvirt_storage_pool_get_name (value poolv)
1627 #ifndef HAVE_VIRSTORAGEPOOLGETNAME
1628 /* Symbol virStoragePoolGetName not found at compile time. */
1629 not_supported ("virStoragePoolGetName");
1630 /* Suppresses a compiler warning. */
1633 /* Check that the symbol virStoragePoolGetName
1634 * is in runtime version of libvirt.
1636 WEAK_SYMBOL_CHECK (virStoragePoolGetName);
1639 virStoragePoolPtr pool = Pool_val (poolv);
1640 virConnectPtr conn = Connect_polv (poolv);
1643 NONBLOCKING (r = virStoragePoolGetName (pool));
1644 CHECK_ERROR (!r, conn, "virStoragePoolGetName");
1646 rv = caml_copy_string (r);
1651 #ifdef HAVE_WEAK_SYMBOLS
1652 #ifdef HAVE_VIRSTORAGEPOOLGETXMLDESC
1653 extern char *virStoragePoolGetXMLDesc (virStoragePoolPtr pool, int flags) __attribute__((weak));
1658 ocaml_libvirt_storage_pool_get_xml_desc (value poolv)
1661 #ifndef HAVE_VIRSTORAGEPOOLGETXMLDESC
1662 /* Symbol virStoragePoolGetXMLDesc not found at compile time. */
1663 not_supported ("virStoragePoolGetXMLDesc");
1664 /* Suppresses a compiler warning. */
1667 /* Check that the symbol virStoragePoolGetXMLDesc
1668 * is in runtime version of libvirt.
1670 WEAK_SYMBOL_CHECK (virStoragePoolGetXMLDesc);
1673 virStoragePoolPtr pool = Pool_val (poolv);
1674 virConnectPtr conn = Connect_polv (poolv);
1677 NONBLOCKING (r = virStoragePoolGetXMLDesc (pool, 0));
1678 CHECK_ERROR (!r, conn, "virStoragePoolGetXMLDesc");
1680 rv = caml_copy_string (r);
1686 #ifdef HAVE_WEAK_SYMBOLS
1687 #ifdef HAVE_VIRSTORAGEPOOLGETUUID
1688 extern int virStoragePoolGetUUID (virStoragePoolPtr pool, unsigned char *) __attribute__((weak));
1693 ocaml_libvirt_storage_pool_get_uuid (value poolv)
1696 #ifndef HAVE_VIRSTORAGEPOOLGETUUID
1697 /* Symbol virStoragePoolGetUUID not found at compile time. */
1698 not_supported ("virStoragePoolGetUUID");
1699 /* Suppresses a compiler warning. */
1702 /* Check that the symbol virStoragePoolGetUUID
1703 * is in runtime version of libvirt.
1705 WEAK_SYMBOL_CHECK (virStoragePoolGetUUID);
1708 virStoragePoolPtr pool = Pool_val (poolv);
1709 virConnectPtr conn = Connect_polv (poolv);
1710 unsigned char uuid[VIR_UUID_BUFLEN];
1713 NONBLOCKING (r = virStoragePoolGetUUID (pool, uuid));
1714 CHECK_ERROR (r == -1, conn, "virStoragePoolGetUUID");
1716 rv = caml_copy_string ((char *) uuid);
1721 #ifdef HAVE_WEAK_SYMBOLS
1722 #ifdef HAVE_VIRSTORAGEPOOLGETUUIDSTRING
1723 extern int virStoragePoolGetUUIDString (virStoragePoolPtr pool, char *) __attribute__((weak));
1728 ocaml_libvirt_storage_pool_get_uuid_string (value poolv)
1731 #ifndef HAVE_VIRSTORAGEPOOLGETUUIDSTRING
1732 /* Symbol virStoragePoolGetUUIDString not found at compile time. */
1733 not_supported ("virStoragePoolGetUUIDString");
1734 /* Suppresses a compiler warning. */
1737 /* Check that the symbol virStoragePoolGetUUIDString
1738 * is in runtime version of libvirt.
1740 WEAK_SYMBOL_CHECK (virStoragePoolGetUUIDString);
1743 virStoragePoolPtr pool = Pool_val (poolv);
1744 virConnectPtr conn = Connect_polv (poolv);
1745 char uuid[VIR_UUID_STRING_BUFLEN];
1748 NONBLOCKING (r = virStoragePoolGetUUIDString (pool, uuid));
1749 CHECK_ERROR (r == -1, conn, "virStoragePoolGetUUIDString");
1751 rv = caml_copy_string (uuid);
1756 #ifdef HAVE_WEAK_SYMBOLS
1757 #ifdef HAVE_VIRSTORAGEPOOLCREATEXML
1758 extern virStoragePoolPtr virStoragePoolCreateXML (virConnectPtr conn, const char *str) __attribute__((weak));
1763 ocaml_libvirt_storage_pool_create_xml (value connv, value strv)
1765 CAMLparam2 (connv, strv);
1766 #ifndef HAVE_VIRSTORAGEPOOLCREATEXML
1767 /* Symbol virStoragePoolCreateXML not found at compile time. */
1768 not_supported ("virStoragePoolCreateXML");
1769 /* Suppresses a compiler warning. */
1772 /* Check that the symbol virStoragePoolCreateXML
1773 * is in runtime version of libvirt.
1775 WEAK_SYMBOL_CHECK (virStoragePoolCreateXML);
1778 virConnectPtr conn = Connect_val (connv);
1779 char *str = String_val (strv);
1780 virStoragePoolPtr r;
1782 NONBLOCKING (r = virStoragePoolCreateXML (conn, str));
1783 CHECK_ERROR (!r, conn, "virStoragePoolCreateXML");
1785 rv = Val_pool (r, connv);
1791 #ifdef HAVE_WEAK_SYMBOLS
1792 #ifdef HAVE_VIRSTORAGEPOOLDEFINEXML
1793 extern virStoragePoolPtr virStoragePoolDefineXML (virConnectPtr conn, const char *str) __attribute__((weak));
1798 ocaml_libvirt_storage_pool_define_xml (value connv, value strv)
1800 CAMLparam2 (connv, strv);
1801 #ifndef HAVE_VIRSTORAGEPOOLDEFINEXML
1802 /* Symbol virStoragePoolDefineXML not found at compile time. */
1803 not_supported ("virStoragePoolDefineXML");
1804 /* Suppresses a compiler warning. */
1807 /* Check that the symbol virStoragePoolDefineXML
1808 * is in runtime version of libvirt.
1810 WEAK_SYMBOL_CHECK (virStoragePoolDefineXML);
1813 virConnectPtr conn = Connect_val (connv);
1814 char *str = String_val (strv);
1815 virStoragePoolPtr r;
1817 NONBLOCKING (r = virStoragePoolDefineXML (conn, str));
1818 CHECK_ERROR (!r, conn, "virStoragePoolDefineXML");
1820 rv = Val_pool (r, connv);
1826 #ifdef HAVE_WEAK_SYMBOLS
1827 #ifdef HAVE_VIRSTORAGEPOOLUNDEFINE
1828 extern int virStoragePoolUndefine (virStoragePoolPtr pool) __attribute__((weak));
1833 ocaml_libvirt_storage_pool_undefine (value poolv)
1836 #ifndef HAVE_VIRSTORAGEPOOLUNDEFINE
1837 /* Symbol virStoragePoolUndefine not found at compile time. */
1838 not_supported ("virStoragePoolUndefine");
1839 /* Suppresses a compiler warning. */
1842 /* Check that the symbol virStoragePoolUndefine
1843 * is in runtime version of libvirt.
1845 WEAK_SYMBOL_CHECK (virStoragePoolUndefine);
1847 virStoragePoolPtr pool = Pool_val (poolv);
1848 virConnectPtr conn = Connect_polv (poolv);
1851 NONBLOCKING (r = virStoragePoolUndefine (pool));
1852 CHECK_ERROR (r == -1, conn, "virStoragePoolUndefine");
1854 CAMLreturn (Val_unit);
1858 #ifdef HAVE_WEAK_SYMBOLS
1859 #ifdef HAVE_VIRSTORAGEPOOLCREATE
1860 extern int virStoragePoolCreate (virStoragePoolPtr pool) __attribute__((weak));
1865 ocaml_libvirt_storage_pool_create (value poolv)
1868 #ifndef HAVE_VIRSTORAGEPOOLCREATE
1869 /* Symbol virStoragePoolCreate not found at compile time. */
1870 not_supported ("virStoragePoolCreate");
1871 /* Suppresses a compiler warning. */
1874 /* Check that the symbol virStoragePoolCreate
1875 * is in runtime version of libvirt.
1877 WEAK_SYMBOL_CHECK (virStoragePoolCreate);
1879 virStoragePoolPtr pool = Pool_val (poolv);
1880 virConnectPtr conn = Connect_polv (poolv);
1883 NONBLOCKING (r = virStoragePoolCreate (pool));
1884 CHECK_ERROR (r == -1, conn, "virStoragePoolCreate");
1886 CAMLreturn (Val_unit);
1890 #ifdef HAVE_WEAK_SYMBOLS
1891 #ifdef HAVE_VIRSTORAGEPOOLSHUTDOWN
1892 extern int virStoragePoolShutdown (virStoragePoolPtr pool) __attribute__((weak));
1897 ocaml_libvirt_storage_pool_shutdown (value poolv)
1900 #ifndef HAVE_VIRSTORAGEPOOLSHUTDOWN
1901 /* Symbol virStoragePoolShutdown not found at compile time. */
1902 not_supported ("virStoragePoolShutdown");
1903 /* Suppresses a compiler warning. */
1906 /* Check that the symbol virStoragePoolShutdown
1907 * is in runtime version of libvirt.
1909 WEAK_SYMBOL_CHECK (virStoragePoolShutdown);
1911 virStoragePoolPtr pool = Pool_val (poolv);
1912 virConnectPtr conn = Connect_polv (poolv);
1915 NONBLOCKING (r = virStoragePoolShutdown (pool));
1916 CHECK_ERROR (r == -1, conn, "virStoragePoolShutdown");
1918 CAMLreturn (Val_unit);
1922 #ifdef HAVE_WEAK_SYMBOLS
1923 #ifdef HAVE_VIRSTORAGEPOOLREFRESH
1924 extern int virStoragePoolRefresh (virStoragePoolPtr pool, unsigned int flags) __attribute__((weak));
1929 ocaml_libvirt_storage_pool_refresh (value poolv)
1932 #ifndef HAVE_VIRSTORAGEPOOLREFRESH
1933 /* Symbol virStoragePoolRefresh not found at compile time. */
1934 not_supported ("virStoragePoolRefresh");
1935 /* Suppresses a compiler warning. */
1938 /* Check that the symbol virStoragePoolRefresh
1939 * is in runtime version of libvirt.
1941 WEAK_SYMBOL_CHECK (virStoragePoolRefresh);
1943 virStoragePoolPtr pool = Pool_val (poolv);
1944 virConnectPtr conn = Connect_polv (poolv);
1947 NONBLOCKING (r = virStoragePoolRefresh (pool, 0));
1948 CHECK_ERROR (r == -1, conn, "virStoragePoolRefresh");
1950 CAMLreturn (Val_unit);
1954 #ifdef HAVE_WEAK_SYMBOLS
1955 #ifdef HAVE_VIRSTORAGEPOOLGETAUTOSTART
1956 extern int virStoragePoolGetAutostart (virStoragePoolPtr pool, int *r) __attribute__((weak));
1961 ocaml_libvirt_storage_pool_get_autostart (value poolv)
1964 #ifndef HAVE_VIRSTORAGEPOOLGETAUTOSTART
1965 /* Symbol virStoragePoolGetAutostart not found at compile time. */
1966 not_supported ("virStoragePoolGetAutostart");
1967 /* Suppresses a compiler warning. */
1970 /* Check that the symbol virStoragePoolGetAutostart
1971 * is in runtime version of libvirt.
1973 WEAK_SYMBOL_CHECK (virStoragePoolGetAutostart);
1975 virStoragePoolPtr pool = Pool_val (poolv);
1976 virConnectPtr conn = Connect_polv (poolv);
1979 NONBLOCKING (r = virStoragePoolGetAutostart (pool, &b));
1980 CHECK_ERROR (r == -1, conn, "virStoragePoolGetAutostart");
1982 CAMLreturn (b ? Val_true : Val_false);
1986 #ifdef HAVE_WEAK_SYMBOLS
1987 #ifdef HAVE_VIRSTORAGEPOOLSETAUTOSTART
1988 extern int virStoragePoolSetAutostart (virStoragePoolPtr pool, int b) __attribute__((weak));
1993 ocaml_libvirt_storage_pool_set_autostart (value poolv, value bv)
1995 CAMLparam2 (poolv, bv);
1996 #ifndef HAVE_VIRSTORAGEPOOLSETAUTOSTART
1997 /* Symbol virStoragePoolSetAutostart not found at compile time. */
1998 not_supported ("virStoragePoolSetAutostart");
1999 /* Suppresses a compiler warning. */
2002 /* Check that the symbol virStoragePoolSetAutostart
2003 * is in runtime version of libvirt.
2005 WEAK_SYMBOL_CHECK (virStoragePoolSetAutostart);
2007 virStoragePoolPtr pool = Pool_val (poolv);
2008 virConnectPtr conn = Connect_polv (poolv);
2011 b = bv == Val_true ? 1 : 0;
2013 NONBLOCKING (r = virStoragePoolSetAutostart (pool, b));
2014 CHECK_ERROR (r == -1, conn, "virStoragePoolSetAutostart");
2016 CAMLreturn (Val_unit);
2020 #ifdef HAVE_WEAK_SYMBOLS
2021 #ifdef HAVE_VIRSTORAGEVOLFREE
2022 extern int virStorageVolFree (virStorageVolPtr vol) __attribute__((weak));
2027 ocaml_libvirt_storage_vol_free (value volv)
2030 #ifndef HAVE_VIRSTORAGEVOLFREE
2031 /* Symbol virStorageVolFree not found at compile time. */
2032 not_supported ("virStorageVolFree");
2033 /* Suppresses a compiler warning. */
2036 /* Check that the symbol virStorageVolFree
2037 * is in runtime version of libvirt.
2039 WEAK_SYMBOL_CHECK (virStorageVolFree);
2041 virStorageVolPtr vol = Volume_val (volv);
2042 virConnectPtr conn = Connect_volv (volv);
2045 NONBLOCKING (r = virStorageVolFree (vol));
2046 CHECK_ERROR (r == -1, conn, "virStorageVolFree");
2048 /* So that we don't double-free in the finalizer: */
2049 Volume_val (volv) = NULL;
2051 CAMLreturn (Val_unit);
2055 #ifdef HAVE_WEAK_SYMBOLS
2056 #ifdef HAVE_VIRSTORAGEVOLDESTROY
2057 extern int virStorageVolDestroy (virStorageVolPtr vol) __attribute__((weak));
2062 ocaml_libvirt_storage_vol_destroy (value volv)
2065 #ifndef HAVE_VIRSTORAGEVOLDESTROY
2066 /* Symbol virStorageVolDestroy not found at compile time. */
2067 not_supported ("virStorageVolDestroy");
2068 /* Suppresses a compiler warning. */
2071 /* Check that the symbol virStorageVolDestroy
2072 * is in runtime version of libvirt.
2074 WEAK_SYMBOL_CHECK (virStorageVolDestroy);
2076 virStorageVolPtr vol = Volume_val (volv);
2077 virConnectPtr conn = Connect_volv (volv);
2080 NONBLOCKING (r = virStorageVolDestroy (vol));
2081 CHECK_ERROR (r == -1, conn, "virStorageVolDestroy");
2083 /* So that we don't double-free in the finalizer: */
2084 Volume_val (volv) = NULL;
2086 CAMLreturn (Val_unit);
2090 #ifdef HAVE_WEAK_SYMBOLS
2091 #ifdef HAVE_VIRSTORAGEVOLLOOKUPBYKEY
2092 extern virStorageVolPtr virStorageVolLookupByKey (virConnectPtr conn, const char *str) __attribute__((weak));
2097 ocaml_libvirt_storage_vol_lookup_by_key (value connv, value strv)
2099 CAMLparam2 (connv, strv);
2100 #ifndef HAVE_VIRSTORAGEVOLLOOKUPBYKEY
2101 /* Symbol virStorageVolLookupByKey not found at compile time. */
2102 not_supported ("virStorageVolLookupByKey");
2103 /* Suppresses a compiler warning. */
2106 /* Check that the symbol virStorageVolLookupByKey
2107 * is in runtime version of libvirt.
2109 WEAK_SYMBOL_CHECK (virStorageVolLookupByKey);
2112 virConnectPtr conn = Connect_val (connv);
2113 char *str = String_val (strv);
2116 NONBLOCKING (r = virStorageVolLookupByKey (conn, str));
2117 CHECK_ERROR (!r, conn, "virStorageVolLookupByKey");
2119 rv = Val_volume (r, connv);
2125 #ifdef HAVE_WEAK_SYMBOLS
2126 #ifdef HAVE_VIRSTORAGEVOLLOOKUPBYPATH
2127 extern virStorageVolPtr virStorageVolLookupByPath (virConnectPtr conn, const char *str) __attribute__((weak));
2132 ocaml_libvirt_storage_vol_lookup_by_path (value connv, value strv)
2134 CAMLparam2 (connv, strv);
2135 #ifndef HAVE_VIRSTORAGEVOLLOOKUPBYPATH
2136 /* Symbol virStorageVolLookupByPath not found at compile time. */
2137 not_supported ("virStorageVolLookupByPath");
2138 /* Suppresses a compiler warning. */
2141 /* Check that the symbol virStorageVolLookupByPath
2142 * is in runtime version of libvirt.
2144 WEAK_SYMBOL_CHECK (virStorageVolLookupByPath);
2147 virConnectPtr conn = Connect_val (connv);
2148 char *str = String_val (strv);
2151 NONBLOCKING (r = virStorageVolLookupByPath (conn, str));
2152 CHECK_ERROR (!r, conn, "virStorageVolLookupByPath");
2154 rv = Val_volume (r, connv);
2160 #ifdef HAVE_WEAK_SYMBOLS
2161 #ifdef HAVE_VIRSTORAGEVOLGETXMLDESC
2162 extern char *virStorageVolGetXMLDesc (virStorageVolPtr vol, int flags) __attribute__((weak));
2167 ocaml_libvirt_storage_vol_get_xml_desc (value volv)
2170 #ifndef HAVE_VIRSTORAGEVOLGETXMLDESC
2171 /* Symbol virStorageVolGetXMLDesc not found at compile time. */
2172 not_supported ("virStorageVolGetXMLDesc");
2173 /* Suppresses a compiler warning. */
2176 /* Check that the symbol virStorageVolGetXMLDesc
2177 * is in runtime version of libvirt.
2179 WEAK_SYMBOL_CHECK (virStorageVolGetXMLDesc);
2182 virStorageVolPtr vol = Volume_val (volv);
2183 virConnectPtr conn = Connect_volv (volv);
2186 NONBLOCKING (r = virStorageVolGetXMLDesc (vol, 0));
2187 CHECK_ERROR (!r, conn, "virStorageVolGetXMLDesc");
2189 rv = caml_copy_string (r);
2195 #ifdef HAVE_WEAK_SYMBOLS
2196 #ifdef HAVE_VIRSTORAGEVOLGETPATH
2197 extern char *virStorageVolGetPath (virStorageVolPtr vol) __attribute__((weak));
2202 ocaml_libvirt_storage_vol_get_path (value volv)
2205 #ifndef HAVE_VIRSTORAGEVOLGETPATH
2206 /* Symbol virStorageVolGetPath not found at compile time. */
2207 not_supported ("virStorageVolGetPath");
2208 /* Suppresses a compiler warning. */
2211 /* Check that the symbol virStorageVolGetPath
2212 * is in runtime version of libvirt.
2214 WEAK_SYMBOL_CHECK (virStorageVolGetPath);
2217 virStorageVolPtr vol = Volume_val (volv);
2218 virConnectPtr conn = Connect_volv (volv);
2221 NONBLOCKING (r = virStorageVolGetPath (vol));
2222 CHECK_ERROR (!r, conn, "virStorageVolGetPath");
2224 rv = caml_copy_string (r);
2230 #ifdef HAVE_WEAK_SYMBOLS
2231 #ifdef HAVE_VIRSTORAGEVOLGETKEY
2232 extern const char *virStorageVolGetKey (virStorageVolPtr vol) __attribute__((weak));
2237 ocaml_libvirt_storage_vol_get_key (value volv)
2240 #ifndef HAVE_VIRSTORAGEVOLGETKEY
2241 /* Symbol virStorageVolGetKey not found at compile time. */
2242 not_supported ("virStorageVolGetKey");
2243 /* Suppresses a compiler warning. */
2246 /* Check that the symbol virStorageVolGetKey
2247 * is in runtime version of libvirt.
2249 WEAK_SYMBOL_CHECK (virStorageVolGetKey);
2252 virStorageVolPtr vol = Volume_val (volv);
2253 virConnectPtr conn = Connect_volv (volv);
2256 NONBLOCKING (r = virStorageVolGetKey (vol));
2257 CHECK_ERROR (!r, conn, "virStorageVolGetKey");
2259 rv = caml_copy_string (r);
2264 #ifdef HAVE_WEAK_SYMBOLS
2265 #ifdef HAVE_VIRSTORAGEVOLGETNAME
2266 extern const char *virStorageVolGetName (virStorageVolPtr vol) __attribute__((weak));
2271 ocaml_libvirt_storage_vol_get_name (value volv)
2274 #ifndef HAVE_VIRSTORAGEVOLGETNAME
2275 /* Symbol virStorageVolGetName not found at compile time. */
2276 not_supported ("virStorageVolGetName");
2277 /* Suppresses a compiler warning. */
2280 /* Check that the symbol virStorageVolGetName
2281 * is in runtime version of libvirt.
2283 WEAK_SYMBOL_CHECK (virStorageVolGetName);
2286 virStorageVolPtr vol = Volume_val (volv);
2287 virConnectPtr conn = Connect_volv (volv);
2290 NONBLOCKING (r = virStorageVolGetName (vol));
2291 CHECK_ERROR (!r, conn, "virStorageVolGetName");
2293 rv = caml_copy_string (r);
2298 #ifdef HAVE_WEAK_SYMBOLS
2299 #ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYVOLUME
2300 extern virStoragePoolPtr virStoragePoolLookupByVolume (virStorageVolPtr vol) __attribute__((weak));
2305 ocaml_libvirt_storage_pool_lookup_by_volume (value volv)
2308 #ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYVOLUME
2309 /* Symbol virStoragePoolLookupByVolume not found at compile time. */
2310 not_supported ("virStoragePoolLookupByVolume");
2311 /* Suppresses a compiler warning. */
2314 /* Check that the symbol virStoragePoolLookupByVolume
2315 * is in runtime version of libvirt.
2317 WEAK_SYMBOL_CHECK (virStoragePoolLookupByVolume);
2319 CAMLlocal2 (rv, connv);
2320 virStorageVolPtr vol = Volume_val (volv);
2321 virConnectPtr conn = Connect_volv (volv);
2322 virStoragePoolPtr r;
2324 NONBLOCKING (r = virStoragePoolLookupByVolume (vol));
2325 CHECK_ERROR (!r, conn, "virStoragePoolLookupByVolume");
2327 connv = Field (volv, 1);
2328 rv = Val_pool (r, connv);
2334 #ifdef HAVE_WEAK_SYMBOLS
2335 #ifdef HAVE_VIRJOBFREE
2336 extern int virJobFree (virJobPtr job) __attribute__((weak));
2341 ocaml_libvirt_job_free (value jobv)
2344 #ifndef HAVE_VIRJOBFREE
2345 /* Symbol virJobFree not found at compile time. */
2346 not_supported ("virJobFree");
2347 /* Suppresses a compiler warning. */
2350 /* Check that the symbol virJobFree
2351 * is in runtime version of libvirt.
2353 WEAK_SYMBOL_CHECK (virJobFree);
2355 virJobPtr job = Job_val (jobv);
2356 virConnectPtr conn = Connect_jobv (jobv);
2359 NONBLOCKING (r = virJobFree (job));
2360 CHECK_ERROR (r == -1, conn, "virJobFree");
2362 /* So that we don't double-free in the finalizer: */
2363 Job_val (jobv) = NULL;
2365 CAMLreturn (Val_unit);
2369 #ifdef HAVE_WEAK_SYMBOLS
2370 #ifdef HAVE_VIRJOBCANCEL
2371 extern int virJobCancel (virJobPtr job) __attribute__((weak));
2376 ocaml_libvirt_job_cancel (value jobv)
2379 #ifndef HAVE_VIRJOBCANCEL
2380 /* Symbol virJobCancel not found at compile time. */
2381 not_supported ("virJobCancel");
2382 /* Suppresses a compiler warning. */
2385 /* Check that the symbol virJobCancel
2386 * is in runtime version of libvirt.
2388 WEAK_SYMBOL_CHECK (virJobCancel);
2390 virJobPtr job = Job_val (jobv);
2391 virConnectPtr conn = Connect_jobv (jobv);
2394 NONBLOCKING (r = virJobCancel (job));
2395 CHECK_ERROR (r == -1, conn, "virJobCancel");
2397 CAMLreturn (Val_unit);
2401 #ifdef HAVE_WEAK_SYMBOLS
2402 #ifdef HAVE_VIRJOBGETNETWORK
2403 extern virNetworkPtr virJobGetNetwork (virJobPtr job) __attribute__((weak));
2408 ocaml_libvirt_job_get_network (value jobv)
2411 #ifndef HAVE_VIRJOBGETNETWORK
2412 /* Symbol virJobGetNetwork not found at compile time. */
2413 not_supported ("virJobGetNetwork");
2414 /* Suppresses a compiler warning. */
2417 /* Check that the symbol virJobGetNetwork
2418 * is in runtime version of libvirt.
2420 WEAK_SYMBOL_CHECK (virJobGetNetwork);
2422 CAMLlocal2 (rv, connv);
2423 virJobPtr job = Job_val (jobv);
2424 virConnectPtr conn = Connect_jobv (jobv);
2427 NONBLOCKING (r = virJobGetNetwork (job));
2428 CHECK_ERROR (!r, conn, "virJobGetNetwork");
2430 connv = Field (jobv, 1);
2431 rv = Val_network (r, connv);
2437 #ifdef HAVE_WEAK_SYMBOLS
2438 #ifdef HAVE_VIRJOBGETDOMAIN
2439 extern virDomainPtr virJobGetDomain (virJobPtr job) __attribute__((weak));
2444 ocaml_libvirt_job_get_domain (value jobv)
2447 #ifndef HAVE_VIRJOBGETDOMAIN
2448 /* Symbol virJobGetDomain not found at compile time. */
2449 not_supported ("virJobGetDomain");
2450 /* Suppresses a compiler warning. */
2453 /* Check that the symbol virJobGetDomain
2454 * is in runtime version of libvirt.
2456 WEAK_SYMBOL_CHECK (virJobGetDomain);
2458 CAMLlocal2 (rv, connv);
2459 virJobPtr job = Job_val (jobv);
2460 virConnectPtr conn = Connect_jobv (jobv);
2463 NONBLOCKING (r = virJobGetDomain (job));
2464 CHECK_ERROR (!r, conn, "virJobGetDomain");
2466 connv = Field (jobv, 1);
2467 rv = Val_domain (r, connv);
2473 /* The following functions are unimplemented and always fail.
2474 * See generator.pl '@unimplemented'
2478 ocaml_libvirt_storage_vol_lookup_by_name ()
2480 failwith ("ocaml_libvirt_storage_vol_lookup_by_name is unimplemented");
2484 ocaml_libvirt_storage_vol_create_xml ()
2486 failwith ("ocaml_libvirt_storage_vol_create_xml is unimplemented");
2489 #include "libvirt_c_epilogue.c"