Disable -Wmissing-prototypes for GCC
[ocaml-libvirt.git] / libvirt / libvirt_c.c
index b1f084b..0e731a8 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 /* OCaml bindings for libvirt.
- * (C) Copyright 2007-2008 Richard W.M. Jones, Red Hat Inc.
+ * (C) Copyright 2007-2015 Richard W.M. Jones, Red Hat Inc.
  * http://libvirt.org/
  *
  * This library is free software; you can redistribute it and/or
@@ -61,7 +61,7 @@ ocaml_libvirt_connect_close (value connv)
   int r;
 
   NONBLOCKING (r = virConnectClose (conn));
-  CHECK_ERROR (r == -1, conn, "virConnectClose");
+  CHECK_ERROR (r == -1, "virConnectClose");
 
   /* So that we don't double-free in the finalizer: */
   Connect_val (connv) = NULL;
@@ -73,74 +73,42 @@ ocaml_libvirt_connect_close (value connv)
  * In generator.pl this function has signature "conn : string".
  */
 
-#ifdef HAVE_WEAK_SYMBOLS
-#ifdef HAVE_VIRCONNECTGETHOSTNAME
-extern char *virConnectGetHostname (virConnectPtr conn) __attribute__((weak));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_connect_get_hostname (value connv)
 {
   CAMLparam1 (connv);
-#ifndef HAVE_VIRCONNECTGETHOSTNAME
-  /* Symbol virConnectGetHostname not found at compile time. */
-  not_supported ("virConnectGetHostname");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virConnectGetHostname
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virConnectGetHostname);
 
   CAMLlocal1 (rv);
   virConnectPtr conn = Connect_val (connv);
   char *r;
 
   NONBLOCKING (r = virConnectGetHostname (conn));
-  CHECK_ERROR (!r, conn, "virConnectGetHostname");
+  CHECK_ERROR (!r, "virConnectGetHostname");
 
   rv = caml_copy_string (r);
   free (r);
   CAMLreturn (rv);
-#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));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_connect_get_uri (value connv)
 {
   CAMLparam1 (connv);
-#ifndef HAVE_VIRCONNECTGETURI
-  /* Symbol virConnectGetURI not found at compile time. */
-  not_supported ("virConnectGetURI");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virConnectGetURI
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virConnectGetURI);
 
   CAMLlocal1 (rv);
   virConnectPtr conn = Connect_val (connv);
   char *r;
 
   NONBLOCKING (r = virConnectGetURI (conn));
-  CHECK_ERROR (!r, conn, "virConnectGetURI");
+  CHECK_ERROR (!r, "virConnectGetURI");
 
   rv = caml_copy_string (r);
   free (r);
   CAMLreturn (rv);
-#endif
 }
 
 /* Automatically generated binding for virConnectGetType.
@@ -157,7 +125,7 @@ ocaml_libvirt_connect_get_type (value connv)
   const char *r;
 
   NONBLOCKING (r = virConnectGetType (conn));
-  CHECK_ERROR (!r, conn, "virConnectGetType");
+  CHECK_ERROR (!r, "virConnectGetType");
 
   rv = caml_copy_string (r);
   CAMLreturn (rv);
@@ -176,7 +144,7 @@ ocaml_libvirt_connect_num_of_domains (value connv)
   int r;
 
   NONBLOCKING (r = virConnectNumOfDomains (conn));
-  CHECK_ERROR (r == -1, conn, "virConnectNumOfDomains");
+  CHECK_ERROR (r == -1, "virConnectNumOfDomains");
 
   CAMLreturn (Val_int (r));
 }
@@ -193,7 +161,7 @@ ocaml_libvirt_connect_list_domains (value connv, value iv)
   CAMLlocal1 (rv);
   virConnectPtr conn = Connect_val (connv);
   int i = Int_val (iv);
-  int ids[i], r;
+  int *ids, r;
 
   /* Some libvirt List* functions still throw exceptions if i == 0,
    * so catch that and return an empty array directly.  This changes
@@ -205,12 +173,17 @@ ocaml_libvirt_connect_list_domains (value connv, value iv)
     CAMLreturn (rv);
   }
 
+  ids = malloc (sizeof (*ids) * i);
+  if (ids == NULL)
+    caml_raise_out_of_memory ();
+
   NONBLOCKING (r = virConnectListDomains (conn, ids, i));
-  CHECK_ERROR (r == -1, conn, "virConnectListDomains");
+  CHECK_ERROR_CLEANUP (r == -1, free (ids), "virConnectListDomains");
 
   rv = caml_alloc (r, 0);
   for (i = 0; i < r; ++i)
     Store_field (rv, i, Val_int (ids[i]));
+  free (ids);
 
   CAMLreturn (rv);
 }
@@ -228,7 +201,7 @@ ocaml_libvirt_connect_num_of_defined_domains (value connv)
   int r;
 
   NONBLOCKING (r = virConnectNumOfDefinedDomains (conn));
-  CHECK_ERROR (r == -1, conn, "virConnectNumOfDefinedDomains");
+  CHECK_ERROR (r == -1, "virConnectNumOfDefinedDomains");
 
   CAMLreturn (Val_int (r));
 }
@@ -245,7 +218,7 @@ ocaml_libvirt_connect_list_defined_domains (value connv, value iv)
   CAMLlocal2 (rv, strv);
   virConnectPtr conn = Connect_val (connv);
   int i = Int_val (iv);
-  char *names[i];
+  char **names;
   int r;
 
   /* Some libvirt List* functions still throw exceptions if i == 0,
@@ -258,8 +231,12 @@ ocaml_libvirt_connect_list_defined_domains (value connv, value iv)
     CAMLreturn (rv);
   }
 
+  names = malloc (sizeof (*names) * i);
+  if (names == NULL)
+    caml_raise_out_of_memory ();
+
   NONBLOCKING (r = virConnectListDefinedDomains (conn, names, i));
-  CHECK_ERROR (r == -1, conn, "virConnectListDefinedDomains");
+  CHECK_ERROR_CLEANUP (r == -1, free (names), "virConnectListDefinedDomains");
 
   rv = caml_alloc (r, 0);
   for (i = 0; i < r; ++i) {
@@ -267,6 +244,7 @@ ocaml_libvirt_connect_list_defined_domains (value connv, value iv)
     Store_field (rv, i, strv);
     free (names[i]);
   }
+  free (names);
 
   CAMLreturn (rv);
 }
@@ -284,7 +262,7 @@ ocaml_libvirt_connect_num_of_networks (value connv)
   int r;
 
   NONBLOCKING (r = virConnectNumOfNetworks (conn));
-  CHECK_ERROR (r == -1, conn, "virConnectNumOfNetworks");
+  CHECK_ERROR (r == -1, "virConnectNumOfNetworks");
 
   CAMLreturn (Val_int (r));
 }
@@ -301,7 +279,7 @@ ocaml_libvirt_connect_list_networks (value connv, value iv)
   CAMLlocal2 (rv, strv);
   virConnectPtr conn = Connect_val (connv);
   int i = Int_val (iv);
-  char *names[i];
+  char **names;
   int r;
 
   /* Some libvirt List* functions still throw exceptions if i == 0,
@@ -314,8 +292,12 @@ ocaml_libvirt_connect_list_networks (value connv, value iv)
     CAMLreturn (rv);
   }
 
+  names = malloc (sizeof (*names) * i);
+  if (names == NULL)
+    caml_raise_out_of_memory ();
+
   NONBLOCKING (r = virConnectListNetworks (conn, names, i));
-  CHECK_ERROR (r == -1, conn, "virConnectListNetworks");
+  CHECK_ERROR_CLEANUP (r == -1, free (names), "virConnectListNetworks");
 
   rv = caml_alloc (r, 0);
   for (i = 0; i < r; ++i) {
@@ -323,6 +305,7 @@ ocaml_libvirt_connect_list_networks (value connv, value iv)
     Store_field (rv, i, strv);
     free (names[i]);
   }
+  free (names);
 
   CAMLreturn (rv);
 }
@@ -340,7 +323,7 @@ ocaml_libvirt_connect_num_of_defined_networks (value connv)
   int r;
 
   NONBLOCKING (r = virConnectNumOfDefinedNetworks (conn));
-  CHECK_ERROR (r == -1, conn, "virConnectNumOfDefinedNetworks");
+  CHECK_ERROR (r == -1, "virConnectNumOfDefinedNetworks");
 
   CAMLreturn (Val_int (r));
 }
@@ -357,7 +340,7 @@ ocaml_libvirt_connect_list_defined_networks (value connv, value iv)
   CAMLlocal2 (rv, strv);
   virConnectPtr conn = Connect_val (connv);
   int i = Int_val (iv);
-  char *names[i];
+  char **names;
   int r;
 
   /* Some libvirt List* functions still throw exceptions if i == 0,
@@ -370,8 +353,12 @@ ocaml_libvirt_connect_list_defined_networks (value connv, value iv)
     CAMLreturn (rv);
   }
 
+  names = malloc (sizeof (*names) * i);
+  if (names == NULL)
+    caml_raise_out_of_memory ();
+
   NONBLOCKING (r = virConnectListDefinedNetworks (conn, names, i));
-  CHECK_ERROR (r == -1, conn, "virConnectListDefinedNetworks");
+  CHECK_ERROR_CLEANUP (r == -1, free (names), "virConnectListDefinedNetworks");
 
   rv = caml_alloc (r, 0);
   for (i = 0; i < r; ++i) {
@@ -379,6 +366,7 @@ ocaml_libvirt_connect_list_defined_networks (value connv, value iv)
     Store_field (rv, i, strv);
     free (names[i]);
   }
+  free (names);
 
   CAMLreturn (rv);
 }
@@ -387,64 +375,33 @@ ocaml_libvirt_connect_list_defined_networks (value connv, value iv)
  * In generator.pl this function has signature "conn : int".
  */
 
