Further work on storage API and autogenerating bindings.
[virt-top.git] / libvirt / libvirt_c.c
index 0bb9442..0dc21e4 100644 (file)
@@ -1,4 +1,7 @@
-/* WARNING: THIS FILE IS AUTOMATICALLY GENERATED BY 'generator.pl'.
+/* !!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!!
+ *
+ * THIS FILE IS AUTOMATICALLY GENERATED BY 'generator.pl'.
+ *
  * Any changes you make to this file may be overwritten.
  */
 
@@ -617,6 +620,38 @@ ocaml_libvirt_domain_create (value domv)
 }
 
 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);
+}
+
+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;
+
+  NONBLOCKING (r = virDomainSetAutostart (dom, b));
+  CHECK_ERROR (r == -1, conn, "virDomainSetAutostart");
+
+  CAMLreturn (Val_unit);
+}
+
+CAMLprim value
 ocaml_libvirt_network_lookup_by_name (value connv, value strv)
 {
   CAMLparam2 (connv, strv);
@@ -735,9 +770,41 @@ ocaml_libvirt_network_create (value netv)
   CAMLreturn (Val_unit);
 }
 
+CAMLprim value
+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");
+
+  CAMLreturn (b ? Val_true : Val_false);
+}
+
+CAMLprim value
+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");
+
+  CAMLreturn (Val_unit);
+}
+
 #ifdef HAVE_WEAK_SYMBOLS
 #ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYNAME
-extern virStoragePoolPtr virStoragePoolLookupByName (virConnectPtr conn dom) __attribute__((weak));
+extern virStoragePoolPtr virStoragePoolLookupByName (virConnectPtr conn, const char *str) __attribute__((weak));
 #endif
 #endif
 
@@ -772,7 +839,7 @@ ocaml_libvirt_storage_pool_lookup_by_name (value connv, value strv)
 
 #ifdef HAVE_WEAK_SYMBOLS
 #ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYUUIDSTRING
-extern virStoragePoolPtr virStoragePoolLookupByUUIDString (virConnectPtr conn dom) __attribute__((weak));
+extern virStoragePoolPtr virStoragePoolLookupByUUIDString (virConnectPtr conn, const char *str) __attribute__((weak));
 #endif
 #endif
 
@@ -841,7 +908,7 @@ ocaml_libvirt_storage_pool_get_name (value poolv)
 
 #ifdef HAVE_WEAK_SYMBOLS
 #ifdef HAVE_VIRSTORAGEPOOLGETXMLDESC
-extern char *virStoragePoolGetXMLDesc (virStoragePoolPtr pool, int flags) __attribute__((weak));
+extern char *virStoragePoolGetXMLDesc (virStoragePoolPtr pool,  int flags) __attribute__((weak));
 #endif
 #endif
 
@@ -876,7 +943,7 @@ ocaml_libvirt_storage_pool_get_xml_desc (value poolv)
 
 #ifdef HAVE_WEAK_SYMBOLS
 #ifdef HAVE_VIRSTORAGEPOOLUNDEFINE
-extern char *virStoragePoolUndefine (virStoragePoolPtr pool) __attribute__((weak));
+extern int virStoragePoolUndefine (virStoragePoolPtr pool) __attribute__((weak));
 #endif
 #endif
 
@@ -895,23 +962,20 @@ ocaml_libvirt_storage_pool_undefine (value poolv)
    */
   WEAK_SYMBOL_CHECK (virStoragePoolUndefine);
 
-  CAMLlocal1 (rv);
   virStoragePoolPtr pool = Pool_val (poolv);
   virConnectPtr conn = Connect_polv (poolv);
-  char *r;
+  int r;
 
   NONBLOCKING (r = virStoragePoolUndefine (pool));
-  CHECK_ERROR (!r, conn, "virStoragePoolUndefine");
+  CHECK_ERROR (r == -1, conn, "virStoragePoolUndefine");
 
-  rv = caml_copy_string (r);
-  free (r);
-  CAMLreturn (rv);
+  CAMLreturn (Val_unit);
 #endif
 }
 
 #ifdef HAVE_WEAK_SYMBOLS
 #ifdef HAVE_VIRSTORAGEPOOLCREATE
-extern char *virStoragePoolCreate (virStoragePoolPtr pool) __attribute__((weak));
+extern int virStoragePoolCreate (virStoragePoolPtr pool) __attribute__((weak));
 #endif
 #endif
 
@@ -930,23 +994,20 @@ ocaml_libvirt_storage_pool_create (value poolv)
    */
   WEAK_SYMBOL_CHECK (virStoragePoolCreate);
 
-  CAMLlocal1 (rv);
   virStoragePoolPtr pool = Pool_val (poolv);
   virConnectPtr conn = Connect_polv (poolv);
