Implemented virStorageVolLookupByName & virStorageVolCreateXML.
[virt-top.git] / libvirt / generator.pl
index 7beac84..8b20adf 100755 (executable)
@@ -155,14 +155,14 @@ my @functions = (
 
     { name => "virStorageVolFree", sig => "vol : free", weak => 1 },
     { name => "virStorageVolDestroy", sig => "vol : free", weak => 1 },
-#    { name => "virStorageVolLookupByName", XXX see libvir-list posting
-#      sig => "pool, string : vol", weak => 1 },
+    { name => "virStorageVolLookupByName",
+      sig => "pool, string : vol from pool", weak => 1 },
     { name => "virStorageVolLookupByKey",
       sig => "conn, string : vol", weak => 1 },
     { name => "virStorageVolLookupByPath",
       sig => "conn, string : vol", weak => 1 },
-#    { name => "virStorageVolCreateXML",
-#      sig => "pool, string : vol", weak => 1 }, XXX
+    { name => "virStorageVolCreateXML",
+      sig => "pool, string, 0 : vol from pool", weak => 1 },
     { name => "virStorageVolGetXMLDesc",
       sig => "vol, 0 : string", weak => 1 },
     { name => "virStorageVolGetPath",
@@ -193,11 +193,6 @@ my @functions = (
 # written in 'libvirt_c_oneoffs.c'.
 
 my @unimplemented = (
-    "ocaml_libvirt_storage_pool_get_info",
-    "ocaml_libvirt_storage_vol_lookup_by_name", # XXX see above
-    "ocaml_libvirt_storage_vol_create_xml",     # XXX see above
-    "ocaml_libvirt_storage_vol_get_info",
-    "ocaml_libvirt_job_get_info",
     );
 
 #----------------------------------------------------------------------
@@ -565,7 +560,9 @@ sub gen_c_code
   NONBLOCKING (r = $c_name ($1, uuid));
   CHECK_ERROR (r == -1, conn, \"$c_name\");
 
-  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);
 "
     } elsif ($sig =~ /^(\w+) : uuid string$/) {
@@ -887,6 +884,13 @@ foreach my $function (@functions) {
        die "cannot convert c_name $c_name to c_external_name"
     }
 
+    print F <<END;
+/* Automatically generated binding for $c_name.
+ * In generator.pl this function has signature "$sig".
+ */
+
+END
+
     # Generate a full function prototype if the function is weak.
     my $have_name = "HAVE_" . uc ($c_name);
     if ($is_weak) {
@@ -951,9 +955,9 @@ END
 
 # Unimplemented functions.
 
-printf "$0: warning: %d unimplemented functions\n", scalar (@unimplemented);
-
 if (@unimplemented) {
+    printf "$0: warning: %d unimplemented functions\n", scalar (@unimplemented);
+
     print F <<'END';
 /* The following functions are unimplemented and always fail.
  * See generator.pl '@unimplemented'