summaryrefslogtreecommitdiffstats
path: root/libvirt/libvirt_c_oneoffs.c
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2008-01-19 17:26:09 +0000
committerRichard W.M. Jones <rjones@redhat.com>2008-01-19 17:26:09 +0000
commitcf1b8052e9bca746a90dc4380bf4d6b09399adf2 (patch)
tree65de92db02964df3bfde719336335d3647dad879 /libvirt/libvirt_c_oneoffs.c
parent4bcef5db5222f7a2596aaa1d8664fbcfd7185076 (diff)
downloadvirt-top-cf1b8052e9bca746a90dc4380bf4d6b09399adf2.tar.gz
virt-top-cf1b8052e9bca746a90dc4380bf4d6b09399adf2.tar.xz
virt-top-cf1b8052e9bca746a90dc4380bf4d6b09399adf2.zip
Complete implementation of storage API.
Diffstat (limited to 'libvirt/libvirt_c_oneoffs.c')
-rw-r--r--libvirt/libvirt_c_oneoffs.c222
1 files changed, 172 insertions, 50 deletions
diff --git a/libvirt/libvirt_c_oneoffs.c b/libvirt/libvirt_c_oneoffs.c
index b1331e0..a3a7e34 100644
--- a/libvirt/libvirt_c_oneoffs.c
+++ b/libvirt/libvirt_c_oneoffs.c
@@ -19,56 +19,6 @@
/* Please read libvirt/README file. */
-#ifdef HAVE_WEAK_SYMBOLS
-#ifdef HAVE_VIRDOMAINBLOCKSTATS
-extern int virDomainBlockStats (virDomainPtr dom,
- const char *path,
- virDomainBlockStatsPtr stats,
- size_t size)
- __attribute__((weak));
-#endif
-#ifdef HAVE_VIRDOMAINGETSCHEDULERPARAMETERS
-extern int virDomainGetSchedulerParameters (virDomainPtr domain,
- virSchedParameterPtr params,
- int *nparams)
- __attribute__((weak));
-#endif
-#ifdef HAVE_VIRDOMAINGETSCHEDULERTYPE
-extern char *virDomainGetSchedulerType(virDomainPtr domain,
- int *nparams)
- __attribute__((weak));
-#endif
-#ifdef HAVE_VIRDOMAININTERFACESTATS
-extern int virDomainInterfaceStats (virDomainPtr dom,
- const char *path,
- virDomainInterfaceStatsPtr stats,
- size_t size)
- __attribute__((weak));
-#endif
-#ifdef HAVE_VIRDOMAINMIGRATE
-extern virDomainPtr virDomainMigrate (virDomainPtr domain, virConnectPtr dconn,
- unsigned long flags, const char *dname,
- const char *uri, unsigned long bandwidth)
- __attribute__((weak));
-#endif
-#ifdef HAVE_VIRDOMAINSETSCHEDULERPARAMETERS
-extern int virDomainSetSchedulerParameters (virDomainPtr domain,
- virSchedParameterPtr params,
- int nparams)
- __attribute__((weak));
-#endif
-#ifdef HAVE_VIRNODEGETFREEMEMORY
-extern unsigned long long virNodeGetFreeMemory (virConnectPtr conn)
- __attribute__((weak));
-#endif
-#ifdef HAVE_VIRNODEGETCELLSFREEMEMORY
-extern int virNodeGetCellsFreeMemory (virConnectPtr conn,
- unsigned long long *freeMems,
- int startCell, int maxCells)
- __attribute__((weak));
-#endif
-#endif /* HAVE_WEAK_SYMBOLS */
-
/*----------------------------------------------------------------------*/
CAMLprim value
@@ -179,6 +129,13 @@ ocaml_libvirt_connect_get_node_info (value connv)
CAMLreturn (rv);
}
+#ifdef HAVE_WEAK_SYMBOLS
+#ifdef HAVE_VIRNODEGETFREEMEMORY
+extern unsigned long long virNodeGetFreeMemory (virConnectPtr conn)
+ __attribute__((weak));
+#endif
+#endif
+
CAMLprim value
ocaml_libvirt_connect_node_get_free_memory (value connv)
{
@@ -199,6 +156,15 @@ ocaml_libvirt_connect_node_get_free_memory (value connv)
#endif
}
+#ifdef HAVE_WEAK_SYMBOLS
+#ifdef HAVE_VIRNODEGETCELLSFREEMEMORY
+extern int virNodeGetCellsFreeMemory (virConnectPtr conn,
+ unsigned long long *freeMems,
+ int startCell, int maxCells)
+ __attribute__((weak));
+#endif
+#endif
+
CAMLprim value
ocaml_libvirt_connect_node_get_cells_free_memory (value connv,
value startv, value maxv)
@@ -315,6 +281,14 @@ ocaml_libvirt_domain_get_info (value domv)
CAMLreturn (rv);
}
+#ifdef HAVE_WEAK_SYMBOLS
+#ifdef HAVE_VIRDOMAINGETSCHEDULERTYPE
+extern char *virDomainGetSchedulerType(virDomainPtr domain,
+ int *nparams)
+ __attribute__((weak));
+#endif
+#endif
+
CAMLprim value
ocaml_libvirt_domain_get_scheduler_type (value domv)
{
@@ -340,6 +314,15 @@ ocaml_libvirt_domain_get_scheduler_type (value domv)
#endif
}
+#ifdef HAVE_WEAK_SYMBOLS
+#ifdef HAVE_VIRDOMAINGETSCHEDULERPARAMETERS
+extern int virDomainGetSchedulerParameters (virDomainPtr domain,
+ virSchedParameterPtr params,
+ int *nparams)
+ __attribute__((weak));
+#endif
+#endif
+
CAMLprim value
ocaml_libvirt_domain_get_scheduler_parameters (value domv, value nparamsv)
{
@@ -396,6 +379,15 @@ ocaml_libvirt_domain_get_scheduler_parameters (value domv, value nparamsv)
#endif
}
+#ifdef HAVE_WEAK_SYMBOLS
+#ifdef HAVE_VIRDOMAINSETSCHEDULERPARAMETERS
+extern int virDomainSetSchedulerParameters (virDomainPtr domain,
+ virSchedParameterPtr params,
+ int nparams)
+ __attribute__((weak));
+#endif
+#endif
+
CAMLprim value
ocaml_libvirt_domain_set_scheduler_parameters (value domv, value paramsv)
{
@@ -528,6 +520,15 @@ ocaml_libvirt_domain_get_vcpus (value domv, value maxinfov, value maplenv)
CAMLreturn (rv);
}
+#ifdef HAVE_WEAK_SYMBOLS
+#ifdef HAVE_VIRDOMAINMIGRATE
+extern virDomainPtr virDomainMigrate (virDomainPtr domain, virConnectPtr dconn,
+ unsigned long flags, const char *dname,
+ const char *uri, unsigned long bandwidth)
+ __attribute__((weak));
+#endif
+#endif
+
CAMLprim value
ocaml_libvirt_domain_migrate_native (value domv, value dconnv, value flagsv, value optdnamev, value opturiv, value optbandwidthv, value unitv)
{
@@ -578,6 +579,16 @@ ocaml_libvirt_domain_migrate_bytecode (value *argv, int argn)
argv[6]);
}
+#ifdef HAVE_WEAK_SYMBOLS
+#ifdef HAVE_VIRDOMAINBLOCKSTATS
+extern int virDomainBlockStats (virDomainPtr dom,
+ const char *path,
+ virDomainBlockStatsPtr stats,
+ size_t size)
+ __attribute__((weak));
+#endif
+#endif
+
CAMLprim value
ocaml_libvirt_domain_block_stats (value domv, value pathv)
{
@@ -607,6 +618,16 @@ ocaml_libvirt_domain_block_stats (value domv, value pathv)
#endif
}
+#ifdef HAVE_WEAK_SYMBOLS
+#ifdef HAVE_VIRDOMAININTERFACESTATS
+extern int virDomainInterfaceStats (virDomainPtr dom,
+ const char *path,
+ virDomainInterfaceStatsPtr stats,
+ size_t size)
+ __attribute__((weak));
+#endif
+#endif
+
CAMLprim value
ocaml_libvirt_domain_interface_stats (value domv, value pathv)
{
@@ -639,6 +660,107 @@ ocaml_libvirt_domain_interface_stats (value domv, value pathv)
#endif
}
+#ifdef HAVE_WEAK_SYMBOLS
+#ifdef HAVE_VIRSTORAGEPOOLGETINFO
+extern int virStoragePoolGetInfo(virStoragePoolPtr pool, virStoragePoolInfoPtr info)
+ __attribute__((weak));
+#endif
+#endif
+
+CAMLprim value
+ocaml_libvirt_storage_pool_get_info (value poolv)
+{
+#if HAVE_VIRSTORAGEPOOLGETINFO
+ CAMLparam1 (poolv);
+ CAMLlocal2 (rv, v);
+ virStoragePoolPtr pool = Pool_val (poolv);
+ virConnectPtr conn = Connect_polv (poolv);
+ virStoragePoolInfo info;
+ int r;
+
+ WEAK_SYMBOL_CHECK (virStoragePoolGetInfo);
+ NONBLOCKING (r = virStoragePoolGetInfo (pool, &info));
+ CHECK_ERROR (r == -1, conn, "virStoragePoolGetInfo");
+
+ rv = caml_alloc (3, 0);
+ Store_field (rv, 0, Val_int (info.state));
+ v = caml_copy_int64 (info.capacity); Store_field (rv, 1, v);
+ v = caml_copy_int64 (info.allocation); Store_field (rv, 1, v);
+
+ CAMLreturn (rv);
+#else
+ not_supported ("virStoragePoolGetInfo");
+#endif
+}
+
+#ifdef HAVE_WEAK_SYMBOLS
+#ifdef HAVE_VIRSTORAGEVOLGETINFO
+extern int virStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info)
+ __attribute__((weak));
+#endif
+#endif
+
+CAMLprim value
+ocaml_libvirt_storage_vol_get_info (value volv)
+{
+#if HAVE_VIRSTORAGEVOLGETINFO
+ CAMLparam1 (volv);
+ CAMLlocal2 (rv, v);
+ virStorageVolPtr vol = Volume_val (volv);
+ virConnectPtr conn = Connect_volv (volv);
+ virStorageVolInfo info;
+ int r;
+
+ WEAK_SYMBOL_CHECK (virStorageVolGetInfo);
+ NONBLOCKING (r = virStorageVolGetInfo (vol, &info));
+ CHECK_ERROR (r == -1, conn, "virStorageVolGetInfo");
+
+ rv = caml_alloc (3, 0);
+ Store_field (rv, 0, Val_int (info.type));
+ v = caml_copy_int64 (info.capacity); Store_field (rv, 1, v);
+ v = caml_copy_int64 (info.allocation); Store_field (rv, 1, v);
+
+ CAMLreturn (rv);
+#else
+ not_supported ("virStorageVolGetInfo");
+#endif
+}
+
+#ifdef HAVE_WEAK_SYMBOLS
+#ifdef HAVE_VIRJOBGETINFO
+extern int virJobGetInfo(virJobPtr job, virJobInfoPtr info)
+ __attribute__((weak));
+#endif
+#endif
+
+CAMLprim value
+ocaml_libvirt_job_get_info (value jobv)
+{
+#if HAVE_VIRJOBGETINFO
+ CAMLparam1 (jobv);
+ CAMLlocal1 (rv);
+ virJobPtr job = Job_val (jobv);
+ virConnectPtr conn = Connect_jobv (jobv);
+ virJobInfo info;
+ int r;
+
+ WEAK_SYMBOL_CHECK (virJobGetInfo);
+ NONBLOCKING (r = virJobGetInfo (job, &info));
+ CHECK_ERROR (r == -1, conn, "virJobGetInfo");
+
+ rv = caml_alloc (5, 0);
+ Store_field (rv, 0, Val_int (info.type));
+ Store_field (rv, 1, Val_int (info.state));
+ Store_field (rv, 2, Val_int (info.runningTime));
+ Store_field (rv, 3, Val_int (info.remainingTime));
+ Store_field (rv, 4, Val_int (info.percentComplete));
+
+ CAMLreturn (rv);
+#else
+ not_supported ("virJobGetInfo");
+#endif
+}
+
/*----------------------------------------------------------------------*/
CAMLprim value