From 87751781213a1252711b896290a7cc3f07ec0169 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 1 Jan 1970 00:00:00 +0000 Subject: [PATCH] Upgrade to released storage API in libvirt CVS. --- config.h.in | 52 ++--------- configure.ac | 33 +++---- libvirt/generator.pl | 85 ++++++++++++------ libvirt/libvirt.ml | 15 +++- libvirt/libvirt.mli | 31 +++++-- libvirt/libvirt_c.c | 212 ++++++++++++++++++++++++++++++++++---------- libvirt/libvirt_c_oneoffs.c | 5 +- 7 files changed, 283 insertions(+), 150 deletions(-) diff --git a/config.h.in b/config.h.in index 95757f8..ab90ff8 100644 --- a/config.h.in +++ b/config.h.in @@ -33,9 +33,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H -/* Define to 1 if you have the `virConnectDiscoverStoragePools' function. */ -#undef HAVE_VIRCONNECTDISCOVERSTORAGEPOOLS - /* Define to 1 if you have the `virConnectGetHostname' function. */ #undef HAVE_VIRCONNECTGETHOSTNAME @@ -59,15 +56,6 @@ /* Define to 1 if you have the `virDomainBlockStats' function. */ #undef HAVE_VIRDOMAINBLOCKSTATS -/* Define to 1 if you have the `virDomainCoreDumpJob' function. */ -#undef HAVE_VIRDOMAINCOREDUMPJOB - -/* Define to 1 if you have the `virDomainCreateJob' function. */ -#undef HAVE_VIRDOMAINCREATEJOB - -/* Define to 1 if you have the `virDomainCreateLinuxJob' function. */ -#undef HAVE_VIRDOMAINCREATELINUXJOB - /* Define to 1 if you have the `virDomainGetSchedulerParameters' function. */ #undef HAVE_VIRDOMAINGETSCHEDULERPARAMETERS @@ -80,45 +68,21 @@ /* Define to 1 if you have the `virDomainMigrate' function. */ #undef HAVE_VIRDOMAINMIGRATE -/* Define to 1 if you have the `virDomainRestoreJob' function. */ -#undef HAVE_VIRDOMAINRESTOREJOB - -/* Define to 1 if you have the `virDomainSaveJob' function. */ -#undef HAVE_VIRDOMAINSAVEJOB - /* Define to 1 if you have the `virDomainSetSchedulerParameters' function. */ #undef HAVE_VIRDOMAINSETSCHEDULERPARAMETERS -/* Define to 1 if you have the `virJobCancel' function. */ -#undef HAVE_VIRJOBCANCEL - -/* Define to 1 if you have the `virJobFree' function. */ -#undef HAVE_VIRJOBFREE - -/* Define to 1 if you have the `virJobGetDomain' function. */ -#undef HAVE_VIRJOBGETDOMAIN - -/* Define to 1 if you have the `virJobGetInfo' function. */ -#undef HAVE_VIRJOBGETINFO - -/* Define to 1 if you have the `virJobGetNetwork' function. */ -#undef HAVE_VIRJOBGETNETWORK - /* Define to 1 if the system has the type `virJobPtr'. */ #undef HAVE_VIRJOBPTR -/* Define to 1 if you have the `virNetworkCreateJob' function. */ -#undef HAVE_VIRNETWORKCREATEJOB - -/* Define to 1 if you have the `virNetworkCreateXMLJob' function. */ -#undef HAVE_VIRNETWORKCREATEXMLJOB - /* Define to 1 if you have the `virNodeGetCellsFreeMemory' function. */ #undef HAVE_VIRNODEGETCELLSFREEMEMORY /* Define to 1 if you have the `virNodeGetFreeMemory' function. */ #undef HAVE_VIRNODEGETFREEMEMORY +/* Define to 1 if you have the `virStoragePoolBuild' function. */ +#undef HAVE_VIRSTORAGEPOOLBUILD + /* Define to 1 if you have the `virStoragePoolCreate' function. */ #undef HAVE_VIRSTORAGEPOOLCREATE @@ -128,6 +92,9 @@ /* Define to 1 if you have the `virStoragePoolDefineXML' function. */ #undef HAVE_VIRSTORAGEPOOLDEFINEXML +/* Define to 1 if you have the `virStoragePoolDelete' function. */ +#undef HAVE_VIRSTORAGEPOOLDELETE + /* Define to 1 if you have the `virStoragePoolDestroy' function. */ #undef HAVE_VIRSTORAGEPOOLDESTROY @@ -182,17 +149,14 @@ /* Define to 1 if you have the `virStoragePoolSetAutostart' function. */ #undef HAVE_VIRSTORAGEPOOLSETAUTOSTART -/* Define to 1 if you have the `virStoragePoolShutdown' function. */ -#undef HAVE_VIRSTORAGEPOOLSHUTDOWN - /* Define to 1 if you have the `virStoragePoolUndefine' function. */ #undef HAVE_VIRSTORAGEPOOLUNDEFINE /* Define to 1 if you have the `virStorageVolCreateXML' function. */ #undef HAVE_VIRSTORAGEVOLCREATEXML -/* Define to 1 if you have the `virStorageVolDestroy' function. */ -#undef HAVE_VIRSTORAGEVOLDESTROY +/* Define to 1 if you have the `virStorageVolDelete' function. */ +#undef HAVE_VIRSTORAGEVOLDELETE /* Define to 1 if you have the `virStorageVolFree' function. */ #undef HAVE_VIRSTORAGEVOLFREE diff --git a/configure.ac b/configure.ac index 1d72e75..8926a9b 100644 --- a/configure.ac +++ b/configure.ac @@ -85,34 +85,22 @@ AC_CHECK_FUNCS([virConnectGetHostname \ virDomainSetSchedulerParameters \ virNodeGetFreeMemory \ virNodeGetCellsFreeMemory \ - virJobGetInfo \ - virJobGetDomain \ - virJobGetNetwork \ - virJobCancel \ - virJobFree \ - virDomainCreateLinuxJob \ - virDomainSaveJob \ - virDomainRestoreJob \ - virDomainCoreDumpJob \ - virDomainCreateJob \ - virNetworkCreateXMLJob \ - virNetworkCreateJob \ virStoragePoolGetConnect \ virConnectNumOfStoragePools \ virConnectListStoragePools \ virConnectNumOfDefinedStoragePools \ virConnectListDefinedStoragePools \ - virConnectDiscoverStoragePools \ virStoragePoolLookupByName \ virStoragePoolLookupByUUID \ virStoragePoolLookupByUUIDString \ virStoragePoolLookupByVolume \ virStoragePoolCreateXML \ virStoragePoolDefineXML \ + virStoragePoolBuild \ virStoragePoolUndefine \ virStoragePoolCreate \ virStoragePoolDestroy \ - virStoragePoolShutdown \ + virStoragePoolDelete \ virStoragePoolFree \ virStoragePoolRefresh \ virStoragePoolGetName \ @@ -130,13 +118,28 @@ AC_CHECK_FUNCS([virConnectGetHostname \ virStorageVolGetName \ virStorageVolGetKey \ virStorageVolCreateXML \ - virStorageVolDestroy \ + virStorageVolDelete \ virStorageVolFree \ virStorageVolGetInfo \ virStorageVolGetXMLDesc \ virStorageVolGetPath \ ]) +# This jobs API was never published and is due to get overhauled +# in the near future: +# virJobGetInfo +# virJobGetDomain +# virJobGetNetwork +# virJobCancel +# virJobFree +# virDomainCreateLinuxJob +# virDomainSaveJob +# virDomainRestoreJob +# virDomainCoreDumpJob +# virDomainCreateJob +# virNetworkCreateXMLJob +# virNetworkCreateJob + dnl Check for optional types added since 0.2.1. AC_CHECK_TYPES([virJobPtr, virStoragePoolPtr, virStorageVolPtr],,, [#include ]) diff --git a/libvirt/generator.pl b/libvirt/generator.pl index 8b20adf..578029b 100755 --- a/libvirt/generator.pl +++ b/libvirt/generator.pl @@ -131,30 +131,37 @@ my @functions = ( { name => "virStoragePoolGetName", sig => "pool : static string", weak => 1 }, { name => "virStoragePoolGetXMLDesc", - sig => "pool, 0 : string", weak => 1 }, + sig => "pool, 0U : string", weak => 1 }, { name => "virStoragePoolGetUUID", sig => "pool : uuid", weak => 1 }, { name => "virStoragePoolGetUUIDString", sig => "pool : uuid string", weak => 1 }, { name => "virStoragePoolCreateXML", - sig => "conn, string : pool", weak => 1 }, + sig => "conn, string, 0U : pool", weak => 1 }, { name => "virStoragePoolDefineXML", - sig => "conn, string : pool", weak => 1 }, + sig => "conn, string, 0U : pool", weak => 1 }, + { name => "virStoragePoolBuild", + sig => "pool, uint : unit", weak => 1 }, { name => "virStoragePoolUndefine", sig => "pool : unit", weak => 1 }, { name => "virStoragePoolCreate", - sig => "pool : unit", weak => 1 }, - { name => "virStoragePoolShutdown", - sig => "pool : unit", weak => 1 }, + sig => "pool, 0U : unit", weak => 1 }, + { name => "virStoragePoolDelete", + sig => "pool, uint : unit", weak => 1 }, { name => "virStoragePoolRefresh", sig => "pool, 0U : unit", weak => 1 }, { name => "virStoragePoolGetAutostart", sig => "pool : bool", weak => 1 }, { name => "virStoragePoolSetAutostart", sig => "pool, bool : unit", weak => 1 }, + { name => "virStoragePoolNumOfVolumes", + sig => "pool : int", weak => 1 }, + { name => "virStoragePoolListVolumes", + sig => "pool, int : string array", weak => 1 }, { name => "virStorageVolFree", sig => "vol : free", weak => 1 }, - { name => "virStorageVolDestroy", sig => "vol : free", weak => 1 }, + { name => "virStorageVolDelete", + sig => "vol, uint : unit", weak => 1 }, { name => "virStorageVolLookupByName", sig => "pool, string : vol from pool", weak => 1 }, { name => "virStorageVolLookupByKey", @@ -162,9 +169,9 @@ my @functions = ( { name => "virStorageVolLookupByPath", sig => "conn, string : vol", weak => 1 }, { name => "virStorageVolCreateXML", - sig => "pool, string, 0 : vol from pool", weak => 1 }, + sig => "pool, string, 0U : vol from pool", weak => 1 }, { name => "virStorageVolGetXMLDesc", - sig => "vol, 0 : string", weak => 1 }, + sig => "vol, 0U : string", weak => 1 }, { name => "virStorageVolGetPath", sig => "vol : string", weak => 1 }, { name => "virStorageVolGetKey", @@ -316,8 +323,9 @@ sub gen_c_signature "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+), int : string array$/) { + my $c_type = short_name_to_c_type ($1); + "int $c_name ($c_type $1, char **const names, int maxnames)" } elsif ($sig =~ /^(\w+), 0(U?) : string$/) { my $c_type = short_name_to_c_type ($1); my $unsigned = $2 eq "U" ? "unsigned " : ""; @@ -338,7 +346,7 @@ sub gen_c_signature } elsif ($sig =~ /^(\w+), string, 0(U?) : unit$/) { my $c_type = short_name_to_c_type ($1); my $unsigned = $2 eq "U" ? "unsigned " : ""; - "int $c_name ($c_type $1, const char *str, $unsigned int flags)" + "int $c_name ($c_type $1, const char *str, ${unsigned}int flags)" } elsif ($sig =~ /^(\w+), string : (\w+)$/) { my $c_type = short_name_to_c_type ($1); my $c_ret_type = short_name_to_c_type ($2); @@ -347,11 +355,16 @@ sub gen_c_signature my $c_type = short_name_to_c_type ($1); my $unsigned = $2 eq "U" ? "unsigned " : ""; my $c_ret_type = short_name_to_c_type ($3); - "$c_ret_type $c_name ($c_type $1, const char *str, $unsigned int flags)" - } elsif ($sig =~ /^(\w+), int : (\w+)$/) { + "$c_ret_type $c_name ($c_type $1, const char *str, ${unsigned}int flags)" + } elsif ($sig =~ /^(\w+), (u?)int : unit$/) { 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, int i)" + my $unsigned = $2 eq "u" ? "unsigned " : ""; + "int $c_name ($c_type $1, ${unsigned}int i)" + } elsif ($sig =~ /^(\w+), (u?)int : (\w+)$/) { + my $c_type = short_name_to_c_type ($1); + my $unsigned = $2 eq "u" ? "unsigned " : ""; + my $c_ret_type = short_name_to_c_type ($3); + "$c_ret_type $c_name ($c_type $1, ${unsigned}int i)" } elsif ($sig =~ /^(\w+), uuid : (\w+)$/) { my $c_type = short_name_to_c_type ($1); my $c_ret_type = short_name_to_c_type ($2); @@ -410,8 +423,8 @@ sub gen_arg_names ( "$1v", "bv" ) } elsif ($sig eq "conn, int : int array") { ( "connv", "iv" ) - } elsif ($sig eq "conn, int : string array") { - ( "connv", "iv" ) + } elsif ($sig =~ /^(\w+), int : string array$/) { + ( "$1v", "iv" ) } elsif ($sig =~ /^(\w+), 0U? : string$/) { ( "$1v" ) } elsif ($sig =~ /^(\w+), 0U? : unit$/) { @@ -428,7 +441,7 @@ sub gen_arg_names ( "$1v", "strv" ) } elsif ($sig =~ /^(\w+), string, 0U? : (\w+)$/) { ( "$1v", "strv" ) - } elsif ($sig =~ /^(\w+), int : (\w+)$/) { + } elsif ($sig =~ /^(\w+), u?int : (\w+)$/) { ( "$1v", "iv" ) } elsif ($sig =~ /^(\w+), uuid : (\w+)$/) { ( "$1v", "uuidv" ) @@ -616,15 +629,15 @@ sub gen_c_code CAMLreturn (rv); " - } elsif ($sig eq "conn, int : string array") { + } elsif ($sig =~ /^(\w+), int : string array$/) { "\ CAMLlocal2 (rv, strv); - virConnectPtr conn = Connect_val (connv); + " . gen_unpack_args ($1) . " int i = Int_val (iv); char *names[i]; int r; - NONBLOCKING (r = $c_name (conn, names, i)); + NONBLOCKING (r = $c_name ($1, names, i)); CHECK_ERROR (r == -1, conn, \"$c_name\"); rv = caml_alloc (r, 0); @@ -684,7 +697,6 @@ sub gen_c_code " } elsif ($sig =~ /^(\w+), string : unit$/) { "\ - CAMLlocal1 (rv); " . gen_unpack_args ($1) . " char *str = String_val (strv); int r; @@ -736,18 +748,31 @@ sub gen_c_code CAMLreturn (rv); " - } elsif ($sig =~ /^(\w+), int : (\w+)$/) { - my $c_ret_type = short_name_to_c_type ($2); + } elsif ($sig =~ /^(\w+), (u?)int : unit$/) { + my $unsigned = $2 eq "u" ? "unsigned " : ""; + "\ + " . gen_unpack_args ($1) . " + ${unsigned}int i = Int_val (iv); + int r; + + NONBLOCKING (r = $c_name ($1, i)); + CHECK_ERROR (!r, conn, \"$c_name\"); + + CAMLreturn (Val_unit); +" + } elsif ($sig =~ /^(\w+), (u?)int : (\w+)$/) { + my $c_ret_type = short_name_to_c_type ($3); + my $unsigned = $2 eq "u" ? "unsigned " : ""; "\ CAMLlocal1 (rv); " . gen_unpack_args ($1) . " - int i = Int_val (iv); + ${unsigned}int i = Int_val (iv); $c_ret_type r; NONBLOCKING (r = $c_name ($1, i)); CHECK_ERROR (!r, conn, \"$c_name\"); - " . gen_pack_result ($2) . " + " . gen_pack_result ($3) . " CAMLreturn (rv); " @@ -868,8 +893,10 @@ foreach my $function (@functions) { my $is_weak = $function->{weak}; my $sig = $function->{sig}; - my $is_pool_func = $c_name =~ /^virStoragePool/; - my $is_vol_func = $c_name =~ /^virStorageVol/; + #print "generating $c_name with sig \"$sig\" ...\n"; + + #my $is_pool_func = $c_name =~ /^virStoragePool/; + #my $is_vol_func = $c_name =~ /^virStorageVol/; # Generate an equivalent C-external name for the function, unless # one is defined already. diff --git a/libvirt/libvirt.ml b/libvirt/libvirt.ml index ae37893..aefc6c4 100644 --- a/libvirt/libvirt.ml +++ b/libvirt/libvirt.ml @@ -228,11 +228,14 @@ end module Pool = struct type 'rw t - type pool_state = Inactive | Active + type pool_state = Inactive | Building | Running | Degraded + type pool_build_flags = New | Repair | Resize + type pool_delete_flags = Normal | Zeroed type pool_info = { state : pool_state; capacity : int64; allocation : int64; + available : int64; } external lookup_by_name : 'a Connect.t -> string -> 'a t = "ocaml_libvirt_storage_pool_lookup_by_name" @@ -240,10 +243,11 @@ struct external lookup_by_uuid_string : 'a Connect.t -> string -> 'a t = "ocaml_libvirt_storage_pool_lookup_by_uuid_string" external create_xml : [>`W] Connect.t -> xml -> rw t = "ocaml_libvirt_storage_pool_create_xml" external define_xml : [>`W] Connect.t -> xml -> rw t = "ocaml_libvirt_storage_pool_define_xml" + external build : [>`W] t -> pool_build_flags -> unit = "ocaml_libvirt_storage_pool_build" external undefine : [>`W] t -> unit = "ocaml_libvirt_storage_pool_undefine" external create : [>`W] t -> unit = "ocaml_libvirt_storage_pool_create" external destroy : [>`W] t -> unit = "ocaml_libvirt_storage_pool_destroy" - external shutdown : [>`W] t -> unit = "ocaml_libvirt_storage_pool_shutdown" + external delete : [>`W] t -> unit = "ocaml_libvirt_storage_pool_delete" external free : [>`R] t -> unit = "ocaml_libvirt_storage_pool_free" external refresh : [`R] t -> unit = "ocaml_libvirt_storage_pool_refresh" external get_name : [`R] t -> string = "ocaml_libvirt_storage_pool_get_name" @@ -253,13 +257,16 @@ struct external get_xml_desc : [`R] t -> xml = "ocaml_libvirt_storage_pool_get_xml_desc" external get_autostart : [`R] t -> bool = "ocaml_libvirt_storage_pool_get_autostart" external set_autostart : [`W] t -> bool -> unit = "ocaml_libvirt_storage_pool_set_autostart" + external num_of_volumes : [`R] t -> int = "ocaml_libvirt_storage_pool_num_of_volumes" + external list_volumes : [`R] t -> int -> string array = "ocaml_libvirt_storage_pool_list_volumes" external const : [>`R] t -> ro t = "%identity" end module Volume = struct type 'rw t - type vol_type = File | Block | Virtual + type vol_type = File | Block + type vol_delete_flags = Normal | Zeroed type vol_info = { typ : vol_type; capacity : int64; @@ -276,7 +283,7 @@ struct external get_info : [`R] t -> vol_info = "ocaml_libvirt_storage_vol_get_info" external get_xml_desc : [`R] t -> xml = "ocaml_libvirt_storage_vol_get_xml_desc" external create_xml : [`W] Pool.t -> xml -> unit = "ocaml_libvirt_storage_vol_create_xml" - external destroy : [`W] t -> unit = "ocaml_libvirt_storage_vol_destroy" + external delete : [`W] t -> unit = "ocaml_libvirt_storage_vol_delete" external free : [>`R] t -> unit = "ocaml_libvirt_storage_vol_free" external const : [>`R] t -> ro t = "%identity" end diff --git a/libvirt/libvirt.mli b/libvirt/libvirt.mli index fe9eb40..af372af 100644 --- a/libvirt/libvirt.mli +++ b/libvirt/libvirt.mli @@ -641,13 +641,20 @@ sig type 'rw t (** Storage pool handle. *) - type pool_state = Inactive | Active + type pool_state = Inactive | Building | Running | Degraded (** State of the storage pool. *) + type pool_build_flags = New | Repair | Resize + (** Flags for creating a storage pool. *) + + type pool_delete_flags = Normal | Zeroed + (** Flags for deleting a storage pool. *) + type pool_info = { - state : pool_state; (** Inactive | Active *) + state : pool_state; (** Pool state. *) capacity : int64; (** Logical size in bytes. *) allocation : int64; (** Currently allocated in bytes. *) + available : int64; (** Remaining free space bytes. *) } val lookup_by_name : 'a Connect.t -> string -> 'a t @@ -659,14 +666,16 @@ sig (** Create a storage pool. *) val define_xml : [>`W] Connect.t -> xml -> rw t (** Define but don't activate a storage pool. *) + val build : [>`W] t -> pool_build_flags -> unit + (** Build a storage pool. *) val undefine : [>`W] t -> unit (** Undefine configuration of a storage pool. *) val create : [>`W] t -> unit (** Start up a defined (inactive) storage pool. *) val destroy : [>`W] t -> unit (** Destroy a storage pool. *) - val shutdown : [>`W] t -> unit - (** Shutdown a storage pool. *) + val delete : [>`W] t -> unit + (** Delete a storage pool. *) val free : [>`R] t -> unit (** Free a storage pool object in memory. @@ -692,6 +701,11 @@ sig val set_autostart : [`W] t -> bool -> unit (** Set the autostart flag for the storage pool. *) + val num_of_volumes : [`R] t -> int + (** Returns the number of storage volumes within the storage pool. *) + val list_volumes : [`R] t -> int -> string array + (** Return list of storage volumes. *) + external const : [>`R] t -> ro t = "%identity" (** [const conn] turns a read/write storage pool into a read-only pool. Note that the opposite operation is impossible. @@ -706,9 +720,12 @@ sig type 'rw t (** Storage volume handle. *) - type vol_type = File | Block | Virtual + type vol_type = File | Block (** Type of a storage volume. *) + type vol_delete_flags = Normal | Zeroed + (** Flags for deleting a storage volume. *) + type vol_info = { typ : vol_type; (** Type of storage volume. *) capacity : int64; (** Logical size in bytes. *) @@ -736,8 +753,8 @@ sig val create_xml : [`W] Pool.t -> xml -> unit (** Create a storage volume. *) - val destroy : [`W] t -> unit - (** Destroy a storage volume. *) + val delete : [`W] t -> unit + (** Delete a storage volume. *) val free : [>`R] t -> unit (** Free a storage volume object in memory. diff --git a/libvirt/libvirt_c.c b/libvirt/libvirt_c.c index 0200b1c..882f016 100644 --- a/libvirt/libvirt_c.c +++ b/libvirt/libvirt_c.c @@ -553,7 +553,7 @@ ocaml_libvirt_domain_create_linux (value connv, value strv) #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRDOMAINCREATELINUXJOB -extern virJobPtr virDomainCreateLinuxJob (virConnectPtr conn, const char *str, unsigned int flags) __attribute__((weak)); +extern virJobPtr virDomainCreateLinuxJob (virConnectPtr conn, const char *str, unsigned int flags) __attribute__((weak)); #endif #endif @@ -857,7 +857,6 @@ ocaml_libvirt_domain_save (value domv, value strv) { CAMLparam2 (domv, strv); - CAMLlocal1 (rv); virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); char *str = String_val (strv); @@ -919,7 +918,6 @@ ocaml_libvirt_domain_restore (value connv, value strv) { CAMLparam2 (connv, strv); - CAMLlocal1 (rv); virConnectPtr conn = Connect_val (connv); char *str = String_val (strv); int r; @@ -1216,7 +1214,6 @@ ocaml_libvirt_domain_attach_device (value domv, value strv) { CAMLparam2 (domv, strv); - CAMLlocal1 (rv); virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); char *str = String_val (strv); @@ -1237,7 +1234,6 @@ ocaml_libvirt_domain_detach_device (value domv, value strv) { CAMLparam2 (domv, strv); - CAMLlocal1 (rv); virDomainPtr dom = Domain_val (domv); virConnectPtr conn = Connect_domv (domv); char *str = String_val (strv); @@ -1945,12 +1941,12 @@ ocaml_libvirt_storage_pool_get_name (value poolv) } /* Automatically generated binding for virStoragePoolGetXMLDesc. - * In generator.pl this function has signature "pool, 0 : string". + * In generator.pl this function has signature "pool, 0U : string". */ #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRSTORAGEPOOLGETXMLDESC -extern char *virStoragePoolGetXMLDesc (virStoragePoolPtr pool, int flags) __attribute__((weak)); +extern char *virStoragePoolGetXMLDesc (virStoragePoolPtr pool, unsigned int flags) __attribute__((weak)); #endif #endif @@ -2064,12 +2060,12 @@ ocaml_libvirt_storage_pool_get_uuid_string (value poolv) } /* Automatically generated binding for virStoragePoolCreateXML. - * In generator.pl this function has signature "conn, string : pool". + * In generator.pl this function has signature "conn, string, 0U : pool". */ #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRSTORAGEPOOLCREATEXML -extern virStoragePoolPtr virStoragePoolCreateXML (virConnectPtr conn, const char *str) __attribute__((weak)); +extern virStoragePoolPtr virStoragePoolCreateXML (virConnectPtr conn, const char *str, unsigned int flags) __attribute__((weak)); #endif #endif @@ -2093,7 +2089,7 @@ ocaml_libvirt_storage_pool_create_xml (value connv, value strv) char *str = String_val (strv); virStoragePoolPtr r; - NONBLOCKING (r = virStoragePoolCreateXML (conn, str)); + NONBLOCKING (r = virStoragePoolCreateXML (conn, str, 0)); CHECK_ERROR (!r, conn, "virStoragePoolCreateXML"); rv = Val_pool (r, connv); @@ -2103,12 +2099,12 @@ ocaml_libvirt_storage_pool_create_xml (value connv, value strv) } /* Automatically generated binding for virStoragePoolDefineXML. - * In generator.pl this function has signature "conn, string : pool". + * In generator.pl this function has signature "conn, string, 0U : pool". */ #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRSTORAGEPOOLDEFINEXML -extern virStoragePoolPtr virStoragePoolDefineXML (virConnectPtr conn, const char *str) __attribute__((weak)); +extern virStoragePoolPtr virStoragePoolDefineXML (virConnectPtr conn, const char *str, unsigned int flags) __attribute__((weak)); #endif #endif @@ -2132,7 +2128,7 @@ ocaml_libvirt_storage_pool_define_xml (value connv, value strv) char *str = String_val (strv); virStoragePoolPtr r; - NONBLOCKING (r = virStoragePoolDefineXML (conn, str)); + NONBLOCKING (r = virStoragePoolDefineXML (conn, str, 0)); CHECK_ERROR (!r, conn, "virStoragePoolDefineXML"); rv = Val_pool (r, connv); @@ -2141,6 +2137,43 @@ ocaml_libvirt_storage_pool_define_xml (value connv, value strv) #endif } +/* Automatically generated binding for virStoragePoolBuild. + * In generator.pl this function has signature "pool, uint : unit". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLBUILD +extern int virStoragePoolBuild (virStoragePoolPtr pool, unsigned int i) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_pool_build (value poolv, value iv) +{ + CAMLparam2 (poolv, iv); +#ifndef HAVE_VIRSTORAGEPOOLBUILD + /* Symbol virStoragePoolBuild not found at compile time. */ + not_supported ("virStoragePoolBuild"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolBuild + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolBuild); + + virStoragePoolPtr pool = Pool_val (poolv); + virConnectPtr conn = Connect_polv (poolv); + unsigned int i = Int_val (iv); + int r; + + NONBLOCKING (r = virStoragePoolBuild (pool, i)); + CHECK_ERROR (!r, conn, "virStoragePoolBuild"); + + CAMLreturn (Val_unit); +#endif +} + /* Automatically generated binding for virStoragePoolUndefine. * In generator.pl this function has signature "pool : unit". */ @@ -2178,12 +2211,12 @@ ocaml_libvirt_storage_pool_undefine (value poolv) } /* Automatically generated binding for virStoragePoolCreate. - * In generator.pl this function has signature "pool : unit". + * In generator.pl this function has signature "pool, 0U : unit". */ #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRSTORAGEPOOLCREATE -extern int virStoragePoolCreate (virStoragePoolPtr pool) __attribute__((weak)); +extern int virStoragePoolCreate (virStoragePoolPtr pool, unsigned int flags) __attribute__((weak)); #endif #endif @@ -2206,44 +2239,45 @@ ocaml_libvirt_storage_pool_create (value poolv) virConnectPtr conn = Connect_polv (poolv); int r; - NONBLOCKING (r = virStoragePoolCreate (pool)); + NONBLOCKING (r = virStoragePoolCreate (pool, 0)); CHECK_ERROR (r == -1, conn, "virStoragePoolCreate"); CAMLreturn (Val_unit); #endif } -/* Automatically generated binding for virStoragePoolShutdown. - * In generator.pl this function has signature "pool : unit". +/* Automatically generated binding for virStoragePoolDelete. + * In generator.pl this function has signature "pool, uint : unit". */ #ifdef HAVE_WEAK_SYMBOLS -#ifdef HAVE_VIRSTORAGEPOOLSHUTDOWN -extern int virStoragePoolShutdown (virStoragePoolPtr pool) __attribute__((weak)); +#ifdef HAVE_VIRSTORAGEPOOLDELETE +extern int virStoragePoolDelete (virStoragePoolPtr pool, unsigned int i) __attribute__((weak)); #endif #endif CAMLprim value -ocaml_libvirt_storage_pool_shutdown (value poolv) +ocaml_libvirt_storage_pool_delete (value poolv, value iv) { - CAMLparam1 (poolv); -#ifndef HAVE_VIRSTORAGEPOOLSHUTDOWN - /* Symbol virStoragePoolShutdown not found at compile time. */ - not_supported ("virStoragePoolShutdown"); + CAMLparam2 (poolv, iv); +#ifndef HAVE_VIRSTORAGEPOOLDELETE + /* Symbol virStoragePoolDelete not found at compile time. */ + not_supported ("virStoragePoolDelete"); /* Suppresses a compiler warning. */ (void) caml__frame; #else - /* Check that the symbol virStoragePoolShutdown + /* Check that the symbol virStoragePoolDelete * is in runtime version of libvirt. */ - WEAK_SYMBOL_CHECK (virStoragePoolShutdown); + WEAK_SYMBOL_CHECK (virStoragePoolDelete); virStoragePoolPtr pool = Pool_val (poolv); virConnectPtr conn = Connect_polv (poolv); + unsigned int i = Int_val (iv); int r; - NONBLOCKING (r = virStoragePoolShutdown (pool)); - CHECK_ERROR (r == -1, conn, "virStoragePoolShutdown"); + NONBLOCKING (r = virStoragePoolDelete (pool, i)); + CHECK_ERROR (!r, conn, "virStoragePoolDelete"); CAMLreturn (Val_unit); #endif @@ -2359,6 +2393,88 @@ ocaml_libvirt_storage_pool_set_autostart (value poolv, value bv) #endif } +/* Automatically generated binding for virStoragePoolNumOfVolumes. + * In generator.pl this function has signature "pool : int". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLNUMOFVOLUMES +extern int virStoragePoolNumOfVolumes (virStoragePoolPtr pool) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_pool_num_of_volumes (value poolv) +{ + CAMLparam1 (poolv); +#ifndef HAVE_VIRSTORAGEPOOLNUMOFVOLUMES + /* Symbol virStoragePoolNumOfVolumes not found at compile time. */ + not_supported ("virStoragePoolNumOfVolumes"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolNumOfVolumes + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolNumOfVolumes); + + virStoragePoolPtr pool = Pool_val (poolv); + virConnectPtr conn = Connect_polv (poolv); + int r; + + NONBLOCKING (r = virStoragePoolNumOfVolumes (pool)); + CHECK_ERROR (r == -1, conn, "virStoragePoolNumOfVolumes"); + + CAMLreturn (Val_int (r)); +#endif +} + +/* Automatically generated binding for virStoragePoolListVolumes. + * In generator.pl this function has signature "pool, int : string array". + */ + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLLISTVOLUMES +extern int virStoragePoolListVolumes (virStoragePoolPtr pool, char **const names, int maxnames) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_pool_list_volumes (value poolv, value iv) +{ + CAMLparam2 (poolv, iv); +#ifndef HAVE_VIRSTORAGEPOOLLISTVOLUMES + /* Symbol virStoragePoolListVolumes not found at compile time. */ + not_supported ("virStoragePoolListVolumes"); + /* Suppresses a compiler warning. */ + (void) caml__frame; +#else + /* Check that the symbol virStoragePoolListVolumes + * is in runtime version of libvirt. + */ + WEAK_SYMBOL_CHECK (virStoragePoolListVolumes); + + CAMLlocal2 (rv, strv); + virStoragePoolPtr pool = Pool_val (poolv); + virConnectPtr conn = Connect_polv (poolv); + int i = Int_val (iv); + char *names[i]; + int r; + + NONBLOCKING (r = virStoragePoolListVolumes (pool, names, i)); + CHECK_ERROR (r == -1, conn, "virStoragePoolListVolumes"); + + 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 virStorageVolFree. * In generator.pl this function has signature "vol : free". */ @@ -2398,40 +2514,38 @@ ocaml_libvirt_storage_vol_free (value volv) #endif } -/* Automatically generated binding for virStorageVolDestroy. - * In generator.pl this function has signature "vol : free". +/* Automatically generated binding for virStorageVolDelete. + * In generator.pl this function has signature "vol, uint : unit". */ #ifdef HAVE_WEAK_SYMBOLS -#ifdef HAVE_VIRSTORAGEVOLDESTROY -extern int virStorageVolDestroy (virStorageVolPtr vol) __attribute__((weak)); +#ifdef HAVE_VIRSTORAGEVOLDELETE +extern int virStorageVolDelete (virStorageVolPtr vol, unsigned int i) __attribute__((weak)); #endif #endif CAMLprim value -ocaml_libvirt_storage_vol_destroy (value volv) +ocaml_libvirt_storage_vol_delete (value volv, value iv) { - CAMLparam1 (volv); -#ifndef HAVE_VIRSTORAGEVOLDESTROY - /* Symbol virStorageVolDestroy not found at compile time. */ - not_supported ("virStorageVolDestroy"); + CAMLparam2 (volv, iv); +#ifndef HAVE_VIRSTORAGEVOLDELETE + /* Symbol virStorageVolDelete not found at compile time. */ + not_supported ("virStorageVolDelete"); /* Suppresses a compiler warning. */ (void) caml__frame; #else - /* Check that the symbol virStorageVolDestroy + /* Check that the symbol virStorageVolDelete * is in runtime version of libvirt. */ - WEAK_SYMBOL_CHECK (virStorageVolDestroy); + WEAK_SYMBOL_CHECK (virStorageVolDelete); virStorageVolPtr vol = Volume_val (volv); virConnectPtr conn = Connect_volv (volv); + unsigned int i = Int_val (iv); 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; + NONBLOCKING (r = virStorageVolDelete (vol, i)); + CHECK_ERROR (!r, conn, "virStorageVolDelete"); CAMLreturn (Val_unit); #endif @@ -2557,12 +2671,12 @@ ocaml_libvirt_storage_vol_lookup_by_path (value connv, value strv) } /* Automatically generated binding for virStorageVolCreateXML. - * In generator.pl this function has signature "pool, string, 0 : vol from pool". + * In generator.pl this function has signature "pool, string, 0U : vol from pool". */ #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRSTORAGEVOLCREATEXML -extern virStorageVolPtr virStorageVolCreateXML (virStoragePoolPtr pool, const char *str, int flags) __attribute__((weak)); +extern virStorageVolPtr virStorageVolCreateXML (virStoragePoolPtr pool, const char *str, unsigned int flags) __attribute__((weak)); #endif #endif @@ -2598,12 +2712,12 @@ ocaml_libvirt_storage_vol_create_xml (value poolv, value strv) } /* Automatically generated binding for virStorageVolGetXMLDesc. - * In generator.pl this function has signature "vol, 0 : string". + * In generator.pl this function has signature "vol, 0U : string". */ #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRSTORAGEVOLGETXMLDESC -extern char *virStorageVolGetXMLDesc (virStorageVolPtr vol, int flags) __attribute__((weak)); +extern char *virStorageVolGetXMLDesc (virStorageVolPtr vol, unsigned int flags) __attribute__((weak)); #endif #endif diff --git a/libvirt/libvirt_c_oneoffs.c b/libvirt/libvirt_c_oneoffs.c index a3a7e34..5df783e 100644 --- a/libvirt/libvirt_c_oneoffs.c +++ b/libvirt/libvirt_c_oneoffs.c @@ -682,10 +682,11 @@ ocaml_libvirt_storage_pool_get_info (value poolv) NONBLOCKING (r = virStoragePoolGetInfo (pool, &info)); CHECK_ERROR (r == -1, conn, "virStoragePoolGetInfo"); - rv = caml_alloc (3, 0); + rv = caml_alloc (4, 0); Store_field (rv, 0, Val_int (info.state)); v = caml_copy_int64 (info.capacity); Store_field (rv, 1, v); - v = caml_copy_int64 (info.allocation); Store_field (rv, 1, v); + v = caml_copy_int64 (info.allocation); Store_field (rv, 2, v); + v = caml_copy_int64 (info.available); Store_field (rv, 3, v); CAMLreturn (rv); #else -- 1.8.3.1