-#ifdef HAVE_WEAK_SYMBOLS
-#ifdef HAVE_VIRCONNECTNUMOFSTORAGEPOOLS
-extern int virConnectNumOfStoragePools (virConnectPtr conn) __attribute__((weak));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_connect_num_of_storage_pools (value connv)
 {
   CAMLparam1 (connv);
-#ifndef HAVE_VIRCONNECTNUMOFSTORAGEPOOLS
-  /* Symbol virConnectNumOfStoragePools not found at compile time. */
-  not_supported ("virConnectNumOfStoragePools");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virConnectNumOfStoragePools
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virConnectNumOfStoragePools);
 
   virConnectPtr conn = Connect_val (connv);
   int r;
 
   NONBLOCKING (r = virConnectNumOfStoragePools (conn));
-  CHECK_ERROR (r == -1, conn, "virConnectNumOfStoragePools");
+  CHECK_ERROR (r == -1, "virConnectNumOfStoragePools");
 
   CAMLreturn (Val_int (r));
-#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));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_connect_list_storage_pools (value connv, value iv)
 {
   CAMLparam2 (connv, iv);
-#ifndef HAVE_VIRCONNECTLISTSTORAGEPOOLS
-  /* Symbol virConnectListStoragePools not found at compile time. */
-  not_supported ("virConnectListStoragePools");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virConnectListStoragePools
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virConnectListStoragePools);
 
   CAMLlocal2 (rv, strv);
   virConnectPtr conn = Connect_val (connv);
   int i = Int_val (iv);
-  char *names[i];
+  char **names;
   int r;
 
   /* Some libvirt List* functions still throw exceptions if i == 0,
@@ -457,8 +414,12 @@ ocaml_libvirt_connect_list_storage_pools (value connv, value iv)
     CAMLreturn (rv);
   }
 
+  names = malloc (sizeof (*names) * i);
+  if (names == NULL)
+    caml_raise_out_of_memory ();
+
   NONBLOCKING (r = virConnectListStoragePools (conn, names, i));
-  CHECK_ERROR (r == -1, conn, "virConnectListStoragePools");
+  CHECK_ERROR_CLEANUP (r == -1, free (names), "virConnectListStoragePools");
 
   rv = caml_alloc (r, 0);
   for (i = 0; i < r; ++i) {
@@ -466,73 +427,42 @@ ocaml_libvirt_connect_list_storage_pools (value connv, value iv)
     Store_field (rv, i, strv);
     free (names[i]);
   }
+  free (names);
 
   CAMLreturn (rv);
-#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));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_connect_num_of_defined_storage_pools (value connv)
 {
   CAMLparam1 (connv);
-#ifndef HAVE_VIRCONNECTNUMOFDEFINEDSTORAGEPOOLS
-  /* Symbol virConnectNumOfDefinedStoragePools not found at compile time. */
-  not_supported ("virConnectNumOfDefinedStoragePools");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virConnectNumOfDefinedStoragePools
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virConnectNumOfDefinedStoragePools);
 
   virConnectPtr conn = Connect_val (connv);
   int r;
 
   NONBLOCKING (r = virConnectNumOfDefinedStoragePools (conn));
-  CHECK_ERROR (r == -1, conn, "virConnectNumOfDefinedStoragePools");
+  CHECK_ERROR (r == -1, "virConnectNumOfDefinedStoragePools");
 
   CAMLreturn (Val_int (r));
-#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));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_connect_list_defined_storage_pools (value connv, value iv)
 {
   CAMLparam2 (connv, iv);
-#ifndef HAVE_VIRCONNECTLISTDEFINEDSTORAGEPOOLS
-  /* Symbol virConnectListDefinedStoragePools not found at compile time. */
-  not_supported ("virConnectListDefinedStoragePools");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virConnectListDefinedStoragePools
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virConnectListDefinedStoragePools);
 
   CAMLlocal2 (rv, strv);
   virConnectPtr conn = Connect_val (connv);
   int i = Int_val (iv);
-  char *names[i];
+  char **names;
   int r;
 
   /* Some libvirt List* functions still throw exceptions if i == 0,
@@ -545,8 +475,12 @@ ocaml_libvirt_connect_list_defined_storage_pools (value connv, value iv)
     CAMLreturn (rv);
   }
 
+  names = malloc (sizeof (*names) * i);
+  if (names == NULL)
+    caml_raise_out_of_memory ();
+
   NONBLOCKING (r = virConnectListDefinedStoragePools (conn, names, i));
-  CHECK_ERROR (r == -1, conn, "virConnectListDefinedStoragePools");
+  CHECK_ERROR_CLEANUP (r == -1, free (names), "virConnectListDefinedStoragePools");
 
   rv = caml_alloc (r, 0);
   for (i = 0; i < r; ++i) {
@@ -554,9 +488,9 @@ ocaml_libvirt_connect_list_defined_storage_pools (value connv, value iv)
     Store_field (rv, i, strv);
     free (names[i]);
   }
+  free (names);
 
   CAMLreturn (rv);
-#endif
 }
 
 /* Automatically generated binding for virConnectGetCapabilities.
@@ -573,13 +507,32 @@ ocaml_libvirt_connect_get_capabilities (value connv)
   char *r;
 
   NONBLOCKING (r = virConnectGetCapabilities (conn));
-  CHECK_ERROR (!r, conn, "virConnectGetCapabilities");
+  CHECK_ERROR (!r, "virConnectGetCapabilities");
 
   rv = caml_copy_string (r);
   free (r);
   CAMLreturn (rv);
 }
 
+/* Automatically generated binding for virConnectDomainEventDeregisterAny.
+ * In generator.pl this function has signature "conn, int : unit".
+ */
+
+CAMLprim value
+ocaml_libvirt_connect_domain_event_deregister_any (value connv, value iv)
+{
+  CAMLparam2 (connv, iv);
+
+  virConnectPtr conn = Connect_val (connv);
+  int i = Int_val (iv);
+  int r;
+
+  NONBLOCKING (r = virConnectDomainEventDeregisterAny (conn, i));
+  CHECK_ERROR (r == -1, "virConnectDomainEventDeregisterAny");
+
+  CAMLreturn (Val_unit);
+}
+
 /* Automatically generated binding for virDomainCreateLinux.
  * In generator.pl this function has signature "conn, string, 0U : dom".
  */
