summaryrefslogtreecommitdiffstats
path: root/libvirt/libvirt_c.c
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2008-01-19 14:51:26 +0000
committerRichard W.M. Jones <rjones@redhat.com>2008-01-19 14:51:26 +0000
commit7a65ae1678144521b42be8856c615cf780a3f85c (patch)
tree858c9371d175f8ee3fa4f4ca77f16143c49b6abd /libvirt/libvirt_c.c
parent3a52f5d4f1becb1fc31eecf4a3a93542f2ff89b8 (diff)
downloadvirt-top-7a65ae1678144521b42be8856c615cf780a3f85c.tar.gz
virt-top-7a65ae1678144521b42be8856c615cf780a3f85c.tar.xz
virt-top-7a65ae1678144521b42be8856c615cf780a3f85c.zip
Autogenerate *Free and *Destroy functions.
Diffstat (limited to 'libvirt/libvirt_c.c')
-rw-r--r--libvirt/libvirt_c.c219
1 files changed, 195 insertions, 24 deletions
diff --git a/libvirt/libvirt_c.c b/libvirt/libvirt_c.c
index 8c31710..a23efbd 100644
--- a/libvirt/libvirt_c.c
+++ b/libvirt/libvirt_c.c
@@ -47,6 +47,23 @@
#include "libvirt_c_oneoffs.c"
+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);
+}
+
#ifdef HAVE_WEAK_SYMBOLS
#ifdef HAVE_VIRCONNECTGETHOSTNAME
extern char *virConnectGetHostname (virConnectPtr conn) __attribute__((weak));
@@ -441,6 +458,42 @@ ocaml_libvirt_connect_get_capabilities (value connv)
}
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);
+}
+
+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);
+}
+
+CAMLprim value
ocaml_libvirt_domain_lookup_by_name (value connv, value strv)
{
CAMLparam2 (connv, strv);
@@ -688,6 +741,42 @@ ocaml_libvirt_domain_set_autostart (value domv, value bv)
}
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);
+}
+
+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);
+}
+
+CAMLprim value
ocaml_libvirt_network_lookup_by_name (value connv, value strv)
{
CAMLparam2 (connv, strv);
@@ -875,6 +964,76 @@ ocaml_libvirt_network_set_autostart (value netv, value bv)
}
#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
+}
+
+#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
+}
+
+#ifdef HAVE_WEAK_SYMBOLS
#ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYNAME
extern virStoragePoolPtr virStoragePoolLookupByName (virConnectPtr conn, const char *str) __attribute__((weak));
#endif
@@ -1277,6 +1436,42 @@ ocaml_libvirt_storage_pool_set_autostart (value poolv, value bv)
#endif
}
+CAMLprim value
+ocaml_libvirt_storage_vol_free (value volv)
+{
+ CAMLparam1 (volv);
+
+ 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);
+}
+
+CAMLprim value
+ocaml_libvirt_storage_vol_destroy (value volv)
+{
+ CAMLparam1 (volv);
+
+ 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);
+}
+
#ifdef HAVE_WEAK_SYMBOLS
#ifdef HAVE_VIRSTORAGEVOLLOOKUPBYKEY
extern virStorageVolPtr virStorageVolLookupByKey (virConnectPtr conn, const char *str) __attribute__((weak));
@@ -1538,18 +1733,6 @@ ocaml_libvirt_storage_pool_get_info ()
}
CAMLprim value
-ocaml_libvirt_storage_pool_free ()
-{
- failwith ("ocaml_libvirt_storage_pool_free is unimplemented");
-}
-
-CAMLprim value
-ocaml_libvirt_storage_pool_destroy ()
-{
- failwith ("ocaml_libvirt_storage_pool_destroy is unimplemented");
-}
-
-CAMLprim value
ocaml_libvirt_storage_pool_define_xml ()
{
failwith ("ocaml_libvirt_storage_pool_define_xml is unimplemented");
@@ -1574,18 +1757,6 @@ ocaml_libvirt_storage_vol_lookup_by_name ()
}
CAMLprim value
-ocaml_libvirt_storage_vol_free ()
-{
- failwith ("ocaml_libvirt_storage_vol_free is unimplemented");
-}
-
-CAMLprim value
-ocaml_libvirt_storage_vol_destroy ()
-{
- failwith ("ocaml_libvirt_storage_vol_destroy is unimplemented");
-}
-
-CAMLprim value
ocaml_libvirt_storage_vol_create_xml ()
{
failwith ("ocaml_libvirt_storage_vol_create_xml is unimplemented");