From b6098f4c7419486227cbe2112904cbc9d58ed787 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 19 Jan 2008 14:14:02 +0000 Subject: Autogenerate all GetUUID and GetUUIDString functions. --- libvirt/generator.pl | 46 ++++++++++++- libvirt/libvirt_c.c | 154 ++++++++++++++++++++++++++++++++++++++++---- libvirt/libvirt_c_oneoffs.c | 68 ------------------- 3 files changed, 186 insertions(+), 82 deletions(-) diff --git a/libvirt/generator.pl b/libvirt/generator.pl index b389a1b..4fd07b8 100755 --- a/libvirt/generator.pl +++ b/libvirt/generator.pl @@ -56,6 +56,8 @@ my @functions = ( { name => "virDomainGetName", sig => "dom : static string" }, { name => "virDomainGetOSType", sig => "dom : string" }, { name => "virDomainGetXMLDesc", sig => "dom, 0 : string" }, + { name => "virDomainGetUUID", sig => "dom : uuid" }, + { name => "virDomainGetUUIDString", sig => "dom : uuid string" }, { name => "virDomainSuspend", sig => "dom : unit" }, { name => "virDomainResume", sig => "dom : unit" }, { name => "virDomainShutdown", sig => "dom : unit" }, @@ -70,6 +72,8 @@ my @functions = ( { name => "virNetworkGetName", sig => "net : static string" }, { name => "virNetworkGetXMLDesc", sig => "net, 0 : string" }, { name => "virNetworkGetBridgeName", sig => "net : string" }, + { name => "virNetworkGetUUID", sig => "net : uuid" }, + { name => "virNetworkGetUUIDString", sig => "net : uuid string" }, { name => "virNetworkUndefine", sig => "net : unit" }, { name => "virNetworkCreate", sig => "net : unit" }, { name => "virNetworkGetAutostart", sig => "net : bool" }, @@ -83,6 +87,10 @@ my @functions = ( sig => "pool : static string", weak => 1 }, { name => "virStoragePoolGetXMLDesc", sig => "pool, 0 : string", weak => 1 }, + { name => "virStoragePoolGetUUID", + sig => "pool : uuid", weak => 1 }, + { name => "virStoragePoolGetUUIDString", + sig => "pool : uuid string", weak => 1 }, { name => "virStoragePoolUndefine", sig => "pool : unit", weak => 1 }, { name => "virStoragePoolCreate", @@ -126,8 +134,6 @@ my @unimplemented = ( "ocaml_libvirt_network_create_job", "ocaml_libvirt_network_create_xml_job", "ocaml_libvirt_storage_pool_get_info", - "ocaml_libvirt_storage_pool_get_uuid_string", #? - "ocaml_libvirt_storage_pool_get_uuid", #? "ocaml_libvirt_storage_pool_free", #? "ocaml_libvirt_storage_pool_destroy", #? "ocaml_libvirt_storage_pool_define_xml", @@ -248,6 +254,12 @@ sub gen_c_signature } elsif ($sig =~ /^(\w+) : int$/) { my $c_type = short_name_to_c_type ($1); "int $c_name ($c_type $1)" + } elsif ($sig =~ /^(\w+) : uuid$/) { + my $c_type = short_name_to_c_type ($1); + "int $c_name ($c_type $1, unsigned char *)" + } elsif ($sig =~ /^(\w+) : uuid string$/) { + my $c_type = short_name_to_c_type ($1); + "int $c_name ($c_type $1, char *)" } elsif ($sig =~ /^(\w+) : bool$/) { my $c_type = short_name_to_c_type ($1); "int $c_name ($c_type $1, int *r)" @@ -288,6 +300,10 @@ sub gen_arg_names ( "$1v" ) } elsif ($sig =~ /^(\w+) : int$/) { ( "$1v" ) + } elsif ($sig =~ /^(\w+) : uuid$/) { + ( "$1v" ) + } elsif ($sig =~ /^(\w+) : uuid string$/) { + ( "$1v" ) } elsif ($sig =~ /^(\w+) : bool$/) { ( "$1v" ) } elsif ($sig =~ /^(\w+), bool : unit$/) { @@ -386,6 +402,32 @@ sub gen_c_code CHECK_ERROR (r == -1, conn, \"$c_name\"); CAMLreturn (Val_int (r)); +" + } elsif ($sig =~ /^(\w+) : uuid$/) { + "\ + CAMLlocal1 (rv); + " . gen_unpack_args ($1) . " + unsigned char uuid[VIR_UUID_BUFLEN]; + int r; + + NONBLOCKING (r = $c_name ($1, uuid)); + CHECK_ERROR (r == -1, conn, \"$c_name\"); + + rv = caml_copy_string ((char *) uuid); + CAMLreturn (rv); +" + } elsif ($sig =~ /^(\w+) : uuid string$/) { + "\ + CAMLlocal1 (rv); + " . gen_unpack_args ($1) . " + char uuid[VIR_UUID_STRING_BUFLEN]; + int r; + + NONBLOCKING (r = $c_name ($1, uuid)); + CHECK_ERROR (r == -1, conn, \"$c_name\"); + + rv = caml_copy_string (uuid); + CAMLreturn (rv); " } elsif ($sig =~ /^(\w+) : bool$/) { "\ diff --git a/libvirt/libvirt_c.c b/libvirt/libvirt_c.c index 0dc21e4..dc7b3c9 100644 --- a/libvirt/libvirt_c.c +++ b/libvirt/libvirt_c.c @@ -529,6 +529,42 @@ ocaml_libvirt_domain_get_xml_desc (value domv) CAMLreturn (rv); } +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; + + NONBLOCKING (r = virDomainGetUUID (dom, uuid)); + CHECK_ERROR (r == -1, conn, "virDomainGetUUID"); + + rv = caml_copy_string ((char *) uuid); + CAMLreturn (rv); +} + +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; + + NONBLOCKING (r = virDomainGetUUIDString (dom, uuid)); + CHECK_ERROR (r == -1, conn, "virDomainGetUUIDString"); + + rv = caml_copy_string (uuid); + CAMLreturn (rv); +} + CAMLprim value ocaml_libvirt_domain_suspend (value domv) { @@ -740,6 +776,42 @@ ocaml_libvirt_network_get_bridge_name (value netv) CAMLreturn (rv); } +CAMLprim value +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; + + NONBLOCKING (r = virNetworkGetUUID (net, uuid)); + CHECK_ERROR (r == -1, conn, "virNetworkGetUUID"); + + rv = caml_copy_string ((char *) uuid); + CAMLreturn (rv); +} + +CAMLprim value +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; + + NONBLOCKING (r = virNetworkGetUUIDString (net, uuid)); + CHECK_ERROR (r == -1, conn, "virNetworkGetUUIDString"); + + rv = caml_copy_string (uuid); + CAMLreturn (rv); +} + CAMLprim value ocaml_libvirt_network_undefine (value netv) { @@ -941,6 +1013,76 @@ ocaml_libvirt_storage_pool_get_xml_desc (value poolv) #endif } +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLGETUUID +extern int virStoragePoolGetUUID (virStoragePoolPtr pool, unsigned char *) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_pool_get_uuid (value poolv) +{ + 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); + + 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"); + + rv = caml_copy_string ((char *) uuid); + CAMLreturn (rv); +#endif +} + +#ifdef HAVE_WEAK_SYMBOLS +#ifdef HAVE_VIRSTORAGEPOOLGETUUIDSTRING +extern int virStoragePoolGetUUIDString (virStoragePoolPtr pool, char *) __attribute__((weak)); +#endif +#endif + +CAMLprim value +ocaml_libvirt_storage_pool_get_uuid_string (value poolv) +{ + 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 +} + #ifdef HAVE_WEAK_SYMBOLS #ifdef HAVE_VIRSTORAGEPOOLUNDEFINE extern int virStoragePoolUndefine (virStoragePoolPtr pool) __attribute__((weak)); @@ -1391,18 +1533,6 @@ ocaml_libvirt_storage_pool_get_info () failwith ("ocaml_libvirt_storage_pool_get_info is unimplemented"); } -CAMLprim value -ocaml_libvirt_storage_pool_get_uuid_string () -{ - failwith ("ocaml_libvirt_storage_pool_get_uuid_string is unimplemented"); -} - -CAMLprim value -ocaml_libvirt_storage_pool_get_uuid () -{ - failwith ("ocaml_libvirt_storage_pool_get_uuid is unimplemented"); -} - CAMLprim value ocaml_libvirt_storage_pool_free () { diff --git a/libvirt/libvirt_c_oneoffs.c b/libvirt/libvirt_c_oneoffs.c index ecfdf9d..27f917d 100644 --- a/libvirt/libvirt_c_oneoffs.c +++ b/libvirt/libvirt_c_oneoffs.c @@ -370,40 +370,6 @@ ocaml_libvirt_domain_core_dump (value domv, value pathv) CAMLreturn (Val_unit); } -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; - - NONBLOCKING (r = virDomainGetUUID (dom, uuid)); - CHECK_ERROR (r == -1, conn, "virDomainGetUUID"); - - rv = caml_copy_string ((char *) uuid); - CAMLreturn (rv); -} - -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; - - NONBLOCKING (r = virDomainGetUUIDString (dom, uuid)); - CHECK_ERROR (r == -1, conn, "virDomainGetUUIDString"); - - rv = caml_copy_string (uuid); - CAMLreturn (rv); -} - CAMLprim value ocaml_libvirt_domain_get_id (value domv) { @@ -957,40 +923,6 @@ ocaml_libvirt_network_free (value netv) CAMLreturn (Val_unit); } -CAMLprim value -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; - - NONBLOCKING (r = virNetworkGetUUID (net, uuid)); - CHECK_ERROR (r == -1, conn, "virNetworkGetUUID"); - - rv = caml_copy_string ((char *) uuid); - CAMLreturn (rv); -} - -CAMLprim value -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; - - NONBLOCKING (r = virNetworkGetUUIDString (net, uuid)); - CHECK_ERROR (r == -1, conn, "virNetworkGetUUIDString"); - - rv = caml_copy_string (uuid); - CAMLreturn (rv); -} - /*----------------------------------------------------------------------*/ CAMLprim value -- cgit