-  char *r;
+  int r;
 
   NONBLOCKING (r = virStoragePoolCreate (pool));
-  CHECK_ERROR (!r, conn, "virStoragePoolCreate");
+  CHECK_ERROR (r == -1, conn, "virStoragePoolCreate");
 
-  rv = caml_copy_string (r);
-  free (r);
-  CAMLreturn (rv);
+  CAMLreturn (Val_unit);
 #endif
 }
 
 #ifdef HAVE_WEAK_SYMBOLS
 #ifdef HAVE_VIRSTORAGEPOOLSHUTDOWN
-extern char *virStoragePoolShutdown (virStoragePoolPtr pool) __attribute__((weak));
+extern int virStoragePoolShutdown (virStoragePoolPtr pool) __attribute__((weak));
 #endif
 #endif
 
@@ -965,23 +1026,20 @@ ocaml_libvirt_storage_pool_shutdown (value poolv)
    */
   WEAK_SYMBOL_CHECK (virStoragePoolShutdown);
 
-  CAMLlocal1 (rv);
   virStoragePoolPtr pool = Pool_val (poolv);
   virConnectPtr conn = Connect_polv (poolv);
-  char *r;
+  int r;
 
   NONBLOCKING (r = virStoragePoolShutdown (pool));
-  CHECK_ERROR (!r, conn, "virStoragePoolShutdown");
+  CHECK_ERROR (r == -1, conn, "virStoragePoolShutdown");
 
-  rv = caml_copy_string (r);
-  free (r);
-  CAMLreturn (rv);
+  CAMLreturn (Val_unit);
 #endif
 }
 
 #ifdef HAVE_WEAK_SYMBOLS
 #ifdef HAVE_VIRSTORAGEPOOLREFRESH
-extern char *virStoragePoolRefresh (virStoragePoolPtr pool, int flags) __attribute__((weak));
+extern int virStoragePoolRefresh (virStoragePoolPtr pool, unsigned  int flags) __attribute__((weak));
 #endif
 #endif
 
@@ -1000,58 +1058,86 @@ ocaml_libvirt_storage_pool_refresh (value poolv)
    */
   WEAK_SYMBOL_CHECK (virStoragePoolRefresh);
 
-  CAMLlocal1 (rv);
   virStoragePoolPtr pool = Pool_val (poolv);
   virConnectPtr conn = Connect_polv (poolv);
-  char *r;
+  int r;
 
   NONBLOCKING (r = virStoragePoolRefresh (pool, 0));
-  CHECK_ERROR (!r, conn, "virStoragePoolRefresh");
+  CHECK_ERROR (r == -1, conn, "virStoragePoolRefresh");
 
-  rv = caml_copy_string (r);
-  free (r);
-  CAMLreturn (rv);
+  CAMLreturn (Val_unit);
 #endif
 }
 
 #ifdef HAVE_WEAK_SYMBOLS
-#ifdef HAVE_VIRSTORAGEVOLLOOKUPBYNAME
-extern virStorageVolPtr virStorageVolLookupByName (virConnectPtr conn dom) __attribute__((weak));
+#ifdef HAVE_VIRSTORAGEPOOLGETAUTOSTART
+extern int virStoragePoolGetAutostart (virStoragePoolPtr pool, int *r) __attribute__((weak));
 #endif
 #endif
 
 CAMLprim value
-ocaml_libvirt_storage_vol_lookup_by_name (value connv, value strv)
+ocaml_libvirt_storage_pool_get_autostart (value poolv)
 {
-  CAMLparam2 (connv, strv);
-#ifndef HAVE_VIRSTORAGEVOLLOOKUPBYNAME
-  /* Symbol virStorageVolLookupByName not found at compile time. */
-  not_supported ("virStorageVolLookupByName");
+  CAMLparam1 (poolv);
+#ifndef HAVE_VIRSTORAGEPOOLGETAUTOSTART
+  /* Symbol virStoragePoolGetAutostart not found at compile time. */
+  not_supported ("virStoragePoolGetAutostart");
   /* Suppresses a compiler warning. */
   (void) caml__frame;
 #else
-  /* Check that the symbol virStorageVolLookupByName
+  /* Check that the symbol virStoragePoolGetAutostart
    * is in runtime version of libvirt.
    */
-  WEAK_SYMBOL_CHECK (virStorageVolLookupByName);
+  WEAK_SYMBOL_CHECK (virStoragePoolGetAutostart);
 
-  CAMLlocal1 (rv);
-  virConnectPtr conn = Connect_val (connv);
-  char *str = String_val (strv);
-  virStorageVolPtr r;
+  virStoragePoolPtr pool = Pool_val (poolv);
+  virConnectPtr conn = Connect_polv (poolv);
+  int r, b;
 
-  NONBLOCKING (r = virStorageVolLookupByName (conn, str));
-  CHECK_ERROR (!r, conn, "virStorageVolLookupByName");
+  NONBLOCKING (r = virStoragePoolGetAutostart (pool, &b));
+  CHECK_ERROR (r == -1, conn, "virStoragePoolGetAutostart");
 
-  rv = Val_volume (r, connv);
+  CAMLreturn (b ? Val_true : Val_false);
+#endif
+}
 