@@ -595,7 +548,30 @@ ocaml_libvirt_domain_create_linux (value connv, value strv)
   virDomainPtr r;
 
   NONBLOCKING (r = virDomainCreateLinux (conn, str, 0));
-  CHECK_ERROR (!r, conn, "virDomainCreateLinux");
+  CHECK_ERROR (!r, "virDomainCreateLinux");
+
+  rv = Val_domain (r, connv);
+
+  CAMLreturn (rv);
+}
+
+/* Automatically generated binding for virDomainCreateXML.
+ * In generator.pl this function has signature "conn, string, unsigned : dom".
+ */
+
+CAMLprim value
+ocaml_libvirt_domain_create_xml (value connv, value strv, value uv)
+{
+  CAMLparam3 (connv, strv, uv);
+
+  CAMLlocal1 (rv);
+  virConnectPtr conn = Connect_val (connv);
+  char *str = String_val (strv);
+  unsigned int u = Int_val (uv);
+  virDomainPtr r;
+
+  NONBLOCKING (r = virDomainCreateXML (conn, str, u));
+  CHECK_ERROR (!r, "virDomainCreateXML");
 
   rv = Val_domain (r, connv);
 
@@ -612,11 +588,10 @@ 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");
+  CHECK_ERROR (r == -1, "virDomainFree");
 
   /* So that we don't double-free in the finalizer: */
   Domain_val (domv) = NULL;
@@ -634,11 +609,10 @@ 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");
+  CHECK_ERROR (r == -1, "virDomainDestroy");
 
   /* So that we don't double-free in the finalizer: */
   Domain_val (domv) = NULL;
@@ -661,7 +635,7 @@ ocaml_libvirt_domain_lookup_by_name (value connv, value strv)
   virDomainPtr r;
 
   NONBLOCKING (r = virDomainLookupByName (conn, str));
-  CHECK_ERROR (!r, conn, "virDomainLookupByName");
+  CHECK_ERROR (!r, "virDomainLookupByName");
 
   rv = Val_domain (r, connv);
 
@@ -683,7 +657,7 @@ ocaml_libvirt_domain_lookup_by_id (value connv, value iv)
   virDomainPtr r;
 
   NONBLOCKING (r = virDomainLookupByID (conn, i));
-  CHECK_ERROR (!r, conn, "virDomainLookupByID");
+  CHECK_ERROR (!r, "virDomainLookupByID");
 
   rv = Val_domain (r, connv);
 
@@ -705,7 +679,7 @@ ocaml_libvirt_domain_lookup_by_uuid (value connv, value uuidv)
   virDomainPtr r;
 
   NONBLOCKING (r = virDomainLookupByUUID (conn, uuid));
-  CHECK_ERROR (!r, conn, "virDomainLookupByUUID");
+  CHECK_ERROR (!r, "virDomainLookupByUUID");
 
   rv = Val_domain (r, connv);
 
@@ -727,7 +701,7 @@ ocaml_libvirt_domain_lookup_by_uuid_string (value connv, value strv)
   virDomainPtr r;
 
   NONBLOCKING (r = virDomainLookupByUUIDString (conn, str));
-  CHECK_ERROR (!r, conn, "virDomainLookupByUUIDString");
+  CHECK_ERROR (!r, "virDomainLookupByUUIDString");
 
   rv = Val_domain (r, connv);
 
@@ -745,11 +719,10 @@ ocaml_libvirt_domain_get_name (value domv)
 
   CAMLlocal1 (rv);
   virDomainPtr dom = Domain_val (domv);
-  virConnectPtr conn = Connect_domv (domv);
   const char *r;
 
   NONBLOCKING (r = virDomainGetName (dom));
-  CHECK_ERROR (!r, conn, "virDomainGetName");
+  CHECK_ERROR (!r, "virDomainGetName");
 
   rv = caml_copy_string (r);
   CAMLreturn (rv);
@@ -766,11 +739,10 @@ ocaml_libvirt_domain_get_os_type (value domv)
 
   CAMLlocal1 (rv);
   virDomainPtr dom = Domain_val (domv);
-  virConnectPtr conn = Connect_domv (domv);
   char *r;
 
   NONBLOCKING (r = virDomainGetOSType (dom));
-  CHECK_ERROR (!r, conn, "virDomainGetOSType");
+  CHECK_ERROR (!r, "virDomainGetOSType");
 
   rv = caml_copy_string (r);
   free (r);
@@ -788,11 +760,10 @@ ocaml_libvirt_domain_get_xml_desc (value domv)
 
   CAMLlocal1 (rv);
   virDomainPtr dom = Domain_val (domv);
-  virConnectPtr conn = Connect_domv (domv);
   char *r;
 
   NONBLOCKING (r = virDomainGetXMLDesc (dom, 0));
-  CHECK_ERROR (!r, conn, "virDomainGetXMLDesc");
+  CHECK_ERROR (!r, "virDomainGetXMLDesc");
 
   rv = caml_copy_string (r);
   free (r);
@@ -810,12 +781,11 @@ ocaml_libvirt_domain_get_uuid (value domv)
 
   CAMLlocal1 (rv);
   virDomainPtr dom = Domain_val (domv);
-  virConnectPtr conn = Connect_domv (domv);
   unsigned char uuid[VIR_UUID_BUFLEN];
   int r;
 
   NONBLOCKING (r = virDomainGetUUID (dom, uuid));
-  CHECK_ERROR (r == -1, conn, "virDomainGetUUID");
+  CHECK_ERROR (r == -1, "virDomainGetUUID");
 
   /* UUIDs are byte arrays with a fixed length. */
   rv = caml_alloc_string (VIR_UUID_BUFLEN);
@@ -834,12 +804,11 @@ ocaml_libvirt_domain_get_uuid_string (value domv)
 
   CAMLlocal1 (rv);
   virDomainPtr dom = Domain_val (domv);
-  virConnectPtr conn = Connect_domv (domv);
   char uuid[VIR_UUID_STRING_BUFLEN];
   int r;
 
   NONBLOCKING (r = virDomainGetUUIDString (dom, uuid));
-  CHECK_ERROR (r == -1, conn, "virDomainGetUUIDString");
+  CHECK_ERROR (r == -1, "virDomainGetUUIDString");
 
   rv = caml_copy_string (uuid);
   CAMLreturn (rv);
@@ -855,11 +824,10 @@ ocaml_libvirt_domain_get_max_vcpus (value domv)
   CAMLparam1 (domv);
 
   virDomainPtr dom = Domain_val (domv);
-  virConnectPtr conn = Connect_domv (domv);
   int r;
 
   NONBLOCKING (r = virDomainGetMaxVcpus (dom));
-  CHECK_ERROR (r == -1, conn, "virDomainGetMaxVcpus");
+  CHECK_ERROR (r == -1, "virDomainGetMaxVcpus");
 
   CAMLreturn (Val_int (r));
 }
