Remove virConnectListAllDomains.
[ocaml-libvirt.git] / libvirt / libvirt_c_oneoffs.c
index 4d69bd1..29a1c05 100644 (file)
@@ -194,110 +194,19 @@ 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,
-                                     int stateflags)
-  __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, 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_NOSTATE; break;
-    case 1: flags |= VIR_DOMAIN_LIST_RUNNING; break;
-    case 2: flags |= VIR_DOMAIN_LIST_BLOCKED; break;
-    case 3: flags |= VIR_DOMAIN_LIST_PAUSED; break;
-    case 4: flags |= VIR_DOMAIN_LIST_SHUTDOWN; break;
-    case 5: flags |= VIR_DOMAIN_LIST_SHUTOFF; break;
-    case 6: flags |= VIR_DOMAIN_LIST_CRASHED; break;
-    case 7: flags |= VIR_DOMAIN_LIST_ACTIVE; break;
-    case 8: flags |= VIR_DOMAIN_LIST_INACTIVE; break;
-    case 9: flags |= VIR_DOMAIN_LIST_ALL; break;
-    }
-  }
-
-  WEAK_SYMBOL_CHECK (virConnectListAllDomains);
-  NONBLOCKING (r = virConnectListAllDomains (conn, &domains,
-                                             want_info ? &infos : NULL,
-                                             flags));
-  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)
 {
   CAMLparam1 (domv);
   virDomainPtr dom = Domain_val (domv);
-  virConnectPtr conn = Connect_domv (domv);
+  /*virConnectPtr conn = Connect_domv (domv);*/
   unsigned int r;
 
   NONBLOCKING (r = virDomainGetID (dom));
-  /* There's a bug in libvirt which means that if you try to get
-   * the ID of a defined-but-not-running domain, it returns -1,
-   * and there's no way to distinguish that from an error.
+  /* In theory this could return -1 on error, but in practice
+   * libvirt never does this unless you call it with a corrupted
+   * or NULL dom object.  So ignore errors here.
    */
-  CHECK_ERROR (r == (unsigned int) -1, conn, "virDomainGetID");
 
   CAMLreturn (Val_int ((int) r));
 }
@@ -925,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