-  CAMLreturn (rv);
+#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");
+  /* Suppresses a compiler warning. */
+  (void) caml__frame;
+#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");
+
+  CAMLreturn (Val_unit);
 #endif
 }
 
 #ifdef HAVE_WEAK_SYMBOLS
 #ifdef HAVE_VIRSTORAGEVOLLOOKUPBYKEY
-extern virStorageVolPtr virStorageVolLookupByKey (virConnectPtr conn dom) __attribute__((weak));
+extern virStorageVolPtr virStorageVolLookupByKey (virConnectPtr conn, const char *str) __attribute__((weak));
 #endif
 #endif
 
@@ -1086,7 +1172,7 @@ ocaml_libvirt_storage_vol_lookup_by_key (value connv, value strv)
 
 #ifdef HAVE_WEAK_SYMBOLS
 #ifdef HAVE_VIRSTORAGEVOLLOOKUPBYPATH
-extern virStorageVolPtr virStorageVolLookupByPath (virConnectPtr conn dom) __attribute__((weak));
+extern virStorageVolPtr virStorageVolLookupByPath (virConnectPtr conn, const char *str) __attribute__((weak));
 #endif
 #endif
 
@@ -1121,14 +1207,14 @@ ocaml_libvirt_storage_vol_lookup_by_path (value connv, value strv)
 
 #ifdef HAVE_WEAK_SYMBOLS
 #ifdef HAVE_VIRSTORAGEVOLGETXMLDESC
-extern char *virStorageVolGetXMLDesc (virStoragePoolPtr pool, int flags) __attribute__((weak));
+extern char *virStorageVolGetXMLDesc (virStorageVolPtr vol,  int flags) __attribute__((weak));
 #endif
 #endif
 
 CAMLprim value