@@ -874,12 +842,11 @@ ocaml_libvirt_domain_save (value domv, value strv)
   CAMLparam2 (domv, strv);
 
   virDomainPtr dom = Domain_val (domv);
-  virConnectPtr conn = Connect_domv (domv);
   char *str = String_val (strv);
   int r;
 
   NONBLOCKING (r = virDomainSave (dom, str));
-  CHECK_ERROR (r == -1, conn, "virDomainSave");
+  CHECK_ERROR (r == -1, "virDomainSave");
 
   CAMLreturn (Val_unit);
 }
@@ -898,7 +865,7 @@ ocaml_libvirt_domain_restore (value connv, value strv)
   int r;
 
   NONBLOCKING (r = virDomainRestore (conn, str));
-  CHECK_ERROR (r == -1, conn, "virDomainRestore");
+  CHECK_ERROR (r == -1, "virDomainRestore");
 
   CAMLreturn (Val_unit);
 }
@@ -914,12 +881,11 @@ ocaml_libvirt_domain_core_dump (value domv, value strv)
 
   CAMLlocal1 (rv);
   virDomainPtr dom = Domain_val (domv);
-  virConnectPtr conn = Connect_domv (domv);
   char *str = String_val (strv);
   int r;
 
   NONBLOCKING (r = virDomainCoreDump (dom, str, 0));
-  CHECK_ERROR (!r, conn, "virDomainCoreDump");
+  CHECK_ERROR (!r, "virDomainCoreDump");
 
   CAMLreturn (Val_unit);
 }
@@ -934,11 +900,10 @@ 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");
+  CHECK_ERROR (r == -1, "virDomainSuspend");
 
   CAMLreturn (Val_unit);
 }
@@ -953,11 +918,10 @@ 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");
+  CHECK_ERROR (r == -1, "virDomainResume");
 
   CAMLreturn (Val_unit);
 }
@@ -972,11 +936,10 @@ 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");
+  CHECK_ERROR (r == -1, "virDomainShutdown");
 
   CAMLreturn (Val_unit);
 }
@@ -991,11 +954,10 @@ 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");
+  CHECK_ERROR (r == -1, "virDomainReboot");
 
   CAMLreturn (Val_unit);
 }
@@ -1015,7 +977,7 @@ ocaml_libvirt_domain_define_xml (value connv, value strv)
   virDomainPtr r;
 
   NONBLOCKING (r = virDomainDefineXML (conn, str));
-  CHECK_ERROR (!r, conn, "virDomainDefineXML");
+  CHECK_ERROR (!r, "virDomainDefineXML");
 
   rv = Val_domain (r, connv);
 
@@ -1032,11 +994,10 @@ 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");
+  CHECK_ERROR (r == -1, "virDomainUndefine");
 
   CAMLreturn (Val_unit);
 }
@@ -1051,11 +1012,10 @@ 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");
+  CHECK_ERROR (r == -1, "virDomainCreate");
 
   CAMLreturn (Val_unit);
 }
@@ -1070,12 +1030,11 @@ ocaml_libvirt_domain_attach_device (value domv, value strv)
   CAMLparam2 (domv, strv);
 
   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");
+  CHECK_ERROR (r == -1, "virDomainAttachDevice");
 
   CAMLreturn (Val_unit);
 }
@@ -1090,12 +1049,11 @@ ocaml_libvirt_domain_detach_device (value domv, value strv)
   CAMLparam2 (domv, strv);
 
   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");
+  CHECK_ERROR (r == -1, "virDomainDetachDevice");
 
   CAMLreturn (Val_unit);
 }
@@ -1110,11 +1068,10 @@ 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");
+  CHECK_ERROR (r == -1, "virDomainGetAutostart");
 
   CAMLreturn (b ? Val_true : Val_false);
 }
@@ -1129,13 +1086,12 @@ 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;
 
   NONBLOCKING (r = virDomainSetAutostart (dom, b));
-  CHECK_ERROR (r == -1, conn, "virDomainSetAutostart");
+  CHECK_ERROR (r == -1, "virDomainSetAutostart");
 
   CAMLreturn (Val_unit);
 }
@@ -1150,11 +1106,10 @@ 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");
+  CHECK_ERROR (r == -1, "virNetworkFree");
 
   /* So that we don't double-free in the finalizer: */
   Network_val (netv) = NULL;
@@ -1172,11 +1127,10 @@ 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");
+  CHECK_ERROR (r == -1, "virNetworkDestroy");
 
   /* So that we don't double-free in the finalizer: */
   Network_val (netv) = NULL;
@@ -1199,7 +1153,7 @@ ocaml_libvirt_network_lookup_by_name (value connv, value strv)
   virNetworkPtr r;
 
   NONBLOCKING (r = virNetworkLookupByName (conn, str));
-  CHECK_ERROR (!r, conn, "virNetworkLookupByName");
+  CHECK_ERROR (!r, "virNetworkLookupByName");
 
   rv = Val_network (r, connv);
 
@@ -1221,7 +1175,7 @@ ocaml_libvirt_network_lookup_by_uuid (value connv, value uuidv)
   virNetworkPtr r;
 
   NONBLOCKING (r = virNetworkLookupByUUID (conn, uuid));
-  CHECK_ERROR (!r, conn, "virNetworkLookupByUUID");
+  CHECK_ERROR (!r, "virNetworkLookupByUUID");
 
   rv = Val_network (r, connv);
 
@@ -1243,7 +1197,7 @@ ocaml_libvirt_network_lookup_by_uuid_string (value connv, value strv)
   virNetworkPtr r;
 
   NONBLOCKING (r = virNetworkLookupByUUIDString (conn, str));
-  CHECK_ERROR (!r, conn, "virNetworkLookupByUUIDString");
+  CHECK_ERROR (!r, "virNetworkLookupByUUIDString");
 
   rv = Val_network (r, connv);
 
@@ -1261,11 +1215,10 @@ ocaml_libvirt_network_get_name (value netv)
 
   CAMLlocal1 (rv);
   virNetworkPtr net = Network_val (netv);
-  virConnectPtr conn = Connect_netv (netv);
   const char *r;
 
   NONBLOCKING (r = virNetworkGetName (net));
-  CHECK_ERROR (!r, conn, "virNetworkGetName");
+  CHECK_ERROR (!r, "virNetworkGetName");
 
   rv = caml_copy_string (r);
   CAMLreturn (rv);
@@ -1282,11 +1235,10 @@ ocaml_libvirt_network_get_xml_desc (value netv)
 
   CAMLlocal1 (rv);
   virNetworkPtr net = Network_val (netv);
-  virConnectPtr conn = Connect_netv (netv);
   char *r;
 
   NONBLOCKING (r = virNetworkGetXMLDesc (net, 0));
-  CHECK_ERROR (!r, conn, "virNetworkGetXMLDesc");
+  CHECK_ERROR (!r, "virNetworkGetXMLDesc");
 
   rv = caml_copy_string (r);
   free (r);
@@ -1304,11 +1256,10 @@ ocaml_libvirt_network_get_bridge_name (value netv)
 
   CAMLlocal1 (rv);
   virNetworkPtr net = Network_val (netv);
-  virConnectPtr conn = Connect_netv (netv);
   char *r;
 
   NONBLOCKING (r = virNetworkGetBridgeName (net));
