X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=libvirt%2Flibvirt_c_oneoffs.c;h=29a1c05f6781082a5dc97f93f0151a71d90e1399;hb=4c713977ca6e6b2daf1b860f42d40e2ef1ef98b2;hp=d87dd21a0aecbb41fd9ca51a93d142350ad1a5fe;hpb=1472f34ab7abc8204e9ea8a2078a84d84f48b1f1;p=ocaml-libvirt.git diff --git a/libvirt/libvirt_c_oneoffs.c b/libvirt/libvirt_c_oneoffs.c index d87dd21..29a1c05 100644 --- a/libvirt/libvirt_c_oneoffs.c +++ b/libvirt/libvirt_c_oneoffs.c @@ -194,91 +194,6 @@ ocaml_libvirt_connect_node_get_cells_free_memory (value connv, #endif } -#ifdef HAVE_WEAK_SYMBOLS -#ifdef HAVE_VIRCONNECTLISTALLDOMAINS -extern int virConnectListAllDomains (virConnectPtr conn, - virDomainPtr **domains, - virDomainInfo **infos, - unsigned long stateflags, - unsigned long flags) - __attribute__((weak)); -#endif -#endif - -CAMLprim value -ocaml_libvirt_connect_list_all_domains (value connv, - value wantinfov, - value flagsv) -{ -#ifdef HAVE_VIRCONNECTLISTALLDOMAINS - CAMLparam3 (connv, wantinfov, flagsv); - CAMLlocal4 (flagv, rv, rv1, rv2); - CAMLlocal2 (v1, v2); - virConnectPtr conn = Connect_val (connv); - virDomainPtr *domains; - virDomainInfo *infos; - int want_info, i, r, flag; - unsigned long flags = 0; - - /* ?want_info */ - if (wantinfov == Val_int (0)) /* None == true */ - want_info = 1; - else - want_info = Bool_val (Field (wantinfov, 0)); - - /* Iterate over the list of flags. */ - for (; flagsv != Val_int (0); flagsv = Field (flagsv, 1)) { - flagv = Field (flagsv, 0); - flag = Int_val (flagv); - switch (flag) { - case 0: flags |= VIR_DOMAIN_LIST_ACTIVE; break; - case 1: flags |= VIR_DOMAIN_LIST_INACTIVE; break; - case 2: flags |= VIR_DOMAIN_LIST_ALL; break; - } - } - - WEAK_SYMBOL_CHECK (virConnectListAllDomains); - NONBLOCKING (r = virConnectListAllDomains (conn, &domains, - want_info ? &infos : NULL, - flags, 0)); - CHECK_ERROR (r == -1, conn, "virConnectListAllDomains"); - - /* Convert the result into a pair of arrays. */ - rv1 = caml_alloc (r, 0); - for (i = 0; i < r; ++i) { - v1 = Val_domain (domains[i], connv); - Store_field (rv1, i, v1); - } - free (domains); - - if (want_info) { - rv2 = caml_alloc (r, 0); - - for (i = 0; i < r; ++i) { - v1 = caml_alloc (5, 0); - Store_field (v1, 0, Val_int (infos[i].state)); - v2 = caml_copy_int64 (infos[i].maxMem); Store_field (v1, 1, v2); - v2 = caml_copy_int64 (infos[i].memory); Store_field (v1, 2, v2); - Store_field (v1, 3, Val_int (infos[i].nrVirtCpu)); - v2 = caml_copy_int64 (infos[i].cpuTime); Store_field (v1, 4, v2); - - Store_field (rv2, i, v1); - } - - free (infos); - } - else - rv2 = caml_alloc (0, 0); /* zero-length array */ - - rv = caml_alloc_tuple (2); - Store_field (rv, 0, rv1); - Store_field (rv, 1, rv2); - CAMLreturn (rv); -#else - not_supported ("virConnectListAllDomains"); -#endif -} - CAMLprim value ocaml_libvirt_domain_get_id (value domv) { @@ -919,41 +834,6 @@ ocaml_libvirt_storage_vol_get_info (value volv) #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