-ocaml_libvirt_storage_vol_get_xml_desc (value poolv)
+ocaml_libvirt_storage_vol_get_xml_desc (value volv)
 {
-  CAMLparam1 (poolv);
+  CAMLparam1 (volv);
 #ifndef HAVE_VIRSTORAGEVOLGETXMLDESC
   /* Symbol virStorageVolGetXMLDesc not found at compile time. */
   not_supported ("virStorageVolGetXMLDesc");
@@ -1141,11 +1227,11 @@ ocaml_libvirt_storage_vol_get_xml_desc (value poolv)
   WEAK_SYMBOL_CHECK (virStorageVolGetXMLDesc);
 
   CAMLlocal1 (rv);
-  virStoragePoolPtr pool = Pool_val (poolv);
-  virConnectPtr conn = Connect_polv (poolv);
+  virStorageVolPtr vol = Volume_val (volv);
+  virConnectPtr conn = Connect_volv (volv);
   char *r;
 
-  NONBLOCKING (r = virStorageVolGetXMLDesc (pool, 0));
+  NONBLOCKING (r = virStorageVolGetXMLDesc (vol, 0));
   CHECK_ERROR (!r, conn, "virStorageVolGetXMLDesc");
 
   rv = caml_copy_string (r);
@@ -1156,14 +1242,14 @@ ocaml_libvirt_storage_vol_get_xml_desc (value poolv)
 
 #ifdef HAVE_WEAK_SYMBOLS
 #ifdef HAVE_VIRSTORAGEVOLGETPATH
-extern char *virStorageVolGetPath (virStoragePoolPtr pool) __attribute__((weak));
+extern char *virStorageVolGetPath (virStorageVolPtr vol) __attribute__((weak));
 #endif
 #endif
 
 CAMLprim value
-ocaml_libvirt_storage_vol_get_path (value poolv)
+ocaml_libvirt_storage_vol_get_path (value volv)
 {
-  CAMLparam1 (poolv);
+  CAMLparam1 (volv);
 #ifndef HAVE_VIRSTORAGEVOLGETPATH
   /* Symbol virStorageVolGetPath not found at compile time. */
   not_supported ("virStorageVolGetPath");
@@ -1176,11 +1262,11 @@ ocaml_libvirt_storage_vol_get_path (value poolv)
   WEAK_SYMBOL_CHECK (virStorageVolGetPath);
 
   CAMLlocal1 (rv);
-  virStoragePoolPtr pool = Pool_val (poolv);
-  virConnectPtr conn = Connect_polv (poolv);
+  virStorageVolPtr vol = Volume_val (volv);
+  virConnectPtr conn = Connect_volv (volv);
   char *r;
 
-  NONBLOCKING (r = virStorageVolGetPath (pool));
+  NONBLOCKING (r = virStorageVolGetPath (vol));
   CHECK_ERROR (!r, conn, "virStorageVolGetPath");
 
   rv = caml_copy_string (r);
@@ -1191,14 +1277,14 @@ ocaml_libvirt_storage_vol_get_path (value poolv)
 
 #ifdef HAVE_WEAK_SYMBOLS
 #ifdef HAVE_VIRSTORAGEVOLGETKEY
-extern const char *virStorageVolGetKey (virStoragePoolPtr pool) __attribute__((weak));
+extern const char *virStorageVolGetKey (virStorageVolPtr vol) __attribute__((weak));
 #endif
 #endif
 
 CAMLprim value
-ocaml_libvirt_storage_vol_get_key (value poolv)
+ocaml_libvirt_storage_vol_get_key (value volv)
 {
-  CAMLparam1 (poolv);
+  CAMLparam1 (volv);
 #ifndef HAVE_VIRSTORAGEVOLGETKEY
   /* Symbol virStorageVolGetKey not found at compile time. */
   not_supported ("virStorageVolGetKey");
@@ -1211,11 +1297,11 @@ ocaml_libvirt_storage_vol_get_key (value poolv)
   WEAK_SYMBOL_CHECK (virStorageVolGetKey);
 
   CAMLlocal1 (rv);
-  virStoragePoolPtr pool = Pool_val (poolv);
-  virConnectPtr conn = Connect_polv (poolv);
+  virStorageVolPtr vol = Volume_val (volv);
+  virConnectPtr conn = Connect_volv (volv);
   const char *r;
 
-  NONBLOCKING (r = virStorageVolGetKey (pool));
+  NONBLOCKING (r = virStorageVolGetKey (vol));
   CHECK_ERROR (!r, conn, "virStorageVolGetKey");
 
   rv = caml_copy_string (r);
@@ -1225,14 +1311,14 @@ ocaml_libvirt_storage_vol_get_key (value poolv)
 
 #ifdef HAVE_WEAK_SYMBOLS
 #ifdef HAVE_VIRSTORAGEVOLGETNAME
-extern const char *virStorageVolGetName (virStoragePoolPtr pool) __attribute__((weak));
+extern const char *virStorageVolGetName (virStorageVolPtr vol) __attribute__((weak));
 #endif
 #endif
 
 CAMLprim value
-ocaml_libvirt_storage_vol_get_name (value poolv)
+ocaml_libvirt_storage_vol_get_name (value volv)
 {
-  CAMLparam1 (poolv);
+  CAMLparam1 (volv);
 #ifndef HAVE_VIRSTORAGEVOLGETNAME
   /* Symbol virStorageVolGetName not found at compile time. */
   not_supported ("virStorageVolGetName");
@@ -1245,11 +1331,11 @@ ocaml_libvirt_storage_vol_get_name (value poolv)
   WEAK_SYMBOL_CHECK (virStorageVolGetName);
 
   CAMLlocal1 (rv);
-  virStoragePoolPtr pool = Pool_val (poolv);
-  virConnectPtr conn = Connect_polv (poolv);
+  virStorageVolPtr vol = Volume_val (volv);
+  virConnectPtr conn = Connect_volv (volv);
   const char *r;
 
-  NONBLOCKING (r = virStorageVolGetName (pool));
+  NONBLOCKING (r = virStorageVolGetName (vol));
   CHECK_ERROR (!r, conn, "virStorageVolGetName");
 
   rv = caml_copy_string (r);
@@ -1300,18 +1386,6 @@ ocaml_libvirt_network_create_xml_job ()
 }
 
 CAMLprim value
-ocaml_libvirt_storage_pool_set_autostart ()
-{
-  failwith ("ocaml_libvirt_storage_pool_set_autostart is unimplemented");
-}
-
-CAMLprim value
-ocaml_libvirt_storage_pool_get_autostart ()
-{
-  failwith ("ocaml_libvirt_storage_pool_get_autostart is unimplemented");
-}
-
-CAMLprim value
 ocaml_libvirt_storage_pool_get_info ()
 {
   failwith ("ocaml_libvirt_storage_pool_get_info is unimplemented");
@@ -1360,6 +1434,12 @@ ocaml_libvirt_storage_pool_lookup_by_uuid ()
 }
 
 CAMLprim value
+ocaml_libvirt_storage_vol_lookup_by_name ()
+{
+  failwith ("ocaml_libvirt_storage_vol_lookup_by_name is unimplemented");
+}
+
+CAMLprim value
 ocaml_libvirt_storage_vol_free ()
 {
   failwith ("ocaml_libvirt_storage_vol_free is unimplemented");