-  CHECK_ERROR (!r, conn, "virNetworkGetBridgeName");
+  CHECK_ERROR (!r, "virNetworkGetBridgeName");
 
   rv = caml_copy_string (r);
   free (r);
@@ -1326,12 +1277,11 @@ ocaml_libvirt_network_get_uuid (value 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");
+  CHECK_ERROR (r == -1, "virNetworkGetUUID");
 
   /* UUIDs are byte arrays with a fixed length. */
   rv = caml_alloc_string (VIR_UUID_BUFLEN);
@@ -1350,12 +1300,11 @@ ocaml_libvirt_network_get_uuid_string (value 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");
+  CHECK_ERROR (r == -1, "virNetworkGetUUIDString");
 
   rv = caml_copy_string (uuid);
   CAMLreturn (rv);
@@ -1371,11 +1320,10 @@ 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");
+  CHECK_ERROR (r == -1, "virNetworkUndefine");
 
   CAMLreturn (Val_unit);
 }
@@ -1395,7 +1343,7 @@ ocaml_libvirt_network_create_xml (value connv, value strv)
   virNetworkPtr r;
 
   NONBLOCKING (r = virNetworkCreateXML (conn, str));
-  CHECK_ERROR (!r, conn, "virNetworkCreateXML");
+  CHECK_ERROR (!r, "virNetworkCreateXML");
 
   rv = Val_network (r, connv);
 
@@ -1417,7 +1365,7 @@ ocaml_libvirt_network_define_xml (value connv, value strv)
   virNetworkPtr r;
 
   NONBLOCKING (r = virNetworkDefineXML (conn, str));
-  CHECK_ERROR (!r, conn, "virNetworkDefineXML");
+  CHECK_ERROR (!r, "virNetworkDefineXML");
 
   rv = Val_network (r, connv);
 
@@ -1434,11 +1382,10 @@ ocaml_libvirt_network_create (value netv)
   CAMLparam1 (netv);
 
   virNetworkPtr net = Network_val (netv);
-  virConnectPtr conn = Connect_netv (netv);
   int r;
 
   NONBLOCKING (r = virNetworkCreate (net));
-  CHECK_ERROR (r == -1, conn, "virNetworkCreate");
+  CHECK_ERROR (r == -1, "virNetworkCreate");
 
   CAMLreturn (Val_unit);
 }
@@ -1453,11 +1400,10 @@ ocaml_libvirt_network_get_autostart (value netv)
   CAMLparam1 (netv);
 
   virNetworkPtr net = Network_val (netv);
-  virConnectPtr conn = Connect_netv (netv);
   int r, b;
 
   NONBLOCKING (r = virNetworkGetAutostart (net, &b));
-  CHECK_ERROR (r == -1, conn, "virNetworkGetAutostart");
+  CHECK_ERROR (r == -1, "virNetworkGetAutostart");
 
   CAMLreturn (b ? Val_true : Val_false);
 }
@@ -1472,13 +1418,12 @@ ocaml_libvirt_network_set_autostart (value netv, value bv)
   CAMLparam2 (netv, bv);
 
   virNetworkPtr net = Network_val (netv);
-  virConnectPtr conn = Connect_netv (netv);
   int r, b;
 
   b = bv == Val_true ? 1 : 0;
 
   NONBLOCKING (r = virNetworkSetAutostart (net, b));
-  CHECK_ERROR (r == -1, conn, "virNetworkSetAutostart");
+  CHECK_ERROR (r == -1, "virNetworkSetAutostart");
 
   CAMLreturn (Val_unit);
 }
@@ -1487,101 +1432,52 @@ ocaml_libvirt_network_set_autostart (value netv, value bv)
  * 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");
-  CAMLnoreturn;
-#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");
+  CHECK_ERROR (r == -1, "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");
-  CAMLnoreturn;
-#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");
+  CHECK_ERROR (r == -1, "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));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_storage_pool_lookup_by_name (value connv, value strv)
 {
   CAMLparam2 (connv, strv);
-#ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYNAME
-  /* Symbol virStoragePoolLookupByName not found at compile time. */
-  not_supported ("virStoragePoolLookupByName");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virStoragePoolLookupByName
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virStoragePoolLookupByName);
 
   CAMLlocal1 (rv);
   virConnectPtr conn = Connect_val (connv);
@@ -1589,37 +1485,21 @@ ocaml_libvirt_storage_pool_lookup_by_name (value connv, value strv)
   virStoragePoolPtr r;
 
   NONBLOCKING (r = virStoragePoolLookupByName (conn, str));
-  CHECK_ERROR (!r, conn, "virStoragePoolLookupByName");
+  CHECK_ERROR (!r, "virStoragePoolLookupByName");
 
   rv = Val_pool (r, connv);
 
   CAMLreturn (rv);
-#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");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virStoragePoolLookupByUUID
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virStoragePoolLookupByUUID);
 
   CAMLlocal1 (rv);
   virConnectPtr conn = Connect_val (connv);
@@ -1627,37 +1507,21 @@ ocaml_libvirt_storage_pool_lookup_by_uuid (value connv, value uuidv)
   virStoragePoolPtr r;
 
   NONBLOCKING (r = virStoragePoolLookupByUUID (conn, uuid));
-  CHECK_ERROR (!r, conn, "virStoragePoolLookupByUUID");
+  CHECK_ERROR (!r, "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));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_storage_pool_lookup_by_uuid_string (value connv, value strv)
 {
   CAMLparam2 (connv, strv);
-#ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYUUIDSTRING
-  /* Symbol virStoragePoolLookupByUUIDString not found at compile time. */
-  not_supported ("virStoragePoolLookupByUUIDString");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virStoragePoolLookupByUUIDString
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virStoragePoolLookupByUUIDString);
 
   CAMLlocal1 (rv);
   virConnectPtr conn = Connect_val (connv);
@@ -1665,190 +1529,106 @@ ocaml_libvirt_storage_pool_lookup_by_uuid_string (value connv, value strv)
   virStoragePoolPtr r;
 
   NONBLOCKING (r = virStoragePoolLookupByUUIDString (conn, str));
-  CHECK_ERROR (!r, conn, "virStoragePoolLookupByUUIDString");
+  CHECK_ERROR (!r, "virStoragePoolLookupByUUIDString");
 
   rv = Val_pool (r, connv);
 
   CAMLreturn (rv);
-#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));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_storage_pool_get_name (value poolv)
 {
   CAMLparam1 (poolv);
-#ifndef HAVE_VIRSTORAGEPOOLGETNAME
-  /* Symbol virStoragePoolGetName not found at compile time. */
-  not_supported ("virStoragePoolGetName");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virStoragePoolGetName
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virStoragePoolGetName);
 
   CAMLlocal1 (rv);
   virStoragePoolPtr pool = Pool_val (poolv);
-  virConnectPtr conn = Connect_polv (poolv);
   const char *r;
 
   NONBLOCKING (r = virStoragePoolGetName (pool));
-  CHECK_ERROR (!r, conn, "virStoragePoolGetName");
+  CHECK_ERROR (!r, "virStoragePoolGetName");
 
   rv = caml_copy_string (r);
   CAMLreturn (rv);
-#endif
 }
 
 /* Automatically generated binding for virStoragePoolGetXMLDesc.
  * In generator.pl this function has signature "pool, 0U : string".
  */
 
