X-Git-Url: http://git.annexia.org/?p=virt-top.git;a=blobdiff_plain;f=libvirt%2Flibvirt_c.c;h=0200b1c8e9723658a4f4c726226347f016bef45d;hp=0dc21e48b577de5229e58e417f0132f6ce12ca04;hb=e7c94d95feb1fb3d7249c2ead935fe2e56ec31a4;hpb=8a8008134e997330d61e0b9736e9067b5689b531 diff --git a/libvirt/libvirt_c.c b/libvirt/libvirt_c.c index 0dc21e4..0200b1c 100644 --- a/libvirt/libvirt_c.c +++ b/libvirt/libvirt_c.c @@ -47,6 +47,31 @@ #include "libvirt_c_oneoffs.c" +/* Automatically generated binding for virConnectClose. + * In generator.pl this function has signature "conn : free". + */ + +CAMLprim value +ocaml_libvirt_connect_close (value connv) +{ + CAMLparam1 (connv); + + virConnectPtr conn = Connect_val (connv); + int r; + + NONBLOCKING (r = virConnectClose (conn)); + CHECK_ERROR (r == -1, conn, "virConnectClose"); + + /* So that we don't double-free in the finalizer: */ + Connect_val (connv) = NULL; + + CAMLreturn (Val_unit); +} + +/* Automatically generated binding for virConnectGetHostname. + * In generator.pl this function has signature "conn : string". + */ + #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRCONNECTGETHOSTNAME extern char *virConnectGetHostname (virConnectPtr conn) __attribute__((weak)); @@ -81,6 +106,10 @@ ocaml_libvirt_connect_get_hostname (value connv) #endif } +/* Automatically generated binding for virConnectGetURI. + * In generator.pl this function has signature "conn : string". + */ + #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRCONNECTGETURI extern char *virConnectGetURI (virConnectPtr conn) __attribute__((weak)); @@ -115,6 +144,10 @@ ocaml_libvirt_connect_get_uri (value connv) #endif } +/* Automatically generated binding for virConnectGetType. + * In generator.pl this function has signature "conn : static string". + */ + CAMLprim value ocaml_libvirt_connect_get_type (value connv) { @@ -131,6 +164,10 @@ ocaml_libvirt_connect_get_type (value connv) CAMLreturn (rv); } +/* Automatically generated binding for virConnectNumOfDomains. + * In generator.pl this function has signature "conn : int". + */ + CAMLprim value ocaml_libvirt_connect_num_of_domains (value connv) { @@ -145,6 +182,10 @@ ocaml_libvirt_connect_num_of_domains (value connv) CAMLreturn (Val_int (r)); } +/* Automatically generated binding for virConnectListDomains. + * In generator.pl this function has signature "conn, int : int array". + */ + CAMLprim value ocaml_libvirt_connect_list_domains (value connv, value iv) { @@ -165,6 +206,10 @@ ocaml_libvirt_connect_list_domains (value connv, value iv) CAMLreturn (rv); } +/* Automatically generated binding for virConnectNumOfDefinedDomains. + * In generator.pl this function has signature "conn : int". + */ + CAMLprim value ocaml_libvirt_connect_num_of_defined_domains (value connv) { @@ -179,6 +224,10 @@ ocaml_libvirt_connect_num_of_defined_domains (value connv) CAMLreturn (Val_int (r)); } +/* Automatically generated binding for virConnectListDefinedDomains. + * In generator.pl this function has signature "conn, int : string array". + */ + CAMLprim value ocaml_libvirt_connect_list_defined_domains (value connv, value iv) { @@ -203,6 +252,10 @@ ocaml_libvirt_connect_list_defined_domains (value connv, value iv) CAMLreturn (rv); } +/* Automatically generated binding for virConnectNumOfNetworks. + * In generator.pl this function has signature "conn : int". + */ + CAMLprim value ocaml_libvirt_connect_num_of_networks (value connv) { @@ -217,6 +270,10 @@ ocaml_libvirt_connect_num_of_networks (value connv) CAMLreturn (Val_int (r)); } +/* Automatically generated binding for virConnectListNetworks. + * In generator.pl this function has signature "conn, int : string array". + */ + CAMLprim value ocaml_libvirt_connect_list_networks (value connv, value iv) { @@ -241,6 +298,10 @@ ocaml_libvirt_connect_list_networks (value connv, value iv) CAMLreturn (rv); } +/* Automatically generated binding for virConnectNumOfDefinedNetworks. + * In generator.pl this function has signature "conn : int". + */ + CAMLprim value ocaml_libvirt_connect_num_of_defined_networks (value connv) { @@ -255,6 +316,10 @@ ocaml_libvirt_connect_num_of_defined_networks (value connv) CAMLreturn (Val_int (r)); } +/* Automatically generated binding for virConnectListDefinedNetworks. + * In generator.pl this function has signature "conn, int : string array". + */ + CAMLprim value ocaml_libvirt_connect_list_defined_networks (value connv, value iv) { @@ -279,6 +344,10 @@ ocaml_libvirt_connect_list_defined_networks (value connv, value iv) CAMLreturn (rv); } +/* Automatically generated binding for virConnectNumOfStoragePools. + * In generator.pl this function has signature "conn : int". + */ + #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRCONNECTNUMOFSTORAGEPOOLS extern int virConnectNumOfStoragePools (virConnectPtr conn) __attribute__((weak)); @@ -310,6 +379,10 @@ ocaml_libvirt_connect_num_of_storage_pools (value connv) #endif } +/* Automatically generated binding for virConnectListStoragePools. + * In generator.pl this function has signature "conn, int : string array". + */ + #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRCONNECTLISTSTORAGEPOOLS extern int virConnectListStoragePools (virConnectPtr conn, char **const names, int maxnames) __attribute__((weak)); @@ -351,6 +424,10 @@ ocaml_libvirt_connect_list_storage_pools (value connv, value iv) #endif } +/* Automatically generated binding for virConnectNumOfDefinedStoragePools. + * In generator.pl this function has signature "conn : int". + */ + #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRCONNECTNUMOFDEFINEDSTORAGEPOOLS extern int virConnectNumOfDefinedStoragePools (virConnectPtr conn) __attribute__((weak)); @@ -382,6 +459,10 @@ ocaml_libvirt_connect_num_of_defined_storage_pools (value connv) #endif } +/* Automatically generated binding for virConnectListDefinedStoragePools. + * In generator.pl this function has signature "conn, int : string array". + */ + #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRCONNECTLISTDEFINEDSTORAGEPOOLS extern int virConnectListDefinedStoragePools (virConnectPtr conn, char **const names, int maxnames) __attribute__((weak)); @@ -423,6 +504,10 @@ ocaml_libvirt_connect_list_defined_storage_pools (value connv, value iv) #endif } +/* Automatically generated binding for virConnectGetCapabilities. + * In generator.pl this function has signature "conn : string". + */ + CAMLprim value ocaml_libvirt_connect_get_capabilities (value connv) { @@ -440,6 +525,115 @@ ocaml_libvirt_connect_get_capabilities (value connv) CAMLreturn (rv); } +/* Automatically generated binding for virDomainCreateLinux. + * In generator.pl this function has signature "conn, string, 0U : dom". + */ + +CAMLprim value +ocaml_libvirt_domain_create_linux (value connv, value strv) +{ + CAMLparam2 (connv, strv); + + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + char *str = String_val (strv); + virDomainPtr r; + + NONBLOCKING (r = virDomainCreateLinux (conn, str, 0)); + CHECK_ERROR (!r, conn, "virDomainCreateLinux"); + + rv = Val_domain (r, connv); + + CAMLreturn (rv); +} + +/* Automatically generated binding for virDomainCreateLinuxJob. + * In generator.pl this function has signature "conn, string, 0U : job". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRDOMAINCREATELINUXJOB +extern virJobPtr virDomainCreateLinuxJob (virConnectPtr conn, const char *str, unsigned int flags) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_domain_create_linux_job (value connv, value strv) +{ + CAMLparam2 (connv, strv); +#ifndef HAVE_VIRDOMAINCREATELINUXJOB + /* Symbol virDomainCreateLinuxJob not found at compile time. */ + not_supported ("virDomainCreateLinuxJob"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virDomainCreateLinuxJob + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virDomainCreateLinuxJob); + + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + char *str = String_val (strv); + virJobPtr r; + + NONBLOCKING (r = virDomainCreateLinuxJob (conn, str, 0)); + CHECK_ERROR (!r, conn, "virDomainCreateLinuxJob"); + + rv = Val_job (r, connv); + + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virDomainFree. + * In generator.pl this function has signature "dom : free". + */ + +CAMLprim value +ocaml_libvirt_domain_free (value domv) +{ + CAMLparam1 (domv); + + virDomainPtr dom = Domain_val (domv); + virConnectPtr conn = Connect_domv (domv); + int r; + + NONBLOCKING (r = virDomainFree (dom)); + CHECK_ERROR (r == -1, conn, "virDomainFree"); + + /* So that we don't double-free in the finalizer: */ + Domain_val (domv) = NULL; + + CAMLreturn (Val_unit); +} + +/* Automatically generated binding for virDomainDestroy. + * In generator.pl this function has signature "dom : free". + */ + +CAMLprim value +ocaml_libvirt_domain_destroy (value domv) +{ + CAMLparam1 (domv); + + virDomainPtr dom = Domain_val (domv); + virConnectPtr conn = Connect_domv (domv); + int r; + + NONBLOCKING (r = virDomainDestroy (dom)); + CHECK_ERROR (r == -1, conn, "virDomainDestroy"); + + /* So that we don't double-free in the finalizer: */ + Domain_val (domv) = NULL; + + CAMLreturn (Val_unit); +} + +/* Automatically generated binding for virDomainLookupByName. + * In generator.pl this function has signature "conn, string : dom". + */ + CAMLprim value ocaml_libvirt_domain_lookup_by_name (value connv, value strv) { @@ -458,6 +652,54 @@ ocaml_libvirt_domain_lookup_by_name (value connv, value strv) CAMLreturn (rv); } +/* Automatically generated binding for virDomainLookupByID. + * In generator.pl this function has signature "conn, int : dom". + */ + +CAMLprim value +ocaml_libvirt_domain_lookup_by_id (value connv, value iv) +{ + CAMLparam2 (connv, iv); + + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + int i = Int_val (iv); + virDomainPtr r; + + NONBLOCKING (r = virDomainLookupByID (conn, i)); + CHECK_ERROR (!r, conn, "virDomainLookupByID"); + + rv = Val_domain (r, connv); + + CAMLreturn (rv); +} + +/* Automatically generated binding for virDomainLookupByUUID. + * In generator.pl this function has signature "conn, uuid : dom". + */ + +CAMLprim value +ocaml_libvirt_domain_lookup_by_uuid (value connv, value uuidv) +{ + CAMLparam2 (connv, uuidv); + + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + unsigned char *uuid = (unsigned char *) String_val (uuidv); + virDomainPtr r; + + NONBLOCKING (r = virDomainLookupByUUID (conn, uuid)); + CHECK_ERROR (!r, conn, "virDomainLookupByUUID"); + + rv = Val_domain (r, connv); + + CAMLreturn (rv); +} + +/* Automatically generated binding for virDomainLookupByUUIDString. + * In generator.pl this function has signature "conn, string : dom". + */ + CAMLprim value ocaml_libvirt_domain_lookup_by_uuid_string (value connv, value strv) { @@ -476,6 +718,10 @@ ocaml_libvirt_domain_lookup_by_uuid_string (value connv, value strv) CAMLreturn (rv); } +/* Automatically generated binding for virDomainGetName. + * In generator.pl this function has signature "dom : static string". + */ + CAMLprim value ocaml_libvirt_domain_get_name (value domv) { @@ -493,6 +739,10 @@ ocaml_libvirt_domain_get_name (value domv) CAMLreturn (rv); } +/* Automatically generated binding for virDomainGetOSType. + * In generator.pl this function has signature "dom : string". + */ + CAMLprim value ocaml_libvirt_domain_get_os_type (value domv) { @@ -511,6 +761,10 @@ ocaml_libvirt_domain_get_os_type (value domv) CAMLreturn (rv); } +/* Automatically generated binding for virDomainGetXMLDesc. + * In generator.pl this function has signature "dom, 0 : string". + */ + CAMLprim value ocaml_libvirt_domain_get_xml_desc (value domv) { @@ -529,38 +783,58 @@ ocaml_libvirt_domain_get_xml_desc (value domv) CAMLreturn (rv); } +/* Automatically generated binding for virDomainGetUUID. + * In generator.pl this function has signature "dom : uuid". + */ + CAMLprim value -ocaml_libvirt_domain_suspend (value domv) +ocaml_libvirt_domain_get_uuid (value domv) { CAMLparam1 (domv); + CAMLlocal1 (rv); virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); + unsigned char uuid[VIR_UUID_BUFLEN]; int r; - NONBLOCKING (r = virDomainSuspend (dom)); - CHECK_ERROR (r == -1, conn, "virDomainSuspend"); + NONBLOCKING (r = virDomainGetUUID (dom, uuid)); + CHECK_ERROR (r == -1, conn, "virDomainGetUUID"); - CAMLreturn (Val_unit); + /* UUIDs are byte arrays with a fixed length. */ + rv = caml_alloc_string (VIR_UUID_BUFLEN); + memcpy (String_val (rv), uuid, VIR_UUID_BUFLEN); + CAMLreturn (rv); } +/* Automatically generated binding for virDomainGetUUIDString. + * In generator.pl this function has signature "dom : uuid string". + */ + CAMLprim value -ocaml_libvirt_domain_resume (value domv) +ocaml_libvirt_domain_get_uuid_string (value domv) { CAMLparam1 (domv); + CAMLlocal1 (rv); virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); + char uuid[VIR_UUID_STRING_BUFLEN]; int r; - NONBLOCKING (r = virDomainResume (dom)); - CHECK_ERROR (r == -1, conn, "virDomainResume"); + NONBLOCKING (r = virDomainGetUUIDString (dom, uuid)); + CHECK_ERROR (r == -1, conn, "virDomainGetUUIDString"); - CAMLreturn (Val_unit); + rv = caml_copy_string (uuid); + CAMLreturn (rv); } +/* Automatically generated binding for virDomainGetMaxVcpus. + * In generator.pl this function has signature "dom : int". + */ + CAMLprim value -ocaml_libvirt_domain_shutdown (value domv) +ocaml_libvirt_domain_get_max_vcpus (value domv) { CAMLparam1 (domv); @@ -568,80 +842,444 @@ ocaml_libvirt_domain_shutdown (value domv) virConnectPtr conn = Connect_domv (domv); int r; - NONBLOCKING (r = virDomainShutdown (dom)); - CHECK_ERROR (r == -1, conn, "virDomainShutdown"); + NONBLOCKING (r = virDomainGetMaxVcpus (dom)); + CHECK_ERROR (r == -1, conn, "virDomainGetMaxVcpus"); - CAMLreturn (Val_unit); + CAMLreturn (Val_int (r)); } +/* Automatically generated binding for virDomainSave. + * In generator.pl this function has signature "dom, string : unit". + */ + CAMLprim value -ocaml_libvirt_domain_reboot (value domv) +ocaml_libvirt_domain_save (value domv, value strv) { - CAMLparam1 (domv); + CAMLparam2 (domv, strv); + CAMLlocal1 (rv); virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); + char *str = String_val (strv); int r; - NONBLOCKING (r = virDomainReboot (dom, 0)); - CHECK_ERROR (r == -1, conn, "virDomainReboot"); + NONBLOCKING (r = virDomainSave (dom, str)); + CHECK_ERROR (r == -1, conn, "virDomainSave"); CAMLreturn (Val_unit); } +/* Automatically generated binding for virDomainSaveJob. + * In generator.pl this function has signature "dom, string : job from dom". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRDOMAINSAVEJOB +extern virJobPtr virDomainSaveJob (virDomainPtr dom, const char *str) __attribute__((weak)); +#endif +#endif + CAMLprim value -ocaml_libvirt_domain_undefine (value domv) +ocaml_libvirt_domain_save_job (value domv, value strv) { - CAMLparam1 (domv); + CAMLparam2 (domv, strv); +#ifndef HAVE_VIRDOMAINSAVEJOB + /* Symbol virDomainSaveJob not found at compile time. */ + not_supported ("virDomainSaveJob"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virDomainSaveJob + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virDomainSaveJob); + CAMLlocal2 (rv, connv); virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); - int r; + char *str = String_val (strv); + virJobPtr r; - NONBLOCKING (r = virDomainUndefine (dom)); - CHECK_ERROR (r == -1, conn, "virDomainUndefine"); + NONBLOCKING (r = virDomainSaveJob (dom, str)); + CHECK_ERROR (!r, conn, "virDomainSaveJob"); - CAMLreturn (Val_unit); + connv = Field (domv, 1); + rv = Val_job (r, connv); + + CAMLreturn (rv); +#endif } +/* Automatically generated binding for virDomainRestore. + * In generator.pl this function has signature "conn, string : unit". + */ + CAMLprim value -ocaml_libvirt_domain_create (value domv) +ocaml_libvirt_domain_restore (value connv, value strv) { - CAMLparam1 (domv); + CAMLparam2 (connv, strv); - virDomainPtr dom = Domain_val (domv); - virConnectPtr conn = Connect_domv (domv); + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + char *str = String_val (strv); int r; - NONBLOCKING (r = virDomainCreate (dom)); - CHECK_ERROR (r == -1, conn, "virDomainCreate"); + NONBLOCKING (r = virDomainRestore (conn, str)); + CHECK_ERROR (r == -1, conn, "virDomainRestore"); CAMLreturn (Val_unit); } +/* Automatically generated binding for virDomainRestoreJob. + * In generator.pl this function has signature "conn, string : job". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRDOMAINRESTOREJOB +extern virJobPtr virDomainRestoreJob (virConnectPtr conn, const char *str) __attribute__((weak)); +#endif +#endif + CAMLprim value -ocaml_libvirt_domain_get_autostart (value domv) +ocaml_libvirt_domain_restore_job (value connv, value strv) { - CAMLparam1 (domv); + CAMLparam2 (connv, strv); +#ifndef HAVE_VIRDOMAINRESTOREJOB + /* Symbol virDomainRestoreJob not found at compile time. */ + not_supported ("virDomainRestoreJob"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virDomainRestoreJob + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virDomainRestoreJob); - virDomainPtr dom = Domain_val (domv); - virConnectPtr conn = Connect_domv (domv); - int r, b; + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + char *str = String_val (strv); + virJobPtr r; - NONBLOCKING (r = virDomainGetAutostart (dom, &b)); - CHECK_ERROR (r == -1, conn, "virDomainGetAutostart"); + NONBLOCKING (r = virDomainRestoreJob (conn, str)); + CHECK_ERROR (!r, conn, "virDomainRestoreJob"); - CAMLreturn (b ? Val_true : Val_false); + rv = Val_job (r, connv); + + CAMLreturn (rv); +#endif } +/* Automatically generated binding for virDomainCoreDump. + * In generator.pl this function has signature "dom, string, 0 : unit". + */ + CAMLprim value -ocaml_libvirt_domain_set_autostart (value domv, value bv) +ocaml_libvirt_domain_core_dump (value domv, value strv) { - CAMLparam2 (domv, bv); + CAMLparam2 (domv, strv); + CAMLlocal1 (rv); virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); - int r, b; + char *str = String_val (strv); + int r; + + NONBLOCKING (r = virDomainCoreDump (dom, str, 0)); + CHECK_ERROR (!r, conn, "virDomainCoreDump"); + + CAMLreturn (Val_unit); +} + +/* Automatically generated binding for virDomainCoreDumpJob. + * In generator.pl this function has signature "dom, string, 0 : job from dom". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRDOMAINCOREDUMPJOB +extern virJobPtr virDomainCoreDumpJob (virDomainPtr dom, const char *str, int flags) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_domain_core_dump_job (value domv, value strv) +{ + CAMLparam2 (domv, strv); +#ifndef HAVE_VIRDOMAINCOREDUMPJOB + /* Symbol virDomainCoreDumpJob not found at compile time. */ + not_supported ("virDomainCoreDumpJob"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virDomainCoreDumpJob + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virDomainCoreDumpJob); + + CAMLlocal2 (rv, connv); + virDomainPtr dom = Domain_val (domv); + virConnectPtr conn = Connect_domv (domv); + char *str = String_val (strv); + virJobPtr r; + + NONBLOCKING (r = virDomainCoreDumpJob (dom, str, 0)); + CHECK_ERROR (!r, conn, "virDomainCoreDumpJob"); + + connv = Field (domv, 1); + rv = Val_job (r, connv); + + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virDomainSuspend. + * In generator.pl this function has signature "dom : unit". + */ + +CAMLprim value +ocaml_libvirt_domain_suspend (value domv) +{ + CAMLparam1 (domv); + + virDomainPtr dom = Domain_val (domv); + virConnectPtr conn = Connect_domv (domv); + int r; + + NONBLOCKING (r = virDomainSuspend (dom)); + CHECK_ERROR (r == -1, conn, "virDomainSuspend"); + + CAMLreturn (Val_unit); +} + +/* Automatically generated binding for virDomainResume. + * In generator.pl this function has signature "dom : unit". + */ + +CAMLprim value +ocaml_libvirt_domain_resume (value domv) +{ + CAMLparam1 (domv); + + virDomainPtr dom = Domain_val (domv); + virConnectPtr conn = Connect_domv (domv); + int r; + + NONBLOCKING (r = virDomainResume (dom)); + CHECK_ERROR (r == -1, conn, "virDomainResume"); + + CAMLreturn (Val_unit); +} + +/* Automatically generated binding for virDomainShutdown. + * In generator.pl this function has signature "dom : unit". + */ + +CAMLprim value +ocaml_libvirt_domain_shutdown (value domv) +{ + CAMLparam1 (domv); + + virDomainPtr dom = Domain_val (domv); + virConnectPtr conn = Connect_domv (domv); + int r; + + NONBLOCKING (r = virDomainShutdown (dom)); + CHECK_ERROR (r == -1, conn, "virDomainShutdown"); + + CAMLreturn (Val_unit); +} + +/* Automatically generated binding for virDomainReboot. + * In generator.pl this function has signature "dom, 0 : unit". + */ + +CAMLprim value +ocaml_libvirt_domain_reboot (value domv) +{ + CAMLparam1 (domv); + + virDomainPtr dom = Domain_val (domv); + virConnectPtr conn = Connect_domv (domv); + int r; + + NONBLOCKING (r = virDomainReboot (dom, 0)); + CHECK_ERROR (r == -1, conn, "virDomainReboot"); + + CAMLreturn (Val_unit); +} + +/* Automatically generated binding for virDomainDefineXML. + * In generator.pl this function has signature "conn, string : dom". + */ + +CAMLprim value +ocaml_libvirt_domain_define_xml (value connv, value strv) +{ + CAMLparam2 (connv, strv); + + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + char *str = String_val (strv); + virDomainPtr r; + + NONBLOCKING (r = virDomainDefineXML (conn, str)); + CHECK_ERROR (!r, conn, "virDomainDefineXML"); + + rv = Val_domain (r, connv); + + CAMLreturn (rv); +} + +/* Automatically generated binding for virDomainUndefine. + * In generator.pl this function has signature "dom : unit". + */ + +CAMLprim value +ocaml_libvirt_domain_undefine (value domv) +{ + CAMLparam1 (domv); + + virDomainPtr dom = Domain_val (domv); + virConnectPtr conn = Connect_domv (domv); + int r; + + NONBLOCKING (r = virDomainUndefine (dom)); + CHECK_ERROR (r == -1, conn, "virDomainUndefine"); + + CAMLreturn (Val_unit); +} + +/* Automatically generated binding for virDomainCreate. + * In generator.pl this function has signature "dom : unit". + */ + +CAMLprim value +ocaml_libvirt_domain_create (value domv) +{ + CAMLparam1 (domv); + + virDomainPtr dom = Domain_val (domv); + virConnectPtr conn = Connect_domv (domv); + int r; + + NONBLOCKING (r = virDomainCreate (dom)); + CHECK_ERROR (r == -1, conn, "virDomainCreate"); + + CAMLreturn (Val_unit); +} + +/* Automatically generated binding for virDomainCreateJob. + * In generator.pl this function has signature "dom, 0U : job from dom". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRDOMAINCREATEJOB +extern virJobPtr virDomainCreateJob (virDomainPtr dom, unsigned int flags) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_domain_create_job (value domv) +{ + CAMLparam1 (domv); +#ifndef HAVE_VIRDOMAINCREATEJOB + /* Symbol virDomainCreateJob not found at compile time. */ + not_supported ("virDomainCreateJob"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virDomainCreateJob + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virDomainCreateJob); + + CAMLlocal2 (rv, connv); + virDomainPtr dom = Domain_val (domv); + virConnectPtr conn = Connect_domv (domv); + virJobPtr r; + + NONBLOCKING (r = virDomainCreateJob (dom, 0)); + CHECK_ERROR (!r, conn, "virDomainCreateJob"); + + connv = Field (domv, 1); + rv = Val_job (r, connv); + + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virDomainAttachDevice. + * In generator.pl this function has signature "dom, string : unit". + */ + +CAMLprim value +ocaml_libvirt_domain_attach_device (value domv, value strv) +{ + CAMLparam2 (domv, strv); + + CAMLlocal1 (rv); + virDomainPtr dom = Domain_val (domv); + virConnectPtr conn = Connect_domv (domv); + char *str = String_val (strv); + int r; + + NONBLOCKING (r = virDomainAttachDevice (dom, str)); + CHECK_ERROR (r == -1, conn, "virDomainAttachDevice"); + + CAMLreturn (Val_unit); +} + +/* Automatically generated binding for virDomainDetachDevice. + * In generator.pl this function has signature "dom, string : unit". + */ + +CAMLprim value +ocaml_libvirt_domain_detach_device (value domv, value strv) +{ + CAMLparam2 (domv, strv); + + CAMLlocal1 (rv); + virDomainPtr dom = Domain_val (domv); + virConnectPtr conn = Connect_domv (domv); + char *str = String_val (strv); + int r; + + NONBLOCKING (r = virDomainDetachDevice (dom, str)); + CHECK_ERROR (r == -1, conn, "virDomainDetachDevice"); + + CAMLreturn (Val_unit); +} + +/* Automatically generated binding for virDomainGetAutostart. + * In generator.pl this function has signature "dom : bool". + */ + +CAMLprim value +ocaml_libvirt_domain_get_autostart (value domv) +{ + CAMLparam1 (domv); + + virDomainPtr dom = Domain_val (domv); + virConnectPtr conn = Connect_domv (domv); + int r, b; + + NONBLOCKING (r = virDomainGetAutostart (dom, &b)); + CHECK_ERROR (r == -1, conn, "virDomainGetAutostart"); + + CAMLreturn (b ? Val_true : Val_false); +} + +/* Automatically generated binding for virDomainSetAutostart. + * In generator.pl this function has signature "dom, bool : unit". + */ + +CAMLprim value +ocaml_libvirt_domain_set_autostart (value domv, value bv) +{ + CAMLparam2 (domv, bv); + + virDomainPtr dom = Domain_val (domv); + virConnectPtr conn = Connect_domv (domv); + int r, b; b = bv == Val_true ? 1 : 0; @@ -651,6 +1289,54 @@ ocaml_libvirt_domain_set_autostart (value domv, value bv) CAMLreturn (Val_unit); } +/* Automatically generated binding for virNetworkFree. + * In generator.pl this function has signature "net : free". + */ + +CAMLprim value +ocaml_libvirt_network_free (value netv) +{ + CAMLparam1 (netv); + + virNetworkPtr net = Network_val (netv); + virConnectPtr conn = Connect_netv (netv); + int r; + + NONBLOCKING (r = virNetworkFree (net)); + CHECK_ERROR (r == -1, conn, "virNetworkFree"); + + /* So that we don't double-free in the finalizer: */ + Network_val (netv) = NULL; + + CAMLreturn (Val_unit); +} + +/* Automatically generated binding for virNetworkDestroy. + * In generator.pl this function has signature "net : free". + */ + +CAMLprim value +ocaml_libvirt_network_destroy (value netv) +{ + CAMLparam1 (netv); + + virNetworkPtr net = Network_val (netv); + virConnectPtr conn = Connect_netv (netv); + int r; + + NONBLOCKING (r = virNetworkDestroy (net)); + CHECK_ERROR (r == -1, conn, "virNetworkDestroy"); + + /* So that we don't double-free in the finalizer: */ + Network_val (netv) = NULL; + + CAMLreturn (Val_unit); +} + +/* Automatically generated binding for virNetworkLookupByName. + * In generator.pl this function has signature "conn, string : net". + */ + CAMLprim value ocaml_libvirt_network_lookup_by_name (value connv, value strv) { @@ -669,6 +1355,32 @@ ocaml_libvirt_network_lookup_by_name (value connv, value strv) CAMLreturn (rv); } +/* Automatically generated binding for virNetworkLookupByUUID. + * In generator.pl this function has signature "conn, uuid : net". + */ + +CAMLprim value +ocaml_libvirt_network_lookup_by_uuid (value connv, value uuidv) +{ + CAMLparam2 (connv, uuidv); + + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + unsigned char *uuid = (unsigned char *) String_val (uuidv); + virNetworkPtr r; + + NONBLOCKING (r = virNetworkLookupByUUID (conn, uuid)); + CHECK_ERROR (!r, conn, "virNetworkLookupByUUID"); + + rv = Val_network (r, connv); + + CAMLreturn (rv); +} + +/* Automatically generated binding for virNetworkLookupByUUIDString. + * In generator.pl this function has signature "conn, string : net". + */ + CAMLprim value ocaml_libvirt_network_lookup_by_uuid_string (value connv, value strv) { @@ -687,6 +1399,10 @@ ocaml_libvirt_network_lookup_by_uuid_string (value connv, value strv) CAMLreturn (rv); } +/* Automatically generated binding for virNetworkGetName. + * In generator.pl this function has signature "net : static string". + */ + CAMLprim value ocaml_libvirt_network_get_name (value netv) { @@ -704,44 +1420,204 @@ ocaml_libvirt_network_get_name (value netv) CAMLreturn (rv); } +/* Automatically generated binding for virNetworkGetXMLDesc. + * In generator.pl this function has signature "net, 0 : string". + */ + CAMLprim value ocaml_libvirt_network_get_xml_desc (value netv) { CAMLparam1 (netv); CAMLlocal1 (rv); - virNetworkPtr net = Network_val (netv); - virConnectPtr conn = Connect_netv (netv); - char *r; + virNetworkPtr net = Network_val (netv); + virConnectPtr conn = Connect_netv (netv); + char *r; + + NONBLOCKING (r = virNetworkGetXMLDesc (net, 0)); + CHECK_ERROR (!r, conn, "virNetworkGetXMLDesc"); + + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); +} + +/* Automatically generated binding for virNetworkGetBridgeName. + * In generator.pl this function has signature "net : string". + */ + +CAMLprim value +ocaml_libvirt_network_get_bridge_name (value netv) +{ + CAMLparam1 (netv); + + CAMLlocal1 (rv); + virNetworkPtr net = Network_val (netv); + virConnectPtr conn = Connect_netv (netv); + char *r; + + NONBLOCKING (r = virNetworkGetBridgeName (net)); + CHECK_ERROR (!r, conn, "virNetworkGetBridgeName"); + + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); +} + +/* Automatically generated binding for virNetworkGetUUID. + * In generator.pl this function has signature "net : uuid". + */ + +CAMLprim value +ocaml_libvirt_network_get_uuid (value netv) +{ + CAMLparam1 (netv); + + CAMLlocal1 (rv); + virNetworkPtr net = Network_val (netv); + virConnectPtr conn = Connect_netv (netv); + unsigned char uuid[VIR_UUID_BUFLEN]; + int r; + + NONBLOCKING (r = virNetworkGetUUID (net, uuid)); + CHECK_ERROR (r == -1, conn, "virNetworkGetUUID"); + + /* UUIDs are byte arrays with a fixed length. */ + rv = caml_alloc_string (VIR_UUID_BUFLEN); + memcpy (String_val (rv), uuid, VIR_UUID_BUFLEN); + CAMLreturn (rv); +} + +/* Automatically generated binding for virNetworkGetUUIDString. + * In generator.pl this function has signature "net : uuid string". + */ + +CAMLprim value +ocaml_libvirt_network_get_uuid_string (value netv) +{ + CAMLparam1 (netv); + + CAMLlocal1 (rv); + virNetworkPtr net = Network_val (netv); + virConnectPtr conn = Connect_netv (netv); + char uuid[VIR_UUID_STRING_BUFLEN]; + int r; + + NONBLOCKING (r = virNetworkGetUUIDString (net, uuid)); + CHECK_ERROR (r == -1, conn, "virNetworkGetUUIDString"); + + rv = caml_copy_string (uuid); + CAMLreturn (rv); +} + +/* Automatically generated binding for virNetworkUndefine. + * In generator.pl this function has signature "net : unit". + */ + +CAMLprim value +ocaml_libvirt_network_undefine (value netv) +{ + CAMLparam1 (netv); + + virNetworkPtr net = Network_val (netv); + virConnectPtr conn = Connect_netv (netv); + int r; + + NONBLOCKING (r = virNetworkUndefine (net)); + CHECK_ERROR (r == -1, conn, "virNetworkUndefine"); + + CAMLreturn (Val_unit); +} + +/* Automatically generated binding for virNetworkCreateXML. + * In generator.pl this function has signature "conn, string : net". + */ + +CAMLprim value +ocaml_libvirt_network_create_xml (value connv, value strv) +{ + CAMLparam2 (connv, strv); + + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + char *str = String_val (strv); + virNetworkPtr r; + + NONBLOCKING (r = virNetworkCreateXML (conn, str)); + CHECK_ERROR (!r, conn, "virNetworkCreateXML"); + + rv = Val_network (r, connv); + + CAMLreturn (rv); +} + +/* Automatically generated binding for virNetworkCreateXMLJob. + * In generator.pl this function has signature "conn, string : job". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRNETWORKCREATEXMLJOB +extern virJobPtr virNetworkCreateXMLJob (virConnectPtr conn, const char *str) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_network_create_xml_job (value connv, value strv) +{ + CAMLparam2 (connv, strv); +#ifndef HAVE_VIRNETWORKCREATEXMLJOB + /* Symbol virNetworkCreateXMLJob not found at compile time. */ + not_supported ("virNetworkCreateXMLJob"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virNetworkCreateXMLJob + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virNetworkCreateXMLJob); + + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + char *str = String_val (strv); + virJobPtr r; - NONBLOCKING (r = virNetworkGetXMLDesc (net, 0)); - CHECK_ERROR (!r, conn, "virNetworkGetXMLDesc"); + NONBLOCKING (r = virNetworkCreateXMLJob (conn, str)); + CHECK_ERROR (!r, conn, "virNetworkCreateXMLJob"); + + rv = Val_job (r, connv); - rv = caml_copy_string (r); - free (r); CAMLreturn (rv); +#endif } +/* Automatically generated binding for virNetworkDefineXML. + * In generator.pl this function has signature "conn, string : net". + */ + CAMLprim value -ocaml_libvirt_network_get_bridge_name (value netv) +ocaml_libvirt_network_define_xml (value connv, value strv) { - CAMLparam1 (netv); + CAMLparam2 (connv, strv); CAMLlocal1 (rv); - virNetworkPtr net = Network_val (netv); - virConnectPtr conn = Connect_netv (netv); - char *r; + virConnectPtr conn = Connect_val (connv); + char *str = String_val (strv); + virNetworkPtr r; - NONBLOCKING (r = virNetworkGetBridgeName (net)); - CHECK_ERROR (!r, conn, "virNetworkGetBridgeName"); + NONBLOCKING (r = virNetworkDefineXML (conn, str)); + CHECK_ERROR (!r, conn, "virNetworkDefineXML"); + + rv = Val_network (r, connv); - rv = caml_copy_string (r); - free (r); CAMLreturn (rv); } +/* Automatically generated binding for virNetworkCreate. + * In generator.pl this function has signature "net : unit". + */ + CAMLprim value -ocaml_libvirt_network_undefine (value netv) +ocaml_libvirt_network_create (value netv) { CAMLparam1 (netv); @@ -749,27 +1625,56 @@ ocaml_libvirt_network_undefine (value netv) virConnectPtr conn = Connect_netv (netv); int r; - NONBLOCKING (r = virNetworkUndefine (net)); - CHECK_ERROR (r == -1, conn, "virNetworkUndefine"); + NONBLOCKING (r = virNetworkCreate (net)); + CHECK_ERROR (r == -1, conn, "virNetworkCreate"); CAMLreturn (Val_unit); } +/* Automatically generated binding for virNetworkCreateJob. + * In generator.pl this function has signature "net : job from net". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRNETWORKCREATEJOB +extern virJobPtr virNetworkCreateJob (virNetworkPtr net) __attribute__((weak)); +#endif +#endif + CAMLprim value -ocaml_libvirt_network_create (value netv) +ocaml_libvirt_network_create_job (value netv) { CAMLparam1 (netv); +#ifndef HAVE_VIRNETWORKCREATEJOB + /* Symbol virNetworkCreateJob not found at compile time. */ + not_supported ("virNetworkCreateJob"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virNetworkCreateJob + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virNetworkCreateJob); + CAMLlocal2 (rv, connv); virNetworkPtr net = Network_val (netv); virConnectPtr conn = Connect_netv (netv); - int r; + virJobPtr r; - NONBLOCKING (r = virNetworkCreate (net)); - CHECK_ERROR (r == -1, conn, "virNetworkCreate"); + NONBLOCKING (r = virNetworkCreateJob (net)); + CHECK_ERROR (!r, conn, "virNetworkCreateJob"); - CAMLreturn (Val_unit); + connv = Field (netv, 1); + rv = Val_job (r, connv); + + CAMLreturn (rv); +#endif } +/* Automatically generated binding for virNetworkGetAutostart. + * In generator.pl this function has signature "net : bool". + */ + CAMLprim value ocaml_libvirt_network_get_autostart (value netv) { @@ -785,6 +1690,10 @@ ocaml_libvirt_network_get_autostart (value netv) CAMLreturn (b ? Val_true : Val_false); } +/* Automatically generated binding for virNetworkSetAutostart. + * In generator.pl this function has signature "net, bool : unit". + */ + CAMLprim value ocaml_libvirt_network_set_autostart (value netv, value bv) { @@ -802,6 +1711,88 @@ ocaml_libvirt_network_set_autostart (value netv, value bv) CAMLreturn (Val_unit); } +/* Automatically generated binding for virStoragePoolFree. + * In generator.pl this function has signature "pool : free". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLFREE +extern int virStoragePoolFree (virStoragePoolPtr pool) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_pool_free (value poolv) +{ + CAMLparam1 (poolv); +#ifndef HAVE_VIRSTORAGEPOOLFREE + /* Symbol virStoragePoolFree not found at compile time. */ + not_supported ("virStoragePoolFree"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolFree + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolFree); + + virStoragePoolPtr pool = Pool_val (poolv); + virConnectPtr conn = Connect_polv (poolv); + int r; + + NONBLOCKING (r = virStoragePoolFree (pool)); + CHECK_ERROR (r == -1, conn, "virStoragePoolFree"); + + /* So that we don't double-free in the finalizer: */ + Pool_val (poolv) = NULL; + + CAMLreturn (Val_unit); +#endif +} + +/* Automatically generated binding for virStoragePoolDestroy. + * In generator.pl this function has signature "pool : free". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLDESTROY +extern int virStoragePoolDestroy (virStoragePoolPtr pool) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_pool_destroy (value poolv) +{ + CAMLparam1 (poolv); +#ifndef HAVE_VIRSTORAGEPOOLDESTROY + /* Symbol virStoragePoolDestroy not found at compile time. */ + not_supported ("virStoragePoolDestroy"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolDestroy + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolDestroy); + + virStoragePoolPtr pool = Pool_val (poolv); + virConnectPtr conn = Connect_polv (poolv); + int r; + + NONBLOCKING (r = virStoragePoolDestroy (pool)); + CHECK_ERROR (r == -1, conn, "virStoragePoolDestroy"); + + /* So that we don't double-free in the finalizer: */ + Pool_val (poolv) = NULL; + + CAMLreturn (Val_unit); +#endif +} + +/* Automatically generated binding for virStoragePoolLookupByName. + * In generator.pl this function has signature "conn, string : pool". + */ + #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYNAME extern virStoragePoolPtr virStoragePoolLookupByName (virConnectPtr conn, const char *str) __attribute__((weak)); @@ -837,6 +1828,49 @@ ocaml_libvirt_storage_pool_lookup_by_name (value connv, value strv) #endif } +/* Automatically generated binding for virStoragePoolLookupByUUID. + * In generator.pl this function has signature "conn, uuid : pool". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYUUID +extern virStoragePoolPtr virStoragePoolLookupByUUID (virConnectPtr conn, const unsigned char *str) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_pool_lookup_by_uuid (value connv, value uuidv) +{ + CAMLparam2 (connv, uuidv); +#ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYUUID + /* Symbol virStoragePoolLookupByUUID not found at compile time. */ + not_supported ("virStoragePoolLookupByUUID"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolLookupByUUID + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolLookupByUUID); + + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + unsigned char *uuid = (unsigned char *) String_val (uuidv); + virStoragePoolPtr r; + + NONBLOCKING (r = virStoragePoolLookupByUUID (conn, uuid)); + CHECK_ERROR (!r, conn, "virStoragePoolLookupByUUID"); + + rv = Val_pool (r, connv); + + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virStoragePoolLookupByUUIDString. + * In generator.pl this function has signature "conn, string : pool". + */ + #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYUUIDSTRING extern virStoragePoolPtr virStoragePoolLookupByUUIDString (virConnectPtr conn, const char *str) __attribute__((weak)); @@ -872,6 +1906,10 @@ ocaml_libvirt_storage_pool_lookup_by_uuid_string (value connv, value strv) #endif } +/* Automatically generated binding for virStoragePoolGetName. + * In generator.pl this function has signature "pool : static string". + */ + #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRSTORAGEPOOLGETNAME extern const char *virStoragePoolGetName (virStoragePoolPtr pool) __attribute__((weak)); @@ -906,6 +1944,10 @@ ocaml_libvirt_storage_pool_get_name (value poolv) #endif } +/* Automatically generated binding for virStoragePoolGetXMLDesc. + * In generator.pl this function has signature "pool, 0 : string". + */ + #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRSTORAGEPOOLGETXMLDESC extern char *virStoragePoolGetXMLDesc (virStoragePoolPtr pool, int flags) __attribute__((weak)); @@ -941,6 +1983,168 @@ ocaml_libvirt_storage_pool_get_xml_desc (value poolv) #endif } +/* Automatically generated binding for virStoragePoolGetUUID. + * In generator.pl this function has signature "pool : uuid". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLGETUUID +extern int virStoragePoolGetUUID (virStoragePoolPtr pool, unsigned char *) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_pool_get_uuid (value poolv) +{ + CAMLparam1 (poolv); +#ifndef HAVE_VIRSTORAGEPOOLGETUUID + /* Symbol virStoragePoolGetUUID not found at compile time. */ + not_supported ("virStoragePoolGetUUID"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolGetUUID + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolGetUUID); + + CAMLlocal1 (rv); + virStoragePoolPtr pool = Pool_val (poolv); + virConnectPtr conn = Connect_polv (poolv); + unsigned char uuid[VIR_UUID_BUFLEN]; + int r; + + NONBLOCKING (r = virStoragePoolGetUUID (pool, uuid)); + CHECK_ERROR (r == -1, conn, "virStoragePoolGetUUID"); + + /* UUIDs are byte arrays with a fixed length. */ + rv = caml_alloc_string (VIR_UUID_BUFLEN); + memcpy (String_val (rv), uuid, VIR_UUID_BUFLEN); + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virStoragePoolGetUUIDString. + * In generator.pl this function has signature "pool : uuid string". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLGETUUIDSTRING +extern int virStoragePoolGetUUIDString (virStoragePoolPtr pool, char *) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_pool_get_uuid_string (value poolv) +{ + CAMLparam1 (poolv); +#ifndef HAVE_VIRSTORAGEPOOLGETUUIDSTRING + /* Symbol virStoragePoolGetUUIDString not found at compile time. */ + not_supported ("virStoragePoolGetUUIDString"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolGetUUIDString + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolGetUUIDString); + + CAMLlocal1 (rv); + virStoragePoolPtr pool = Pool_val (poolv); + virConnectPtr conn = Connect_polv (poolv); + char uuid[VIR_UUID_STRING_BUFLEN]; + int r; + + NONBLOCKING (r = virStoragePoolGetUUIDString (pool, uuid)); + CHECK_ERROR (r == -1, conn, "virStoragePoolGetUUIDString"); + + rv = caml_copy_string (uuid); + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virStoragePoolCreateXML. + * In generator.pl this function has signature "conn, string : pool". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLCREATEXML +extern virStoragePoolPtr virStoragePoolCreateXML (virConnectPtr conn, const char *str) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_pool_create_xml (value connv, value strv) +{ + CAMLparam2 (connv, strv); +#ifndef HAVE_VIRSTORAGEPOOLCREATEXML + /* Symbol virStoragePoolCreateXML not found at compile time. */ + not_supported ("virStoragePoolCreateXML"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolCreateXML + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolCreateXML); + + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + char *str = String_val (strv); + virStoragePoolPtr r; + + NONBLOCKING (r = virStoragePoolCreateXML (conn, str)); + CHECK_ERROR (!r, conn, "virStoragePoolCreateXML"); + + rv = Val_pool (r, connv); + + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virStoragePoolDefineXML. + * In generator.pl this function has signature "conn, string : pool". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLDEFINEXML +extern virStoragePoolPtr virStoragePoolDefineXML (virConnectPtr conn, const char *str) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_pool_define_xml (value connv, value strv) +{ + CAMLparam2 (connv, strv); +#ifndef HAVE_VIRSTORAGEPOOLDEFINEXML + /* Symbol virStoragePoolDefineXML not found at compile time. */ + not_supported ("virStoragePoolDefineXML"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolDefineXML + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolDefineXML); + + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + char *str = String_val (strv); + virStoragePoolPtr r; + + NONBLOCKING (r = virStoragePoolDefineXML (conn, str)); + CHECK_ERROR (!r, conn, "virStoragePoolDefineXML"); + + rv = Val_pool (r, connv); + + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virStoragePoolUndefine. + * In generator.pl this function has signature "pool : unit". + */ + #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRSTORAGEPOOLUNDEFINE extern int virStoragePoolUndefine (virStoragePoolPtr pool) __attribute__((weak)); @@ -973,6 +2177,10 @@ ocaml_libvirt_storage_pool_undefine (value poolv) #endif } +/* Automatically generated binding for virStoragePoolCreate. + * In generator.pl this function has signature "pool : unit". + */ + #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRSTORAGEPOOLCREATE extern int virStoragePoolCreate (virStoragePoolPtr pool) __attribute__((weak)); @@ -1005,6 +2213,10 @@ ocaml_libvirt_storage_pool_create (value poolv) #endif } +/* Automatically generated binding for virStoragePoolShutdown. + * In generator.pl this function has signature "pool : unit". + */ + #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRSTORAGEPOOLSHUTDOWN extern int virStoragePoolShutdown (virStoragePoolPtr pool) __attribute__((weak)); @@ -1037,6 +2249,10 @@ ocaml_libvirt_storage_pool_shutdown (value poolv) #endif } +/* Automatically generated binding for virStoragePoolRefresh. + * In generator.pl this function has signature "pool, 0U : unit". + */ + #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRSTORAGEPOOLREFRESH extern int virStoragePoolRefresh (virStoragePoolPtr pool, unsigned int flags) __attribute__((weak)); @@ -1069,6 +2285,10 @@ ocaml_libvirt_storage_pool_refresh (value poolv) #endif } +/* Automatically generated binding for virStoragePoolGetAutostart. + * In generator.pl this function has signature "pool : bool". + */ + #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRSTORAGEPOOLGETAUTOSTART extern int virStoragePoolGetAutostart (virStoragePoolPtr pool, int *r) __attribute__((weak)); @@ -1101,6 +2321,10 @@ ocaml_libvirt_storage_pool_get_autostart (value poolv) #endif } +/* Automatically generated binding for virStoragePoolSetAutostart. + * In generator.pl this function has signature "pool, bool : unit". + */ + #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRSTORAGEPOOLSETAUTOSTART extern int virStoragePoolSetAutostart (virStoragePoolPtr pool, int b) __attribute__((weak)); @@ -1135,6 +2359,129 @@ ocaml_libvirt_storage_pool_set_autostart (value poolv, value bv) #endif } +/* Automatically generated binding for virStorageVolFree. + * In generator.pl this function has signature "vol : free". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEVOLFREE +extern int virStorageVolFree (virStorageVolPtr vol) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_vol_free (value volv) +{ + CAMLparam1 (volv); +#ifndef HAVE_VIRSTORAGEVOLFREE + /* Symbol virStorageVolFree not found at compile time. */ + not_supported ("virStorageVolFree"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStorageVolFree + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStorageVolFree); + + virStorageVolPtr vol = Volume_val (volv); + virConnectPtr conn = Connect_volv (volv); + int r; + + NONBLOCKING (r = virStorageVolFree (vol)); + CHECK_ERROR (r == -1, conn, "virStorageVolFree"); + + /* So that we don't double-free in the finalizer: */ + Volume_val (volv) = NULL; + + CAMLreturn (Val_unit); +#endif +} + +/* Automatically generated binding for virStorageVolDestroy. + * In generator.pl this function has signature "vol : free". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEVOLDESTROY +extern int virStorageVolDestroy (virStorageVolPtr vol) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_vol_destroy (value volv) +{ + CAMLparam1 (volv); +#ifndef HAVE_VIRSTORAGEVOLDESTROY + /* Symbol virStorageVolDestroy not found at compile time. */ + not_supported ("virStorageVolDestroy"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStorageVolDestroy + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStorageVolDestroy); + + virStorageVolPtr vol = Volume_val (volv); + virConnectPtr conn = Connect_volv (volv); + int r; + + NONBLOCKING (r = virStorageVolDestroy (vol)); + CHECK_ERROR (r == -1, conn, "virStorageVolDestroy"); + + /* So that we don't double-free in the finalizer: */ + Volume_val (volv) = NULL; + + CAMLreturn (Val_unit); +#endif +} + +/* Automatically generated binding for virStorageVolLookupByName. + * In generator.pl this function has signature "pool, string : vol from pool". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEVOLLOOKUPBYNAME +extern virStorageVolPtr virStorageVolLookupByName (virStoragePoolPtr pool, const char *str) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_vol_lookup_by_name (value poolv, value strv) +{ + CAMLparam2 (poolv, strv); +#ifndef HAVE_VIRSTORAGEVOLLOOKUPBYNAME + /* Symbol virStorageVolLookupByName not found at compile time. */ + not_supported ("virStorageVolLookupByName"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStorageVolLookupByName + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStorageVolLookupByName); + + CAMLlocal2 (rv, connv); + virStoragePoolPtr pool = Pool_val (poolv); + virConnectPtr conn = Connect_polv (poolv); + char *str = String_val (strv); + virStorageVolPtr r; + + NONBLOCKING (r = virStorageVolLookupByName (pool, str)); + CHECK_ERROR (!r, conn, "virStorageVolLookupByName"); + + connv = Field (poolv, 1); + rv = Val_volume (r, connv); + + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virStorageVolLookupByKey. + * In generator.pl this function has signature "conn, string : vol". + */ + #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRSTORAGEVOLLOOKUPBYKEY extern virStorageVolPtr virStorageVolLookupByKey (virConnectPtr conn, const char *str) __attribute__((weak)); @@ -1170,6 +2517,10 @@ ocaml_libvirt_storage_vol_lookup_by_key (value connv, value strv) #endif } +/* Automatically generated binding for virStorageVolLookupByPath. + * In generator.pl this function has signature "conn, string : vol". + */ + #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRSTORAGEVOLLOOKUPBYPATH extern virStorageVolPtr virStorageVolLookupByPath (virConnectPtr conn, const char *str) __attribute__((weak)); @@ -1205,6 +2556,51 @@ ocaml_libvirt_storage_vol_lookup_by_path (value connv, value strv) #endif } +/* Automatically generated binding for virStorageVolCreateXML. + * In generator.pl this function has signature "pool, string, 0 : vol from pool". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEVOLCREATEXML +extern virStorageVolPtr virStorageVolCreateXML (virStoragePoolPtr pool, const char *str, int flags) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_vol_create_xml (value poolv, value strv) +{ + CAMLparam2 (poolv, strv); +#ifndef HAVE_VIRSTORAGEVOLCREATEXML + /* Symbol virStorageVolCreateXML not found at compile time. */ + not_supported ("virStorageVolCreateXML"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStorageVolCreateXML + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStorageVolCreateXML); + + CAMLlocal2 (rv, connv); + virStoragePoolPtr pool = Pool_val (poolv); + virConnectPtr conn = Connect_polv (poolv); + char *str = String_val (strv); + virStorageVolPtr r; + + NONBLOCKING (r = virStorageVolCreateXML (pool, str, 0)); + CHECK_ERROR (!r, conn, "virStorageVolCreateXML"); + + connv = Field (poolv, 1); + rv = Val_volume (r, connv); + + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virStorageVolGetXMLDesc. + * In generator.pl this function has signature "vol, 0 : string". + */ + #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRSTORAGEVOLGETXMLDESC extern char *virStorageVolGetXMLDesc (virStorageVolPtr vol, int flags) __attribute__((weak)); @@ -1240,6 +2636,10 @@ ocaml_libvirt_storage_vol_get_xml_desc (value volv) #endif } +/* Automatically generated binding for virStorageVolGetPath. + * In generator.pl this function has signature "vol : string". + */ + #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRSTORAGEVOLGETPATH extern char *virStorageVolGetPath (virStorageVolPtr vol) __attribute__((weak)); @@ -1275,6 +2675,10 @@ ocaml_libvirt_storage_vol_get_path (value volv) #endif } +/* Automatically generated binding for virStorageVolGetKey. + * In generator.pl this function has signature "vol : static string". + */ + #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRSTORAGEVOLGETKEY extern const char *virStorageVolGetKey (virStorageVolPtr vol) __attribute__((weak)); @@ -1309,6 +2713,10 @@ ocaml_libvirt_storage_vol_get_key (value volv) #endif } +/* Automatically generated binding for virStorageVolGetName. + * In generator.pl this function has signature "vol : static string". + */ + #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRSTORAGEVOLGETNAME extern const char *virStorageVolGetName (virStorageVolPtr vol) __attribute__((weak)); @@ -1343,154 +2751,199 @@ ocaml_libvirt_storage_vol_get_name (value volv) #endif } -CAMLprim value -ocaml_libvirt_domain_create_job () -{ - failwith ("ocaml_libvirt_domain_create_job is unimplemented"); -} +/* Automatically generated binding for virStoragePoolLookupByVolume. + * In generator.pl this function has signature "vol : pool from vol". + */ -CAMLprim value -ocaml_libvirt_domain_core_dump_job () -{ - failwith ("ocaml_libvirt_domain_core_dump_job is unimplemented"); -} +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYVOLUME +extern virStoragePoolPtr virStoragePoolLookupByVolume (virStorageVolPtr vol) __attribute__((weak)); +#endif +#endif CAMLprim value -ocaml_libvirt_domain_restore_job () +ocaml_libvirt_storage_pool_lookup_by_volume (value volv) { - failwith ("ocaml_libvirt_domain_restore_job is unimplemented"); -} + CAMLparam1 (volv); +#ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYVOLUME + /* Symbol virStoragePoolLookupByVolume not found at compile time. */ + not_supported ("virStoragePoolLookupByVolume"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolLookupByVolume + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolLookupByVolume); -CAMLprim value -ocaml_libvirt_domain_save_job () -{ - failwith ("ocaml_libvirt_domain_save_job is unimplemented"); -} + CAMLlocal2 (rv, connv); + virStorageVolPtr vol = Volume_val (volv); + virConnectPtr conn = Connect_volv (volv); + virStoragePoolPtr r; -CAMLprim value -ocaml_libvirt_connect_create_linux_job () -{ - failwith ("ocaml_libvirt_connect_create_linux_job is unimplemented"); -} + NONBLOCKING (r = virStoragePoolLookupByVolume (vol)); + CHECK_ERROR (!r, conn, "virStoragePoolLookupByVolume"); -CAMLprim value -ocaml_libvirt_network_create_job () -{ - failwith ("ocaml_libvirt_network_create_job is unimplemented"); -} + connv = Field (volv, 1); + rv = Val_pool (r, connv); -CAMLprim value -ocaml_libvirt_network_create_xml_job () -{ - failwith ("ocaml_libvirt_network_create_xml_job is unimplemented"); + CAMLreturn (rv); +#endif } -CAMLprim value -ocaml_libvirt_storage_pool_get_info () -{ - failwith ("ocaml_libvirt_storage_pool_get_info is unimplemented"); -} +/* Automatically generated binding for virJobFree. + * In generator.pl this function has signature "job : free". + */ -CAMLprim value -ocaml_libvirt_storage_pool_get_uuid_string () -{ - failwith ("ocaml_libvirt_storage_pool_get_uuid_string is unimplemented"); -} +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRJOBFREE +extern int virJobFree (virJobPtr job) __attribute__((weak)); +#endif +#endif CAMLprim value -ocaml_libvirt_storage_pool_get_uuid () +ocaml_libvirt_job_free (value jobv) { - failwith ("ocaml_libvirt_storage_pool_get_uuid is unimplemented"); -} + CAMLparam1 (jobv); +#ifndef HAVE_VIRJOBFREE + /* Symbol virJobFree not found at compile time. */ + not_supported ("virJobFree"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virJobFree + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virJobFree); -CAMLprim value -ocaml_libvirt_storage_pool_free () -{ - failwith ("ocaml_libvirt_storage_pool_free is unimplemented"); -} + virJobPtr job = Job_val (jobv); + virConnectPtr conn = Connect_jobv (jobv); + int r; -CAMLprim value -ocaml_libvirt_storage_pool_destroy () -{ - failwith ("ocaml_libvirt_storage_pool_destroy is unimplemented"); -} + NONBLOCKING (r = virJobFree (job)); + CHECK_ERROR (r == -1, conn, "virJobFree"); -CAMLprim value -ocaml_libvirt_storage_pool_define_xml () -{ - failwith ("ocaml_libvirt_storage_pool_define_xml is unimplemented"); -} + /* So that we don't double-free in the finalizer: */ + Job_val (jobv) = NULL; -CAMLprim value -ocaml_libvirt_storage_pool_create_xml () -{ - failwith ("ocaml_libvirt_storage_pool_create_xml is unimplemented"); + CAMLreturn (Val_unit); +#endif } -CAMLprim value -ocaml_libvirt_storage_pool_lookup_by_uuid () -{ - failwith ("ocaml_libvirt_storage_pool_lookup_by_uuid is unimplemented"); -} +/* Automatically generated binding for virJobCancel. + * In generator.pl this function has signature "job : unit". + */ -CAMLprim value -ocaml_libvirt_storage_vol_lookup_by_name () -{ - failwith ("ocaml_libvirt_storage_vol_lookup_by_name is unimplemented"); -} +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRJOBCANCEL +extern int virJobCancel (virJobPtr job) __attribute__((weak)); +#endif +#endif CAMLprim value -ocaml_libvirt_storage_vol_free () +ocaml_libvirt_job_cancel (value jobv) { - failwith ("ocaml_libvirt_storage_vol_free is unimplemented"); -} + CAMLparam1 (jobv); +#ifndef HAVE_VIRJOBCANCEL + /* Symbol virJobCancel not found at compile time. */ + not_supported ("virJobCancel"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virJobCancel + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virJobCancel); -CAMLprim value -ocaml_libvirt_storage_vol_destroy () -{ - failwith ("ocaml_libvirt_storage_vol_destroy is unimplemented"); -} + virJobPtr job = Job_val (jobv); + virConnectPtr conn = Connect_jobv (jobv); + int r; -CAMLprim value -ocaml_libvirt_storage_vol_create_xml () -{ - failwith ("ocaml_libvirt_storage_vol_create_xml is unimplemented"); -} + NONBLOCKING (r = virJobCancel (job)); + CHECK_ERROR (r == -1, conn, "virJobCancel"); -CAMLprim value -ocaml_libvirt_storage_vol_get_info () -{ - failwith ("ocaml_libvirt_storage_vol_get_info is unimplemented"); + CAMLreturn (Val_unit); +#endif } -CAMLprim value -ocaml_libvirt_pool_of_volume () -{ - failwith ("ocaml_libvirt_pool_of_volume is unimplemented"); -} +/* Automatically generated binding for virJobGetNetwork. + * In generator.pl this function has signature "job : net from job". + */ -CAMLprim value -ocaml_libvirt_job_cancel () -{ - failwith ("ocaml_libvirt_job_cancel is unimplemented"); -} +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRJOBGETNETWORK +extern virNetworkPtr virJobGetNetwork (virJobPtr job) __attribute__((weak)); +#endif +#endif CAMLprim value -ocaml_libvirt_job_get_network () +ocaml_libvirt_job_get_network (value jobv) { - failwith ("ocaml_libvirt_job_get_network is unimplemented"); -} + CAMLparam1 (jobv); +#ifndef HAVE_VIRJOBGETNETWORK + /* Symbol virJobGetNetwork not found at compile time. */ + not_supported ("virJobGetNetwork"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virJobGetNetwork + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virJobGetNetwork); -CAMLprim value -ocaml_libvirt_job_get_domain () -{ - failwith ("ocaml_libvirt_job_get_domain is unimplemented"); + CAMLlocal2 (rv, connv); + virJobPtr job = Job_val (jobv); + virConnectPtr conn = Connect_jobv (jobv); + virNetworkPtr r; + + NONBLOCKING (r = virJobGetNetwork (job)); + CHECK_ERROR (!r, conn, "virJobGetNetwork"); + + connv = Field (jobv, 1); + rv = Val_network (r, connv); + + CAMLreturn (rv); +#endif } +/* Automatically generated binding for virJobGetDomain. + * In generator.pl this function has signature "job : dom from job". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRJOBGETDOMAIN +extern virDomainPtr virJobGetDomain (virJobPtr job) __attribute__((weak)); +#endif +#endif + CAMLprim value -ocaml_libvirt_job_get_info () +ocaml_libvirt_job_get_domain (value jobv) { - failwith ("ocaml_libvirt_job_get_info is unimplemented"); + CAMLparam1 (jobv); +#ifndef HAVE_VIRJOBGETDOMAIN + /* Symbol virJobGetDomain not found at compile time. */ + not_supported ("virJobGetDomain"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virJobGetDomain + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virJobGetDomain); + + CAMLlocal2 (rv, connv); + virJobPtr job = Job_val (jobv); + virConnectPtr conn = Connect_jobv (jobv); + virDomainPtr r; + + NONBLOCKING (r = virJobGetDomain (job)); + CHECK_ERROR (!r, conn, "virJobGetDomain"); + + connv = Field (jobv, 1); + rv = Val_domain (r, connv); + + CAMLreturn (rv); +#endif } #include "libvirt_c_epilogue.c"