+#ifdef HAVE_VIRSTORAGEVOLLOOKUPBYNAME
+extern virStorageVolPtr virStorageVolLookupByName (virConnectPtr conn dom) __attribute__((weak));
+#endif
+#endif
+
+CAMLprim value
+ocaml_libvirt_storage_vol_lookup_by_name (value connv, value strv)
+{
+ CAMLparam2 (connv, 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);
+
+ CAMLlocal1 (rv);
+ virConnectPtr conn = Connect_val (connv);
+ char *str = String_val (strv);
+ virStorageVolPtr r;
+
+ NONBLOCKING (r = virStorageVolLookupByName (conn, str));
+ CHECK_ERROR (!r, conn, "virStorageVolLookupByName");
+
+ rv = Val_volume (r, connv);
+
+ CAMLreturn (rv);
+#endif
+}
+
+#ifdef HAVE_WEAK_SYMBOLS
+#ifdef HAVE_VIRSTORAGEVOLLOOKUPBYKEY
+extern virStorageVolPtr virStorageVolLookupByKey (virConnectPtr conn dom) __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");
+ /* Suppresses a compiler warning. */
+ (void) caml__frame;
+#else
+ /* Check that the symbol virStorageVolLookupByKey
+ * is in runtime version of libvirt.
+ */
+ WEAK_SYMBOL_CHECK (virStorageVolLookupByKey);
+
+ CAMLlocal1 (rv);
+ virConnectPtr conn = Connect_val (connv);
+ char *str = String_val (strv);
+ virStorageVolPtr r;
+
+ NONBLOCKING (r = virStorageVolLookupByKey (conn, str));
+ CHECK_ERROR (!r, conn, "virStorageVolLookupByKey");
+
+ rv = Val_volume (r, connv);
+
+ CAMLreturn (rv);
+#endif
+}
+
+#ifdef HAVE_WEAK_SYMBOLS
+#ifdef HAVE_VIRSTORAGEVOLLOOKUPBYPATH
+extern virStorageVolPtr virStorageVolLookupByPath (virConnectPtr conn dom) __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");
+ /* Suppresses a compiler warning. */
+ (void) caml__frame;
+#else
+ /* Check that the symbol virStorageVolLookupByPath
+ * is in runtime version of libvirt.
+ */
+ WEAK_SYMBOL_CHECK (virStorageVolLookupByPath);
+
+ CAMLlocal1 (rv);
+ virConnectPtr conn = Connect_val (connv);
+ char *str = String_val (strv);
+ virStorageVolPtr r;
+
+ NONBLOCKING (r = virStorageVolLookupByPath (conn, str));
+ CHECK_ERROR (!r, conn, "virStorageVolLookupByPath");
+
+ rv = Val_volume (r, connv);
+
+ CAMLreturn (rv);
+#endif
+}
+
+#ifdef HAVE_WEAK_SYMBOLS