-#ifdef HAVE_WEAK_SYMBOLS
-#ifdef HAVE_VIRSTORAGEPOOLGETXMLDESC
-extern char *virStoragePoolGetXMLDesc (virStoragePoolPtr pool, unsigned  int flags) __attribute__((weak));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_storage_pool_get_xml_desc (value poolv)
 {
   CAMLparam1 (poolv);
-#ifndef HAVE_VIRSTORAGEPOOLGETXMLDESC
-  /* Symbol virStoragePoolGetXMLDesc not found at compile time. */
-  not_supported ("virStoragePoolGetXMLDesc");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virStoragePoolGetXMLDesc
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virStoragePoolGetXMLDesc);
 
   CAMLlocal1 (rv);
   virStoragePoolPtr pool = Pool_val (poolv);
-  virConnectPtr conn = Connect_polv (poolv);
   char *r;
 
   NONBLOCKING (r = virStoragePoolGetXMLDesc (pool, 0));
-  CHECK_ERROR (!r, conn, "virStoragePoolGetXMLDesc");
+  CHECK_ERROR (!r, "virStoragePoolGetXMLDesc");
 
   rv = caml_copy_string (r);
   free (r);
   CAMLreturn (rv);
-#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");
-  CAMLnoreturn;
-#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");
+  CHECK_ERROR (r == -1, "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");
-  CAMLnoreturn;
-#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");
+  CHECK_ERROR (r == -1, "virStoragePoolGetUUIDString");
 
   rv = caml_copy_string (uuid);
   CAMLreturn (rv);
-#endif
 }
 
 /* Automatically generated binding for virStoragePoolCreateXML.
  * In generator.pl this function has signature "conn, string, 0U : pool".
  */
 
-#ifdef HAVE_WEAK_SYMBOLS
-#ifdef HAVE_VIRSTORAGEPOOLCREATEXML
-extern virStoragePoolPtr virStoragePoolCreateXML (virConnectPtr conn, const char *str, unsigned int flags) __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");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virStoragePoolCreateXML
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virStoragePoolCreateXML);
 
   CAMLlocal1 (rv);
   virConnectPtr conn = Connect_val (connv);
@@ -1856,37 +1636,21 @@ ocaml_libvirt_storage_pool_create_xml (value connv, value strv)
   virStoragePoolPtr r;
 
   NONBLOCKING (r = virStoragePoolCreateXML (conn, str, 0));
-  CHECK_ERROR (!r, conn, "virStoragePoolCreateXML");
+  CHECK_ERROR (!r, "virStoragePoolCreateXML");
 
   rv = Val_pool (r, connv);
 
   CAMLreturn (rv);
-#endif
 }
 
 /* Automatically generated binding for virStoragePoolDefineXML.
  * In generator.pl this function has signature "conn, string, 0U : pool".
  */
 
-#ifdef HAVE_WEAK_SYMBOLS
-#ifdef HAVE_VIRSTORAGEPOOLDEFINEXML
-extern virStoragePoolPtr virStoragePoolDefineXML (virConnectPtr conn, const char *str, unsigned int flags) __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");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virStoragePoolDefineXML
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virStoragePoolDefineXML);
 
   CAMLlocal1 (rv);
   virConnectPtr conn = Connect_val (connv);
@@ -1894,327 +1658,174 @@ ocaml_libvirt_storage_pool_define_xml (value connv, value strv)
   virStoragePoolPtr r;
 
   NONBLOCKING (r = virStoragePoolDefineXML (conn, str, 0));
-  CHECK_ERROR (!r, conn, "virStoragePoolDefineXML");
+  CHECK_ERROR (!r, "virStoragePoolDefineXML");
 
   rv = Val_pool (r, connv);
 
   CAMLreturn (rv);
-#endif
 }
 
 /* Automatically generated binding for virStoragePoolBuild.
  * In generator.pl this function has signature "pool, uint : unit".
  */
 
-#ifdef HAVE_WEAK_SYMBOLS
-#ifdef HAVE_VIRSTORAGEPOOLBUILD
-extern int virStoragePoolBuild (virStoragePoolPtr pool, unsigned int i) __attribute__((weak));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_storage_pool_build (value poolv, value iv)
 {
   CAMLparam2 (poolv, iv);
-#ifndef HAVE_VIRSTORAGEPOOLBUILD
-  /* Symbol virStoragePoolBuild not found at compile time. */
-  not_supported ("virStoragePoolBuild");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virStoragePoolBuild
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virStoragePoolBuild);
 
   virStoragePoolPtr pool = Pool_val (poolv);
-  virConnectPtr conn = Connect_polv (poolv);
   unsigned int i = Int_val (iv);
   int r;
 
   NONBLOCKING (r = virStoragePoolBuild (pool, i));
-  CHECK_ERROR (!r, conn, "virStoragePoolBuild");
+  CHECK_ERROR (r == -1, "virStoragePoolBuild");
 
   CAMLreturn (Val_unit);
-#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));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_storage_pool_undefine (value poolv)
 {
   CAMLparam1 (poolv);
-#ifndef HAVE_VIRSTORAGEPOOLUNDEFINE
-  /* Symbol virStoragePoolUndefine not found at compile time. */
-  not_supported ("virStoragePoolUndefine");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virStoragePoolUndefine
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virStoragePoolUndefine);
 
   virStoragePoolPtr pool = Pool_val (poolv);
-  virConnectPtr conn = Connect_polv (poolv);
   int r;
 
   NONBLOCKING (r = virStoragePoolUndefine (pool));
-  CHECK_ERROR (r == -1, conn, "virStoragePoolUndefine");
+  CHECK_ERROR (r == -1, "virStoragePoolUndefine");
 
   CAMLreturn (Val_unit);
-#endif
 }
 
 /* Automatically generated binding for virStoragePoolCreate.
  * In generator.pl this function has signature "pool, 0U : unit".
  */
 
-#ifdef HAVE_WEAK_SYMBOLS
-#ifdef HAVE_VIRSTORAGEPOOLCREATE
-extern int virStoragePoolCreate (virStoragePoolPtr pool, unsigned  int flags) __attribute__((weak));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_storage_pool_create (value poolv)
 {
   CAMLparam1 (poolv);
-#ifndef HAVE_VIRSTORAGEPOOLCREATE
-  /* Symbol virStoragePoolCreate not found at compile time. */
-  not_supported ("virStoragePoolCreate");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virStoragePoolCreate
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virStoragePoolCreate);
 
   virStoragePoolPtr pool = Pool_val (poolv);
-  virConnectPtr conn = Connect_polv (poolv);
   int r;
 
   NONBLOCKING (r = virStoragePoolCreate (pool, 0));
-  CHECK_ERROR (r == -1, conn, "virStoragePoolCreate");
+  CHECK_ERROR (r == -1, "virStoragePoolCreate");
 
   CAMLreturn (Val_unit);
-#endif
 }
 
 /* Automatically generated binding for virStoragePoolDelete.
  * In generator.pl this function has signature "pool, uint : unit".
  */
 
-#ifdef HAVE_WEAK_SYMBOLS
-#ifdef HAVE_VIRSTORAGEPOOLDELETE
-extern int virStoragePoolDelete (virStoragePoolPtr pool, unsigned int i) __attribute__((weak));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_storage_pool_delete (value poolv, value iv)
 {
   CAMLparam2 (poolv, iv);
-#ifndef HAVE_VIRSTORAGEPOOLDELETE
-  /* Symbol virStoragePoolDelete not found at compile time. */
-  not_supported ("virStoragePoolDelete");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virStoragePoolDelete
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virStoragePoolDelete);
 
   virStoragePoolPtr pool = Pool_val (poolv);
-  virConnectPtr conn = Connect_polv (poolv);
   unsigned int i = Int_val (iv);
   int r;
 
   NONBLOCKING (r = virStoragePoolDelete (pool, i));
