From: Richard W.M. Jones <"Richard W.M. Jones "> Date: Sat, 19 Jan 2008 14:14:02 +0000 (+0000) Subject: Autogenerate all GetUUID and GetUUIDString functions. X-Git-Tag: 1.0.4~60 X-Git-Url: http://git.annexia.org/?p=virt-top.git;a=commitdiff_plain;h=b6098f4c7419486227cbe2112904cbc9d58ed787 Autogenerate all GetUUID and GetUUIDString functions. --- 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$/) { @@ -387,6 +403,32 @@ sub gen_c_code 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$/) { "\ " . gen_unpack_args ($1) . " 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 @@ -530,6 +530,42 @@ ocaml_libvirt_domain_get_xml_desc (value domv) } 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) { CAMLparam1 (domv); @@ -741,6 +777,42 @@ ocaml_libvirt_network_get_bridge_name (value netv) } 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) { CAMLparam1 (netv); @@ -942,6 +1014,76 @@ ocaml_libvirt_storage_pool_get_xml_desc (value poolv) } #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)); #endif @@ -1392,18 +1534,6 @@ ocaml_libvirt_storage_pool_get_info () } 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 () { failwith ("ocaml_libvirt_storage_pool_free is unimplemented"); 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 @@ -371,40 +371,6 @@ ocaml_libvirt_domain_core_dump (value domv, value pathv) } 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) { CAMLparam1 (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