X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=libvirt%2Flibvirt_c.c;h=e8d071dc811fc87b1beb021d38729a683fb011c5;hb=fdf0429a9b933e666b95713db0ccf3c26b62a4a7;hp=ca7f30350598931eea001907d63942aba3670245;hpb=e4e4312d992f04d1dfe901dd8e95f62e528a574a;p=ocaml-libvirt.git diff --git a/libvirt/libvirt_c.c b/libvirt/libvirt_c.c index ca7f303..e8d071d 100644 --- a/libvirt/libvirt_c.c +++ b/libvirt/libvirt_c.c @@ -194,6 +194,16 @@ ocaml_libvirt_connect_list_domains (value connv, value iv) int i = Int_val (iv); int ids[i], r; + /* Some libvirt List* functions still throw exceptions if i == 0, + * so catch that and return an empty array directly. This changes + * the semantics slightly (masking other failures) but it's + * unlikely anyone will care. RWMJ 2008/06/10 + */ + if (i == 0) { + rv = caml_alloc (0, 0); + CAMLreturn (rv); + } + NONBLOCKING (r = virConnectListDomains (conn, ids, i)); CHECK_ERROR (r == -1, conn, "virConnectListDomains"); @@ -237,6 +247,16 @@ ocaml_libvirt_connect_list_defined_domains (value connv, value iv) char *names[i]; int r; + /* Some libvirt List* functions still throw exceptions if i == 0, + * so catch that and return an empty array directly. This changes + * the semantics slightly (masking other failures) but it's + * unlikely anyone will care. RWMJ 2008/06/10 + */ + if (i == 0) { + rv = caml_alloc (0, 0); + CAMLreturn (rv); + } + NONBLOCKING (r = virConnectListDefinedDomains (conn, names, i)); CHECK_ERROR (r == -1, conn, "virConnectListDefinedDomains"); @@ -283,6 +303,16 @@ ocaml_libvirt_connect_list_networks (value connv, value iv) char *names[i]; int r; + /* Some libvirt List* functions still throw exceptions if i == 0, + * so catch that and return an empty array directly. This changes + * the semantics slightly (masking other failures) but it's + * unlikely anyone will care. RWMJ 2008/06/10 + */ + if (i == 0) { + rv = caml_alloc (0, 0); + CAMLreturn (rv); + } + NONBLOCKING (r = virConnectListNetworks (conn, names, i)); CHECK_ERROR (r == -1, conn, "virConnectListNetworks"); @@ -329,6 +359,16 @@ ocaml_libvirt_connect_list_defined_networks (value connv, value iv) char *names[i]; int r; + /* Some libvirt List* functions still throw exceptions if i == 0, + * so catch that and return an empty array directly. This changes + * the semantics slightly (masking other failures) but it's + * unlikely anyone will care. RWMJ 2008/06/10 + */ + if (i == 0) { + rv = caml_alloc (0, 0); + CAMLreturn (rv); + } + NONBLOCKING (r = virConnectListDefinedNetworks (conn, names, i)); CHECK_ERROR (r == -1, conn, "virConnectListDefinedNetworks"); @@ -406,6 +446,16 @@ ocaml_libvirt_connect_list_storage_pools (value connv, value iv) char *names[i]; int r; + /* Some libvirt List* functions still throw exceptions if i == 0, + * so catch that and return an empty array directly. This changes + * the semantics slightly (masking other failures) but it's + * unlikely anyone will care. RWMJ 2008/06/10 + */ + if (i == 0) { + rv = caml_alloc (0, 0); + CAMLreturn (rv); + } + NONBLOCKING (r = virConnectListStoragePools (conn, names, i)); CHECK_ERROR (r == -1, conn, "virConnectListStoragePools"); @@ -484,6 +534,16 @@ ocaml_libvirt_connect_list_defined_storage_pools (value connv, value iv) char *names[i]; int r; + /* Some libvirt List* functions still throw exceptions if i == 0, + * so catch that and return an empty array directly. This changes + * the semantics slightly (masking other failures) but it's + * unlikely anyone will care. RWMJ 2008/06/10 + */ + if (i == 0) { + rv = caml_alloc (0, 0); + CAMLreturn (rv); + } + NONBLOCKING (r = virConnectListDefinedStoragePools (conn, names, i)); CHECK_ERROR (r == -1, conn, "virConnectListDefinedStoragePools"); @@ -2428,6 +2488,16 @@ ocaml_libvirt_storage_pool_list_volumes (value poolv, value iv) char *names[i]; int r; + /* Some libvirt List* functions still throw exceptions if i == 0, + * so catch that and return an empty array directly. This changes + * the semantics slightly (masking other failures) but it's + * unlikely anyone will care. RWMJ 2008/06/10 + */ + if (i == 0) { + rv = caml_alloc (0, 0); + CAMLreturn (rv); + } + NONBLOCKING (r = virStoragePoolListVolumes (pool, names, i)); CHECK_ERROR (r == -1, conn, "virStoragePoolListVolumes");