-  CHECK_ERROR (!r, conn, "virStoragePoolDelete");
+  CHECK_ERROR (r == -1, "virStoragePoolDelete");
 
   CAMLreturn (Val_unit);
-#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));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_storage_pool_refresh (value poolv)
 {
   CAMLparam1 (poolv);
-#ifndef HAVE_VIRSTORAGEPOOLREFRESH
-  /* Symbol virStoragePoolRefresh not found at compile time. */
-  not_supported ("virStoragePoolRefresh");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virStoragePoolRefresh
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virStoragePoolRefresh);
 
   virStoragePoolPtr pool = Pool_val (poolv);
-  virConnectPtr conn = Connect_polv (poolv);
   int r;
 
   NONBLOCKING (r = virStoragePoolRefresh (pool, 0));
-  CHECK_ERROR (r == -1, conn, "virStoragePoolRefresh");
+  CHECK_ERROR (r == -1, "virStoragePoolRefresh");
 
   CAMLreturn (Val_unit);
-#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));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_storage_pool_get_autostart (value poolv)
 {
   CAMLparam1 (poolv);
-#ifndef HAVE_VIRSTORAGEPOOLGETAUTOSTART
-  /* Symbol virStoragePoolGetAutostart not found at compile time. */
-  not_supported ("virStoragePoolGetAutostart");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virStoragePoolGetAutostart
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virStoragePoolGetAutostart);
 
   virStoragePoolPtr pool = Pool_val (poolv);
-  virConnectPtr conn = Connect_polv (poolv);
   int r, b;
 
   NONBLOCKING (r = virStoragePoolGetAutostart (pool, &b));
-  CHECK_ERROR (r == -1, conn, "virStoragePoolGetAutostart");
+  CHECK_ERROR (r == -1, "virStoragePoolGetAutostart");
 
   CAMLreturn (b ? Val_true : Val_false);
-#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));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_storage_pool_set_autostart (value poolv, value bv)
 {
   CAMLparam2 (poolv, bv);
-#ifndef HAVE_VIRSTORAGEPOOLSETAUTOSTART
-  /* Symbol virStoragePoolSetAutostart not found at compile time. */
-  not_supported ("virStoragePoolSetAutostart");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virStoragePoolSetAutostart
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virStoragePoolSetAutostart);
 
   virStoragePoolPtr pool = Pool_val (poolv);
-  virConnectPtr conn = Connect_polv (poolv);
   int r, b;
 
   b = bv == Val_true ? 1 : 0;
 
   NONBLOCKING (r = virStoragePoolSetAutostart (pool, b));
-  CHECK_ERROR (r == -1, conn, "virStoragePoolSetAutostart");
+  CHECK_ERROR (r == -1, "virStoragePoolSetAutostart");
 
   CAMLreturn (Val_unit);
-#endif
 }
 
 /* Automatically generated binding for virStoragePoolNumOfVolumes.
  * In generator.pl this function has signature "pool : int".
  */
 
-#ifdef HAVE_WEAK_SYMBOLS
-#ifdef HAVE_VIRSTORAGEPOOLNUMOFVOLUMES
-extern int virStoragePoolNumOfVolumes (virStoragePoolPtr pool) __attribute__((weak));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_storage_pool_num_of_volumes (value poolv)
 {
   CAMLparam1 (poolv);
-#ifndef HAVE_VIRSTORAGEPOOLNUMOFVOLUMES
-  /* Symbol virStoragePoolNumOfVolumes not found at compile time. */
-  not_supported ("virStoragePoolNumOfVolumes");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virStoragePoolNumOfVolumes
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virStoragePoolNumOfVolumes);
 
   virStoragePoolPtr pool = Pool_val (poolv);
-  virConnectPtr conn = Connect_polv (poolv);
   int r;
 
   NONBLOCKING (r = virStoragePoolNumOfVolumes (pool));
-  CHECK_ERROR (r == -1, conn, "virStoragePoolNumOfVolumes");
+  CHECK_ERROR (r == -1, "virStoragePoolNumOfVolumes");
 
   CAMLreturn (Val_int (r));
-#endif
 }
 
 /* Automatically generated binding for virStoragePoolListVolumes.
  * In generator.pl this function has signature "pool, int : string array".
  */
 
-#ifdef HAVE_WEAK_SYMBOLS
-#ifdef HAVE_VIRSTORAGEPOOLLISTVOLUMES
-extern int virStoragePoolListVolumes (virStoragePoolPtr pool, char **const names, int maxnames) __attribute__((weak));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_storage_pool_list_volumes (value poolv, value iv)
 {
   CAMLparam2 (poolv, iv);
-#ifndef HAVE_VIRSTORAGEPOOLLISTVOLUMES
-  /* Symbol virStoragePoolListVolumes not found at compile time. */
-  not_supported ("virStoragePoolListVolumes");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virStoragePoolListVolumes
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virStoragePoolListVolumes);
 
   CAMLlocal2 (rv, strv);
   virStoragePoolPtr pool = Pool_val (poolv);
-  virConnectPtr conn = Connect_polv (poolv);
   int i = Int_val (iv);
-  char *names[i];
+  char **names;
   int r;
 
   /* Some libvirt List* functions still throw exceptions if i == 0,
@@ -2227,8 +1838,12 @@ ocaml_libvirt_storage_pool_list_volumes (value poolv, value iv)
     CAMLreturn (rv);
   }
 
+  names = malloc (sizeof (*names) * i);
+  if (names == NULL)
+    caml_raise_out_of_memory ();
+
   NONBLOCKING (r = virStoragePoolListVolumes (pool, names, i));
-  CHECK_ERROR (r == -1, conn, "virStoragePoolListVolumes");
+  CHECK_ERROR_CLEANUP (r == -1, free (names), "virStoragePoolListVolumes");
 
   rv = caml_alloc (r, 0);
   for (i = 0; i < r; ++i) {
@@ -2236,148 +1851,82 @@ ocaml_libvirt_storage_pool_list_volumes (value poolv, value iv)
     Store_field (rv, i, strv);
     free (names[i]);
   }
+  free (names);
 
   CAMLreturn (rv);
-#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");
-  CAMLnoreturn;
-#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");
+  CHECK_ERROR (r == -1, "virStorageVolFree");
 
   /* So that we don't double-free in the finalizer: */
   Volume_val (volv) = NULL;
 
   CAMLreturn (Val_unit);
-#endif
 }
 
 /* Automatically generated binding for virStorageVolDelete.
  * In generator.pl this function has signature "vol, uint : unit".
  */
 
-#ifdef HAVE_WEAK_SYMBOLS
-#ifdef HAVE_VIRSTORAGEVOLDELETE
-extern int virStorageVolDelete (virStorageVolPtr vol, unsigned int i) __attribute__((weak));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_storage_vol_delete (value volv, value iv)
 {
   CAMLparam2 (volv, iv);
-#ifndef HAVE_VIRSTORAGEVOLDELETE
-  /* Symbol virStorageVolDelete not found at compile time. */
-  not_supported ("virStorageVolDelete");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virStorageVolDelete
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virStorageVolDelete);
 
   virStorageVolPtr vol = Volume_val (volv);
-  virConnectPtr conn = Connect_volv (volv);
   unsigned int i = Int_val (iv);
   int r;
 
   NONBLOCKING (r = virStorageVolDelete (vol, i));
-  CHECK_ERROR (!r, conn, "virStorageVolDelete");
+  CHECK_ERROR (r == -1, "virStorageVolDelete");
 
   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");
