X-Git-Url: http://git.annexia.org/?p=virt-top.git;a=blobdiff_plain;f=libvirt%2Flibvirt_c.c;h=0200b1c8e9723658a4f4c726226347f016bef45d;hp=0fdcbacdf0ee4a8fd8748a180c9471781624a670;hb=e7c94d95feb1fb3d7249c2ead935fe2e56ec31a4;hpb=9bb5f67c0d8a6e8dad7de72e2488ee73c90f7d43 diff --git a/libvirt/libvirt_c.c b/libvirt/libvirt_c.c index 0fdcbac..0200b1c 100644 --- a/libvirt/libvirt_c.c +++ b/libvirt/libvirt_c.c @@ -1,5 +1,12 @@ +/* !!! 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. + */ + /* OCaml bindings for libvirt. - * (C) Copyright 2007 Richard W.M. Jones, Red Hat Inc. + * (C) Copyright 2007-2008 Richard W.M. Jones, Red Hat Inc. * http://libvirt.org/ * * This library is free software; you can redistribute it and/or @@ -34,230 +41,25 @@ #include #include #include +#include -static char *Optstring_val (value strv); -typedef value (*Val_ptr_t) (void *); -static value Val_opt (void *ptr, Val_ptr_t Val_ptr); -/*static value option_default (value option, value deflt);*/ -static value _raise_virterror (virConnectPtr conn, const char *fn); -static value Val_virterror (virErrorPtr err); - -#define CHECK_ERROR(cond, conn, fn) \ - do { if (cond) _raise_virterror (conn, fn); } while (0) - -#define NOT_SUPPORTED(fn) \ - caml_invalid_argument (fn " not supported") - -/* For more about weak symbols, see: - * http://kolpackov.net/pipermail/notes/2004-March/000006.html - * We are using this to do runtime detection of library functions - * so that if we dynamically link with an older version of - * libvirt than we were compiled against, it won't fail (provided - * libvirt >= 0.2.1 - we don't support anything older). - */ -#ifdef __GNUC__ -#ifdef linux -#if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (__GNUC__ > 3) -#define HAVE_WEAK_SYMBOLS 1 -#endif -#endif -#endif - -#ifdef HAVE_WEAK_SYMBOLS -#define WEAK_SYMBOL_CHECK(sym) \ - do { if (!sym) NOT_SUPPORTED(#sym); } while (0) -#else -#define WEAK_SYMBOL_CHECK(sym) -#endif /* HAVE_WEAK_SYMBOLS */ - -#ifdef HAVE_WEAK_SYMBOLS -#ifdef HAVE_VIRCONNECTGETHOSTNAME -extern char *virConnectGetHostname (virConnectPtr conn) - __attribute__((weak)); -#endif -#ifdef HAVE_VIRCONNECTGETURI -extern char *virConnectGetURI (virConnectPtr conn) - __attribute__((weak)); -#endif -#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 -#endif /* HAVE_WEAK_SYMBOLS */ - -/*----------------------------------------------------------------------*/ - -CAMLprim value -ocaml_libvirt_get_version (value driverv, value unit) -{ - CAMLparam2 (driverv, unit); - CAMLlocal1 (rv); - const char *driver = Optstring_val (driverv); - unsigned long libVer, typeVer = 0, *typeVer_ptr; - int r; - - typeVer_ptr = driver ? &typeVer : NULL; - r = virGetVersion (&libVer, driver, typeVer_ptr); - CHECK_ERROR (r == -1, NULL, "virGetVersion"); - - rv = caml_alloc_tuple (2); - Store_field (rv, 0, Val_int (libVer)); - Store_field (rv, 1, Val_int (typeVer)); - CAMLreturn (rv); -} - -/*----------------------------------------------------------------------*/ - -/* Some notes about the use of custom blocks to store virConnectPtr, - * virDomainPtr and virNetworkPtr. - *------------------------------------------------------------------ - * - * Libvirt does some tricky reference counting to keep track of - * virConnectPtr's, virDomainPtr's and virNetworkPtr's. - * - * There is only one function which can return a virConnectPtr - * (virConnectOpen*) and that allocates a new one each time. - * - * virDomainPtr/virNetworkPtr's on the other hand can be returned - * repeatedly (for the same underlying domain/network), and we must - * keep track of each one and explicitly free it with virDomainFree - * or virNetworkFree. If we lose track of one then the reference - * counting in libvirt will keep it open. We therefore wrap these - * in a custom block with a finalizer function. - * - * We also have to allow the user to explicitly free them, in - * which case we set the pointer inside the custom block to NULL. - * The finalizer notices this and doesn't free the object. - * - * Domains and networks "belong to" a connection. We have to avoid - * the situation like this: - * - * let conn = Connect.open ... in - * let dom = Domain.lookup_by_id conn 0 in - * (* conn goes out of scope and is garbage collected *) - * printf "dom name = %s\n" (Domain.get_name dom) - * - * The reason is that when conn is garbage collected, virConnectClose - * is called and any subsequent operations on dom will fail (in fact - * will probably segfault). To stop this from happening, the OCaml - * wrappers store domains (and networks) as explicit (dom, conn) - * pairs. - * - * Further complication with virterror / exceptions: Virterror gives - * us virConnectPtr, virDomainPtr, virNetworkPtr pointers. If we - * follow standard practice and wrap these up in blocks with - * finalizers then we'll end up double-freeing (in particular, calling - * virConnectClose at the wrong time). So for virterror, we have - * "special" wrapper functions (Val_connect_no_finalize, etc.). - */ - -/* Unwrap a custom block. */ -#define Connect_val(rv) (*((virConnectPtr *)Data_custom_val(rv))) -#define Dom_val(rv) (*((virDomainPtr *)Data_custom_val(rv))) -#define Net_val(rv) (*((virNetworkPtr *)Data_custom_val(rv))) - -/* Wrap up a pointer to something in a custom block. */ -static value Val_connect (virConnectPtr conn); -static value Val_dom (virDomainPtr dom); -static value Val_net (virNetworkPtr net); +#include "libvirt_c_prologue.c" -/* ONLY for use by virterror wrappers. */ -static value Val_connect_no_finalize (virConnectPtr conn); -static value Val_dom_no_finalize (virDomainPtr dom); -static value Val_net_no_finalize (virNetworkPtr net); +#include "libvirt_c_oneoffs.c" -/* Domains and networks are stored as pairs (dom/net, conn), so have - * some convenience functions for unwrapping and wrapping them. +/* Automatically generated binding for virConnectClose. + * In generator.pl this function has signature "conn : free". */ -#define Domain_val(rv) (Dom_val(Field((rv),0))) -#define Network_val(rv) (Net_val(Field((rv),0))) -#define Connect_domv(rv) (Connect_val(Field((rv),1))) -#define Connect_netv(rv) (Connect_val(Field((rv),1))) - -static value Val_domain (virDomainPtr dom, value connv); -static value Val_network (virNetworkPtr net, value connv); - -/* ONLY for use by virterror wrappers. */ -static value Val_domain_no_finalize (virDomainPtr dom, value connv); -static value Val_network_no_finalize (virNetworkPtr net, value connv); - -/*----------------------------------------------------------------------*/ - -/* Connection object. */ - -CAMLprim value -ocaml_libvirt_connect_open (value namev, value unit) -{ - CAMLparam2 (namev, unit); - CAMLlocal1 (rv); - const char *name = Optstring_val (namev); - virConnectPtr conn; - - conn = virConnectOpen (name); - CHECK_ERROR (!conn, NULL, "virConnectOpen"); - - rv = Val_connect (conn); - - CAMLreturn (rv); -} - -CAMLprim value -ocaml_libvirt_connect_open_readonly (value namev, value unit) -{ - CAMLparam2 (namev, unit); - CAMLlocal1 (rv); - const char *name = Optstring_val (namev); - virConnectPtr conn; - - conn = virConnectOpenReadOnly (name); - CHECK_ERROR (!conn, NULL, "virConnectOpen"); - - rv = Val_connect (conn); - - CAMLreturn (rv); -} CAMLprim value ocaml_libvirt_connect_close (value connv) { CAMLparam1 (connv); + virConnectPtr conn = Connect_val (connv); int r; - r = virConnectClose (conn); + NONBLOCKING (r = virConnectClose (conn)); CHECK_ERROR (r == -1, conn, "virConnectClose"); /* So that we don't double-free in the finalizer: */ @@ -266,164 +68,178 @@ ocaml_libvirt_connect_close (value connv) CAMLreturn (Val_unit); } -CAMLprim value -ocaml_libvirt_connect_get_type (value connv) -{ - CAMLparam1 (connv); - CAMLlocal1 (rv); - virConnectPtr conn = Connect_val (connv); - const char *r; - - r = virConnectGetType (conn); - CHECK_ERROR (!r, conn, "virConnectGetType"); - - rv = caml_copy_string (r); - CAMLreturn (rv); -} - -CAMLprim value -ocaml_libvirt_connect_get_version (value connv) -{ - CAMLparam1 (connv); - virConnectPtr conn = Connect_val (connv); - unsigned long hvVer; - int r; - - r = virConnectGetVersion (conn, &hvVer); - CHECK_ERROR (r == -1, conn, "virConnectGetVersion"); +/* Automatically generated binding for virConnectGetHostname. + * In generator.pl this function has signature "conn : string". + */ - CAMLreturn (Val_int (hvVer)); -} +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRCONNECTGETHOSTNAME +extern char *virConnectGetHostname (virConnectPtr conn) __attribute__((weak)); +#endif +#endif CAMLprim value ocaml_libvirt_connect_get_hostname (value connv) { -#ifdef HAVE_VIRCONNECTGETHOSTNAME CAMLparam1 (connv); +#ifndef HAVE_VIRCONNECTGETHOSTNAME + /* Symbol virConnectGetHostname not found at compile time. */ + not_supported ("virConnectGetHostname"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virConnectGetHostname + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virConnectGetHostname); + CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); char *r; - WEAK_SYMBOL_CHECK (virConnectGetHostname); - r = virConnectGetHostname (conn); + NONBLOCKING (r = virConnectGetHostname (conn)); CHECK_ERROR (!r, conn, "virConnectGetHostname"); rv = caml_copy_string (r); free (r); CAMLreturn (rv); -#else - NOT_SUPPORTED ("virConnectGetHostname"); #endif } +/* Automatically generated binding for virConnectGetURI. + * In generator.pl this function has signature "conn : string". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRCONNECTGETURI +extern char *virConnectGetURI (virConnectPtr conn) __attribute__((weak)); +#endif +#endif + CAMLprim value ocaml_libvirt_connect_get_uri (value connv) { -#ifdef HAVE_VIRCONNECTGETURI CAMLparam1 (connv); +#ifndef HAVE_VIRCONNECTGETURI + /* Symbol virConnectGetURI not found at compile time. */ + not_supported ("virConnectGetURI"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virConnectGetURI + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virConnectGetURI); + CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); char *r; - WEAK_SYMBOL_CHECK (virConnectGetURI); - r = virConnectGetURI (conn); + NONBLOCKING (r = virConnectGetURI (conn)); CHECK_ERROR (!r, conn, "virConnectGetURI"); rv = caml_copy_string (r); free (r); CAMLreturn (rv); -#else - NOT_SUPPORTED ("virConnectGetURI"); #endif } -CAMLprim value -ocaml_libvirt_connect_get_max_vcpus (value connv, value typev) -{ - CAMLparam2 (connv, typev); - virConnectPtr conn = Connect_val (connv); - const char *type = Optstring_val (typev); - int r; - - r = virConnectGetMaxVcpus (conn, type); - CHECK_ERROR (r == -1, conn, "virConnectGetMaxVcpus"); - - CAMLreturn (Val_int (r)); -} +/* Automatically generated binding for virConnectGetType. + * In generator.pl this function has signature "conn : static string". + */ CAMLprim value -ocaml_libvirt_connect_list_domains (value connv, value iv) +ocaml_libvirt_connect_get_type (value connv) { - CAMLparam2 (connv, iv); + CAMLparam1 (connv); + CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); - int i = Int_val (iv); - int ids[i], r; - - r = virConnectListDomains (conn, ids, i); - CHECK_ERROR (r == -1, conn, "virConnectListDomains"); + const char *r; - rv = caml_alloc (r, 0); - for (i = 0; i < r; ++i) - Store_field (rv, i, Val_int (ids[i])); + NONBLOCKING (r = virConnectGetType (conn)); + CHECK_ERROR (!r, conn, "virConnectGetType"); + rv = caml_copy_string (r); CAMLreturn (rv); } +/* Automatically generated binding for virConnectNumOfDomains. + * In generator.pl this function has signature "conn : int". + */ + CAMLprim value ocaml_libvirt_connect_num_of_domains (value connv) { CAMLparam1 (connv); + virConnectPtr conn = Connect_val (connv); int r; - r = virConnectNumOfDomains (conn); + NONBLOCKING (r = virConnectNumOfDomains (conn)); CHECK_ERROR (r == -1, conn, "virConnectNumOfDomains"); CAMLreturn (Val_int (r)); } +/* Automatically generated binding for virConnectListDomains. + * In generator.pl this function has signature "conn, int : int array". + */ + CAMLprim value -ocaml_libvirt_connect_get_capabilities (value connv) +ocaml_libvirt_connect_list_domains (value connv, value iv) { - CAMLparam1 (connv); + CAMLparam2 (connv, iv); + CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); - char *r; + int i = Int_val (iv); + int ids[i], r; - r = virConnectGetCapabilities (conn); - CHECK_ERROR (!r, conn, "virConnectGetCapabilities"); + NONBLOCKING (r = virConnectListDomains (conn, ids, i)); + CHECK_ERROR (r == -1, conn, "virConnectListDomains"); - rv = caml_copy_string (r); - free (r); + rv = caml_alloc (r, 0); + for (i = 0; i < r; ++i) + Store_field (rv, i, Val_int (ids[i])); CAMLreturn (rv); } +/* Automatically generated binding for virConnectNumOfDefinedDomains. + * In generator.pl this function has signature "conn : int". + */ + CAMLprim value ocaml_libvirt_connect_num_of_defined_domains (value connv) { CAMLparam1 (connv); + virConnectPtr conn = Connect_val (connv); int r; - r = virConnectNumOfDefinedDomains (conn); + NONBLOCKING (r = virConnectNumOfDefinedDomains (conn)); CHECK_ERROR (r == -1, conn, "virConnectNumOfDefinedDomains"); CAMLreturn (Val_int (r)); } +/* Automatically generated binding for virConnectListDefinedDomains. + * In generator.pl this function has signature "conn, int : string array". + */ + CAMLprim value ocaml_libvirt_connect_list_defined_domains (value connv, value iv) { CAMLparam2 (connv, iv); + CAMLlocal2 (rv, strv); virConnectPtr conn = Connect_val (connv); int i = Int_val (iv); char *names[i]; int r; - r = virConnectListDefinedDomains (conn, names, i); + NONBLOCKING (r = virConnectListDefinedDomains (conn, names, i)); CHECK_ERROR (r == -1, conn, "virConnectListDefinedDomains"); rv = caml_alloc (r, 0); @@ -436,30 +252,40 @@ ocaml_libvirt_connect_list_defined_domains (value connv, value iv) CAMLreturn (rv); } +/* Automatically generated binding for virConnectNumOfNetworks. + * In generator.pl this function has signature "conn : int". + */ + CAMLprim value ocaml_libvirt_connect_num_of_networks (value connv) { CAMLparam1 (connv); + virConnectPtr conn = Connect_val (connv); int r; - r = virConnectNumOfNetworks (conn); + NONBLOCKING (r = virConnectNumOfNetworks (conn)); CHECK_ERROR (r == -1, conn, "virConnectNumOfNetworks"); CAMLreturn (Val_int (r)); } +/* Automatically generated binding for virConnectListNetworks. + * In generator.pl this function has signature "conn, int : string array". + */ + CAMLprim value ocaml_libvirt_connect_list_networks (value connv, value iv) { CAMLparam2 (connv, iv); + CAMLlocal2 (rv, strv); virConnectPtr conn = Connect_val (connv); int i = Int_val (iv); char *names[i]; int r; - r = virConnectListNetworks (conn, names, i); + NONBLOCKING (r = virConnectListNetworks (conn, names, i)); CHECK_ERROR (r == -1, conn, "virConnectListNetworks"); rv = caml_alloc (r, 0); @@ -472,30 +298,40 @@ ocaml_libvirt_connect_list_networks (value connv, value iv) CAMLreturn (rv); } +/* Automatically generated binding for virConnectNumOfDefinedNetworks. + * In generator.pl this function has signature "conn : int". + */ + CAMLprim value ocaml_libvirt_connect_num_of_defined_networks (value connv) { CAMLparam1 (connv); + virConnectPtr conn = Connect_val (connv); int r; - r = virConnectNumOfDefinedNetworks (conn); + NONBLOCKING (r = virConnectNumOfDefinedNetworks (conn)); CHECK_ERROR (r == -1, conn, "virConnectNumOfDefinedNetworks"); CAMLreturn (Val_int (r)); } +/* Automatically generated binding for virConnectListDefinedNetworks. + * In generator.pl this function has signature "conn, int : string array". + */ + CAMLprim value ocaml_libvirt_connect_list_defined_networks (value connv, value iv) { CAMLparam2 (connv, iv); + CAMLlocal2 (rv, strv); virConnectPtr conn = Connect_val (connv); int i = Int_val (iv); char *names[i]; int r; - r = virConnectListDefinedNetworks (conn, names, i); + NONBLOCKING (r = virConnectListDefinedNetworks (conn, names, i)); CHECK_ERROR (r == -1, conn, "virConnectListDefinedNetworks"); rv = caml_alloc (r, 0); @@ -508,137 +344,262 @@ ocaml_libvirt_connect_list_defined_networks (value connv, value iv) CAMLreturn (rv); } +/* Automatically generated binding for virConnectNumOfStoragePools. + * In generator.pl this function has signature "conn : int". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRCONNECTNUMOFSTORAGEPOOLS +extern int virConnectNumOfStoragePools (virConnectPtr conn) __attribute__((weak)); +#endif +#endif + CAMLprim value -ocaml_libvirt_connect_get_node_info (value connv) +ocaml_libvirt_connect_num_of_storage_pools (value connv) { CAMLparam1 (connv); - CAMLlocal2 (rv, v); +#ifndef HAVE_VIRCONNECTNUMOFSTORAGEPOOLS + /* Symbol virConnectNumOfStoragePools not found at compile time. */ + not_supported ("virConnectNumOfStoragePools"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virConnectNumOfStoragePools + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virConnectNumOfStoragePools); + virConnectPtr conn = Connect_val (connv); - virNodeInfo info; int r; - r = virNodeGetInfo (conn, &info); - CHECK_ERROR (r == -1, conn, "virNodeGetInfo"); - - rv = caml_alloc (8, 0); - v = caml_copy_string (info.model); Store_field (rv, 0, v); - v = caml_copy_int64 (info.memory); Store_field (rv, 1, v); - Store_field (rv, 2, Val_int (info.cpus)); - Store_field (rv, 3, Val_int (info.mhz)); - Store_field (rv, 4, Val_int (info.nodes)); - Store_field (rv, 5, Val_int (info.sockets)); - Store_field (rv, 6, Val_int (info.cores)); - Store_field (rv, 7, Val_int (info.threads)); + NONBLOCKING (r = virConnectNumOfStoragePools (conn)); + CHECK_ERROR (r == -1, conn, "virConnectNumOfStoragePools"); - CAMLreturn (rv); + CAMLreturn (Val_int (r)); +#endif } -CAMLprim value -ocaml_libvirt_domain_create_linux (value connv, value xmlv) -{ - CAMLparam2 (connv, xmlv); - CAMLlocal1 (rv); - virConnectPtr conn = Connect_val (connv); - char *xml = String_val (xmlv); - virDomainPtr r; - - r = virDomainCreateLinux (conn, xml, 0); - CHECK_ERROR (!r, conn, "virDomainCreateLinux"); +/* Automatically generated binding for virConnectListStoragePools. + * In generator.pl this function has signature "conn, int : string array". + */ - rv = Val_domain (r, connv); - CAMLreturn (rv); -} +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRCONNECTLISTSTORAGEPOOLS +extern int virConnectListStoragePools (virConnectPtr conn, char **const names, int maxnames) __attribute__((weak)); +#endif +#endif CAMLprim value -ocaml_libvirt_domain_lookup_by_id (value connv, value iv) +ocaml_libvirt_connect_list_storage_pools (value connv, value iv) { CAMLparam2 (connv, iv); - CAMLlocal1 (rv); +#ifndef HAVE_VIRCONNECTLISTSTORAGEPOOLS + /* Symbol virConnectListStoragePools not found at compile time. */ + not_supported ("virConnectListStoragePools"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virConnectListStoragePools + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virConnectListStoragePools); + + CAMLlocal2 (rv, strv); virConnectPtr conn = Connect_val (connv); int i = Int_val (iv); - virDomainPtr r; + char *names[i]; + int r; - r = virDomainLookupByID (conn, i); - CHECK_ERROR (!r, conn, "virDomainLookupByID"); + NONBLOCKING (r = virConnectListStoragePools (conn, names, i)); + CHECK_ERROR (r == -1, conn, "virConnectListStoragePools"); + + rv = caml_alloc (r, 0); + for (i = 0; i < r; ++i) { + strv = caml_copy_string (names[i]); + Store_field (rv, i, strv); + free (names[i]); + } - rv = Val_domain (r, connv); CAMLreturn (rv); +#endif } +/* Automatically generated binding for virConnectNumOfDefinedStoragePools. + * In generator.pl this function has signature "conn : int". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRCONNECTNUMOFDEFINEDSTORAGEPOOLS +extern int virConnectNumOfDefinedStoragePools (virConnectPtr conn) __attribute__((weak)); +#endif +#endif + CAMLprim value -ocaml_libvirt_domain_lookup_by_uuid (value connv, value uuidv) +ocaml_libvirt_connect_num_of_defined_storage_pools (value connv) { - CAMLparam2 (connv, uuidv); - CAMLlocal1 (rv); + CAMLparam1 (connv); +#ifndef HAVE_VIRCONNECTNUMOFDEFINEDSTORAGEPOOLS + /* Symbol virConnectNumOfDefinedStoragePools not found at compile time. */ + not_supported ("virConnectNumOfDefinedStoragePools"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virConnectNumOfDefinedStoragePools + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virConnectNumOfDefinedStoragePools); + virConnectPtr conn = Connect_val (connv); - char *uuid = String_val (uuidv); - virDomainPtr r; + int r; - r = virDomainLookupByUUID (conn, (unsigned char *) uuid); - CHECK_ERROR (!r, conn, "virDomainLookupByUUID"); + NONBLOCKING (r = virConnectNumOfDefinedStoragePools (conn)); + CHECK_ERROR (r == -1, conn, "virConnectNumOfDefinedStoragePools"); - rv = Val_domain (r, connv); - CAMLreturn (rv); + CAMLreturn (Val_int (r)); +#endif } +/* Automatically generated binding for virConnectListDefinedStoragePools. + * In generator.pl this function has signature "conn, int : string array". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRCONNECTLISTDEFINEDSTORAGEPOOLS +extern int virConnectListDefinedStoragePools (virConnectPtr conn, char **const names, int maxnames) __attribute__((weak)); +#endif +#endif + CAMLprim value -ocaml_libvirt_domain_lookup_by_uuid_string (value connv, value uuidv) +ocaml_libvirt_connect_list_defined_storage_pools (value connv, value iv) { - CAMLparam2 (connv, uuidv); - CAMLlocal1 (rv); + CAMLparam2 (connv, iv); +#ifndef HAVE_VIRCONNECTLISTDEFINEDSTORAGEPOOLS + /* Symbol virConnectListDefinedStoragePools not found at compile time. */ + not_supported ("virConnectListDefinedStoragePools"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virConnectListDefinedStoragePools + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virConnectListDefinedStoragePools); + + CAMLlocal2 (rv, strv); virConnectPtr conn = Connect_val (connv); - char *uuid = String_val (uuidv); - virDomainPtr r; + int i = Int_val (iv); + char *names[i]; + int r; - r = virDomainLookupByUUIDString (conn, uuid); - CHECK_ERROR (!r, conn, "virDomainLookupByUUIDString"); + NONBLOCKING (r = virConnectListDefinedStoragePools (conn, names, i)); + CHECK_ERROR (r == -1, conn, "virConnectListDefinedStoragePools"); - rv = Val_domain (r, connv); - CAMLreturn (rv); + rv = caml_alloc (r, 0); + for (i = 0; i < r; ++i) { + strv = caml_copy_string (names[i]); + Store_field (rv, i, strv); + free (names[i]); + } + + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virConnectGetCapabilities. + * In generator.pl this function has signature "conn : string". + */ + +CAMLprim value +ocaml_libvirt_connect_get_capabilities (value connv) +{ + CAMLparam1 (connv); + + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + char *r; + + NONBLOCKING (r = virConnectGetCapabilities (conn)); + CHECK_ERROR (!r, conn, "virConnectGetCapabilities"); + + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); } +/* Automatically generated binding for virDomainCreateLinux. + * In generator.pl this function has signature "conn, string, 0U : dom". + */ + CAMLprim value -ocaml_libvirt_domain_lookup_by_name (value connv, value namev) +ocaml_libvirt_domain_create_linux (value connv, value strv) { - CAMLparam2 (connv, namev); + CAMLparam2 (connv, strv); + CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); - char *name = String_val (namev); + char *str = String_val (strv); virDomainPtr r; - r = virDomainLookupByName (conn, name); - CHECK_ERROR (!r, conn, "virDomainLookupByName"); + NONBLOCKING (r = virDomainCreateLinux (conn, str, 0)); + CHECK_ERROR (!r, conn, "virDomainCreateLinux"); rv = Val_domain (r, connv); + CAMLreturn (rv); } +/* Automatically generated binding for virDomainCreateLinuxJob. + * In generator.pl this function has signature "conn, string, 0U : job". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRDOMAINCREATELINUXJOB +extern virJobPtr virDomainCreateLinuxJob (virConnectPtr conn, const char *str, unsigned int flags) __attribute__((weak)); +#endif +#endif + CAMLprim value -ocaml_libvirt_domain_destroy (value domv) +ocaml_libvirt_domain_create_linux_job (value connv, value strv) { - CAMLparam1 (domv); - virDomainPtr dom = Domain_val (domv); - virConnectPtr conn = Connect_domv (domv); - int r; + CAMLparam2 (connv, strv); +#ifndef HAVE_VIRDOMAINCREATELINUXJOB + /* Symbol virDomainCreateLinuxJob not found at compile time. */ + not_supported ("virDomainCreateLinuxJob"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virDomainCreateLinuxJob + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virDomainCreateLinuxJob); - r = virDomainDestroy (dom); - CHECK_ERROR (r == -1, conn, "virDomainDestroy"); + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + char *str = String_val (strv); + virJobPtr r; - /* So that we don't double-free in the finalizer: */ - Domain_val (domv) = NULL; + NONBLOCKING (r = virDomainCreateLinuxJob (conn, str, 0)); + CHECK_ERROR (!r, conn, "virDomainCreateLinuxJob"); - CAMLreturn (Val_unit); + rv = Val_job (r, connv); + + CAMLreturn (rv); +#endif } +/* Automatically generated binding for virDomainFree. + * In generator.pl this function has signature "dom : free". + */ + CAMLprim value ocaml_libvirt_domain_free (value domv) { CAMLparam1 (domv); + virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); int r; - r = virDomainFree (dom); + NONBLOCKING (r = virDomainFree (dom)); CHECK_ERROR (r == -1, conn, "virDomainFree"); /* So that we don't double-free in the finalizer: */ @@ -647,1320 +608,2344 @@ ocaml_libvirt_domain_free (value domv) CAMLreturn (Val_unit); } +/* Automatically generated binding for virDomainDestroy. + * In generator.pl this function has signature "dom : free". + */ + CAMLprim value -ocaml_libvirt_domain_suspend (value domv) +ocaml_libvirt_domain_destroy (value domv) { CAMLparam1 (domv); + virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); int r; - r = virDomainSuspend (dom); - CHECK_ERROR (r == -1, conn, "virDomainSuspend"); + NONBLOCKING (r = virDomainDestroy (dom)); + CHECK_ERROR (r == -1, conn, "virDomainDestroy"); + + /* So that we don't double-free in the finalizer: */ + Domain_val (domv) = NULL; CAMLreturn (Val_unit); } +/* Automatically generated binding for virDomainLookupByName. + * In generator.pl this function has signature "conn, string : dom". + */ + CAMLprim value -ocaml_libvirt_domain_resume (value domv) +ocaml_libvirt_domain_lookup_by_name (value connv, value strv) { - CAMLparam1 (domv); - virDomainPtr dom = Domain_val (domv); - virConnectPtr conn = Connect_domv (domv); - int r; + CAMLparam2 (connv, strv); - r = virDomainResume (dom); - CHECK_ERROR (r == -1, conn, "virDomainResume"); + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + char *str = String_val (strv); + virDomainPtr r; - CAMLreturn (Val_unit); + NONBLOCKING (r = virDomainLookupByName (conn, str)); + CHECK_ERROR (!r, conn, "virDomainLookupByName"); + + rv = Val_domain (r, connv); + + CAMLreturn (rv); } +/* Automatically generated binding for virDomainLookupByID. + * In generator.pl this function has signature "conn, int : dom". + */ + CAMLprim value -ocaml_libvirt_domain_save (value domv, value pathv) +ocaml_libvirt_domain_lookup_by_id (value connv, value iv) { - CAMLparam2 (domv, pathv); - virDomainPtr dom = Domain_val (domv); - virConnectPtr conn = Connect_domv (domv); - char *path = String_val (pathv); - int r; + CAMLparam2 (connv, iv); - r = virDomainSave (dom, path); - CHECK_ERROR (r == -1, conn, "virDomainSave"); + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + int i = Int_val (iv); + virDomainPtr r; - CAMLreturn (Val_unit); + NONBLOCKING (r = virDomainLookupByID (conn, i)); + CHECK_ERROR (!r, conn, "virDomainLookupByID"); + + rv = Val_domain (r, connv); + + CAMLreturn (rv); } +/* Automatically generated binding for virDomainLookupByUUID. + * In generator.pl this function has signature "conn, uuid : dom". + */ + CAMLprim value -ocaml_libvirt_domain_restore (value connv, value pathv) +ocaml_libvirt_domain_lookup_by_uuid (value connv, value uuidv) { - CAMLparam2 (connv, pathv); + CAMLparam2 (connv, uuidv); + + CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); - char *path = String_val (pathv); - int r; + unsigned char *uuid = (unsigned char *) String_val (uuidv); + virDomainPtr r; - r = virDomainRestore (conn, path); - CHECK_ERROR (r == -1, conn, "virDomainRestore"); + NONBLOCKING (r = virDomainLookupByUUID (conn, uuid)); + CHECK_ERROR (!r, conn, "virDomainLookupByUUID"); - CAMLreturn (Val_unit); + rv = Val_domain (r, connv); + + CAMLreturn (rv); } +/* Automatically generated binding for virDomainLookupByUUIDString. + * In generator.pl this function has signature "conn, string : dom". + */ + CAMLprim value -ocaml_libvirt_domain_core_dump (value domv, value pathv) +ocaml_libvirt_domain_lookup_by_uuid_string (value connv, value strv) { - CAMLparam2 (domv, pathv); - virDomainPtr dom = Domain_val (domv); - virConnectPtr conn = Connect_domv (domv); - char *path = String_val (pathv); - int r; + CAMLparam2 (connv, strv); + + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + char *str = String_val (strv); + virDomainPtr r; - r = virDomainCoreDump (dom, path, 0); - CHECK_ERROR (r == -1, conn, "virDomainCoreDump"); + NONBLOCKING (r = virDomainLookupByUUIDString (conn, str)); + CHECK_ERROR (!r, conn, "virDomainLookupByUUIDString"); - CAMLreturn (Val_unit); + rv = Val_domain (r, connv); + + CAMLreturn (rv); } +/* Automatically generated binding for virDomainGetName. + * In generator.pl this function has signature "dom : static string". + */ + CAMLprim value -ocaml_libvirt_domain_shutdown (value domv) +ocaml_libvirt_domain_get_name (value domv) { CAMLparam1 (domv); + + CAMLlocal1 (rv); virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); - int r; + const char *r; - r = virDomainShutdown (dom); - CHECK_ERROR (r == -1, conn, "virDomainShutdown"); + NONBLOCKING (r = virDomainGetName (dom)); + CHECK_ERROR (!r, conn, "virDomainGetName"); - CAMLreturn (Val_unit); + rv = caml_copy_string (r); + CAMLreturn (rv); } +/* Automatically generated binding for virDomainGetOSType. + * In generator.pl this function has signature "dom : string". + */ + CAMLprim value -ocaml_libvirt_domain_reboot (value domv) +ocaml_libvirt_domain_get_os_type (value domv) { CAMLparam1 (domv); + + CAMLlocal1 (rv); virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); - int r; + char *r; - r = virDomainReboot (dom, 0); - CHECK_ERROR (r == -1, conn, "virDomainReboot"); + NONBLOCKING (r = virDomainGetOSType (dom)); + CHECK_ERROR (!r, conn, "virDomainGetOSType"); - CAMLreturn (Val_unit); + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); } +/* Automatically generated binding for virDomainGetXMLDesc. + * In generator.pl this function has signature "dom, 0 : string". + */ + CAMLprim value -ocaml_libvirt_domain_get_name (value domv) +ocaml_libvirt_domain_get_xml_desc (value domv) { CAMLparam1 (domv); + CAMLlocal1 (rv); virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); - const char *r; + char *r; - r = virDomainGetName (dom); - CHECK_ERROR (!r, conn, "virDomainGetName"); + NONBLOCKING (r = virDomainGetXMLDesc (dom, 0)); + CHECK_ERROR (!r, conn, "virDomainGetXMLDesc"); rv = caml_copy_string (r); + free (r); CAMLreturn (rv); } +/* Automatically generated binding for virDomainGetUUID. + * In generator.pl this function has signature "dom : uuid". + */ + CAMLprim value ocaml_libvirt_domain_get_uuid (value domv) { CAMLparam1 (domv); + CAMLlocal1 (rv); virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); unsigned char uuid[VIR_UUID_BUFLEN]; int r; - r = virDomainGetUUID (dom, uuid); + NONBLOCKING (r = virDomainGetUUID (dom, uuid)); CHECK_ERROR (r == -1, conn, "virDomainGetUUID"); - rv = caml_copy_string ((char *) uuid); + /* UUIDs are byte arrays with a fixed length. */ + rv = caml_alloc_string (VIR_UUID_BUFLEN); + memcpy (String_val (rv), uuid, VIR_UUID_BUFLEN); CAMLreturn (rv); } +/* Automatically generated binding for virDomainGetUUIDString. + * In generator.pl this function has signature "dom : uuid string". + */ + CAMLprim value ocaml_libvirt_domain_get_uuid_string (value domv) { CAMLparam1 (domv); + CAMLlocal1 (rv); virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); char uuid[VIR_UUID_STRING_BUFLEN]; int r; - r = virDomainGetUUIDString (dom, uuid); + NONBLOCKING (r = virDomainGetUUIDString (dom, uuid)); CHECK_ERROR (r == -1, conn, "virDomainGetUUIDString"); rv = caml_copy_string (uuid); CAMLreturn (rv); } +/* Automatically generated binding for virDomainGetMaxVcpus. + * In generator.pl this function has signature "dom : int". + */ + CAMLprim value -ocaml_libvirt_domain_get_id (value domv) +ocaml_libvirt_domain_get_max_vcpus (value domv) { CAMLparam1 (domv); + virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); - unsigned int r; + int r; - 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. - */ - CHECK_ERROR (r == (unsigned int) -1, conn, "virDomainGetID"); + NONBLOCKING (r = virDomainGetMaxVcpus (dom)); + CHECK_ERROR (r == -1, conn, "virDomainGetMaxVcpus"); - CAMLreturn (Val_int ((int) r)); + CAMLreturn (Val_int (r)); } +/* Automatically generated binding for virDomainSave. + * In generator.pl this function has signature "dom, string : unit". + */ + CAMLprim value -ocaml_libvirt_domain_get_os_type (value domv) +ocaml_libvirt_domain_save (value domv, value strv) { - CAMLparam1 (domv); + CAMLparam2 (domv, strv); + CAMLlocal1 (rv); virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); - char *r; + char *str = String_val (strv); + int r; - r = virDomainGetOSType (dom); - CHECK_ERROR (!r, conn, "virDomainGetOSType"); + NONBLOCKING (r = virDomainSave (dom, str)); + CHECK_ERROR (r == -1, conn, "virDomainSave"); - rv = caml_copy_string (r); - free (r); - CAMLreturn (rv); + CAMLreturn (Val_unit); } +/* Automatically generated binding for virDomainSaveJob. + * In generator.pl this function has signature "dom, string : job from dom". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRDOMAINSAVEJOB +extern virJobPtr virDomainSaveJob (virDomainPtr dom, const char *str) __attribute__((weak)); +#endif +#endif + CAMLprim value -ocaml_libvirt_domain_get_max_memory (value domv) +ocaml_libvirt_domain_save_job (value domv, value strv) { - CAMLparam1 (domv); - CAMLlocal1 (rv); + CAMLparam2 (domv, strv); +#ifndef HAVE_VIRDOMAINSAVEJOB + /* Symbol virDomainSaveJob not found at compile time. */ + not_supported ("virDomainSaveJob"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virDomainSaveJob + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virDomainSaveJob); + + CAMLlocal2 (rv, connv); virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); - unsigned long r; + char *str = String_val (strv); + virJobPtr r; - r = virDomainGetMaxMemory (dom); - CHECK_ERROR (r == 0 /* [sic] */, conn, "virDomainGetMaxMemory"); + NONBLOCKING (r = virDomainSaveJob (dom, str)); + CHECK_ERROR (!r, conn, "virDomainSaveJob"); + + connv = Field (domv, 1); + rv = Val_job (r, connv); - rv = caml_copy_int64 (r); CAMLreturn (rv); +#endif } +/* Automatically generated binding for virDomainRestore. + * In generator.pl this function has signature "conn, string : unit". + */ + CAMLprim value -ocaml_libvirt_domain_set_max_memory (value domv, value memv) +ocaml_libvirt_domain_restore (value connv, value strv) { - CAMLparam2 (domv, memv); - virDomainPtr dom = Domain_val (domv); - virConnectPtr conn = Connect_domv (domv); - unsigned long mem = Int64_val (memv); + CAMLparam2 (connv, strv); + + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + char *str = String_val (strv); int r; - r = virDomainSetMaxMemory (dom, mem); - CHECK_ERROR (r == -1, conn, "virDomainSetMaxMemory"); + NONBLOCKING (r = virDomainRestore (conn, str)); + CHECK_ERROR (r == -1, conn, "virDomainRestore"); CAMLreturn (Val_unit); } +/* Automatically generated binding for virDomainRestoreJob. + * In generator.pl this function has signature "conn, string : job". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRDOMAINRESTOREJOB +extern virJobPtr virDomainRestoreJob (virConnectPtr conn, const char *str) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_domain_restore_job (value connv, value strv) +{ + CAMLparam2 (connv, strv); +#ifndef HAVE_VIRDOMAINRESTOREJOB + /* Symbol virDomainRestoreJob not found at compile time. */ + not_supported ("virDomainRestoreJob"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virDomainRestoreJob + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virDomainRestoreJob); + + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + char *str = String_val (strv); + virJobPtr r; + + NONBLOCKING (r = virDomainRestoreJob (conn, str)); + CHECK_ERROR (!r, conn, "virDomainRestoreJob"); + + rv = Val_job (r, connv); + + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virDomainCoreDump. + * In generator.pl this function has signature "dom, string, 0 : unit". + */ + CAMLprim value -ocaml_libvirt_domain_set_memory (value domv, value memv) +ocaml_libvirt_domain_core_dump (value domv, value strv) { - CAMLparam2 (domv, memv); + CAMLparam2 (domv, strv); + + CAMLlocal1 (rv); virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); - unsigned long mem = Int64_val (memv); + char *str = String_val (strv); int r; - r = virDomainSetMemory (dom, mem); - CHECK_ERROR (r == -1, conn, "virDomainSetMemory"); + NONBLOCKING (r = virDomainCoreDump (dom, str, 0)); + CHECK_ERROR (!r, conn, "virDomainCoreDump"); CAMLreturn (Val_unit); } +/* Automatically generated binding for virDomainCoreDumpJob. + * In generator.pl this function has signature "dom, string, 0 : job from dom". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRDOMAINCOREDUMPJOB +extern virJobPtr virDomainCoreDumpJob (virDomainPtr dom, const char *str, int flags) __attribute__((weak)); +#endif +#endif + CAMLprim value -ocaml_libvirt_domain_get_info (value domv) +ocaml_libvirt_domain_core_dump_job (value domv, value strv) { - CAMLparam1 (domv); - CAMLlocal2 (rv, v); + CAMLparam2 (domv, strv); +#ifndef HAVE_VIRDOMAINCOREDUMPJOB + /* Symbol virDomainCoreDumpJob not found at compile time. */ + not_supported ("virDomainCoreDumpJob"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virDomainCoreDumpJob + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virDomainCoreDumpJob); + + CAMLlocal2 (rv, connv); virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); - virDomainInfo info; - int r; + char *str = String_val (strv); + virJobPtr r; - r = virDomainGetInfo (dom, &info); - CHECK_ERROR (r == -1, conn, "virDomainGetInfo"); + NONBLOCKING (r = virDomainCoreDumpJob (dom, str, 0)); + CHECK_ERROR (!r, conn, "virDomainCoreDumpJob"); - rv = caml_alloc (5, 0); - Store_field (rv, 0, Val_int (info.state)); // These flags are compatible. - v = caml_copy_int64 (info.maxMem); Store_field (rv, 1, v); - v = caml_copy_int64 (info.memory); Store_field (rv, 2, v); - Store_field (rv, 3, Val_int (info.nrVirtCpu)); - v = caml_copy_int64 (info.cpuTime); Store_field (rv, 4, v); + connv = Field (domv, 1); + rv = Val_job (r, connv); CAMLreturn (rv); +#endif } +/* Automatically generated binding for virDomainSuspend. + * In generator.pl this function has signature "dom : unit". + */ + CAMLprim value -ocaml_libvirt_domain_get_xml_desc (value domv) +ocaml_libvirt_domain_suspend (value domv) { CAMLparam1 (domv); - CAMLlocal1 (rv); + virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); - char *r; + int r; - r = virDomainGetXMLDesc (dom, 0); - CHECK_ERROR (!r, conn, "virDomainGetXMLDesc"); + NONBLOCKING (r = virDomainSuspend (dom)); + CHECK_ERROR (r == -1, conn, "virDomainSuspend"); - rv = caml_copy_string (r); - free (r); - CAMLreturn (rv); + CAMLreturn (Val_unit); } +/* Automatically generated binding for virDomainResume. + * In generator.pl this function has signature "dom : unit". + */ + CAMLprim value -ocaml_libvirt_domain_get_scheduler_type (value domv) +ocaml_libvirt_domain_resume (value domv) { -#ifdef HAVE_VIRDOMAINGETSCHEDULERTYPE CAMLparam1 (domv); - CAMLlocal2 (rv, strv); + virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); - char *r; - int nparams; + int r; - WEAK_SYMBOL_CHECK (virDomainGetSchedulerType); - r = virDomainGetSchedulerType (dom, &nparams); - CHECK_ERROR (!r, conn, "virDomainGetSchedulerType"); + NONBLOCKING (r = virDomainResume (dom)); + CHECK_ERROR (r == -1, conn, "virDomainResume"); - rv = caml_alloc_tuple (2); - strv = caml_copy_string (r); Store_field (rv, 0, strv); - free (r); - Store_field (rv, 1, nparams); - CAMLreturn (rv); -#else - NOT_SUPPORTED ("virDomainGetSchedulerType"); -#endif + CAMLreturn (Val_unit); } +/* Automatically generated binding for virDomainShutdown. + * In generator.pl this function has signature "dom : unit". + */ + CAMLprim value -ocaml_libvirt_domain_get_scheduler_parameters (value domv, value nparamsv) +ocaml_libvirt_domain_shutdown (value domv) { -#ifdef HAVE_VIRDOMAINGETSCHEDULERPARAMETERS - CAMLparam2 (domv, nparamsv); - CAMLlocal4 (rv, v, v2, v3); + CAMLparam1 (domv); + virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); - int nparams = Int_val (nparamsv); - virSchedParameter params[nparams]; - int r, i; - - WEAK_SYMBOL_CHECK (virDomainGetSchedulerParameters); - r = virDomainGetSchedulerParameters (dom, params, &nparams); - CHECK_ERROR (r == -1, conn, "virDomainGetSchedulerParameters"); - - rv = caml_alloc (nparams, 0); - for (i = 0; i < nparams; ++i) { - v = caml_alloc_tuple (2); Store_field (rv, i, v); - v2 = caml_copy_string (params[i].field); Store_field (v, 0, v2); - switch (params[i].type) { - case VIR_DOMAIN_SCHED_FIELD_INT: - v2 = caml_alloc (1, 0); - v3 = caml_copy_int32 (params[i].value.i); Store_field (v2, 0, v3); - break; - case VIR_DOMAIN_SCHED_FIELD_UINT: - v2 = caml_alloc (1, 1); - v3 = caml_copy_int32 (params[i].value.ui); Store_field (v2, 0, v3); - break; - case VIR_DOMAIN_SCHED_FIELD_LLONG: - v2 = caml_alloc (1, 2); - v3 = caml_copy_int64 (params[i].value.l); Store_field (v2, 0, v3); - break; - case VIR_DOMAIN_SCHED_FIELD_ULLONG: - v2 = caml_alloc (1, 3); - v3 = caml_copy_int64 (params[i].value.ul); Store_field (v2, 0, v3); - break; - case VIR_DOMAIN_SCHED_FIELD_DOUBLE: - v2 = caml_alloc (1, 4); - v3 = caml_copy_double (params[i].value.d); Store_field (v2, 0, v3); - break; - case VIR_DOMAIN_SCHED_FIELD_BOOLEAN: - v2 = caml_alloc (1, 5); - Store_field (v2, 0, Val_int (params[i].value.b)); - break; - default: - caml_failwith ((char *)__FUNCTION__); - } - Store_field (v, 1, v2); - } - CAMLreturn (rv); -#else - NOT_SUPPORTED ("virDomainGetSchedulerParameters"); -#endif + int r; + + NONBLOCKING (r = virDomainShutdown (dom)); + CHECK_ERROR (r == -1, conn, "virDomainShutdown"); + + CAMLreturn (Val_unit); } +/* Automatically generated binding for virDomainReboot. + * In generator.pl this function has signature "dom, 0 : unit". + */ + CAMLprim value -ocaml_libvirt_domain_set_scheduler_parameters (value domv, value paramsv) +ocaml_libvirt_domain_reboot (value domv) { -#ifdef HAVE_VIRDOMAINSETSCHEDULERPARAMETERS - CAMLparam2 (domv, paramsv); - CAMLlocal1 (v); + CAMLparam1 (domv); + virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); - int nparams = Wosize_val (paramsv); - virSchedParameter params[nparams]; - int r, i; - char *name; - - for (i = 0; i < nparams; ++i) { - v = Field (paramsv, i); /* Points to the two-element tuple. */ - name = String_val (Field (v, 0)); - strncpy (params[i].field, name, VIR_DOMAIN_SCHED_FIELD_LENGTH); - params[i].field[VIR_DOMAIN_SCHED_FIELD_LENGTH-1] = '\0'; - v = Field (v, 1); /* Points to the sched_param_value block. */ - switch (Tag_val (v)) { - case 0: - params[i].type = VIR_DOMAIN_SCHED_FIELD_INT; - params[i].value.i = Int32_val (Field (v, 0)); - break; - case 1: - params[i].type = VIR_DOMAIN_SCHED_FIELD_UINT; - params[i].value.ui = Int32_val (Field (v, 0)); - break; - case 2: - params[i].type = VIR_DOMAIN_SCHED_FIELD_LLONG; - params[i].value.l = Int64_val (Field (v, 0)); - break; - case 3: - params[i].type = VIR_DOMAIN_SCHED_FIELD_ULLONG; - params[i].value.ul = Int64_val (Field (v, 0)); - break; - case 4: - params[i].type = VIR_DOMAIN_SCHED_FIELD_DOUBLE; - params[i].value.d = Double_val (Field (v, 0)); - break; - case 5: - params[i].type = VIR_DOMAIN_SCHED_FIELD_BOOLEAN; - params[i].value.b = Int_val (Field (v, 0)); - break; - default: - caml_failwith ((char *)__FUNCTION__); - } - } + int r; - WEAK_SYMBOL_CHECK (virDomainSetSchedulerParameters); - r = virDomainSetSchedulerParameters (dom, params, nparams); - CHECK_ERROR (r == -1, conn, "virDomainSetSchedulerParameters"); + NONBLOCKING (r = virDomainReboot (dom, 0)); + CHECK_ERROR (r == -1, conn, "virDomainReboot"); CAMLreturn (Val_unit); -#else - NOT_SUPPORTED ("virDomainSetSchedulerParameters"); -#endif } +/* Automatically generated binding for virDomainDefineXML. + * In generator.pl this function has signature "conn, string : dom". + */ + CAMLprim value -ocaml_libvirt_domain_define_xml (value connv, value xmlv) +ocaml_libvirt_domain_define_xml (value connv, value strv) { - CAMLparam2 (connv, xmlv); + CAMLparam2 (connv, strv); + CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); - char *xml = String_val (xmlv); + char *str = String_val (strv); virDomainPtr r; - r = virDomainDefineXML (conn, xml); + NONBLOCKING (r = virDomainDefineXML (conn, str)); CHECK_ERROR (!r, conn, "virDomainDefineXML"); rv = Val_domain (r, connv); + CAMLreturn (rv); } +/* Automatically generated binding for virDomainUndefine. + * In generator.pl this function has signature "dom : unit". + */ + CAMLprim value ocaml_libvirt_domain_undefine (value domv) { CAMLparam1 (domv); + virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); int r; - r = virDomainUndefine (dom); + NONBLOCKING (r = virDomainUndefine (dom)); CHECK_ERROR (r == -1, conn, "virDomainUndefine"); CAMLreturn (Val_unit); } +/* Automatically generated binding for virDomainCreate. + * In generator.pl this function has signature "dom : unit". + */ + CAMLprim value ocaml_libvirt_domain_create (value domv) { CAMLparam1 (domv); + virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); int r; - r = virDomainCreate (dom); + NONBLOCKING (r = virDomainCreate (dom)); CHECK_ERROR (r == -1, conn, "virDomainCreate"); CAMLreturn (Val_unit); } -CAMLprim value -ocaml_libvirt_domain_get_autostart (value domv) -{ - CAMLparam1 (domv); - virDomainPtr dom = Domain_val (domv); - virConnectPtr conn = Connect_domv (domv); - int r, autostart; - - r = virDomainGetAutostart (dom, &autostart); - CHECK_ERROR (r == -1, conn, "virDomainGetAutostart"); +/* Automatically generated binding for virDomainCreateJob. + * In generator.pl this function has signature "dom, 0U : job from dom". + */ - CAMLreturn (autostart ? Val_true : Val_false); -} +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRDOMAINCREATEJOB +extern virJobPtr virDomainCreateJob (virDomainPtr dom, unsigned int flags) __attribute__((weak)); +#endif +#endif CAMLprim value -ocaml_libvirt_domain_set_autostart (value domv, value autostartv) +ocaml_libvirt_domain_create_job (value domv) { - CAMLparam2 (domv, autostartv); - virDomainPtr dom = Domain_val (domv); - virConnectPtr conn = Connect_domv (domv); - int r, autostart = autostartv == Val_true ? 1 : 0; - - r = virDomainSetAutostart (dom, autostart); - CHECK_ERROR (r == -1, conn, "virDomainSetAutostart"); - - CAMLreturn (Val_unit); -} + CAMLparam1 (domv); +#ifndef HAVE_VIRDOMAINCREATEJOB + /* Symbol virDomainCreateJob not found at compile time. */ + not_supported ("virDomainCreateJob"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virDomainCreateJob + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virDomainCreateJob); -CAMLprim value -ocaml_libvirt_domain_set_vcpus (value domv, value nvcpusv) -{ - CAMLparam2 (domv, nvcpusv); + CAMLlocal2 (rv, connv); virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); - int r, nvcpus = Int_val (nvcpusv); + virJobPtr r; - r = virDomainSetVcpus (dom, nvcpus); - CHECK_ERROR (r == -1, conn, "virDomainSetVcpus"); + NONBLOCKING (r = virDomainCreateJob (dom, 0)); + CHECK_ERROR (!r, conn, "virDomainCreateJob"); - CAMLreturn (Val_unit); + connv = Field (domv, 1); + rv = Val_job (r, connv); + + CAMLreturn (rv); +#endif } +/* Automatically generated binding for virDomainAttachDevice. + * In generator.pl this function has signature "dom, string : unit". + */ + CAMLprim value -ocaml_libvirt_domain_pin_vcpu (value domv, value vcpuv, value cpumapv) +ocaml_libvirt_domain_attach_device (value domv, value strv) { - CAMLparam3 (domv, vcpuv, cpumapv); + CAMLparam2 (domv, strv); + + CAMLlocal1 (rv); virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); - int maplen = caml_string_length (cpumapv); - unsigned char *cpumap = (unsigned char *) String_val (cpumapv); - int vcpu = Int_val (vcpuv); + char *str = String_val (strv); int r; - r = virDomainPinVcpu (dom, vcpu, cpumap, maplen); - CHECK_ERROR (r == -1, conn, "virDomainPinVcpu"); + NONBLOCKING (r = virDomainAttachDevice (dom, str)); + CHECK_ERROR (r == -1, conn, "virDomainAttachDevice"); CAMLreturn (Val_unit); } -CAMLprim value -ocaml_libvirt_domain_get_vcpus (value domv, value maxinfov, value maplenv) -{ - CAMLparam3 (domv, maxinfov, maplenv); - CAMLlocal5 (rv, infov, strv, v, v2); - virDomainPtr dom = Domain_val (domv); - virConnectPtr conn = Connect_domv (domv); - int maxinfo = Int_val (maxinfov); - int maplen = Int_val (maplenv); - virVcpuInfo info[maxinfo]; - unsigned char cpumaps[maxinfo * maplen]; - int r, i; - - memset (info, 0, sizeof (virVcpuInfo) * maxinfo); - memset (cpumaps, 0, maxinfo * maplen); - - r = virDomainGetVcpus (dom, info, maxinfo, cpumaps, maplen); - CHECK_ERROR (r == -1, conn, "virDomainPinVcpu"); - - /* Copy the virVcpuInfo structures. */ - infov = caml_alloc (maxinfo, 0); - for (i = 0; i < maxinfo; ++i) { - v2 = caml_alloc (4, 0); Store_field (infov, i, v2); - Store_field (v2, 0, Val_int (info[i].number)); - Store_field (v2, 1, Val_int (info[i].state)); - v = caml_copy_int64 (info[i].cpuTime); Store_field (v2, 2, v); - Store_field (v2, 3, Val_int (info[i].cpu)); - } - - /* Copy the bitmap. */ - strv = caml_alloc_string (maxinfo * maplen); - memcpy (String_val (strv), cpumaps, maxinfo * maplen); - - /* Allocate the tuple and return it. */ - rv = caml_alloc_tuple (3); - Store_field (rv, 0, Val_int (r)); /* number of CPUs. */ - Store_field (rv, 1, infov); - Store_field (rv, 2, strv); - - CAMLreturn (rv); -} +/* Automatically generated binding for virDomainDetachDevice. + * In generator.pl this function has signature "dom, string : unit". + */ CAMLprim value -ocaml_libvirt_domain_get_max_vcpus (value domv) +ocaml_libvirt_domain_detach_device (value domv, value strv) { - CAMLparam1 (domv); - virDomainPtr dom = Domain_val (domv); - virConnectPtr conn = Connect_domv (domv); - int r; - - r = virDomainGetMaxVcpus (dom); - CHECK_ERROR (r == -1, conn, "virDomainGetMaxVcpus"); - - CAMLreturn (Val_int (r)); -} + CAMLparam2 (domv, strv); -CAMLprim value -ocaml_libvirt_domain_attach_device (value domv, value xmlv) -{ - CAMLparam2 (domv, xmlv); + CAMLlocal1 (rv); virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); - char *xml = String_val (xmlv); + char *str = String_val (strv); int r; - r = virDomainAttachDevice (dom, xml); - CHECK_ERROR (r == -1, conn, "virDomainAttachDevice"); + NONBLOCKING (r = virDomainDetachDevice (dom, str)); + CHECK_ERROR (r == -1, conn, "virDomainDetachDevice"); CAMLreturn (Val_unit); } +/* Automatically generated binding for virDomainGetAutostart. + * In generator.pl this function has signature "dom : bool". + */ + CAMLprim value -ocaml_libvirt_domain_detach_device (value domv, value xmlv) +ocaml_libvirt_domain_get_autostart (value domv) { - CAMLparam2 (domv, xmlv); + CAMLparam1 (domv); + virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); - char *xml = String_val (xmlv); - int r; + int r, b; - r = virDomainDetachDevice (dom, xml); - CHECK_ERROR (r == -1, conn, "virDomainDetachDevice"); + NONBLOCKING (r = virDomainGetAutostart (dom, &b)); + CHECK_ERROR (r == -1, conn, "virDomainGetAutostart"); - CAMLreturn (Val_unit); + CAMLreturn (b ? Val_true : Val_false); } +/* Automatically generated binding for virDomainSetAutostart. + * In generator.pl this function has signature "dom, bool : unit". + */ + CAMLprim value -ocaml_libvirt_domain_migrate_native (value domv, value dconnv, value flagsv, value optdnamev, value opturiv, value optbandwidthv, value unitv) +ocaml_libvirt_domain_set_autostart (value domv, value bv) { -#ifdef HAVE_VIRDOMAINMIGRATE - CAMLparam5 (domv, dconnv, flagsv, optdnamev, opturiv); - CAMLxparam2 (optbandwidthv, unitv); - CAMLlocal2 (flagv, rv); + CAMLparam2 (domv, bv); + virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); - virConnectPtr dconn = Connect_val (dconnv); - int flags = 0; - const char *dname = Optstring_val (optdnamev); - const char *uri = Optstring_val (opturiv); - unsigned long bandwidth; - virDomainPtr r; - - /* Iterate over the list of flags. */ - for (; flagsv != Val_int (0); flagsv = Field (flagsv, 1)) - { - flagv = Field (flagsv, 0); - if (flagv == Int_val(0)) - flags |= VIR_MIGRATE_LIVE; - } - - if (optbandwidthv == Val_int (0)) /* None */ - bandwidth = 0; - else /* Some bandwidth */ - bandwidth = Int_val (Field (optbandwidthv, 0)); + int r, b; - WEAK_SYMBOL_CHECK (virDomainMigrate); - r = virDomainMigrate (dom, dconn, flags, dname, uri, bandwidth); - CHECK_ERROR (!r, conn, "virDomainMigrate"); + b = bv == Val_true ? 1 : 0; - rv = Val_domain (r, dconnv); - - CAMLreturn (rv); + NONBLOCKING (r = virDomainSetAutostart (dom, b)); + CHECK_ERROR (r == -1, conn, "virDomainSetAutostart"); -#else /* virDomainMigrate not supported */ - NOT_SUPPORTED ("virDomainMigrate"); -#endif + CAMLreturn (Val_unit); } -CAMLprim value -ocaml_libvirt_domain_migrate_bytecode (value *argv, int argn) -{ - return ocaml_libvirt_domain_migrate_native (argv[0], argv[1], argv[2], - argv[3], argv[4], argv[5], - argv[6]); -} +/* Automatically generated binding for virNetworkFree. + * In generator.pl this function has signature "net : free". + */ CAMLprim value -ocaml_libvirt_domain_block_stats (value domv, value pathv) +ocaml_libvirt_network_free (value netv) { -#if HAVE_VIRDOMAINBLOCKSTATS - CAMLparam2 (domv, pathv); - CAMLlocal2 (rv,v); - virDomainPtr dom = Domain_val (domv); - virConnectPtr conn = Connect_domv (domv); - char *path = String_val (pathv); - struct _virDomainBlockStats stats; + CAMLparam1 (netv); + + virNetworkPtr net = Network_val (netv); + virConnectPtr conn = Connect_netv (netv); int r; - WEAK_SYMBOL_CHECK (virDomainBlockStats); - r = virDomainBlockStats (dom, path, &stats, sizeof stats); - CHECK_ERROR (r == -1, conn, "virDomainBlockStats"); + NONBLOCKING (r = virNetworkFree (net)); + CHECK_ERROR (r == -1, conn, "virNetworkFree"); - rv = caml_alloc (5, 0); - v = caml_copy_int64 (stats.rd_req); Store_field (rv, 0, v); - v = caml_copy_int64 (stats.rd_bytes); Store_field (rv, 1, v); - v = caml_copy_int64 (stats.wr_req); Store_field (rv, 2, v); - v = caml_copy_int64 (stats.wr_bytes); Store_field (rv, 3, v); - v = caml_copy_int64 (stats.errs); Store_field (rv, 4, v); + /* So that we don't double-free in the finalizer: */ + Network_val (netv) = NULL; - CAMLreturn (rv); -#else - NOT_SUPPORTED ("virDomainBlockStats"); -#endif + CAMLreturn (Val_unit); } +/* Automatically generated binding for virNetworkDestroy. + * In generator.pl this function has signature "net : free". + */ + CAMLprim value -ocaml_libvirt_domain_interface_stats (value domv, value pathv) +ocaml_libvirt_network_destroy (value netv) { -#if HAVE_VIRDOMAININTERFACESTATS - CAMLparam2 (domv, pathv); - CAMLlocal2 (rv,v); - virDomainPtr dom = Domain_val (domv); - virConnectPtr conn = Connect_domv (domv); - char *path = String_val (pathv); - struct _virDomainInterfaceStats stats; + CAMLparam1 (netv); + + virNetworkPtr net = Network_val (netv); + virConnectPtr conn = Connect_netv (netv); int r; - WEAK_SYMBOL_CHECK (virDomainInterfaceStats); - r = virDomainInterfaceStats (dom, path, &stats, sizeof stats); - CHECK_ERROR (r == -1, conn, "virDomainInterfaceStats"); + NONBLOCKING (r = virNetworkDestroy (net)); + CHECK_ERROR (r == -1, conn, "virNetworkDestroy"); - rv = caml_alloc (8, 0); - v = caml_copy_int64 (stats.rx_bytes); Store_field (rv, 0, v); - v = caml_copy_int64 (stats.rx_packets); Store_field (rv, 1, v); - v = caml_copy_int64 (stats.rx_errs); Store_field (rv, 2, v); - v = caml_copy_int64 (stats.rx_drop); Store_field (rv, 3, v); - v = caml_copy_int64 (stats.tx_bytes); Store_field (rv, 4, v); - v = caml_copy_int64 (stats.tx_packets); Store_field (rv, 5, v); - v = caml_copy_int64 (stats.tx_errs); Store_field (rv, 6, v); - v = caml_copy_int64 (stats.tx_drop); Store_field (rv, 7, v); + /* So that we don't double-free in the finalizer: */ + Network_val (netv) = NULL; - CAMLreturn (rv); -#else - NOT_SUPPORTED ("virDomainInterfaceStats"); -#endif + CAMLreturn (Val_unit); } +/* Automatically generated binding for virNetworkLookupByName. + * In generator.pl this function has signature "conn, string : net". + */ + CAMLprim value -ocaml_libvirt_network_lookup_by_name (value connv, value namev) +ocaml_libvirt_network_lookup_by_name (value connv, value strv) { - CAMLparam2 (connv, namev); + CAMLparam2 (connv, strv); + CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); - char *name = String_val (namev); + char *str = String_val (strv); virNetworkPtr r; - r = virNetworkLookupByName (conn, name); + NONBLOCKING (r = virNetworkLookupByName (conn, str)); CHECK_ERROR (!r, conn, "virNetworkLookupByName"); rv = Val_network (r, connv); + CAMLreturn (rv); } +/* Automatically generated binding for virNetworkLookupByUUID. + * In generator.pl this function has signature "conn, uuid : net". + */ + CAMLprim value ocaml_libvirt_network_lookup_by_uuid (value connv, value uuidv) { CAMLparam2 (connv, uuidv); + CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); - char *uuid = String_val (uuidv); + unsigned char *uuid = (unsigned char *) String_val (uuidv); virNetworkPtr r; - r = virNetworkLookupByUUID (conn, (unsigned char *) uuid); + NONBLOCKING (r = virNetworkLookupByUUID (conn, uuid)); CHECK_ERROR (!r, conn, "virNetworkLookupByUUID"); rv = Val_network (r, connv); + CAMLreturn (rv); } +/* Automatically generated binding for virNetworkLookupByUUIDString. + * In generator.pl this function has signature "conn, string : net". + */ + CAMLprim value -ocaml_libvirt_network_lookup_by_uuid_string (value connv, value uuidv) +ocaml_libvirt_network_lookup_by_uuid_string (value connv, value strv) { - CAMLparam2 (connv, uuidv); + CAMLparam2 (connv, strv); + CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); - char *uuid = String_val (uuidv); + char *str = String_val (strv); virNetworkPtr r; - r = virNetworkLookupByUUIDString (conn, uuid); + NONBLOCKING (r = virNetworkLookupByUUIDString (conn, str)); CHECK_ERROR (!r, conn, "virNetworkLookupByUUIDString"); rv = Val_network (r, connv); + CAMLreturn (rv); } +/* Automatically generated binding for virNetworkGetName. + * In generator.pl this function has signature "net : static string". + */ + CAMLprim value -ocaml_libvirt_network_create_xml (value connv, value xmlv) +ocaml_libvirt_network_get_name (value netv) { - CAMLparam2 (connv, xmlv); + CAMLparam1 (netv); + CAMLlocal1 (rv); - virConnectPtr conn = Connect_val (connv); - char *xml = String_val (xmlv); - virNetworkPtr r; + virNetworkPtr net = Network_val (netv); + virConnectPtr conn = Connect_netv (netv); + const char *r; - r = virNetworkCreateXML (conn, xml); - CHECK_ERROR (!r, conn, "virNetworkCreateXML"); + NONBLOCKING (r = virNetworkGetName (net)); + CHECK_ERROR (!r, conn, "virNetworkGetName"); - rv = Val_network (r, connv); + rv = caml_copy_string (r); CAMLreturn (rv); } +/* Automatically generated binding for virNetworkGetXMLDesc. + * In generator.pl this function has signature "net, 0 : string". + */ + CAMLprim value -ocaml_libvirt_network_define_xml (value connv, value xmlv) +ocaml_libvirt_network_get_xml_desc (value netv) { - CAMLparam2 (connv, xmlv); + CAMLparam1 (netv); + CAMLlocal1 (rv); - virConnectPtr conn = Connect_val (connv); - char *xml = String_val (xmlv); - virNetworkPtr r; + virNetworkPtr net = Network_val (netv); + virConnectPtr conn = Connect_netv (netv); + char *r; - r = virNetworkDefineXML (conn, xml); - CHECK_ERROR (!r, conn, "virNetworkDefineXML"); + NONBLOCKING (r = virNetworkGetXMLDesc (net, 0)); + CHECK_ERROR (!r, conn, "virNetworkGetXMLDesc"); - rv = Val_network (r, connv); + rv = caml_copy_string (r); + free (r); CAMLreturn (rv); } +/* Automatically generated binding for virNetworkGetBridgeName. + * In generator.pl this function has signature "net : string". + */ + CAMLprim value -ocaml_libvirt_network_undefine (value netv) +ocaml_libvirt_network_get_bridge_name (value netv) { CAMLparam1 (netv); + + CAMLlocal1 (rv); virNetworkPtr net = Network_val (netv); virConnectPtr conn = Connect_netv (netv); - int r; + char *r; - r = virNetworkUndefine (net); - CHECK_ERROR (r == -1, conn, "virNetworkUndefine"); + NONBLOCKING (r = virNetworkGetBridgeName (net)); + CHECK_ERROR (!r, conn, "virNetworkGetBridgeName"); - CAMLreturn (Val_unit); + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); } +/* Automatically generated binding for virNetworkGetUUID. + * In generator.pl this function has signature "net : uuid". + */ + CAMLprim value -ocaml_libvirt_network_create (value netv) +ocaml_libvirt_network_get_uuid (value netv) { CAMLparam1 (netv); + + CAMLlocal1 (rv); virNetworkPtr net = Network_val (netv); virConnectPtr conn = Connect_netv (netv); + unsigned char uuid[VIR_UUID_BUFLEN]; int r; - r = virNetworkCreate (net); - CHECK_ERROR (r == -1, conn, "virNetworkCreate"); + NONBLOCKING (r = virNetworkGetUUID (net, uuid)); + CHECK_ERROR (r == -1, conn, "virNetworkGetUUID"); - CAMLreturn (Val_unit); + /* UUIDs are byte arrays with a fixed length. */ + rv = caml_alloc_string (VIR_UUID_BUFLEN); + memcpy (String_val (rv), uuid, VIR_UUID_BUFLEN); + CAMLreturn (rv); } +/* Automatically generated binding for virNetworkGetUUIDString. + * In generator.pl this function has signature "net : uuid string". + */ + CAMLprim value -ocaml_libvirt_network_destroy (value netv) +ocaml_libvirt_network_get_uuid_string (value netv) { CAMLparam1 (netv); + + CAMLlocal1 (rv); virNetworkPtr net = Network_val (netv); virConnectPtr conn = Connect_netv (netv); + char uuid[VIR_UUID_STRING_BUFLEN]; int r; - r = virNetworkDestroy (net); - CHECK_ERROR (r == -1, conn, "virNetworkDestroy"); - - /* So that we don't double-free in the finalizer: */ - Network_val (netv) = NULL; + NONBLOCKING (r = virNetworkGetUUIDString (net, uuid)); + CHECK_ERROR (r == -1, conn, "virNetworkGetUUIDString"); - CAMLreturn (Val_unit); + rv = caml_copy_string (uuid); + CAMLreturn (rv); } +/* Automatically generated binding for virNetworkUndefine. + * In generator.pl this function has signature "net : unit". + */ + CAMLprim value -ocaml_libvirt_network_free (value netv) +ocaml_libvirt_network_undefine (value netv) { CAMLparam1 (netv); + virNetworkPtr net = Network_val (netv); virConnectPtr conn = Connect_netv (netv); int r; - r = virNetworkFree (net); - CHECK_ERROR (r == -1, conn, "virNetworkFree"); - - /* So that we don't double-free in the finalizer: */ - Network_val (netv) = NULL; + NONBLOCKING (r = virNetworkUndefine (net)); + CHECK_ERROR (r == -1, conn, "virNetworkUndefine"); CAMLreturn (Val_unit); } +/* Automatically generated binding for virNetworkCreateXML. + * In generator.pl this function has signature "conn, string : net". + */ + CAMLprim value -ocaml_libvirt_network_get_name (value netv) +ocaml_libvirt_network_create_xml (value connv, value strv) { - CAMLparam1 (netv); + CAMLparam2 (connv, strv); + CAMLlocal1 (rv); - virNetworkPtr net = Network_val (netv); - virConnectPtr conn = Connect_netv (netv); - const char *r; + virConnectPtr conn = Connect_val (connv); + char *str = String_val (strv); + virNetworkPtr r; - r = virNetworkGetName (net); - CHECK_ERROR (!r, conn, "virNetworkGetName"); + NONBLOCKING (r = virNetworkCreateXML (conn, str)); + CHECK_ERROR (!r, conn, "virNetworkCreateXML"); + + rv = Val_network (r, connv); - rv = caml_copy_string (r); CAMLreturn (rv); } +/* Automatically generated binding for virNetworkCreateXMLJob. + * In generator.pl this function has signature "conn, string : job". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRNETWORKCREATEXMLJOB +extern virJobPtr virNetworkCreateXMLJob (virConnectPtr conn, const char *str) __attribute__((weak)); +#endif +#endif + CAMLprim value -ocaml_libvirt_network_get_uuid (value netv) +ocaml_libvirt_network_create_xml_job (value connv, value strv) { - CAMLparam1 (netv); + CAMLparam2 (connv, strv); +#ifndef HAVE_VIRNETWORKCREATEXMLJOB + /* Symbol virNetworkCreateXMLJob not found at compile time. */ + not_supported ("virNetworkCreateXMLJob"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virNetworkCreateXMLJob + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virNetworkCreateXMLJob); + CAMLlocal1 (rv); - virNetworkPtr net = Network_val (netv); - virConnectPtr conn = Connect_netv (netv); - unsigned char uuid[VIR_UUID_BUFLEN]; - int r; + virConnectPtr conn = Connect_val (connv); + char *str = String_val (strv); + virJobPtr r; - r = virNetworkGetUUID (net, uuid); - CHECK_ERROR (r == -1, conn, "virNetworkGetUUID"); + NONBLOCKING (r = virNetworkCreateXMLJob (conn, str)); + CHECK_ERROR (!r, conn, "virNetworkCreateXMLJob"); + + rv = Val_job (r, connv); - rv = caml_copy_string ((char *) uuid); CAMLreturn (rv); +#endif } +/* Automatically generated binding for virNetworkDefineXML. + * In generator.pl this function has signature "conn, string : net". + */ + CAMLprim value -ocaml_libvirt_network_get_uuid_string (value netv) +ocaml_libvirt_network_define_xml (value connv, value strv) { - CAMLparam1 (netv); + CAMLparam2 (connv, strv); + CAMLlocal1 (rv); - virNetworkPtr net = Network_val (netv); - virConnectPtr conn = Connect_netv (netv); - char uuid[VIR_UUID_STRING_BUFLEN]; - int r; + virConnectPtr conn = Connect_val (connv); + char *str = String_val (strv); + virNetworkPtr r; - r = virNetworkGetUUIDString (net, uuid); - CHECK_ERROR (r == -1, conn, "virNetworkGetUUIDString"); + NONBLOCKING (r = virNetworkDefineXML (conn, str)); + CHECK_ERROR (!r, conn, "virNetworkDefineXML"); + + rv = Val_network (r, connv); - rv = caml_copy_string (uuid); CAMLreturn (rv); } +/* Automatically generated binding for virNetworkCreate. + * In generator.pl this function has signature "net : unit". + */ + CAMLprim value -ocaml_libvirt_network_get_xml_desc (value netv) +ocaml_libvirt_network_create (value netv) { CAMLparam1 (netv); - CAMLlocal1 (rv); + virNetworkPtr net = Network_val (netv); virConnectPtr conn = Connect_netv (netv); - char *r; + int r; - r = virNetworkGetXMLDesc (net, 0); - CHECK_ERROR (!r, conn, "virNetworkGetXMLDesc"); + NONBLOCKING (r = virNetworkCreate (net)); + CHECK_ERROR (r == -1, conn, "virNetworkCreate"); - rv = caml_copy_string (r); - free (r); - CAMLreturn (rv); + CAMLreturn (Val_unit); } +/* Automatically generated binding for virNetworkCreateJob. + * In generator.pl this function has signature "net : job from net". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRNETWORKCREATEJOB +extern virJobPtr virNetworkCreateJob (virNetworkPtr net) __attribute__((weak)); +#endif +#endif + CAMLprim value -ocaml_libvirt_network_get_bridge_name (value netv) +ocaml_libvirt_network_create_job (value netv) { CAMLparam1 (netv); - CAMLlocal1 (rv); +#ifndef HAVE_VIRNETWORKCREATEJOB + /* Symbol virNetworkCreateJob not found at compile time. */ + not_supported ("virNetworkCreateJob"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virNetworkCreateJob + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virNetworkCreateJob); + + CAMLlocal2 (rv, connv); virNetworkPtr net = Network_val (netv); virConnectPtr conn = Connect_netv (netv); - char *r; + virJobPtr r; - r = virNetworkGetBridgeName (net); - CHECK_ERROR (!r, conn, "virNetworkGetBridgeName"); + NONBLOCKING (r = virNetworkCreateJob (net)); + CHECK_ERROR (!r, conn, "virNetworkCreateJob"); + + connv = Field (netv, 1); + rv = Val_job (r, connv); - rv = caml_copy_string (r); - free (r); CAMLreturn (rv); +#endif } +/* Automatically generated binding for virNetworkGetAutostart. + * In generator.pl this function has signature "net : bool". + */ + CAMLprim value ocaml_libvirt_network_get_autostart (value netv) { CAMLparam1 (netv); + virNetworkPtr net = Network_val (netv); virConnectPtr conn = Connect_netv (netv); - int r, autostart; + int r, b; - r = virNetworkGetAutostart (net, &autostart); + NONBLOCKING (r = virNetworkGetAutostart (net, &b)); CHECK_ERROR (r == -1, conn, "virNetworkGetAutostart"); - CAMLreturn (autostart ? Val_true : Val_false); + CAMLreturn (b ? Val_true : Val_false); } +/* Automatically generated binding for virNetworkSetAutostart. + * In generator.pl this function has signature "net, bool : unit". + */ + CAMLprim value -ocaml_libvirt_network_set_autostart (value netv, value autostartv) +ocaml_libvirt_network_set_autostart (value netv, value bv) { - CAMLparam2 (netv, autostartv); + CAMLparam2 (netv, bv); + virNetworkPtr net = Network_val (netv); virConnectPtr conn = Connect_netv (netv); - int r, autostart = autostartv == Val_true ? 1 : 0; + int r, b; - r = virNetworkSetAutostart (net, autostart); + b = bv == Val_true ? 1 : 0; + + NONBLOCKING (r = virNetworkSetAutostart (net, b)); CHECK_ERROR (r == -1, conn, "virNetworkSetAutostart"); CAMLreturn (Val_unit); } -/*----------------------------------------------------------------------*/ - -CAMLprim value -ocaml_libvirt_virterror_get_last_error (value unitv) -{ - CAMLparam1 (unitv); - CAMLlocal1 (rv); - virErrorPtr err = virGetLastError (); - - rv = Val_opt (err, (Val_ptr_t) Val_virterror); +/* Automatically generated binding for virStoragePoolFree. + * In generator.pl this function has signature "pool : free". + */ - CAMLreturn (rv); -} +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLFREE +extern int virStoragePoolFree (virStoragePoolPtr pool) __attribute__((weak)); +#endif +#endif CAMLprim value -ocaml_libvirt_virterror_get_last_conn_error (value connv) +ocaml_libvirt_storage_pool_free (value poolv) { - CAMLparam1 (connv); - CAMLlocal1 (rv); - virConnectPtr conn = Connect_val (connv); + CAMLparam1 (poolv); +#ifndef HAVE_VIRSTORAGEPOOLFREE + /* Symbol virStoragePoolFree not found at compile time. */ + not_supported ("virStoragePoolFree"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolFree + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolFree); + + virStoragePoolPtr pool = Pool_val (poolv); + virConnectPtr conn = Connect_polv (poolv); + int r; - rv = Val_opt (conn, (Val_ptr_t) Val_connect); + NONBLOCKING (r = virStoragePoolFree (pool)); + CHECK_ERROR (r == -1, conn, "virStoragePoolFree"); - CAMLreturn (rv); -} + /* So that we don't double-free in the finalizer: */ + Pool_val (poolv) = NULL; -CAMLprim value -ocaml_libvirt_virterror_reset_last_error (value unitv) -{ - CAMLparam1 (unitv); - virResetLastError (); CAMLreturn (Val_unit); +#endif } -CAMLprim value -ocaml_libvirt_virterror_reset_last_conn_error (value connv) -{ - CAMLparam1 (connv); - virConnectPtr conn = Connect_val (connv); - virConnResetLastError (conn); - CAMLreturn (Val_unit); -} +/* Automatically generated binding for virStoragePoolDestroy. + * In generator.pl this function has signature "pool : free". + */ -/*----------------------------------------------------------------------*/ +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLDESTROY +extern int virStoragePoolDestroy (virStoragePoolPtr pool) __attribute__((weak)); +#endif +#endif -/* Initialise the library. */ CAMLprim value -ocaml_libvirt_init (value unit) +ocaml_libvirt_storage_pool_destroy (value poolv) { - CAMLparam1 (unit); - CAMLlocal1 (rv); + CAMLparam1 (poolv); +#ifndef HAVE_VIRSTORAGEPOOLDESTROY + /* Symbol virStoragePoolDestroy not found at compile time. */ + not_supported ("virStoragePoolDestroy"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolDestroy + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolDestroy); + + virStoragePoolPtr pool = Pool_val (poolv); + virConnectPtr conn = Connect_polv (poolv); int r; - r = virInitialize (); - CHECK_ERROR (r == -1, NULL, "virInitialize"); + NONBLOCKING (r = virStoragePoolDestroy (pool)); + CHECK_ERROR (r == -1, conn, "virStoragePoolDestroy"); + + /* So that we don't double-free in the finalizer: */ + Pool_val (poolv) = NULL; CAMLreturn (Val_unit); +#endif } -/*----------------------------------------------------------------------*/ +/* Automatically generated binding for virStoragePoolLookupByName. + * In generator.pl this function has signature "conn, string : pool". + */ -static char * -Optstring_val (value strv) -{ - if (strv == Val_int (0)) /* None */ - return NULL; - else /* Some string */ - return String_val (Field (strv, 0)); -} +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYNAME +extern virStoragePoolPtr virStoragePoolLookupByName (virConnectPtr conn, const char *str) __attribute__((weak)); +#endif +#endif -static value -Val_opt (void *ptr, Val_ptr_t Val_ptr) +CAMLprim value +ocaml_libvirt_storage_pool_lookup_by_name (value connv, value strv) { - CAMLparam0 (); - CAMLlocal2 (optv, ptrv); + CAMLparam2 (connv, strv); +#ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYNAME + /* Symbol virStoragePoolLookupByName not found at compile time. */ + not_supported ("virStoragePoolLookupByName"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolLookupByName + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolLookupByName); - if (ptr) { /* Some ptr */ - optv = caml_alloc (1, 0); - ptrv = Val_ptr (ptr); - Store_field (optv, 0, ptrv); - } else /* None */ - optv = Val_int (0); + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + char *str = String_val (strv); + virStoragePoolPtr r; - CAMLreturn (optv); -} + NONBLOCKING (r = virStoragePoolLookupByName (conn, str)); + CHECK_ERROR (!r, conn, "virStoragePoolLookupByName"); -#if 0 -static value -option_default (value option, value deflt) -{ - if (option == Val_int (0)) /* "None" */ - return deflt; - else /* "Some 'a" */ - return Field (option, 0); + rv = Val_pool (r, connv); + + CAMLreturn (rv); +#endif } + +/* Automatically generated binding for virStoragePoolLookupByUUID. + * In generator.pl this function has signature "conn, uuid : pool". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYUUID +extern virStoragePoolPtr virStoragePoolLookupByUUID (virConnectPtr conn, const unsigned char *str) __attribute__((weak)); +#endif #endif -static value -_raise_virterror (virConnectPtr conn, const char *fn) +CAMLprim value +ocaml_libvirt_storage_pool_lookup_by_uuid (value connv, value uuidv) { - CAMLparam0 (); - CAMLlocal1 (rv); - virErrorPtr errp; - struct _virError err; - - errp = conn ? virConnGetLastError (conn) : virGetLastError (); - - if (!errp) { - /* Fake a _virError structure. */ - memset (&err, 0, sizeof err); - err.code = VIR_ERR_INTERNAL_ERROR; - err.domain = VIR_FROM_NONE; - err.level = VIR_ERR_ERROR; - err.message = (char *) fn; - errp = &err; - } - - rv = Val_virterror (errp); - caml_raise_with_arg (*caml_named_value ("ocaml_libvirt_virterror"), rv); + CAMLparam2 (connv, uuidv); +#ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYUUID + /* Symbol virStoragePoolLookupByUUID not found at compile time. */ + not_supported ("virStoragePoolLookupByUUID"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolLookupByUUID + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolLookupByUUID); - /*NOTREACHED*/ - CAMLreturn (Val_unit); -} + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + unsigned char *uuid = (unsigned char *) String_val (uuidv); + virStoragePoolPtr r; -static value -Val_virterror (virErrorPtr err) -{ - CAMLparam0 (); - CAMLlocal3 (rv, connv, optv); - - rv = caml_alloc (12, 0); - Store_field (rv, 0, Val_int (err->code)); - Store_field (rv, 1, Val_int (err->domain)); - Store_field (rv, 2, - Val_opt (err->message, (Val_ptr_t) caml_copy_string)); - Store_field (rv, 3, Val_int (err->level)); - - /* conn, dom and net fields, all optional */ - if (err->conn) { - connv = Val_connect_no_finalize (err->conn); - optv = caml_alloc (1, 0); - Store_field (optv, 0, connv); - Store_field (rv, 4, optv); /* Some conn */ - - if (err->dom) { - optv = caml_alloc (1, 0); - Store_field (optv, 0, Val_domain_no_finalize (err->dom, connv)); - Store_field (rv, 5, optv); /* Some (dom, conn) */ - } - else - Store_field (rv, 5, Val_int (0)); /* None */ - if (err->net) { - optv = caml_alloc (1, 0); - Store_field (optv, 0, Val_network_no_finalize (err->net, connv)); - Store_field (rv, 11, optv); /* Some (net, conn) */ - } else - Store_field (rv, 11, Val_int (0)); /* None */ - } else { - Store_field (rv, 4, Val_int (0)); /* None */ - Store_field (rv, 5, Val_int (0)); /* None */ - Store_field (rv, 11, Val_int (0)); /* None */ - } + NONBLOCKING (r = virStoragePoolLookupByUUID (conn, uuid)); + CHECK_ERROR (!r, conn, "virStoragePoolLookupByUUID"); - Store_field (rv, 6, - Val_opt (err->str1, (Val_ptr_t) caml_copy_string)); - Store_field (rv, 7, - Val_opt (err->str2, (Val_ptr_t) caml_copy_string)); - Store_field (rv, 8, - Val_opt (err->str3, (Val_ptr_t) caml_copy_string)); - Store_field (rv, 9, caml_copy_int32 (err->int1)); - Store_field (rv, 10, caml_copy_int32 (err->int2)); + rv = Val_pool (r, connv); CAMLreturn (rv); +#endif } -static void conn_finalize (value); -static void dom_finalize (value); -static void net_finalize (value); - -static struct custom_operations conn_custom_operations = { - "conn_custom_operations", - conn_finalize, - custom_compare_default, - custom_hash_default, - custom_serialize_default, - custom_deserialize_default -}; - -static struct custom_operations dom_custom_operations = { - "dom_custom_operations", - dom_finalize, - custom_compare_default, - custom_hash_default, - custom_serialize_default, - custom_deserialize_default - -}; - -static struct custom_operations net_custom_operations = { - "net_custom_operations", - net_finalize, - custom_compare_default, - custom_hash_default, - custom_serialize_default, - custom_deserialize_default -}; - -static value -Val_connect (virConnectPtr conn) -{ - CAMLparam0 (); - CAMLlocal1 (rv); - rv = caml_alloc_custom (&conn_custom_operations, - sizeof (virConnectPtr), 0, 1); - Connect_val (rv) = conn; - CAMLreturn (rv); -} +/* Automatically generated binding for virStoragePoolLookupByUUIDString. + * In generator.pl this function has signature "conn, string : pool". + */ -/* This wraps up the raw domain handle (Domain.dom). */ -static value -Val_dom (virDomainPtr dom) -{ - CAMLparam0 (); - CAMLlocal1 (rv); - rv = caml_alloc_custom (&dom_custom_operations, - sizeof (virDomainPtr), 0, 1); - Dom_val (rv) = dom; - CAMLreturn (rv); -} +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYUUIDSTRING +extern virStoragePoolPtr virStoragePoolLookupByUUIDString (virConnectPtr conn, const char *str) __attribute__((weak)); +#endif +#endif -/* This wraps up the raw network handle (Network.net). */ -static value -Val_net (virNetworkPtr net) +CAMLprim value +ocaml_libvirt_storage_pool_lookup_by_uuid_string (value connv, value strv) { - CAMLparam0 (); + CAMLparam2 (connv, strv); +#ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYUUIDSTRING + /* Symbol virStoragePoolLookupByUUIDString not found at compile time. */ + not_supported ("virStoragePoolLookupByUUIDString"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolLookupByUUIDString + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolLookupByUUIDString); + CAMLlocal1 (rv); - rv = caml_alloc_custom (&net_custom_operations, - sizeof (virNetworkPtr), 0, 1); - Net_val (rv) = net; + virConnectPtr conn = Connect_val (connv); + char *str = String_val (strv); + virStoragePoolPtr r; + + NONBLOCKING (r = virStoragePoolLookupByUUIDString (conn, str)); + CHECK_ERROR (!r, conn, "virStoragePoolLookupByUUIDString"); + + rv = Val_pool (r, connv); + CAMLreturn (rv); +#endif } -/* No-finalize versions of Val_connect, Val_dom, Val_net ONLY for use - * by virterror wrappers. +/* Automatically generated binding for virStoragePoolGetName. + * In generator.pl this function has signature "pool : static string". */ -static value -Val_connect_no_finalize (virConnectPtr conn) -{ - CAMLparam0 (); - CAMLlocal1 (rv); - rv = caml_alloc (1, Abstract_tag); - Store_field (rv, 0, (value) conn); - CAMLreturn (rv); -} -static value -Val_dom_no_finalize (virDomainPtr dom) -{ - CAMLparam0 (); - CAMLlocal1 (rv); - rv = caml_alloc (1, Abstract_tag); - Store_field (rv, 0, (value) dom); - CAMLreturn (rv); -} +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLGETNAME +extern const char *virStoragePoolGetName (virStoragePoolPtr pool) __attribute__((weak)); +#endif +#endif -static value -Val_net_no_finalize (virNetworkPtr net) +CAMLprim value +ocaml_libvirt_storage_pool_get_name (value poolv) { - CAMLparam0 (); + CAMLparam1 (poolv); +#ifndef HAVE_VIRSTORAGEPOOLGETNAME + /* Symbol virStoragePoolGetName not found at compile time. */ + not_supported ("virStoragePoolGetName"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolGetName + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolGetName); + CAMLlocal1 (rv); - rv = caml_alloc (1, Abstract_tag); - Store_field (rv, 0, (value) net); - CAMLreturn (rv); -} + virStoragePoolPtr pool = Pool_val (poolv); + virConnectPtr conn = Connect_polv (poolv); + const char *r; -/* This wraps up the (dom, conn) pair (Domain.t). */ -static value -Val_domain (virDomainPtr dom, value connv) -{ - CAMLparam1 (connv); - CAMLlocal2 (rv, v); + NONBLOCKING (r = virStoragePoolGetName (pool)); + CHECK_ERROR (!r, conn, "virStoragePoolGetName"); - rv = caml_alloc_tuple (2); - v = Val_dom (dom); - Store_field (rv, 0, v); - Store_field (rv, 1, connv); + rv = caml_copy_string (r); CAMLreturn (rv); +#endif } -/* This wraps up the (net, conn) pair (Network.t). */ -static value -Val_network (virNetworkPtr net, value connv) +/* Automatically generated binding for virStoragePoolGetXMLDesc. + * In generator.pl this function has signature "pool, 0 : string". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLGETXMLDESC +extern char *virStoragePoolGetXMLDesc (virStoragePoolPtr pool, int flags) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_pool_get_xml_desc (value poolv) { - CAMLparam1 (connv); - CAMLlocal2 (rv, v); + CAMLparam1 (poolv); +#ifndef HAVE_VIRSTORAGEPOOLGETXMLDESC + /* Symbol virStoragePoolGetXMLDesc not found at compile time. */ + not_supported ("virStoragePoolGetXMLDesc"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolGetXMLDesc + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolGetXMLDesc); + + CAMLlocal1 (rv); + virStoragePoolPtr pool = Pool_val (poolv); + virConnectPtr conn = Connect_polv (poolv); + char *r; + + NONBLOCKING (r = virStoragePoolGetXMLDesc (pool, 0)); + CHECK_ERROR (!r, conn, "virStoragePoolGetXMLDesc"); - rv = caml_alloc_tuple (2); - v = Val_net (net); - Store_field (rv, 0, v); - Store_field (rv, 1, connv); + rv = caml_copy_string (r); + free (r); CAMLreturn (rv); +#endif } -/* No-finalize versions of Val_domain, Val_network ONLY for use by - * virterror wrappers. +/* Automatically generated binding for virStoragePoolGetUUID. + * In generator.pl this function has signature "pool : uuid". */ -static value -Val_domain_no_finalize (virDomainPtr dom, value connv) -{ - CAMLparam1 (connv); - CAMLlocal2 (rv, v); - rv = caml_alloc_tuple (2); - v = Val_dom_no_finalize (dom); - Store_field (rv, 0, v); - Store_field (rv, 1, connv); - CAMLreturn (rv); -} +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLGETUUID +extern int virStoragePoolGetUUID (virStoragePoolPtr pool, unsigned char *) __attribute__((weak)); +#endif +#endif -static value -Val_network_no_finalize (virNetworkPtr net, value connv) +CAMLprim value +ocaml_libvirt_storage_pool_get_uuid (value poolv) { - CAMLparam1 (connv); - CAMLlocal2 (rv, v); + CAMLparam1 (poolv); +#ifndef HAVE_VIRSTORAGEPOOLGETUUID + /* Symbol virStoragePoolGetUUID not found at compile time. */ + not_supported ("virStoragePoolGetUUID"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolGetUUID + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolGetUUID); - rv = caml_alloc_tuple (2); - v = Val_net_no_finalize (net); - Store_field (rv, 0, v); - Store_field (rv, 1, connv); + CAMLlocal1 (rv); + virStoragePoolPtr pool = Pool_val (poolv); + virConnectPtr conn = Connect_polv (poolv); + unsigned char uuid[VIR_UUID_BUFLEN]; + int r; + + NONBLOCKING (r = virStoragePoolGetUUID (pool, uuid)); + CHECK_ERROR (r == -1, conn, "virStoragePoolGetUUID"); + + /* UUIDs are byte arrays with a fixed length. */ + rv = caml_alloc_string (VIR_UUID_BUFLEN); + memcpy (String_val (rv), uuid, VIR_UUID_BUFLEN); CAMLreturn (rv); +#endif } -static void -conn_finalize (value connv) -{ - virConnectPtr conn = Connect_val (connv); - if (conn) (void) virConnectClose (conn); -} +/* Automatically generated binding for virStoragePoolGetUUIDString. + * In generator.pl this function has signature "pool : uuid string". + */ -static void -dom_finalize (value domv) -{ - virDomainPtr dom = Dom_val (domv); - if (dom) (void) virDomainFree (dom); -} +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLGETUUIDSTRING +extern int virStoragePoolGetUUIDString (virStoragePoolPtr pool, char *) __attribute__((weak)); +#endif +#endif -static void -net_finalize (value netv) +CAMLprim value +ocaml_libvirt_storage_pool_get_uuid_string (value poolv) { - virNetworkPtr net = Net_val (netv); - if (net) (void) virNetworkFree (net); + CAMLparam1 (poolv); +#ifndef HAVE_VIRSTORAGEPOOLGETUUIDSTRING + /* Symbol virStoragePoolGetUUIDString not found at compile time. */ + not_supported ("virStoragePoolGetUUIDString"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolGetUUIDString + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolGetUUIDString); + + CAMLlocal1 (rv); + virStoragePoolPtr pool = Pool_val (poolv); + virConnectPtr conn = Connect_polv (poolv); + char uuid[VIR_UUID_STRING_BUFLEN]; + int r; + + NONBLOCKING (r = virStoragePoolGetUUIDString (pool, uuid)); + CHECK_ERROR (r == -1, conn, "virStoragePoolGetUUIDString"); + + rv = caml_copy_string (uuid); + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virStoragePoolCreateXML. + * In generator.pl this function has signature "conn, string : pool". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLCREATEXML +extern virStoragePoolPtr virStoragePoolCreateXML (virConnectPtr conn, const char *str) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_pool_create_xml (value connv, value strv) +{ + CAMLparam2 (connv, strv); +#ifndef HAVE_VIRSTORAGEPOOLCREATEXML + /* Symbol virStoragePoolCreateXML not found at compile time. */ + not_supported ("virStoragePoolCreateXML"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolCreateXML + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolCreateXML); + + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + char *str = String_val (strv); + virStoragePoolPtr r; + + NONBLOCKING (r = virStoragePoolCreateXML (conn, str)); + CHECK_ERROR (!r, conn, "virStoragePoolCreateXML"); + + rv = Val_pool (r, connv); + + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virStoragePoolDefineXML. + * In generator.pl this function has signature "conn, string : pool". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLDEFINEXML +extern virStoragePoolPtr virStoragePoolDefineXML (virConnectPtr conn, const char *str) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_pool_define_xml (value connv, value strv) +{ + CAMLparam2 (connv, strv); +#ifndef HAVE_VIRSTORAGEPOOLDEFINEXML + /* Symbol virStoragePoolDefineXML not found at compile time. */ + not_supported ("virStoragePoolDefineXML"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolDefineXML + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolDefineXML); + + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + char *str = String_val (strv); + virStoragePoolPtr r; + + NONBLOCKING (r = virStoragePoolDefineXML (conn, str)); + CHECK_ERROR (!r, conn, "virStoragePoolDefineXML"); + + rv = Val_pool (r, connv); + + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virStoragePoolUndefine. + * In generator.pl this function has signature "pool : unit". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLUNDEFINE +extern int virStoragePoolUndefine (virStoragePoolPtr pool) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_pool_undefine (value poolv) +{ + CAMLparam1 (poolv); +#ifndef HAVE_VIRSTORAGEPOOLUNDEFINE + /* Symbol virStoragePoolUndefine not found at compile time. */ + not_supported ("virStoragePoolUndefine"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolUndefine + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolUndefine); + + virStoragePoolPtr pool = Pool_val (poolv); + virConnectPtr conn = Connect_polv (poolv); + int r; + + NONBLOCKING (r = virStoragePoolUndefine (pool)); + CHECK_ERROR (r == -1, conn, "virStoragePoolUndefine"); + + CAMLreturn (Val_unit); +#endif } + +/* Automatically generated binding for virStoragePoolCreate. + * In generator.pl this function has signature "pool : unit". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLCREATE +extern int virStoragePoolCreate (virStoragePoolPtr pool) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_pool_create (value poolv) +{ + CAMLparam1 (poolv); +#ifndef HAVE_VIRSTORAGEPOOLCREATE + /* Symbol virStoragePoolCreate not found at compile time. */ + not_supported ("virStoragePoolCreate"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolCreate + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolCreate); + + virStoragePoolPtr pool = Pool_val (poolv); + virConnectPtr conn = Connect_polv (poolv); + int r; + + NONBLOCKING (r = virStoragePoolCreate (pool)); + CHECK_ERROR (r == -1, conn, "virStoragePoolCreate"); + + CAMLreturn (Val_unit); +#endif +} + +/* Automatically generated binding for virStoragePoolShutdown. + * In generator.pl this function has signature "pool : unit". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLSHUTDOWN +extern int virStoragePoolShutdown (virStoragePoolPtr pool) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_pool_shutdown (value poolv) +{ + CAMLparam1 (poolv); +#ifndef HAVE_VIRSTORAGEPOOLSHUTDOWN + /* Symbol virStoragePoolShutdown not found at compile time. */ + not_supported ("virStoragePoolShutdown"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolShutdown + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolShutdown); + + virStoragePoolPtr pool = Pool_val (poolv); + virConnectPtr conn = Connect_polv (poolv); + int r; + + NONBLOCKING (r = virStoragePoolShutdown (pool)); + CHECK_ERROR (r == -1, conn, "virStoragePoolShutdown"); + + CAMLreturn (Val_unit); +#endif +} + +/* Automatically generated binding for virStoragePoolRefresh. + * In generator.pl this function has signature "pool, 0U : unit". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLREFRESH +extern int virStoragePoolRefresh (virStoragePoolPtr pool, unsigned int flags) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_pool_refresh (value poolv) +{ + CAMLparam1 (poolv); +#ifndef HAVE_VIRSTORAGEPOOLREFRESH + /* Symbol virStoragePoolRefresh not found at compile time. */ + not_supported ("virStoragePoolRefresh"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolRefresh + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolRefresh); + + virStoragePoolPtr pool = Pool_val (poolv); + virConnectPtr conn = Connect_polv (poolv); + int r; + + NONBLOCKING (r = virStoragePoolRefresh (pool, 0)); + CHECK_ERROR (r == -1, conn, "virStoragePoolRefresh"); + + CAMLreturn (Val_unit); +#endif +} + +/* Automatically generated binding for virStoragePoolGetAutostart. + * In generator.pl this function has signature "pool : bool". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLGETAUTOSTART +extern int virStoragePoolGetAutostart (virStoragePoolPtr pool, int *r) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_pool_get_autostart (value poolv) +{ + 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 virStoragePoolGetAutostart + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolGetAutostart); + + virStoragePoolPtr pool = Pool_val (poolv); + virConnectPtr conn = Connect_polv (poolv); + int r, b; + + NONBLOCKING (r = virStoragePoolGetAutostart (pool, &b)); + CHECK_ERROR (r == -1, conn, "virStoragePoolGetAutostart"); + + CAMLreturn (b ? Val_true : Val_false); +#endif +} + +/* Automatically generated binding for virStoragePoolSetAutostart. + * In generator.pl this function has signature "pool, bool : unit". + */ + +#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 +} + +/* Automatically generated binding for virStorageVolFree. + * In generator.pl this function has signature "vol : free". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEVOLFREE +extern int virStorageVolFree (virStorageVolPtr vol) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_vol_free (value volv) +{ + CAMLparam1 (volv); +#ifndef HAVE_VIRSTORAGEVOLFREE + /* Symbol virStorageVolFree not found at compile time. */ + not_supported ("virStorageVolFree"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStorageVolFree + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStorageVolFree); + + virStorageVolPtr vol = Volume_val (volv); + virConnectPtr conn = Connect_volv (volv); + int r; + + NONBLOCKING (r = virStorageVolFree (vol)); + CHECK_ERROR (r == -1, conn, "virStorageVolFree"); + + /* So that we don't double-free in the finalizer: */ + Volume_val (volv) = NULL; + + CAMLreturn (Val_unit); +#endif +} + +/* Automatically generated binding for virStorageVolDestroy. + * In generator.pl this function has signature "vol : free". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEVOLDESTROY +extern int virStorageVolDestroy (virStorageVolPtr vol) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_vol_destroy (value volv) +{ + CAMLparam1 (volv); +#ifndef HAVE_VIRSTORAGEVOLDESTROY + /* Symbol virStorageVolDestroy not found at compile time. */ + not_supported ("virStorageVolDestroy"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStorageVolDestroy + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStorageVolDestroy); + + virStorageVolPtr vol = Volume_val (volv); + virConnectPtr conn = Connect_volv (volv); + int r; + + NONBLOCKING (r = virStorageVolDestroy (vol)); + CHECK_ERROR (r == -1, conn, "virStorageVolDestroy"); + + /* So that we don't double-free in the finalizer: */ + Volume_val (volv) = NULL; + + CAMLreturn (Val_unit); +#endif +} + +/* Automatically generated binding for virStorageVolLookupByName. + * In generator.pl this function has signature "pool, string : vol from pool". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEVOLLOOKUPBYNAME +extern virStorageVolPtr virStorageVolLookupByName (virStoragePoolPtr pool, const char *str) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_vol_lookup_by_name (value poolv, value strv) +{ + CAMLparam2 (poolv, strv); +#ifndef HAVE_VIRSTORAGEVOLLOOKUPBYNAME + /* Symbol virStorageVolLookupByName not found at compile time. */ + not_supported ("virStorageVolLookupByName"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStorageVolLookupByName + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStorageVolLookupByName); + + CAMLlocal2 (rv, connv); + virStoragePoolPtr pool = Pool_val (poolv); + virConnectPtr conn = Connect_polv (poolv); + char *str = String_val (strv); + virStorageVolPtr r; + + NONBLOCKING (r = virStorageVolLookupByName (pool, str)); + CHECK_ERROR (!r, conn, "virStorageVolLookupByName"); + + connv = Field (poolv, 1); + rv = Val_volume (r, connv); + + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virStorageVolLookupByKey. + * In generator.pl this function has signature "conn, string : vol". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEVOLLOOKUPBYKEY +extern virStorageVolPtr virStorageVolLookupByKey (virConnectPtr conn, const char *str) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_vol_lookup_by_key (value connv, value strv) +{ + CAMLparam2 (connv, strv); +#ifndef HAVE_VIRSTORAGEVOLLOOKUPBYKEY + /* Symbol virStorageVolLookupByKey not found at compile time. */ + not_supported ("virStorageVolLookupByKey"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStorageVolLookupByKey + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStorageVolLookupByKey); + + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + char *str = String_val (strv); + virStorageVolPtr r; + + NONBLOCKING (r = virStorageVolLookupByKey (conn, str)); + CHECK_ERROR (!r, conn, "virStorageVolLookupByKey"); + + rv = Val_volume (r, connv); + + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virStorageVolLookupByPath. + * In generator.pl this function has signature "conn, string : vol". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEVOLLOOKUPBYPATH +extern virStorageVolPtr virStorageVolLookupByPath (virConnectPtr conn, const char *str) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_vol_lookup_by_path (value connv, value strv) +{ + CAMLparam2 (connv, strv); +#ifndef HAVE_VIRSTORAGEVOLLOOKUPBYPATH + /* Symbol virStorageVolLookupByPath not found at compile time. */ + not_supported ("virStorageVolLookupByPath"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStorageVolLookupByPath + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStorageVolLookupByPath); + + CAMLlocal1 (rv); + virConnectPtr conn = Connect_val (connv); + char *str = String_val (strv); + virStorageVolPtr r; + + NONBLOCKING (r = virStorageVolLookupByPath (conn, str)); + CHECK_ERROR (!r, conn, "virStorageVolLookupByPath"); + + rv = Val_volume (r, connv); + + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virStorageVolCreateXML. + * In generator.pl this function has signature "pool, string, 0 : vol from pool". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEVOLCREATEXML +extern virStorageVolPtr virStorageVolCreateXML (virStoragePoolPtr pool, const char *str, int flags) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_vol_create_xml (value poolv, value strv) +{ + CAMLparam2 (poolv, strv); +#ifndef HAVE_VIRSTORAGEVOLCREATEXML + /* Symbol virStorageVolCreateXML not found at compile time. */ + not_supported ("virStorageVolCreateXML"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStorageVolCreateXML + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStorageVolCreateXML); + + CAMLlocal2 (rv, connv); + virStoragePoolPtr pool = Pool_val (poolv); + virConnectPtr conn = Connect_polv (poolv); + char *str = String_val (strv); + virStorageVolPtr r; + + NONBLOCKING (r = virStorageVolCreateXML (pool, str, 0)); + CHECK_ERROR (!r, conn, "virStorageVolCreateXML"); + + connv = Field (poolv, 1); + rv = Val_volume (r, connv); + + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virStorageVolGetXMLDesc. + * In generator.pl this function has signature "vol, 0 : string". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEVOLGETXMLDESC +extern char *virStorageVolGetXMLDesc (virStorageVolPtr vol, int flags) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_vol_get_xml_desc (value volv) +{ + CAMLparam1 (volv); +#ifndef HAVE_VIRSTORAGEVOLGETXMLDESC + /* Symbol virStorageVolGetXMLDesc not found at compile time. */ + not_supported ("virStorageVolGetXMLDesc"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStorageVolGetXMLDesc + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStorageVolGetXMLDesc); + + CAMLlocal1 (rv); + virStorageVolPtr vol = Volume_val (volv); + virConnectPtr conn = Connect_volv (volv); + char *r; + + NONBLOCKING (r = virStorageVolGetXMLDesc (vol, 0)); + CHECK_ERROR (!r, conn, "virStorageVolGetXMLDesc"); + + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virStorageVolGetPath. + * In generator.pl this function has signature "vol : string". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEVOLGETPATH +extern char *virStorageVolGetPath (virStorageVolPtr vol) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_vol_get_path (value volv) +{ + CAMLparam1 (volv); +#ifndef HAVE_VIRSTORAGEVOLGETPATH + /* Symbol virStorageVolGetPath not found at compile time. */ + not_supported ("virStorageVolGetPath"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStorageVolGetPath + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStorageVolGetPath); + + CAMLlocal1 (rv); + virStorageVolPtr vol = Volume_val (volv); + virConnectPtr conn = Connect_volv (volv); + char *r; + + NONBLOCKING (r = virStorageVolGetPath (vol)); + CHECK_ERROR (!r, conn, "virStorageVolGetPath"); + + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virStorageVolGetKey. + * In generator.pl this function has signature "vol : static string". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEVOLGETKEY +extern const char *virStorageVolGetKey (virStorageVolPtr vol) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_vol_get_key (value volv) +{ + CAMLparam1 (volv); +#ifndef HAVE_VIRSTORAGEVOLGETKEY + /* Symbol virStorageVolGetKey not found at compile time. */ + not_supported ("virStorageVolGetKey"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStorageVolGetKey + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStorageVolGetKey); + + CAMLlocal1 (rv); + virStorageVolPtr vol = Volume_val (volv); + virConnectPtr conn = Connect_volv (volv); + const char *r; + + NONBLOCKING (r = virStorageVolGetKey (vol)); + CHECK_ERROR (!r, conn, "virStorageVolGetKey"); + + rv = caml_copy_string (r); + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virStorageVolGetName. + * In generator.pl this function has signature "vol : static string". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEVOLGETNAME +extern const char *virStorageVolGetName (virStorageVolPtr vol) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_vol_get_name (value volv) +{ + CAMLparam1 (volv); +#ifndef HAVE_VIRSTORAGEVOLGETNAME + /* Symbol virStorageVolGetName not found at compile time. */ + not_supported ("virStorageVolGetName"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStorageVolGetName + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStorageVolGetName); + + CAMLlocal1 (rv); + virStorageVolPtr vol = Volume_val (volv); + virConnectPtr conn = Connect_volv (volv); + const char *r; + + NONBLOCKING (r = virStorageVolGetName (vol)); + CHECK_ERROR (!r, conn, "virStorageVolGetName"); + + rv = caml_copy_string (r); + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virStoragePoolLookupByVolume. + * In generator.pl this function has signature "vol : pool from vol". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYVOLUME +extern virStoragePoolPtr virStoragePoolLookupByVolume (virStorageVolPtr vol) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_pool_lookup_by_volume (value volv) +{ + CAMLparam1 (volv); +#ifndef HAVE_VIRSTORAGEPOOLLOOKUPBYVOLUME + /* Symbol virStoragePoolLookupByVolume not found at compile time. */ + not_supported ("virStoragePoolLookupByVolume"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolLookupByVolume + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolLookupByVolume); + + CAMLlocal2 (rv, connv); + virStorageVolPtr vol = Volume_val (volv); + virConnectPtr conn = Connect_volv (volv); + virStoragePoolPtr r; + + NONBLOCKING (r = virStoragePoolLookupByVolume (vol)); + CHECK_ERROR (!r, conn, "virStoragePoolLookupByVolume"); + + connv = Field (volv, 1); + rv = Val_pool (r, connv); + + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virJobFree. + * In generator.pl this function has signature "job : free". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRJOBFREE +extern int virJobFree (virJobPtr job) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_job_free (value jobv) +{ + CAMLparam1 (jobv); +#ifndef HAVE_VIRJOBFREE + /* Symbol virJobFree not found at compile time. */ + not_supported ("virJobFree"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virJobFree + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virJobFree); + + virJobPtr job = Job_val (jobv); + virConnectPtr conn = Connect_jobv (jobv); + int r; + + NONBLOCKING (r = virJobFree (job)); + CHECK_ERROR (r == -1, conn, "virJobFree"); + + /* So that we don't double-free in the finalizer: */ + Job_val (jobv) = NULL; + + CAMLreturn (Val_unit); +#endif +} + +/* Automatically generated binding for virJobCancel. + * In generator.pl this function has signature "job : unit". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRJOBCANCEL +extern int virJobCancel (virJobPtr job) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_job_cancel (value jobv) +{ + CAMLparam1 (jobv); +#ifndef HAVE_VIRJOBCANCEL + /* Symbol virJobCancel not found at compile time. */ + not_supported ("virJobCancel"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virJobCancel + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virJobCancel); + + virJobPtr job = Job_val (jobv); + virConnectPtr conn = Connect_jobv (jobv); + int r; + + NONBLOCKING (r = virJobCancel (job)); + CHECK_ERROR (r == -1, conn, "virJobCancel"); + + CAMLreturn (Val_unit); +#endif +} + +/* Automatically generated binding for virJobGetNetwork. + * In generator.pl this function has signature "job : net from job". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRJOBGETNETWORK +extern virNetworkPtr virJobGetNetwork (virJobPtr job) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_job_get_network (value jobv) +{ + CAMLparam1 (jobv); +#ifndef HAVE_VIRJOBGETNETWORK + /* Symbol virJobGetNetwork not found at compile time. */ + not_supported ("virJobGetNetwork"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virJobGetNetwork + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virJobGetNetwork); + + CAMLlocal2 (rv, connv); + virJobPtr job = Job_val (jobv); + virConnectPtr conn = Connect_jobv (jobv); + virNetworkPtr r; + + NONBLOCKING (r = virJobGetNetwork (job)); + CHECK_ERROR (!r, conn, "virJobGetNetwork"); + + connv = Field (jobv, 1); + rv = Val_network (r, connv); + + CAMLreturn (rv); +#endif +} + +/* Automatically generated binding for virJobGetDomain. + * In generator.pl this function has signature "job : dom from job". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRJOBGETDOMAIN +extern virDomainPtr virJobGetDomain (virJobPtr job) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_job_get_domain (value jobv) +{ + CAMLparam1 (jobv); +#ifndef HAVE_VIRJOBGETDOMAIN + /* Symbol virJobGetDomain not found at compile time. */ + not_supported ("virJobGetDomain"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virJobGetDomain + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virJobGetDomain); + + CAMLlocal2 (rv, connv); + virJobPtr job = Job_val (jobv); + virConnectPtr conn = Connect_jobv (jobv); + virDomainPtr r; + + NONBLOCKING (r = virJobGetDomain (job)); + CHECK_ERROR (!r, conn, "virJobGetDomain"); + + connv = Field (jobv, 1); + rv = Val_domain (r, connv); + + CAMLreturn (rv); +#endif +} + +#include "libvirt_c_epilogue.c" + +/* EOF */