[],
AC_MSG_ERROR([You must install libvirt development package]))
+dnl We also use <libvirt/virterror.h>
+AC_CHECK_HEADER([libvirt/virterror.h],
+ [],
+ AC_MSG_ERROR([You must install libvirt development package]))
+
dnl Check for libvirt >= 0.2.1 (our minimum supported version).
dnl See: http://libvirt.org/hvsupport.html
AC_CHECK_FUNC(virConnectGetCapabilities,
])
dnl Check for optional types added since 0.2.1.
-AC_CHECK_TYPES([virJobPtr, virStoragePoolPtr, virStorageVolPtr])
-
-dnl We also use <libvirt/virterror.h>
-AC_CHECK_HEADER([libvirt/virterror.h],
- [],
- AC_MSG_ERROR([You must install libvirt development package]))
+AC_CHECK_TYPES([virJobPtr, virStoragePoolPtr, virStorageVolPtr],,,
+ [#include <libvirt/libvirt.h>])
dnl Check for optional ncurses.
AC_CHECK_LIB(ncurses,initscr)
# Automatically generate the C code from a Perl script 'generator.pl'.
libvirt_c.c: generator.pl
- perl -w $< > $@
+ perl -w $<
# Status of automatically generated bindings.
-autostatus:
- @echo -n "Functions which have manual bindings: "
+autostatus: libvirt_c.c
+ @echo -n "Functions which have manual bindings: "
@grep ^ocaml_libvirt_ libvirt_c_oneoffs.c | wc -l
- @echo -n "LOC in manual bindings: "
+ @echo -n "Functions which have automatic bindings: "
+ @grep ^ocaml_libvirt_ libvirt_c.c | wc -l
+ @echo -n "LOC in manual bindings: "
@wc -l < libvirt_c_oneoffs.c
+ @echo -n "LOC in automatic bindings: "
+ @wc -l < libvirt_c.c
libvirt.cmo: libvirt.cmi
libvirt.cmi: libvirt.mli
{ name => "virDomainReboot", sig => "dom, 0 : unit" },
{ name => "virDomainUndefine", sig => "dom : unit" },
{ name => "virDomainCreate", sig => "dom : unit" },
+ { name => "virDomainGetAutostart", sig => "dom : bool" },
+ { name => "virDomainSetAutostart", sig => "dom, bool : unit" },
{ name => "virNetworkLookupByName", sig => "conn, string : net" },
{ name => "virNetworkLookupByUUIDString", sig => "conn, string : net" },
{ name => "virNetworkGetBridgeName", sig => "net : string" },
{ name => "virNetworkUndefine", sig => "net : unit" },
{ name => "virNetworkCreate", sig => "net : unit" },
+ { name => "virNetworkGetAutostart", sig => "net : bool" },
+ { name => "virNetworkSetAutostart", sig => "net, bool : unit" },
{ name => "virStoragePoolLookupByName",
sig => "conn, string : pool", weak => 1 },
{ name => "virStoragePoolGetXMLDesc",
sig => "pool, 0 : string", weak => 1 },
{ name => "virStoragePoolUndefine",
- sig => "pool : string", weak => 1 },
+ sig => "pool : unit", weak => 1 },
{ name => "virStoragePoolCreate",
- sig => "pool : string", weak => 1 },
+ sig => "pool : unit", weak => 1 },
{ name => "virStoragePoolShutdown",
- sig => "pool : string", weak => 1 },
+ sig => "pool : unit", weak => 1 },
{ name => "virStoragePoolRefresh",
- sig => "pool, 0 : string", weak => 1 },
-
- { name => "virStorageVolLookupByName",
- sig => "conn, string : vol", weak => 1 },
+ sig => "pool, 0U : unit", weak => 1 },
+ { name => "virStoragePoolGetAutostart",
+ sig => "pool : bool", weak => 1 },
+ { name => "virStoragePoolSetAutostart",
+ sig => "pool, bool : unit", weak => 1 },
+
+# { name => "virStorageVolLookupByName", XXX see libvir-list posting
+# sig => "pool, string : vol", weak => 1 },
{ name => "virStorageVolLookupByKey",
sig => "conn, string : vol", weak => 1 },
{ name => "virStorageVolLookupByPath",
sig => "conn, string : vol", weak => 1 },
{ name => "virStorageVolGetXMLDesc",
- sig => "pool, 0 : string", weak => 1 },
+ sig => "vol, 0 : string", weak => 1 },
{ name => "virStorageVolGetPath",
- sig => "pool : string", weak => 1 },
+ sig => "vol : string", weak => 1 },
{ name => "virStorageVolGetKey",
- sig => "pool : static string", weak => 1 },
+ sig => "vol : static string", weak => 1 },
{ name => "virStorageVolGetName",
- sig => "pool : static string", weak => 1 },
+ sig => "vol : static string", weak => 1 },
);
"ocaml_libvirt_connect_create_linux_job",
"ocaml_libvirt_network_create_job",
"ocaml_libvirt_network_create_xml_job",
- "ocaml_libvirt_storage_pool_set_autostart", #?
- "ocaml_libvirt_storage_pool_get_autostart", #?
"ocaml_libvirt_storage_pool_get_info",
"ocaml_libvirt_storage_pool_get_uuid_string", #?
"ocaml_libvirt_storage_pool_get_uuid", #?
"ocaml_libvirt_storage_pool_define_xml",
"ocaml_libvirt_storage_pool_create_xml",
"ocaml_libvirt_storage_pool_lookup_by_uuid",
+ "ocaml_libvirt_storage_vol_lookup_by_name", # XXX
"ocaml_libvirt_storage_vol_free", #?
"ocaml_libvirt_storage_vol_destroy", #?
"ocaml_libvirt_storage_vol_create_xml",
# Write the prologue.
print F <<'END';
-/* WARNING: THIS FILE IS AUTOMATICALLY GENERATED BY 'generator.pl'.
+/* !!! 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.
*/
} elsif ($sig =~ /^(\w+) : int$/) {
my $c_type = short_name_to_c_type ($1);
"int $c_name ($c_type $1)"
+ } elsif ($sig =~ /^(\w+) : bool$/) {
+ my $c_type = short_name_to_c_type ($1);
+ "int $c_name ($c_type $1, int *r)"
+ } elsif ($sig =~ /^(\w+), bool : unit$/) {
+ my $c_type = short_name_to_c_type ($1);
+ "int $c_name ($c_type $1, int b)"
} elsif ($sig eq "conn, int : int array") {
"int $c_name (virConnectPtr conn, int *ids, int maxids)"
} elsif ($sig eq "conn, int : string array") {
"int $c_name (virConnectPtr conn, char **const names, int maxnames)"
- } elsif ($sig =~ /^(\w+), 0 : string$/) {
+ } elsif ($sig =~ /^(\w+), 0(U?) : string$/) {
my $c_type = short_name_to_c_type ($1);
- "char *$c_name ($c_type $1, int flags)"
- } elsif ($sig =~ /^(\w+), 0 : unit$/) {
+ my $unsigned = $2 eq "U" ? "unsigned " : "";
+ "char *$c_name ($c_type $1, $unsigned int flags)"
+ } elsif ($sig =~ /^(\w+), 0(U?) : unit$/) {
my $c_type = short_name_to_c_type ($1);
- "int $c_name ($c_type $1, int flags)"
+ my $unsigned = $2 eq "U" ? "unsigned " : "";
+ "int $c_name ($c_type $1, $unsigned int flags)"
} elsif ($sig =~ /^(\w+) : unit$/) {
my $c_type = short_name_to_c_type ($1);
- "int $c_name ($c_type $1 dom)"
+ "int $c_name ($c_type $1)"
} elsif ($sig =~ /^(\w+), string : (\w+)$/) {
my $c_type = short_name_to_c_type ($1);
my $c_ret_type = short_name_to_c_type ($2);
- "$c_ret_type $c_name ($c_type $1 dom)"
+ "$c_ret_type $c_name ($c_type $1, const char *str)"
} else {
die "unknown signature $sig"
}
( "$1v" )
} elsif ($sig =~ /^(\w+) : int$/) {
( "$1v" )
+ } elsif ($sig =~ /^(\w+) : bool$/) {
+ ( "$1v" )
+ } elsif ($sig =~ /^(\w+), bool : unit$/) {
+ ( "$1v", "bv" )
} elsif ($sig eq "conn, int : int array") {
( "connv", "iv" )
} elsif ($sig eq "conn, int : string array") {
( "connv", "iv" )
- } elsif ($sig =~ /^(\w+), 0 : string$/) {
+ } elsif ($sig =~ /^(\w+), 0U? : string$/) {
( "$1v" )
- } elsif ($sig =~ /^(\w+), 0 : unit$/) {
+ } elsif ($sig =~ /^(\w+), 0U? : unit$/) {
( "$1v" )
} elsif ($sig =~ /^(\w+) : unit$/) {
( "$1v" )
CAMLreturn (Val_int (r));
"
+ } elsif ($sig =~ /^(\w+) : bool$/) {
+ "\
+ " . gen_unpack_args ($1) . "
+ int r, b;
+
+ NONBLOCKING (r = $c_name ($1, &b));
+ CHECK_ERROR (r == -1, conn, \"$c_name\");
+
+ CAMLreturn (b ? Val_true : Val_false);
+"
+ } elsif ($sig =~ /^(\w+), bool : unit$/) {
+ "\
+ " . gen_unpack_args ($1) . "
+ int r, b;
+
+ b = bv == Val_true ? 1 : 0;
+
+ NONBLOCKING (r = $c_name ($1, b));
+ CHECK_ERROR (r == -1, conn, \"$c_name\");
+
+ CAMLreturn (Val_unit);
+"
} elsif ($sig eq "conn, int : int array") {
"\
CAMLlocal1 (rv);
CAMLreturn (rv);
"
- } elsif ($sig =~ /^(\w+), 0 : string$/) {
+ } elsif ($sig =~ /^(\w+), 0U? : string$/) {
"\
CAMLlocal1 (rv);
" . gen_unpack_args ($1) . "
CAMLreturn (Val_unit);
"
- } elsif ($sig =~ /^(\w+), 0 : unit$/) {
+ } elsif ($sig =~ /^(\w+), 0U? : unit$/) {
"\
" . gen_unpack_args ($1) . "
int r;
| VIR_ERR_NO_DOMAIN
| VIR_ERR_NO_NETWORK
| VIR_ERR_INVALID_MAC
+ | VIR_ERR_AUTH_FAILED
+ | VIR_ERR_INVALID_STORAGE_POOL
+ | VIR_ERR_INVALID_STORAGE_VOL
+ | VIR_WAR_NO_STORAGE
+ | VIR_ERR_NO_STORAGE_POOL
+ | VIR_ERR_NO_STORAGE_VOL
| VIR_ERR_UNKNOWN of int
let string_of_code = function
| VIR_ERR_NO_DOMAIN -> "VIR_ERR_NO_DOMAIN"
| VIR_ERR_NO_NETWORK -> "VIR_ERR_NO_NETWORK"
| VIR_ERR_INVALID_MAC -> "VIR_ERR_INVALID_MAC"
+ | VIR_ERR_AUTH_FAILED -> "VIR_ERR_AUTH_FAILED"
+ | VIR_ERR_INVALID_STORAGE_POOL -> "VIR_ERR_INVALID_STORAGE_POOL"
+ | VIR_ERR_INVALID_STORAGE_VOL -> "VIR_ERR_INVALID_STORAGE_VOL"
+ | VIR_WAR_NO_STORAGE -> "VIR_WAR_NO_STORAGE"
+ | VIR_ERR_NO_STORAGE_POOL -> "VIR_ERR_NO_STORAGE_POOL"
+ | VIR_ERR_NO_STORAGE_VOL -> "VIR_ERR_NO_STORAGE_VOL"
| VIR_ERR_UNKNOWN i -> "VIR_ERR_" ^ string_of_int i
type domain =
| VIR_FROM_OPENVZ
| VIR_FROM_XENXM
| VIR_FROM_STATS_LINUX
+ | VIR_FROM_STORAGE
| VIR_FROM_UNKNOWN of int
let string_of_domain = function
| VIR_FROM_OPENVZ -> "VIR_FROM_OPENVZ"
| VIR_FROM_XENXM -> "VIR_FROM_XENXM"
| VIR_FROM_STATS_LINUX -> "VIR_FROM_STATS_LINUX"
+ | VIR_FROM_STORAGE -> "VIR_FROM_STORAGE"
| VIR_FROM_UNKNOWN i -> "VIR_FROM_" ^ string_of_int i
type level =
*)
end
(** Module dealing with connections. [Connect.t] is the
- connection object.
- *)
+ connection object. *)
(** {3 Domains} *)
*)
end
(** Module dealing with domains. [Domain.t] is the
- domain object.
- *)
+ domain object. *)
(** {3 Networks} *)
*)
end
(** Module dealing with networks. [Network.t] is the
- network object.
- *)
+ network object. *)
(** {3 Storage pools} *)
The possible types for a job are:
{v
-(`Domain, `W) Job.t Job creating a r/w domain
+(`Domain, `W) Job.t Job creating a new domain
(`Domain_nocreate, `W) Job.t Job acting on an existing domain
-(`Network, `W) Job.t Job creating a r/w network
+(`Network, `W) Job.t Job creating a new network
(`Network_nocreate, `W) Job.t Job acting on an existing network
v}
*)
(** State of the job. *)
type job_info = {
- typ : job_type; (** Job type *)
- state : job_state; (** Job state *)
+ typ : job_type; (** Job type (Bounded, Unbounded) *)
+ state : job_state; (** Job state (Running, etc.) *)
running_time : int; (** Actual running time (seconds) *)
(** The following fields are only available in Bounded jobs: *)
remaining_time : int; (** Estimated time left (seconds) *)
job. Note that the opposite operation is impossible.
*)
end
+ (** Module dealing with asynchronous jobs. *)
(** {3 Error handling and exceptions} *)
| VIR_ERR_NO_DOMAIN
| VIR_ERR_NO_NETWORK
| VIR_ERR_INVALID_MAC
- (* ^^ NB: If you add a variant you MUST edit libvirt_c.c:MAX_VIR_* *)
+ | VIR_ERR_AUTH_FAILED
+ | VIR_ERR_INVALID_STORAGE_POOL
+ | VIR_ERR_INVALID_STORAGE_VOL
+ | VIR_WAR_NO_STORAGE
+ | VIR_ERR_NO_STORAGE_POOL
+ | VIR_ERR_NO_STORAGE_VOL
+ (* ^^ NB: If you add a variant you MUST edit
+ libvirt_c_epilogue.c:MAX_VIR_* *)
| VIR_ERR_UNKNOWN of int
(** See [<libvirt/virterror.h>] for meaning of these codes. *)
| VIR_FROM_OPENVZ
| VIR_FROM_XENXM
| VIR_FROM_STATS_LINUX
- (* ^^ NB: If you add a variant you MUST edit libvirt_c.c: MAX_VIR_* *)
+ | VIR_FROM_STORAGE
+ (* ^^ NB: If you add a variant you MUST edit
+ libvirt_c_epilogue.c: MAX_VIR_* *)
| VIR_FROM_UNKNOWN of int
(** Subsystem / driver which produced the error. *)
-/* WARNING: THIS FILE IS AUTOMATICALLY GENERATED BY 'generator.pl'.
+/* !!! 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.
*/
}
CAMLprim value
+ocaml_libvirt_domain_get_autostart (value domv)
+{
+ CAMLparam1 (domv);
+
+ virDomainPtr dom = Domain_val (domv);
+ virConnectPtr conn = Connect_domv (domv);
+ int r, b;
+
+ NONBLOCKING (r = virDomainGetAutostart (dom, &b));
+ CHECK_ERROR (r == -1, conn, "virDomainGetAutostart");
+
+ CAMLreturn (b ? Val_true : Val_false);
+}
+
+CAMLprim value
+ocaml_libvirt_domain_set_autostart (value domv, value bv)
+{
+ CAMLparam2 (domv, bv);
+
+ virDomainPtr dom = Domain_val (domv);
+ virConnectPtr conn = Connect_domv (domv);
+ int r, b;
+
+ b = bv == Val_true ? 1 : 0;
+
+ NONBLOCKING (r = virDomainSetAutostart (dom, b));
+ CHECK_ERROR (r == -1, conn, "virDomainSetAutostart");
+
+ CAMLreturn (Val_unit);
+}
+
+CAMLprim value
ocaml_libvirt_network_lookup_by_name (value connv, value strv)
{
CAMLparam2 (connv, strv);
CAMLreturn (Val_unit);
}
+CAMLprim value
+ocaml_libvirt_network_get_autostart (value netv)
+{
+ CAMLparam1 (netv);
+
+ virNetworkPtr net = Network_val (netv);
+ virConnectPtr conn = Connect_netv (netv);
+ int r, b;
+
+ NONBLOCKING (r = virNetworkGetAutostart (net, &b));
+ CHECK_ERROR (r == -1, conn, "virNetworkGetAutostart");
+
+ CAMLreturn (b ? Val_true : Val_false);
+}
+
+CAMLprim value
+ocaml_libvirt_network_set_autostart (value netv, value bv)
+{
+ CAMLparam2 (netv, bv);
+
+ virNetworkPtr net = Network_val (netv);
+ virConnectPtr conn = Connect_netv (netv);
+ int r, b;
+
+ b = bv == Val_true ? 1 : 0;
+
+ NONBLOCKING (r = virNetworkSetAutostart (net, b));
+ CHECK_ERROR (r == -1, conn, "virNetworkSetAutostart");
+
+ CAMLreturn (Val_unit);
+}
+
#ifdef HAVE_WEAK_SYMBOLS
#ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYNAME
-extern virStoragePoolPtr virStoragePoolLookupByName (virConnectPtr conn dom) __attribute__((weak));
+extern virStoragePoolPtr virStoragePoolLookupByName (virConnectPtr conn, const char *str) __attribute__((weak));
#endif
#endif
#ifdef HAVE_WEAK_SYMBOLS
#ifdef HAVE_VIRSTORAGEPOOLLOOKUPBYUUIDSTRING
-extern virStoragePoolPtr virStoragePoolLookupByUUIDString (virConnectPtr conn dom) __attribute__((weak));
+extern virStoragePoolPtr virStoragePoolLookupByUUIDString (virConnectPtr conn, const char *str) __attribute__((weak));
#endif
#endif
#ifdef HAVE_WEAK_SYMBOLS
#ifdef HAVE_VIRSTORAGEPOOLGETXMLDESC
-extern char *virStoragePoolGetXMLDesc (virStoragePoolPtr pool, int flags) __attribute__((weak));
+extern char *virStoragePoolGetXMLDesc (virStoragePoolPtr pool, int flags) __attribute__((weak));
#endif
#endif
#ifdef HAVE_WEAK_SYMBOLS
#ifdef HAVE_VIRSTORAGEPOOLUNDEFINE
-extern char *virStoragePoolUndefine (virStoragePoolPtr pool) __attribute__((weak));
+extern int virStoragePoolUndefine (virStoragePoolPtr pool) __attribute__((weak));
#endif
#endif
*/
WEAK_SYMBOL_CHECK (virStoragePoolUndefine);
- CAMLlocal1 (rv);
virStoragePoolPtr pool = Pool_val (poolv);
virConnectPtr conn = Connect_polv (poolv);
- char *r;
+ int r;
NONBLOCKING (r = virStoragePoolUndefine (pool));
- CHECK_ERROR (!r, conn, "virStoragePoolUndefine");
+ CHECK_ERROR (r == -1, conn, "virStoragePoolUndefine");
- rv = caml_copy_string (r);
- free (r);
- CAMLreturn (rv);
+ CAMLreturn (Val_unit);
#endif
}
#ifdef HAVE_WEAK_SYMBOLS
#ifdef HAVE_VIRSTORAGEPOOLCREATE
-extern char *virStoragePoolCreate (virStoragePoolPtr pool) __attribute__((weak));
+extern int virStoragePoolCreate (virStoragePoolPtr pool) __attribute__((weak));
#endif
#endif
*/
WEAK_SYMBOL_CHECK (virStoragePoolCreate);
- CAMLlocal1 (rv);
virStoragePoolPtr pool = Pool_val (poolv);
virConnectPtr conn = Connect_polv (poolv);
- char *r;
+ int r;
NONBLOCKING (r = virStoragePoolCreate (pool));
- CHECK_ERROR (!r, conn, "virStoragePoolCreate");
+ CHECK_ERROR (r == -1, conn, "virStoragePoolCreate");
- rv = caml_copy_string (r);
- free (r);
- CAMLreturn (rv);
+ CAMLreturn (Val_unit);
#endif
}
#ifdef HAVE_WEAK_SYMBOLS
#ifdef HAVE_VIRSTORAGEPOOLSHUTDOWN
-extern char *virStoragePoolShutdown (virStoragePoolPtr pool) __attribute__((weak));
+extern int virStoragePoolShutdown (virStoragePoolPtr pool) __attribute__((weak));
#endif
#endif
*/
WEAK_SYMBOL_CHECK (virStoragePoolShutdown);
- CAMLlocal1 (rv);
virStoragePoolPtr pool = Pool_val (poolv);
virConnectPtr conn = Connect_polv (poolv);
- char *r;
+ int r;
NONBLOCKING (r = virStoragePoolShutdown (pool));
- CHECK_ERROR (!r, conn, "virStoragePoolShutdown");
+ CHECK_ERROR (r == -1, conn, "virStoragePoolShutdown");
- rv = caml_copy_string (r);
- free (r);
- CAMLreturn (rv);
+ CAMLreturn (Val_unit);
#endif
}
#ifdef HAVE_WEAK_SYMBOLS
#ifdef HAVE_VIRSTORAGEPOOLREFRESH
-extern char *virStoragePoolRefresh (virStoragePoolPtr pool, int flags) __attribute__((weak));
+extern int virStoragePoolRefresh (virStoragePoolPtr pool, unsigned int flags) __attribute__((weak));
#endif
#endif
*/
WEAK_SYMBOL_CHECK (virStoragePoolRefresh);
- CAMLlocal1 (rv);
virStoragePoolPtr pool = Pool_val (poolv);
virConnectPtr conn = Connect_polv (poolv);
- char *r;
+ int r;
NONBLOCKING (r = virStoragePoolRefresh (pool, 0));
- CHECK_ERROR (!r, conn, "virStoragePoolRefresh");
+ CHECK_ERROR (r == -1, conn, "virStoragePoolRefresh");
- rv = caml_copy_string (r);
- free (r);
- CAMLreturn (rv);
+ CAMLreturn (Val_unit);
#endif
}
#ifdef HAVE_WEAK_SYMBOLS
-#ifdef HAVE_VIRSTORAGEVOLLOOKUPBYNAME
-extern virStorageVolPtr virStorageVolLookupByName (virConnectPtr conn dom) __attribute__((weak));
+#ifdef HAVE_VIRSTORAGEPOOLGETAUTOSTART
+extern int virStoragePoolGetAutostart (virStoragePoolPtr pool, int *r) __attribute__((weak));
#endif
#endif
CAMLprim value
-ocaml_libvirt_storage_vol_lookup_by_name (value connv, value strv)
+ocaml_libvirt_storage_pool_get_autostart (value poolv)
{
- CAMLparam2 (connv, strv);
-#ifndef HAVE_VIRSTORAGEVOLLOOKUPBYNAME
- /* Symbol virStorageVolLookupByName not found at compile time. */
- not_supported ("virStorageVolLookupByName");
+ 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 virStorageVolLookupByName
+ /* Check that the symbol virStoragePoolGetAutostart
* is in runtime version of libvirt.
*/
- WEAK_SYMBOL_CHECK (virStorageVolLookupByName);
+ WEAK_SYMBOL_CHECK (virStoragePoolGetAutostart);
- CAMLlocal1 (rv);
- virConnectPtr conn = Connect_val (connv);
- char *str = String_val (strv);
- virStorageVolPtr r;
+ virStoragePoolPtr pool = Pool_val (poolv);
+ virConnectPtr conn = Connect_polv (poolv);
+ int r, b;
- NONBLOCKING (r = virStorageVolLookupByName (conn, str));
- CHECK_ERROR (!r, conn, "virStorageVolLookupByName");
+ NONBLOCKING (r = virStoragePoolGetAutostart (pool, &b));
+ CHECK_ERROR (r == -1, conn, "virStoragePoolGetAutostart");
- rv = Val_volume (r, connv);
+ CAMLreturn (b ? Val_true : Val_false);
+#endif
+}
- CAMLreturn (rv);
+#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
}
#ifdef HAVE_WEAK_SYMBOLS
#ifdef HAVE_VIRSTORAGEVOLLOOKUPBYKEY
-extern virStorageVolPtr virStorageVolLookupByKey (virConnectPtr conn dom) __attribute__((weak));
+extern virStorageVolPtr virStorageVolLookupByKey (virConnectPtr conn, const char *str) __attribute__((weak));
#endif
#endif
#ifdef HAVE_WEAK_SYMBOLS
#ifdef HAVE_VIRSTORAGEVOLLOOKUPBYPATH
-extern virStorageVolPtr virStorageVolLookupByPath (virConnectPtr conn dom) __attribute__((weak));
+extern virStorageVolPtr virStorageVolLookupByPath (virConnectPtr conn, const char *str) __attribute__((weak));
#endif
#endif
#ifdef HAVE_WEAK_SYMBOLS
#ifdef HAVE_VIRSTORAGEVOLGETXMLDESC
-extern char *virStorageVolGetXMLDesc (virStoragePoolPtr pool, int flags) __attribute__((weak));
+extern char *virStorageVolGetXMLDesc (virStorageVolPtr vol, int flags) __attribute__((weak));
#endif
#endif
CAMLprim value
-ocaml_libvirt_storage_vol_get_xml_desc (value poolv)
+ocaml_libvirt_storage_vol_get_xml_desc (value volv)
{
- CAMLparam1 (poolv);
+ CAMLparam1 (volv);
#ifndef HAVE_VIRSTORAGEVOLGETXMLDESC
/* Symbol virStorageVolGetXMLDesc not found at compile time. */
not_supported ("virStorageVolGetXMLDesc");
WEAK_SYMBOL_CHECK (virStorageVolGetXMLDesc);
CAMLlocal1 (rv);
- virStoragePoolPtr pool = Pool_val (poolv);
- virConnectPtr conn = Connect_polv (poolv);
+ virStorageVolPtr vol = Volume_val (volv);
+ virConnectPtr conn = Connect_volv (volv);
char *r;
- NONBLOCKING (r = virStorageVolGetXMLDesc (pool, 0));
+ NONBLOCKING (r = virStorageVolGetXMLDesc (vol, 0));
CHECK_ERROR (!r, conn, "virStorageVolGetXMLDesc");
rv = caml_copy_string (r);
#ifdef HAVE_WEAK_SYMBOLS
#ifdef HAVE_VIRSTORAGEVOLGETPATH
-extern char *virStorageVolGetPath (virStoragePoolPtr pool) __attribute__((weak));
+extern char *virStorageVolGetPath (virStorageVolPtr vol) __attribute__((weak));
#endif
#endif
CAMLprim value
-ocaml_libvirt_storage_vol_get_path (value poolv)
+ocaml_libvirt_storage_vol_get_path (value volv)
{
- CAMLparam1 (poolv);
+ CAMLparam1 (volv);
#ifndef HAVE_VIRSTORAGEVOLGETPATH
/* Symbol virStorageVolGetPath not found at compile time. */
not_supported ("virStorageVolGetPath");
WEAK_SYMBOL_CHECK (virStorageVolGetPath);
CAMLlocal1 (rv);
- virStoragePoolPtr pool = Pool_val (poolv);
- virConnectPtr conn = Connect_polv (poolv);
+ virStorageVolPtr vol = Volume_val (volv);
+ virConnectPtr conn = Connect_volv (volv);
char *r;
- NONBLOCKING (r = virStorageVolGetPath (pool));
+ NONBLOCKING (r = virStorageVolGetPath (vol));
CHECK_ERROR (!r, conn, "virStorageVolGetPath");
rv = caml_copy_string (r);
#ifdef HAVE_WEAK_SYMBOLS
#ifdef HAVE_VIRSTORAGEVOLGETKEY
-extern const char *virStorageVolGetKey (virStoragePoolPtr pool) __attribute__((weak));
+extern const char *virStorageVolGetKey (virStorageVolPtr vol) __attribute__((weak));
#endif
#endif
CAMLprim value
-ocaml_libvirt_storage_vol_get_key (value poolv)
+ocaml_libvirt_storage_vol_get_key (value volv)
{
- CAMLparam1 (poolv);
+ CAMLparam1 (volv);
#ifndef HAVE_VIRSTORAGEVOLGETKEY
/* Symbol virStorageVolGetKey not found at compile time. */
not_supported ("virStorageVolGetKey");
WEAK_SYMBOL_CHECK (virStorageVolGetKey);
CAMLlocal1 (rv);
- virStoragePoolPtr pool = Pool_val (poolv);
- virConnectPtr conn = Connect_polv (poolv);
+ virStorageVolPtr vol = Volume_val (volv);
+ virConnectPtr conn = Connect_volv (volv);
const char *r;
- NONBLOCKING (r = virStorageVolGetKey (pool));
+ NONBLOCKING (r = virStorageVolGetKey (vol));
CHECK_ERROR (!r, conn, "virStorageVolGetKey");
rv = caml_copy_string (r);
#ifdef HAVE_WEAK_SYMBOLS
#ifdef HAVE_VIRSTORAGEVOLGETNAME
-extern const char *virStorageVolGetName (virStoragePoolPtr pool) __attribute__((weak));
+extern const char *virStorageVolGetName (virStorageVolPtr vol) __attribute__((weak));
#endif
#endif
CAMLprim value
-ocaml_libvirt_storage_vol_get_name (value poolv)
+ocaml_libvirt_storage_vol_get_name (value volv)
{
- CAMLparam1 (poolv);
+ CAMLparam1 (volv);
#ifndef HAVE_VIRSTORAGEVOLGETNAME
/* Symbol virStorageVolGetName not found at compile time. */
not_supported ("virStorageVolGetName");
WEAK_SYMBOL_CHECK (virStorageVolGetName);
CAMLlocal1 (rv);
- virStoragePoolPtr pool = Pool_val (poolv);
- virConnectPtr conn = Connect_polv (poolv);
+ virStorageVolPtr vol = Volume_val (volv);
+ virConnectPtr conn = Connect_volv (volv);
const char *r;
- NONBLOCKING (r = virStorageVolGetName (pool));
+ NONBLOCKING (r = virStorageVolGetName (vol));
CHECK_ERROR (!r, conn, "virStorageVolGetName");
rv = caml_copy_string (r);
}
CAMLprim value
-ocaml_libvirt_storage_pool_set_autostart ()
-{
- failwith ("ocaml_libvirt_storage_pool_set_autostart is unimplemented");
-}
-
-CAMLprim value
-ocaml_libvirt_storage_pool_get_autostart ()
-{
- failwith ("ocaml_libvirt_storage_pool_get_autostart is unimplemented");
-}
-
-CAMLprim value
ocaml_libvirt_storage_pool_get_info ()
{
failwith ("ocaml_libvirt_storage_pool_get_info is unimplemented");
}
CAMLprim value
+ocaml_libvirt_storage_vol_lookup_by_name ()
+{
+ failwith ("ocaml_libvirt_storage_vol_lookup_by_name is unimplemented");
+}
+
+CAMLprim value
ocaml_libvirt_storage_vol_free ()
{
failwith ("ocaml_libvirt_storage_vol_free is unimplemented");
* to convert it into VIR_*_UNKNOWN (code).
*/
-#define MAX_VIR_CODE 44 /* VIR_ERR_INVALID_MAC */
-#define MAX_VIR_DOMAIN 16 /* VIR_FROM_STATS_LINUX */
+#define MAX_VIR_CODE VIR_ERR_NO_STORAGE_VOL
+#define MAX_VIR_DOMAIN VIR_FROM_STORAGE
#define MAX_VIR_LEVEL VIR_ERR_ERROR
static inline value
#ifdef HAVE_VIRSTORAGEVOLPTR
static value
-Val_vol (virStorageVolPtr net)
+Val_vol (virStorageVolPtr vol)
{
CAMLparam0 ();
CAMLlocal1 (rv);
}
CAMLprim value
-ocaml_libvirt_domain_get_autostart (value domv)
-{
- CAMLparam1 (domv);
- virDomainPtr dom = Domain_val (domv);
- virConnectPtr conn = Connect_domv (domv);
- int r, autostart;
-
- NONBLOCKING (r = virDomainGetAutostart (dom, &autostart));
- CHECK_ERROR (r == -1, conn, "virDomainGetAutostart");
-
- CAMLreturn (autostart ? Val_true : Val_false);
-}
-
-CAMLprim value
-ocaml_libvirt_domain_set_autostart (value domv, value autostartv)
-{
- CAMLparam2 (domv, autostartv);
- virDomainPtr dom = Domain_val (domv);
- virConnectPtr conn = Connect_domv (domv);
- int r, autostart = autostartv == Val_true ? 1 : 0;
-
- NONBLOCKING (r = virDomainSetAutostart (dom, autostart));
- CHECK_ERROR (r == -1, conn, "virDomainSetAutostart");
-
- CAMLreturn (Val_unit);
-}
-
-CAMLprim value
ocaml_libvirt_domain_set_vcpus (value domv, value nvcpusv)
{
CAMLparam2 (domv, nvcpusv);
CAMLreturn (rv);
}
-CAMLprim value
-ocaml_libvirt_network_get_autostart (value netv)
-{
- CAMLparam1 (netv);
- virNetworkPtr net = Network_val (netv);
- virConnectPtr conn = Connect_netv (netv);
- int r, autostart;
-
- NONBLOCKING (r = virNetworkGetAutostart (net, &autostart));
- CHECK_ERROR (r == -1, conn, "virNetworkGetAutostart");
-
- CAMLreturn (autostart ? Val_true : Val_false);
-}
-
-CAMLprim value
-ocaml_libvirt_network_set_autostart (value netv, value autostartv)
-{
- CAMLparam2 (netv, autostartv);
- virNetworkPtr net = Network_val (netv);
- virConnectPtr conn = Connect_netv (netv);
- int r, autostart = autostartv == Val_true ? 1 : 0;
-
- NONBLOCKING (r = virNetworkSetAutostart (net, autostart));
- CHECK_ERROR (r == -1, conn, "virNetworkSetAutostart");
-
- CAMLreturn (Val_unit);
-}
-
/*----------------------------------------------------------------------*/
CAMLprim value