-  CAMLnoreturn;
-#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");
+  CHECK_ERROR (!r, "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));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_storage_vol_lookup_by_key (value connv, value strv)
 {
   CAMLparam2 (connv, strv);
-#ifndef HAVE_VIRSTORAGEVOLLOOKUPBYKEY
-  /* Symbol virStorageVolLookupByKey not found at compile time. */
-  not_supported ("virStorageVolLookupByKey");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virStorageVolLookupByKey
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virStorageVolLookupByKey);
 
   CAMLlocal1 (rv);
   virConnectPtr conn = Connect_val (connv);
@@ -2385,37 +1934,21 @@ ocaml_libvirt_storage_vol_lookup_by_key (value connv, value strv)
   virStorageVolPtr r;
 
   NONBLOCKING (r = virStorageVolLookupByKey (conn, str));
-  CHECK_ERROR (!r, conn, "virStorageVolLookupByKey");
+  CHECK_ERROR (!r, "virStorageVolLookupByKey");
 
   rv = Val_volume (r, connv);
 
   CAMLreturn (rv);
-#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));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_storage_vol_lookup_by_path (value connv, value strv)
 {
   CAMLparam2 (connv, strv);
-#ifndef HAVE_VIRSTORAGEVOLLOOKUPBYPATH
-  /* Symbol virStorageVolLookupByPath not found at compile time. */
-  not_supported ("virStorageVolLookupByPath");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virStorageVolLookupByPath
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virStorageVolLookupByPath);
 
   CAMLlocal1 (rv);
   virConnectPtr conn = Connect_val (connv);
@@ -2423,241 +1956,138 @@ ocaml_libvirt_storage_vol_lookup_by_path (value connv, value strv)
   virStorageVolPtr r;
 
   NONBLOCKING (r = virStorageVolLookupByPath (conn, str));
-  CHECK_ERROR (!r, conn, "virStorageVolLookupByPath");
+  CHECK_ERROR (!r, "virStorageVolLookupByPath");
 
   rv = Val_volume (r, connv);
 
   CAMLreturn (rv);
-#endif
 }
 
 /* Automatically generated binding for virStorageVolCreateXML.
  * In generator.pl this function has signature "pool, string, 0U : vol from pool".
  */
 
-#ifdef HAVE_WEAK_SYMBOLS
-#ifdef HAVE_VIRSTORAGEVOLCREATEXML
-extern virStorageVolPtr virStorageVolCreateXML (virStoragePoolPtr pool, const char *str, unsigned  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");
-  CAMLnoreturn;
-#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");
+  CHECK_ERROR (!r, "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, 0U : string".
  */
 
-#ifdef HAVE_WEAK_SYMBOLS
-#ifdef HAVE_VIRSTORAGEVOLGETXMLDESC
-extern char *virStorageVolGetXMLDesc (virStorageVolPtr vol, unsigned  int flags) __attribute__((weak));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_storage_vol_get_xml_desc (value volv)
 {
   CAMLparam1 (volv);
-#ifndef HAVE_VIRSTORAGEVOLGETXMLDESC
-  /* Symbol virStorageVolGetXMLDesc not found at compile time. */
-  not_supported ("virStorageVolGetXMLDesc");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virStorageVolGetXMLDesc
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virStorageVolGetXMLDesc);
 
   CAMLlocal1 (rv);
   virStorageVolPtr vol = Volume_val (volv);
-  virConnectPtr conn = Connect_volv (volv);
   char *r;
 
   NONBLOCKING (r = virStorageVolGetXMLDesc (vol, 0));
-  CHECK_ERROR (!r, conn, "virStorageVolGetXMLDesc");
+  CHECK_ERROR (!r, "virStorageVolGetXMLDesc");
 
   rv = caml_copy_string (r);
   free (r);
   CAMLreturn (rv);
-#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));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_storage_vol_get_path (value volv)
 {
   CAMLparam1 (volv);
-#ifndef HAVE_VIRSTORAGEVOLGETPATH
-  /* Symbol virStorageVolGetPath not found at compile time. */
-  not_supported ("virStorageVolGetPath");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virStorageVolGetPath
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virStorageVolGetPath);
 
   CAMLlocal1 (rv);
   virStorageVolPtr vol = Volume_val (volv);
-  virConnectPtr conn = Connect_volv (volv);
   char *r;
 
   NONBLOCKING (r = virStorageVolGetPath (vol));
-  CHECK_ERROR (!r, conn, "virStorageVolGetPath");
+  CHECK_ERROR (!r, "virStorageVolGetPath");
 
   rv = caml_copy_string (r);
   free (r);
   CAMLreturn (rv);
-#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));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_storage_vol_get_key (value volv)
 {
   CAMLparam1 (volv);
-#ifndef HAVE_VIRSTORAGEVOLGETKEY
-  /* Symbol virStorageVolGetKey not found at compile time. */
-  not_supported ("virStorageVolGetKey");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virStorageVolGetKey
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virStorageVolGetKey);
 
   CAMLlocal1 (rv);
   virStorageVolPtr vol = Volume_val (volv);
-  virConnectPtr conn = Connect_volv (volv);
   const char *r;
 
   NONBLOCKING (r = virStorageVolGetKey (vol));
-  CHECK_ERROR (!r, conn, "virStorageVolGetKey");
+  CHECK_ERROR (!r, "virStorageVolGetKey");
 
   rv = caml_copy_string (r);
   CAMLreturn (rv);
-#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));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_storage_vol_get_name (value volv)
 {
   CAMLparam1 (volv);
-#ifndef HAVE_VIRSTORAGEVOLGETNAME
-  /* Symbol virStorageVolGetName not found at compile time. */
-  not_supported ("virStorageVolGetName");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virStorageVolGetName
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virStorageVolGetName);
 
   CAMLlocal1 (rv);
   virStorageVolPtr vol = Volume_val (volv);
-  virConnectPtr conn = Connect_volv (volv);
   const char *r;
 
   NONBLOCKING (r = virStorageVolGetName (vol));
-  CHECK_ERROR (!r, conn, "virStorageVolGetName");
+  CHECK_ERROR (!r, "virStorageVolGetName");
 
   rv = caml_copy_string (r);
   CAMLreturn (rv);
-#endif
 }
 
 /* Automatically generated binding for virStoragePoolLookupByVolume.
  * In generator.pl this function has signature "vol : pool from vol".
  */
 
-#ifdef HAVE_WEAK_SYMBOLS
-#ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYVOLUME
-extern virStoragePoolPtr virStoragePoolLookupByVolume (virStorageVolPtr vol) __attribute__((weak));
-#endif
-#endif
-
 CAMLprim value
 ocaml_libvirt_storage_pool_lookup_by_volume (value volv)
 {
   CAMLparam1 (volv);
-#ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYVOLUME
-  /* Symbol virStoragePoolLookupByVolume not found at compile time. */
-  not_supported ("virStoragePoolLookupByVolume");
-  CAMLnoreturn;
-#else
-  /* Check that the symbol virStoragePoolLookupByVolume
-   * is in runtime version of libvirt.
-   */
-  WEAK_SYMBOL_CHECK (virStoragePoolLookupByVolume);
 
   CAMLlocal2 (rv, connv);
   virStorageVolPtr vol = Volume_val (volv);
-  virConnectPtr conn = Connect_volv (volv);
   virStoragePoolPtr r;
 
   NONBLOCKING (r = virStoragePoolLookupByVolume (vol));
-  CHECK_ERROR (!r, conn, "virStoragePoolLookupByVolume");
+  CHECK_ERROR (!r, "virStoragePoolLookupByVolume");
 
   connv = Field (volv, 1);
   rv = Val_pool (r, connv);
 
   CAMLreturn (rv);
-#endif
 }
 
 #include "libvirt_c_epilogue.c"