X-Original-To: alpine-aports@lists.alpinelinux.org Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-oln040092069103.outbound.protection.outlook.com [40.92.69.103]) by lists.alpinelinux.org (Postfix) with ESMTP id E730EF81606 for ; Wed, 6 Feb 2019 23:33:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AHU9ZEEs4TWwcd5YxA/d2zQ6cAB0bv7+TqH+wsudM3s=; b=qtSEBy0rzEbt+dr1PxR0MjXGCM6pLeCgutGqNWpxT+5sUY6Yjziv3vVsrSdvuDKHu6mqOOG09cIkfemjZlgMp4VA9LB93FzrPieJ34MotZ7ifmPAfrS9LVXh8HlmQPeR5wi/V2oy5mZsNyCYWCS8Bu65FCVSiFwZjPKPzxQY2q5/vvM9R6UebSSaNihGz0b5i4Y9J9rj2CfduQA68lYPwzCJByvMDYdiG0GY9Zls/pl6Kwi43Rj4QeABeFqm8hPqsC6mUt4IE7QAO5BAqERyZDRyjB+tTfRDeRqWxOvGDiMFGQ9ERBpIR/zbzUVeGziO0omWX3PU18H5IkhjEWhAcg== Received: from HE1EUR02FT061.eop-EUR02.prod.protection.outlook.com (10.152.10.58) by HE1EUR02HT180.eop-EUR02.prod.protection.outlook.com (10.152.11.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1580.10; Wed, 6 Feb 2019 23:33:01 +0000 Received: from VI1PR0602MB3245.eurprd06.prod.outlook.com (10.152.10.58) by HE1EUR02FT061.mail.protection.outlook.com (10.152.11.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1580.10 via Frontend Transport; Wed, 6 Feb 2019 23:33:01 +0000 Received: from VI1PR0602MB3245.eurprd06.prod.outlook.com ([fe80::158c:76c2:a615:1be4]) by VI1PR0602MB3245.eurprd06.prod.outlook.com ([fe80::158c:76c2:a615:1be4%3]) with mapi id 15.20.1601.016; Wed, 6 Feb 2019 23:33:01 +0000 From: =?iso-8859-1?Q?Fernando_Casas_Sch=F6ssow?= To: "alpine-aports@lists.alpinelinux.org" CC: =?iso-8859-1?Q?Fernando_Casas_Sch=F6ssow?= Subject: [alpine-aports] [PATCH] testing/ocaml-libvirt: new aport Thread-Topic: [PATCH] testing/ocaml-libvirt: new aport Thread-Index: AQHUvnRMlQuxPcA1gU2Ip22rmd8RLA== Date: Wed, 6 Feb 2019 23:33:01 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MR2P264CA0043.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500::31) To VI1PR0602MB3245.eurprd06.prod.outlook.com (2603:10a6:802:7::11) x-incomingtopheadermarker: OriginalChecksum:087487C07CD16C9666D47521135FAE6B2AEF2EB26D1AAD053B2D46B06D92C3B3;UpperCasedChecksum:37E88B82A490ADBED18D041ACDA3EE0FA545F8ABDA5799C0F1F7F05CC7D950CA;SizeAsReceived:8478;Count:63 x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-tmn: [0PGB9gHuY0JctVuLNkOkg/fRnIeDjkDs] x-microsoft-original-message-id: <20190206233236.20486-1-casasfernando@outlook.com> x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;HE1EUR02HT180;6:JvOp2E9CFWygGiZwwfUJ1lcoHnEBpjEEYWbrES+9CuOrN73f1UW/B9htZE+HSYkoPVJznpXGkRjF9lnDaF+RpY1G/WdcbApbCFF0LBPystg+4F6Ib8WgWRuMvbO7pxTvGXZkQjwlR1F+m762QbNpdoSveJqxb4XmuOq1zqbZmd7aDEUHiGw+rN9P7/mMYMMDSrgC5u4UNsnfMNJ8hgUkagYUT6Xdlg3HsHafSRywH586jnmVFO7cgHFNZcOWiuFUqOi0XKA9jYBiBQ3v0xLRF85jzeK9gSzLBdieBOCbFD+8LCuM5+/XR3gtFouwDe200V8av+e66rYCZu0lOD4iJqYQlhYsw7cKSa1xWHJHnU6yKkL969dODBBmdUCEnF5g2orRZn16gKHh0mQIp06FbBzvPa6+gJtP5bgwY5AO7+wTsy3BnSILg4CHRIFf7sMARlMOpVcpigF6y374mopyxw==;5:nQOiI0W7OKJStz/FLuJwDnOioFBMzQyd9n6MYiaSk/va43gJderfRvKTZP10AkAV6A3HmP86hTYkmKN0sPYmpagkdQDAUnXp7P6nzRU06VojgYq0ooC9fn2EsnVXQLGVg3H38WTRwvScWHQSaQbNGEx3zaVMVtdWalSmf4zVkb5haNMFmbodBDhkM7r+6TXLBbZzx/28MArEMIWj9stCwg==;7:GJGCEZumgLGzDTKmppjk5z9HO++VxUHJd1w3PFWkHpAKm9sDjTR0WfUlZPCWONIp7KjP5B7fHjswhcaehe7b9yFgMQtZHImOv0VcosTGfIk5Os4+pyEdOjtBczNs59yeZBAWuU8aZAKjMrXgUSMu+A== x-incomingheadercount: 63 x-eopattributedmessage: 0 x-ms-exchange-slblob-mailprops: pt8ZUcDWjMUv5dNCIpN4bBtV6sEYxXr3uWHxD6nKEsClPfthMqdUlSKYSB1cDnJ9IapEDHUjMFWEmw+YMPVUXPZZKFoPPc8Efj7X/ulfXdsZzaPu8gVtrGZQDdOcw+1f8YmIXb1hF5Lr6Y7kdUWhsBjdY471hjx5ZM8PbTCFCGM0lWgrCHwl7a4eANXelvF085lbgeftvgnJt2FpiutyqSXGGkVCFqvOWkFVoelfR62Rr8AVyVibLxGLM0ckYiHkO7zWy9hLNcQEVY/u6vWMOrtyJZ++ySansxOV8RGHERRjaW/AU3sW91QrG706OS//8IhfFZgTf39LPm4iE56HThE27lCcbBpiuxNybOBPzTX3oQgB1vAsp+6f3zbq7xBP1ZlmXjdfVcIOBXl38MZK5VfOjyBfYcFm7a8zGGLm+gp0ZO173o9zY28tUnTowwU3laCbPeiQAyJvtJgXEf4bxPM6HOZ2IFq7mC6ACxhOn0hIuU4n7S4mD/KM1vFLCQiD/kLhdfLApNJBeN9GtW2VNOZq9bzEI+4M+U8B8xXJ1o+EnRkKkoy5UmGmdLiVMJsVHt0vn6C2X/+XyofyqNI96ph2KCgJpk/Pin5cFVeTEs3995LDvsEnHK5QYKMBQ9o1jNCED2F9UlqgnrQqc7wSUFnHARj3yobvIcnW7m8+LhuMObMnWoO11r/rGLh2ko9qzfGPk9ugUStFEsbWnKQMOu2GBlXSnRatvbIPp5WTKpom0InG1hM3+kvVRi+/ka5XOS7hPgkw2eG2G+O7II4QF3hhNL6gGyq4tXNMQ6XZUo3VcIPmfAccorzbdzmOz19/83tEtGmf3x8GutbmpYBhVM1ke7995RcG7lEj8UKFM3xs8Py5dUD6AjRUL4R3m69sEjVckUZXG/QXFusXCSMwKoUBTLSzqQ3VYhA4XE+gzS4T9NcbDEVs+dEUjE7dPej+ x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(201702181274)(2017031322404)(2017031323274)(2017031324274)(1601125500)(1603101475)(1701031045);SRVR:HE1EUR02HT180; x-ms-traffictypediagnostic: HE1EUR02HT180: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(4566010)(82015058);SRVR:HE1EUR02HT180;BCL:0;PCL:0;RULEID:;SRVR:HE1EUR02HT180; x-microsoft-antispam-message-info: AZ6T6Dh8i3VP63+i2RVMp9qZG0kdXThx1BfJhT0c/X/JqrgCc5X/gaVTXQYoOrZ5 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailinglist: alpine-aports Precedence: list List-Id: Alpine Development List-Unsubscribe: List-Post: List-Help: List-Subscribe: MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: c001924d-3e68-4f40-89c2-901a49278da7 X-MS-Exchange-CrossTenant-Network-Message-Id: 528a1533-b9d1-442d-7320-08d68c8b6ec3 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: c001924d-3e68-4f40-89c2-901a49278da7 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Feb 2019 23:33:00.4548 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR02HT180 http://libvirt.org/ocaml/ OCaml binding for libvirt --- ...Add-a-binding-for-virDomainCreateXML.patch | 213 ++ ...Remove-unused-not_supported-function.patch | 57 + ...to-stderr-and-use-thread-local-virEr.patch | 1864 +++++++++++++++++ ...-int64_t-instead-of-OCaml-defined-an.patch | 35 + .../ocaml-libvirt/0001-Use-g-warn-error.patch | 78 + ...r-checking-return-from-virInitialize.patch | 32 + .../0002-Update-dependencies.patch | 44 + ...r-virConnectGetAllDomainStats-RHBZ-1.patch | 393 ++++ ...ore-stats-in-the-get_all_domain_stat.patch | 42 + ...f-virConnectGetAllDomainStats-to-ret.patch | 127 ++ testing/ocaml-libvirt/APKBUILD | 58 + 11 files changed, 2943 insertions(+) create mode 100644 testing/ocaml-libvirt/0001-Add-a-binding-for-virDomainC= reateXML.patch create mode 100644 testing/ocaml-libvirt/0001-Remove-unused-not_supported-= function.patch create mode 100644 testing/ocaml-libvirt/0001-Suppress-errors-to-stderr-an= d-use-thread-local-virEr.patch create mode 100644 testing/ocaml-libvirt/0001-Use-C99-standard-int64_t-ins= tead-of-OCaml-defined-an.patch create mode 100644 testing/ocaml-libvirt/0001-Use-g-warn-error.patch create mode 100644 testing/ocaml-libvirt/0002-Don-t-bother-checking-return= -from-virInitialize.patch create mode 100644 testing/ocaml-libvirt/0002-Update-dependencies.patch create mode 100644 testing/ocaml-libvirt/0003-Add-a-binding-for-virConnect= GetAllDomainStats-RHBZ-1.patch create mode 100644 testing/ocaml-libvirt/0004-examples-Print-more-stats-in= -the-get_all_domain_stat.patch create mode 100644 testing/ocaml-libvirt/0005-Change-binding-of-virConnect= GetAllDomainStats-to-ret.patch create mode 100644 testing/ocaml-libvirt/APKBUILD diff --git a/testing/ocaml-libvirt/0001-Add-a-binding-for-virDomainCreateXM= L.patch b/testing/ocaml-libvirt/0001-Add-a-binding-for-virDomainCreateXML.p= atch new file mode 100644 index 0000000000..a25507b4f0 --- /dev/null +++ b/testing/ocaml-libvirt/0001-Add-a-binding-for-virDomainCreateXML.patch @@ -0,0 +1,213 @@ +From 7483c7454538584a3dbe4582096f058e6e877df6 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Fri, 6 Mar 2015 15:35:46 +0000 +Subject: [PATCH] Add a binding for virDomainCreateXML. + +This is more modern than the ancient virDomainCreateLinux API, +and crucially allows you to pass flags such as AUTODESTROY. +--- + configure.ac | 2 +- + libvirt/generator.pl | 23 +++++++++++++++++++++-- + libvirt/libvirt.ml | 19 ++++++++++++++++++- + libvirt/libvirt.mli | 13 +++++++++++-- + libvirt/libvirt_c.c | 25 ++++++++++++++++++++++++- + 5 files changed, 75 insertions(+), 7 deletions(-) + +diff --git a/configure.ac b/configure.ac +index b7544b4..a719fb3 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1,5 +1,5 @@ + # ocaml-libvirt +-# Copyright (C) 2007-2008 Red Hat Inc., Richard W.M. Jones ++# Copyright (C) 2007-2015 Red Hat Inc., Richard W.M. Jones + # + # This library is free software; you can redistribute it and/or + # modify it under the terms of the GNU Lesser General Public +diff --git a/libvirt/generator.pl b/libvirt/generator.pl +index 8229ad1..421592b 100755 +--- a/libvirt/generator.pl ++++ b/libvirt/generator.pl +@@ -1,7 +1,7 @@ + #!/usr/bin/perl -w + # + # OCaml bindings for libvirt. +-# (C) Copyright 2007-2008 Richard W.M. Jones, Red Hat Inc. ++# (C) Copyright 2007-2015 Richard W.M. Jones, Red Hat Inc. + # http://libvirt.org/ + # + # This library is free software; you can redistribute it and/or +@@ -63,6 +63,7 @@ my @functions =3D ( + sig =3D> "conn, int : unit" }, +=20 + { name =3D> "virDomainCreateLinux", sig =3D> "conn, string, 0U : dom"= }, ++ { name =3D> "virDomainCreateXML", sig =3D> "conn, string, unsigned : = dom" }, + { name =3D> "virDomainFree", sig =3D> "dom : free" }, + { name =3D> "virDomainDestroy", sig =3D> "dom : free" }, + { name =3D> "virDomainLookupByName", sig =3D> "conn, string : dom" }, +@@ -198,7 +199,7 @@ print F <<'END'; + */ +=20 + /* OCaml bindings for libvirt. +- * (C) Copyright 2007-2008 Richard W.M. Jones, Red Hat Inc. ++ * (C) Copyright 2007-2015 Richard W.M. Jones, Red Hat Inc. + * http://libvirt.org/ + * + * This library is free software; you can redistribute it and/or +@@ -310,6 +311,8 @@ sub gen_arg_names + ( "$1v", "strv" ) + } elsif ($sig =3D~ /^(\w+), string, 0U? : (\w+)$/) { + ( "$1v", "strv" ) ++ } elsif ($sig =3D~ /^(\w+), string, unsigned : (\w+)$/) { ++ ( "$1v", "strv", "uv" ) + } elsif ($sig =3D~ /^(\w+), u?int : (\w+)$/) { + ( "$1v", "iv" ) + } elsif ($sig =3D~ /^(\w+), uuid : (\w+)$/) { +@@ -632,6 +635,22 @@ sub gen_c_code +=20 + CAMLreturn (rv); + " ++ } elsif ($sig =3D~ /^(\w+), string, unsigned : (\w+)$/) { ++ my $c_ret_type =3D short_name_to_c_type ($2); ++ "\ ++ CAMLlocal1 (rv); ++ " . gen_unpack_args ($1) . " ++ char *str =3D String_val (strv); ++ unsigned int u =3D Int_val (uv); ++ $c_ret_type r; ++ ++ NONBLOCKING (r =3D $c_name ($1, str, u)); ++ CHECK_ERROR (!r, conn, \"$c_name\"); ++ ++ " . gen_pack_result ($2) . " ++ ++ CAMLreturn (rv); ++" + } elsif ($sig =3D~ /^(\w+), (u?)int : unit$/) { + my $unsigned =3D $2 eq "u" ? "unsigned " : ""; + "\ +diff --git a/libvirt/libvirt.ml b/libvirt/libvirt.ml +index 9c9368a..1be023d 100644 +--- a/libvirt/libvirt.ml ++++ b/libvirt/libvirt.ml +@@ -1,5 +1,5 @@ + (* OCaml bindings for libvirt. +- (C) Copyright 2007 Richard W.M. Jones, Red Hat Inc. ++ (C) Copyright 2007-2015 Richard W.M. Jones, Red Hat Inc. + http://libvirt.org/ +=20 + This library is free software; you can redistribute it and/or +@@ -337,6 +337,20 @@ struct + cpu : int; + } +=20 ++ type domain_create_flag =3D ++ | START_PAUSED ++ | START_AUTODESTROY ++ | START_BYPASS_CACHE ++ | START_FORCE_BOOT ++ | START_VALIDATE ++ let rec int_of_domain_create_flags =3D function ++ | [] -> 0 ++ | START_PAUSED :: flags -> 1 lor int_of_domain_create_flags fla= gs ++ | START_AUTODESTROY :: flags -> 2 lor int_of_domain_create_flags fla= gs ++ | START_BYPASS_CACHE :: flags -> 4 lor int_of_domain_create_flags fla= gs ++ | START_FORCE_BOOT :: flags -> 8 lor int_of_domain_create_flags fla= gs ++ | START_VALIDATE :: flags -> 16 lor int_of_domain_create_flags fla= gs ++ + type sched_param =3D string * sched_param_value + and sched_param_value =3D + | SchedFieldInt32 of int32 | SchedFieldUInt32 of int32 +@@ -385,6 +399,9 @@ struct + let max_peek _ =3D 65536 +=20 + external create_linux : [>`W] Connect.t -> xml -> rw t =3D "ocaml_libvi= rt_domain_create_linux" ++ external _create_xml : [>`W] Connect.t -> xml -> int -> rw t =3D "ocaml= _libvirt_domain_create_xml" ++ let create_xml conn xml flags =3D ++ _create_xml conn xml (int_of_domain_create_flags flags) + external lookup_by_id : 'a Connect.t -> int -> 'a t =3D "ocaml_libvirt_= domain_lookup_by_id" + external lookup_by_uuid : 'a Connect.t -> uuid -> 'a t =3D "ocaml_libvi= rt_domain_lookup_by_uuid" + external lookup_by_uuid_string : 'a Connect.t -> string -> 'a t =3D "oc= aml_libvirt_domain_lookup_by_uuid_string" +diff --git a/libvirt/libvirt.mli b/libvirt/libvirt.mli +index 36cd113..8cfcae2 100644 +--- a/libvirt/libvirt.mli ++++ b/libvirt/libvirt.mli +@@ -1,5 +1,5 @@ + (** OCaml bindings for libvirt. *) +-(* (C) Copyright 2007 Richard W.M. Jones, Red Hat Inc. ++(* (C) Copyright 2007-2015 Richard W.M. Jones, Red Hat Inc. + http://libvirt.org/ +=20 + This library is free software; you can redistribute it and/or +@@ -430,6 +430,13 @@ sig + cpu : int; (** real CPU number, -1 if offline *) + } +=20 ++ type domain_create_flag =3D ++ | START_PAUSED (** Launch guest in paused state = *) ++ | START_AUTODESTROY (** Automatically kill guest on c= lose *) ++ | START_BYPASS_CACHE (** Avoid filesystem cache pollut= ion *) ++ | START_FORCE_BOOT (** Discard any managed save *) ++ | START_VALIDATE (** Validate XML against schema *= ) ++ + type sched_param =3D string * sched_param_value + and sched_param_value =3D + | SchedFieldInt32 of int32 | SchedFieldUInt32 of int32 +@@ -478,8 +485,10 @@ sig +=20 + val create_linux : [>`W] Connect.t -> xml -> rw t + (** Create a new guest domain (not necessarily a Linux one) +- from the given XML. ++ from the given XML. Use {!create_xml} instead. + *) ++ val create_xml : [>`W] Connect.t -> xml -> domain_create_flag list -> r= w t ++ (** Create a new guest domain from the given XML. *) + val lookup_by_id : 'a Connect.t -> int -> 'a t + (** Lookup a domain by ID. *) + val lookup_by_uuid : 'a Connect.t -> uuid -> 'a t +diff --git a/libvirt/libvirt_c.c b/libvirt/libvirt_c.c +index 71e6f61..6e56682 100644 +--- a/libvirt/libvirt_c.c ++++ b/libvirt/libvirt_c.c +@@ -6,7 +6,7 @@ + */ +=20 + /* OCaml bindings for libvirt. +- * (C) Copyright 2007-2008 Richard W.M. Jones, Red Hat Inc. ++ * (C) Copyright 2007-2015 Richard W.M. Jones, Red Hat Inc. + * http://libvirt.org/ + * + * This library is free software; you can redistribute it and/or +@@ -525,6 +525,29 @@ ocaml_libvirt_domain_create_linux (value connv, value= strv) + CAMLreturn (rv); + } +=20 ++/* Automatically generated binding for virDomainCreateXML. ++ * In generator.pl this function has signature "conn, string, unsigned : = dom". ++ */ ++ ++CAMLprim value ++ocaml_libvirt_domain_create_xml (value connv, value strv, value uv) ++{ ++ CAMLparam3 (connv, strv, uv); ++ ++ CAMLlocal1 (rv); ++ virConnectPtr conn =3D Connect_val (connv); ++ char *str =3D String_val (strv); ++ unsigned int u =3D Int_val (uv); ++ virDomainPtr r; ++ ++ NONBLOCKING (r =3D virDomainCreateXML (conn, str, u)); ++ CHECK_ERROR (!r, conn, "virDomainCreateXML"); ++ ++ rv =3D Val_domain (r, connv); ++ ++ CAMLreturn (rv); ++} ++ + /* Automatically generated binding for virDomainFree. + * In generator.pl this function has signature "dom : free". + */ +--=20 +2.3.1 + diff --git a/testing/ocaml-libvirt/0001-Remove-unused-not_supported-functio= n.patch b/testing/ocaml-libvirt/0001-Remove-unused-not_supported-function.p= atch new file mode 100644 index 0000000000..851385cba3 --- /dev/null +++ b/testing/ocaml-libvirt/0001-Remove-unused-not_supported-function.patch @@ -0,0 +1,57 @@ +From 8853f5a49587f00a7d2a5c8c7e52480a16bbdb02 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Fri, 5 Feb 2016 16:28:34 +0000 +Subject: [PATCH] Remove unused 'not_supported' function. + +Found by compiling under GCC 6. The warning was: + +In file included from libvirt_c.c:2058:0: +libvirt_c_epilogue.c:89:1: error: 'not_supported' defined but not used [-W= error=3Dunused-function] + not_supported (const char *fn) + ^~~~~~~~~~~~~ +--- + libvirt/libvirt_c_epilogue.c | 15 --------------- + libvirt/libvirt_c_prologue.c | 1 - + 2 files changed, 16 deletions(-) + +diff --git a/libvirt/libvirt_c_epilogue.c b/libvirt/libvirt_c_epilogue.c +index 4972e50..fa592c9 100644 +--- a/libvirt/libvirt_c_epilogue.c ++++ b/libvirt/libvirt_c_epilogue.c +@@ -84,21 +84,6 @@ _raise_virterror (const char *fn) + (void) caml__frame; + } +=20 +-/* Raise an error if a function is not supported. */ +-static void +-not_supported (const char *fn) +-{ +- CAMLparam0 (); +- CAMLlocal1 (fnv); +- +- fnv =3D caml_copy_string (fn); +- caml_raise_with_arg (*caml_named_value ("ocaml_libvirt_not_supported"),= fnv); +- +- /*NOTREACHED*/ +- /* Suppresses a compiler warning. */ +- (void) caml__frame; +-} +- + /* Convert the virErrorNumber, virErrorDomain and virErrorLevel enums + * into values (longs because they are variants in OCaml). + * +diff --git a/libvirt/libvirt_c_prologue.c b/libvirt/libvirt_c_prologue.c +index bf972e9..710c0d6 100644 +--- a/libvirt/libvirt_c_prologue.c ++++ b/libvirt/libvirt_c_prologue.c +@@ -25,7 +25,6 @@ typedef value (*Val_ptr_t) (void *); + static value Val_opt (void *ptr, Val_ptr_t Val_ptr); + /*static value option_default (value option, value deflt);*/ + static void _raise_virterror (const char *fn) Noreturn; +-static void not_supported (const char *fn) Noreturn; + static value Val_virterror (virErrorPtr err); +=20 + /* Use this around synchronous libvirt API calls to release the OCaml +--=20 +2.5.0 + diff --git a/testing/ocaml-libvirt/0001-Suppress-errors-to-stderr-and-use-t= hread-local-virEr.patch b/testing/ocaml-libvirt/0001-Suppress-errors-to-std= err-and-use-thread-local-virEr.patch new file mode 100644 index 0000000000..f3655349e8 --- /dev/null +++ b/testing/ocaml-libvirt/0001-Suppress-errors-to-stderr-and-use-thread-l= ocal-virEr.patch @@ -0,0 +1,1864 @@ +From 68fae1ec3de46fd9eec88fb7c1894ea7ed85ccc9 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Tue, 17 Mar 2015 12:51:50 +0000 +Subject: [PATCH 1/2] Suppress errors to stderr and use thread-local + virErrorPtr + +This allows us to capture errors that happen during virConnectOpen, +without spewing error messages on stderr. + +The patch is rather large, only because we don't need to pass the +virConnectPtr argument to CHECK_ERROR/_raise_virterror any longer. +--- + libvirt/generator.pl | 66 ++++++------ + libvirt/libvirt_c.c | 241 +++++++++++++++++---------------------= ----- + libvirt/libvirt_c_epilogue.c | 4 +- + libvirt/libvirt_c_oneoffs.c | 94 +++++++---------- + libvirt/libvirt_c_prologue.c | 6 +- + 5 files changed, 169 insertions(+), 242 deletions(-) + +diff --git a/libvirt/generator.pl b/libvirt/generator.pl +index 421592b..34801ba 100755 +--- a/libvirt/generator.pl ++++ b/libvirt/generator.pl +@@ -343,17 +343,13 @@ sub gen_unpack_args + if ($_ eq "conn") { + "virConnectPtr conn =3D Connect_val (connv);" + } elsif ($_ eq "dom") { +- "virDomainPtr dom =3D Domain_val (domv);\n". +- " virConnectPtr conn =3D Connect_domv (domv);" ++ "virDomainPtr dom =3D Domain_val (domv);" + } elsif ($_ eq "net") { +- "virNetworkPtr net =3D Network_val (netv);\n". +- " virConnectPtr conn =3D Connect_netv (netv);" ++ "virNetworkPtr net =3D Network_val (netv);" + } elsif ($_ eq "pool") { +- "virStoragePoolPtr pool =3D Pool_val (poolv);\n". +- " virConnectPtr conn =3D Connect_polv (poolv);" ++ "virStoragePoolPtr pool =3D Pool_val (poolv);" + } elsif ($_ eq "vol") { +- "virStorageVolPtr vol =3D Volume_val (volv);\n". +- " virConnectPtr conn =3D Connect_volv (volv);" ++ "virStorageVolPtr vol =3D Volume_val (volv);" + } else { + die "unknown short name $_" + } +@@ -402,7 +398,7 @@ sub gen_c_code + char *r; +=20 + NONBLOCKING (r =3D $c_name ($1)); +- CHECK_ERROR (!r, conn, \"$c_name\"); ++ CHECK_ERROR (!r, \"$c_name\"); +=20 + rv =3D caml_copy_string (r); + free (r); +@@ -415,7 +411,7 @@ sub gen_c_code + const char *r; +=20 + NONBLOCKING (r =3D $c_name ($1)); +- CHECK_ERROR (!r, conn, \"$c_name\"); ++ CHECK_ERROR (!r, \"$c_name\"); +=20 + rv =3D caml_copy_string (r); + CAMLreturn (rv); +@@ -426,7 +422,7 @@ sub gen_c_code + int r; +=20 + NONBLOCKING (r =3D $c_name ($1)); +- CHECK_ERROR (r =3D=3D -1, conn, \"$c_name\"); ++ CHECK_ERROR (r =3D=3D -1, \"$c_name\"); +=20 + CAMLreturn (Val_int (r)); + " +@@ -438,7 +434,7 @@ sub gen_c_code + int r; +=20 + NONBLOCKING (r =3D $c_name ($1, uuid)); +- CHECK_ERROR (r =3D=3D -1, conn, \"$c_name\"); ++ CHECK_ERROR (r =3D=3D -1, \"$c_name\"); +=20 + /* UUIDs are byte arrays with a fixed length. */ + rv =3D caml_alloc_string (VIR_UUID_BUFLEN); +@@ -453,7 +449,7 @@ sub gen_c_code + int r; +=20 + NONBLOCKING (r =3D $c_name ($1, uuid)); +- CHECK_ERROR (r =3D=3D -1, conn, \"$c_name\"); ++ CHECK_ERROR (r =3D=3D -1, \"$c_name\"); +=20 + rv =3D caml_copy_string (uuid); + CAMLreturn (rv); +@@ -464,7 +460,7 @@ sub gen_c_code + int r, b; +=20 + NONBLOCKING (r =3D $c_name ($1, &b)); +- CHECK_ERROR (r =3D=3D -1, conn, \"$c_name\"); ++ CHECK_ERROR (r =3D=3D -1, \"$c_name\"); +=20 + CAMLreturn (b ? Val_true : Val_false); + " +@@ -476,7 +472,7 @@ sub gen_c_code + b =3D bv =3D=3D Val_true ? 1 : 0; +=20 + NONBLOCKING (r =3D $c_name ($1, b)); +- CHECK_ERROR (r =3D=3D -1, conn, \"$c_name\"); ++ CHECK_ERROR (r =3D=3D -1, \"$c_name\"); +=20 + CAMLreturn (Val_unit); + " +@@ -498,7 +494,7 @@ sub gen_c_code + } +=20 + NONBLOCKING (r =3D $c_name (conn, ids, i)); +- CHECK_ERROR (r =3D=3D -1, conn, \"$c_name\"); ++ CHECK_ERROR (r =3D=3D -1, \"$c_name\"); +=20 + rv =3D caml_alloc (r, 0); + for (i =3D 0; i < r; ++i) +@@ -525,7 +521,7 @@ sub gen_c_code + } +=20 + NONBLOCKING (r =3D $c_name ($1, names, i)); +- CHECK_ERROR (r =3D=3D -1, conn, \"$c_name\"); ++ CHECK_ERROR (r =3D=3D -1, \"$c_name\"); +=20 + rv =3D caml_alloc (r, 0); + for (i =3D 0; i < r; ++i) { +@@ -543,7 +539,7 @@ sub gen_c_code + char *r; +=20 + NONBLOCKING (r =3D $c_name ($1, 0)); +- CHECK_ERROR (!r, conn, \"$c_name\"); ++ CHECK_ERROR (!r, \"$c_name\"); +=20 + rv =3D caml_copy_string (r); + free (r); +@@ -555,7 +551,7 @@ sub gen_c_code + int r; +=20 + NONBLOCKING (r =3D $c_name ($1, 0)); +- CHECK_ERROR (r =3D=3D -1, conn, \"$c_name\"); ++ CHECK_ERROR (r =3D=3D -1, \"$c_name\"); +=20 + CAMLreturn (Val_unit); + " +@@ -565,7 +561,7 @@ sub gen_c_code + int r; +=20 + NONBLOCKING (r =3D $c_name ($1)); +- CHECK_ERROR (r =3D=3D -1, conn, \"$c_name\"); ++ CHECK_ERROR (r =3D=3D -1, \"$c_name\"); +=20 + CAMLreturn (Val_unit); + " +@@ -575,7 +571,7 @@ sub gen_c_code + int r; +=20 + NONBLOCKING (r =3D $c_name ($1)); +- CHECK_ERROR (r =3D=3D -1, conn, \"$c_name\"); ++ CHECK_ERROR (r =3D=3D -1, \"$c_name\"); +=20 + /* So that we don't double-free in the finalizer: */ + " . gen_free_arg ($1) . " +@@ -589,7 +585,7 @@ sub gen_c_code + int r; +=20 + NONBLOCKING (r =3D $c_name ($1, str)); +- CHECK_ERROR (r =3D=3D -1, conn, \"$c_name\"); ++ CHECK_ERROR (r =3D=3D -1, \"$c_name\"); +=20 + CAMLreturn (Val_unit); + " +@@ -601,7 +597,7 @@ sub gen_c_code + int r; +=20 + NONBLOCKING (r =3D $c_name ($1, str, 0)); +- CHECK_ERROR (!r, conn, \"$c_name\"); ++ CHECK_ERROR (!r, \"$c_name\"); +=20 + CAMLreturn (Val_unit); + " +@@ -614,7 +610,7 @@ sub gen_c_code + $c_ret_type r; +=20 + NONBLOCKING (r =3D $c_name ($1, str)); +- CHECK_ERROR (!r, conn, \"$c_name\"); ++ CHECK_ERROR (!r, \"$c_name\"); +=20 + " . gen_pack_result ($2) . " +=20 +@@ -629,7 +625,7 @@ sub gen_c_code + $c_ret_type r; +=20 + NONBLOCKING (r =3D $c_name ($1, str, 0)); +- CHECK_ERROR (!r, conn, \"$c_name\"); ++ CHECK_ERROR (!r, \"$c_name\"); +=20 + " . gen_pack_result ($2) . " +=20 +@@ -645,7 +641,7 @@ sub gen_c_code + $c_ret_type r; +=20 + NONBLOCKING (r =3D $c_name ($1, str, u)); +- CHECK_ERROR (!r, conn, \"$c_name\"); ++ CHECK_ERROR (!r, \"$c_name\"); +=20 + " . gen_pack_result ($2) . " +=20 +@@ -659,7 +655,7 @@ sub gen_c_code + int r; +=20 + NONBLOCKING (r =3D $c_name ($1, i)); +- CHECK_ERROR (r =3D=3D -1, conn, \"$c_name\"); ++ CHECK_ERROR (r =3D=3D -1, \"$c_name\"); +=20 + CAMLreturn (Val_unit); + " +@@ -673,7 +669,7 @@ sub gen_c_code + $c_ret_type r; +=20 + NONBLOCKING (r =3D $c_name ($1, i)); +- CHECK_ERROR (!r, conn, \"$c_name\"); ++ CHECK_ERROR (!r, \"$c_name\"); +=20 + " . gen_pack_result ($3) . " +=20 +@@ -688,7 +684,7 @@ sub gen_c_code + $c_ret_type r; +=20 + NONBLOCKING (r =3D $c_name ($1, uuid)); +- CHECK_ERROR (!r, conn, \"$c_name\"); ++ CHECK_ERROR (!r, \"$c_name\"); +=20 + " . gen_pack_result ($2) . " +=20 +@@ -702,7 +698,7 @@ sub gen_c_code + $c_ret_type r; +=20 + NONBLOCKING (r =3D $c_name ($1, 0)); +- CHECK_ERROR (!r, conn, \"$c_name\"); ++ CHECK_ERROR (!r, \"$c_name\"); +=20 + " . gen_pack_result ($2) . " +=20 +@@ -716,7 +712,7 @@ sub gen_c_code + $c_ret_type r; +=20 + NONBLOCKING (r =3D $c_name ($1)); +- CHECK_ERROR (!r, conn, \"$c_name\"); ++ CHECK_ERROR (!r, \"$c_name\"); +=20 + " . gen_pack_result ($2) . " +=20 +@@ -731,7 +727,7 @@ sub gen_c_code + $c_ret_type r; +=20 + NONBLOCKING (r =3D $c_name ($1, str)); +- CHECK_ERROR (!r, conn, \"$c_name\"); ++ CHECK_ERROR (!r, \"$c_name\"); +=20 + connv =3D Field ($3v, 1); + " . gen_pack_result ($2) . " +@@ -747,7 +743,7 @@ sub gen_c_code + $c_ret_type r; +=20 + NONBLOCKING (r =3D $c_name ($1, str, 0)); +- CHECK_ERROR (!r, conn, \"$c_name\"); ++ CHECK_ERROR (!r, \"$c_name\"); +=20 + connv =3D Field ($3v, 1); + " . gen_pack_result ($2) . " +@@ -762,7 +758,7 @@ sub gen_c_code + $c_ret_type r; +=20 + NONBLOCKING (r =3D $c_name ($1, 0)); +- CHECK_ERROR (!r, conn, \"$c_name\"); ++ CHECK_ERROR (!r, \"$c_name\"); +=20 + connv =3D Field ($3v, 1); + " . gen_pack_result ($2) . " +@@ -777,7 +773,7 @@ sub gen_c_code + $c_ret_type r; +=20 + NONBLOCKING (r =3D $c_name ($1)); +- CHECK_ERROR (!r, conn, \"$c_name\"); ++ CHECK_ERROR (!r, \"$c_name\"); +=20 + connv =3D Field ($3v, 1); + " . gen_pack_result ($2) . " +diff --git a/libvirt/libvirt_c.c b/libvirt/libvirt_c.c +index 6e56682..8d51944 100644 +--- a/libvirt/libvirt_c.c ++++ b/libvirt/libvirt_c.c +@@ -61,7 +61,7 @@ ocaml_libvirt_connect_close (value connv) + int r; +=20 + NONBLOCKING (r =3D virConnectClose (conn)); +- CHECK_ERROR (r =3D=3D -1, conn, "virConnectClose"); ++ CHECK_ERROR (r =3D=3D -1, "virConnectClose"); +=20 + /* So that we don't double-free in the finalizer: */ + Connect_val (connv) =3D NULL; +@@ -83,7 +83,7 @@ ocaml_libvirt_connect_get_hostname (value connv) + char *r; +=20 + NONBLOCKING (r =3D virConnectGetHostname (conn)); +- CHECK_ERROR (!r, conn, "virConnectGetHostname"); ++ CHECK_ERROR (!r, "virConnectGetHostname"); +=20 + rv =3D caml_copy_string (r); + free (r); +@@ -104,7 +104,7 @@ ocaml_libvirt_connect_get_uri (value connv) + char *r; +=20 + NONBLOCKING (r =3D virConnectGetURI (conn)); +- CHECK_ERROR (!r, conn, "virConnectGetURI"); ++ CHECK_ERROR (!r, "virConnectGetURI"); +=20 + rv =3D caml_copy_string (r); + free (r); +@@ -125,7 +125,7 @@ ocaml_libvirt_connect_get_type (value connv) + const char *r; +=20 + NONBLOCKING (r =3D virConnectGetType (conn)); +- CHECK_ERROR (!r, conn, "virConnectGetType"); ++ CHECK_ERROR (!r, "virConnectGetType"); +=20 + rv =3D caml_copy_string (r); + CAMLreturn (rv); +@@ -144,7 +144,7 @@ ocaml_libvirt_connect_num_of_domains (value connv) + int r; +=20 + NONBLOCKING (r =3D virConnectNumOfDomains (conn)); +- CHECK_ERROR (r =3D=3D -1, conn, "virConnectNumOfDomains"); ++ CHECK_ERROR (r =3D=3D -1, "virConnectNumOfDomains"); +=20 + CAMLreturn (Val_int (r)); + } +@@ -174,7 +174,7 @@ ocaml_libvirt_connect_list_domains (value connv, value= iv) + } +=20 + NONBLOCKING (r =3D virConnectListDomains (conn, ids, i)); +- CHECK_ERROR (r =3D=3D -1, conn, "virConnectListDomains"); ++ CHECK_ERROR (r =3D=3D -1, "virConnectListDomains"); +=20 + rv =3D caml_alloc (r, 0); + for (i =3D 0; i < r; ++i) +@@ -196,7 +196,7 @@ ocaml_libvirt_connect_num_of_defined_domains (value co= nnv) + int r; +=20 + NONBLOCKING (r =3D virConnectNumOfDefinedDomains (conn)); +- CHECK_ERROR (r =3D=3D -1, conn, "virConnectNumOfDefinedDomains"); ++ CHECK_ERROR (r =3D=3D -1, "virConnectNumOfDefinedDomains"); +=20 + CAMLreturn (Val_int (r)); + } +@@ -227,7 +227,7 @@ ocaml_libvirt_connect_list_defined_domains (value conn= v, value iv) + } +=20 + NONBLOCKING (r =3D virConnectListDefinedDomains (conn, names, i)); +- CHECK_ERROR (r =3D=3D -1, conn, "virConnectListDefinedDomains"); ++ CHECK_ERROR (r =3D=3D -1, "virConnectListDefinedDomains"); +=20 + rv =3D caml_alloc (r, 0); + for (i =3D 0; i < r; ++i) { +@@ -252,7 +252,7 @@ ocaml_libvirt_connect_num_of_networks (value connv) + int r; +=20 + NONBLOCKING (r =3D virConnectNumOfNetworks (conn)); +- CHECK_ERROR (r =3D=3D -1, conn, "virConnectNumOfNetworks"); ++ CHECK_ERROR (r =3D=3D -1, "virConnectNumOfNetworks"); +=20 + CAMLreturn (Val_int (r)); + } +@@ -283,7 +283,7 @@ ocaml_libvirt_connect_list_networks (value connv, valu= e iv) + } +=20 + NONBLOCKING (r =3D virConnectListNetworks (conn, names, i)); +- CHECK_ERROR (r =3D=3D -1, conn, "virConnectListNetworks"); ++ CHECK_ERROR (r =3D=3D -1, "virConnectListNetworks"); +=20 + rv =3D caml_alloc (r, 0); + for (i =3D 0; i < r; ++i) { +@@ -308,7 +308,7 @@ ocaml_libvirt_connect_num_of_defined_networks (value c= onnv) + int r; +=20 + NONBLOCKING (r =3D virConnectNumOfDefinedNetworks (conn)); +- CHECK_ERROR (r =3D=3D -1, conn, "virConnectNumOfDefinedNetworks"); ++ CHECK_ERROR (r =3D=3D -1, "virConnectNumOfDefinedNetworks"); +=20 + CAMLreturn (Val_int (r)); + } +@@ -339,7 +339,7 @@ ocaml_libvirt_connect_list_defined_networks (value con= nv, value iv) + } +=20 + NONBLOCKING (r =3D virConnectListDefinedNetworks (conn, names, i)); +- CHECK_ERROR (r =3D=3D -1, conn, "virConnectListDefinedNetworks"); ++ CHECK_ERROR (r =3D=3D -1, "virConnectListDefinedNetworks"); +=20 + rv =3D caml_alloc (r, 0); + for (i =3D 0; i < r; ++i) { +@@ -364,7 +364,7 @@ ocaml_libvirt_connect_num_of_storage_pools (value conn= v) + int r; +=20 + NONBLOCKING (r =3D virConnectNumOfStoragePools (conn)); +- CHECK_ERROR (r =3D=3D -1, conn, "virConnectNumOfStoragePools"); ++ CHECK_ERROR (r =3D=3D -1, "virConnectNumOfStoragePools"); +=20 + CAMLreturn (Val_int (r)); + } +@@ -395,7 +395,7 @@ ocaml_libvirt_connect_list_storage_pools (value connv,= value iv) + } +=20 + NONBLOCKING (r =3D virConnectListStoragePools (conn, names, i)); +- CHECK_ERROR (r =3D=3D -1, conn, "virConnectListStoragePools"); ++ CHECK_ERROR (r =3D=3D -1, "virConnectListStoragePools"); +=20 + rv =3D caml_alloc (r, 0); + for (i =3D 0; i < r; ++i) { +@@ -420,7 +420,7 @@ ocaml_libvirt_connect_num_of_defined_storage_pools (va= lue connv) + int r; +=20 + NONBLOCKING (r =3D virConnectNumOfDefinedStoragePools (conn)); +- CHECK_ERROR (r =3D=3D -1, conn, "virConnectNumOfDefinedStoragePools"); ++ CHECK_ERROR (r =3D=3D -1, "virConnectNumOfDefinedStoragePools"); +=20 + CAMLreturn (Val_int (r)); + } +@@ -451,7 +451,7 @@ ocaml_libvirt_connect_list_defined_storage_pools (valu= e connv, value iv) + } +=20 + NONBLOCKING (r =3D virConnectListDefinedStoragePools (conn, names, i)); +- CHECK_ERROR (r =3D=3D -1, conn, "virConnectListDefinedStoragePools"); ++ CHECK_ERROR (r =3D=3D -1, "virConnectListDefinedStoragePools"); +=20 + rv =3D caml_alloc (r, 0); + for (i =3D 0; i < r; ++i) { +@@ -477,7 +477,7 @@ ocaml_libvirt_connect_get_capabilities (value connv) + char *r; +=20 + NONBLOCKING (r =3D virConnectGetCapabilities (conn)); +- CHECK_ERROR (!r, conn, "virConnectGetCapabilities"); ++ CHECK_ERROR (!r, "virConnectGetCapabilities"); +=20 + rv =3D caml_copy_string (r); + free (r); +@@ -498,7 +498,7 @@ ocaml_libvirt_connect_domain_event_deregister_any (val= ue connv, value iv) + int r; +=20 + NONBLOCKING (r =3D virConnectDomainEventDeregisterAny (conn, i)); +- CHECK_ERROR (r =3D=3D -1, conn, "virConnectDomainEventDeregisterAny"); ++ CHECK_ERROR (r =3D=3D -1, "virConnectDomainEventDeregisterAny"); +=20 + CAMLreturn (Val_unit); + } +@@ -518,7 +518,7 @@ ocaml_libvirt_domain_create_linux (value connv, value = strv) + virDomainPtr r; +=20 + NONBLOCKING (r =3D virDomainCreateLinux (conn, str, 0)); +- CHECK_ERROR (!r, conn, "virDomainCreateLinux"); ++ CHECK_ERROR (!r, "virDomainCreateLinux"); +=20 + rv =3D Val_domain (r, connv); +=20 +@@ -541,7 +541,7 @@ ocaml_libvirt_domain_create_xml (value connv, value st= rv, value uv) + virDomainPtr r; +=20 + NONBLOCKING (r =3D virDomainCreateXML (conn, str, u)); +- CHECK_ERROR (!r, conn, "virDomainCreateXML"); ++ CHECK_ERROR (!r, "virDomainCreateXML"); +=20 + rv =3D Val_domain (r, connv); +=20 +@@ -558,11 +558,10 @@ ocaml_libvirt_domain_free (value domv) + CAMLparam1 (domv); +=20 + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + int r; +=20 + NONBLOCKING (r =3D virDomainFree (dom)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainFree"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainFree"); +=20 + /* So that we don't double-free in the finalizer: */ + Domain_val (domv) =3D NULL; +@@ -580,11 +579,10 @@ ocaml_libvirt_domain_destroy (value domv) + CAMLparam1 (domv); +=20 + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + int r; +=20 + NONBLOCKING (r =3D virDomainDestroy (dom)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainDestroy"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainDestroy"); +=20 + /* So that we don't double-free in the finalizer: */ + Domain_val (domv) =3D NULL; +@@ -607,7 +605,7 @@ ocaml_libvirt_domain_lookup_by_name (value connv, valu= e strv) + virDomainPtr r; +=20 + NONBLOCKING (r =3D virDomainLookupByName (conn, str)); +- CHECK_ERROR (!r, conn, "virDomainLookupByName"); ++ CHECK_ERROR (!r, "virDomainLookupByName"); +=20 + rv =3D Val_domain (r, connv); +=20 +@@ -629,7 +627,7 @@ ocaml_libvirt_domain_lookup_by_id (value connv, value = iv) + virDomainPtr r; +=20 + NONBLOCKING (r =3D virDomainLookupByID (conn, i)); +- CHECK_ERROR (!r, conn, "virDomainLookupByID"); ++ CHECK_ERROR (!r, "virDomainLookupByID"); +=20 + rv =3D Val_domain (r, connv); +=20 +@@ -651,7 +649,7 @@ ocaml_libvirt_domain_lookup_by_uuid (value connv, valu= e uuidv) + virDomainPtr r; +=20 + NONBLOCKING (r =3D virDomainLookupByUUID (conn, uuid)); +- CHECK_ERROR (!r, conn, "virDomainLookupByUUID"); ++ CHECK_ERROR (!r, "virDomainLookupByUUID"); +=20 + rv =3D Val_domain (r, connv); +=20 +@@ -673,7 +671,7 @@ ocaml_libvirt_domain_lookup_by_uuid_string (value conn= v, value strv) + virDomainPtr r; +=20 + NONBLOCKING (r =3D virDomainLookupByUUIDString (conn, str)); +- CHECK_ERROR (!r, conn, "virDomainLookupByUUIDString"); ++ CHECK_ERROR (!r, "virDomainLookupByUUIDString"); +=20 + rv =3D Val_domain (r, connv); +=20 +@@ -691,11 +689,10 @@ ocaml_libvirt_domain_get_name (value domv) +=20 + CAMLlocal1 (rv); + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + const char *r; +=20 + NONBLOCKING (r =3D virDomainGetName (dom)); +- CHECK_ERROR (!r, conn, "virDomainGetName"); ++ CHECK_ERROR (!r, "virDomainGetName"); +=20 + rv =3D caml_copy_string (r); + CAMLreturn (rv); +@@ -712,11 +709,10 @@ ocaml_libvirt_domain_get_os_type (value domv) +=20 + CAMLlocal1 (rv); + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + char *r; +=20 + NONBLOCKING (r =3D virDomainGetOSType (dom)); +- CHECK_ERROR (!r, conn, "virDomainGetOSType"); ++ CHECK_ERROR (!r, "virDomainGetOSType"); +=20 + rv =3D caml_copy_string (r); + free (r); +@@ -734,11 +730,10 @@ ocaml_libvirt_domain_get_xml_desc (value domv) +=20 + CAMLlocal1 (rv); + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + char *r; +=20 + NONBLOCKING (r =3D virDomainGetXMLDesc (dom, 0)); +- CHECK_ERROR (!r, conn, "virDomainGetXMLDesc"); ++ CHECK_ERROR (!r, "virDomainGetXMLDesc"); +=20 + rv =3D caml_copy_string (r); + free (r); +@@ -756,12 +751,11 @@ ocaml_libvirt_domain_get_uuid (value domv) +=20 + CAMLlocal1 (rv); + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + unsigned char uuid[VIR_UUID_BUFLEN]; + int r; +=20 + NONBLOCKING (r =3D virDomainGetUUID (dom, uuid)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainGetUUID"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainGetUUID"); +=20 + /* UUIDs are byte arrays with a fixed length. */ + rv =3D caml_alloc_string (VIR_UUID_BUFLEN); +@@ -780,12 +774,11 @@ ocaml_libvirt_domain_get_uuid_string (value domv) +=20 + CAMLlocal1 (rv); + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + char uuid[VIR_UUID_STRING_BUFLEN]; + int r; +=20 + NONBLOCKING (r =3D virDomainGetUUIDString (dom, uuid)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainGetUUIDString"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainGetUUIDString"); +=20 + rv =3D caml_copy_string (uuid); + CAMLreturn (rv); +@@ -801,11 +794,10 @@ ocaml_libvirt_domain_get_max_vcpus (value domv) + CAMLparam1 (domv); +=20 + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + int r; +=20 + NONBLOCKING (r =3D virDomainGetMaxVcpus (dom)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainGetMaxVcpus"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainGetMaxVcpus"); +=20 + CAMLreturn (Val_int (r)); + } +@@ -820,12 +812,11 @@ ocaml_libvirt_domain_save (value domv, value strv) + CAMLparam2 (domv, strv); +=20 + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + char *str =3D String_val (strv); + int r; +=20 + NONBLOCKING (r =3D virDomainSave (dom, str)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainSave"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainSave"); +=20 + CAMLreturn (Val_unit); + } +@@ -844,7 +835,7 @@ ocaml_libvirt_domain_restore (value connv, value strv) + int r; +=20 + NONBLOCKING (r =3D virDomainRestore (conn, str)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainRestore"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainRestore"); +=20 + CAMLreturn (Val_unit); + } +@@ -860,12 +851,11 @@ ocaml_libvirt_domain_core_dump (value domv, value st= rv) +=20 + CAMLlocal1 (rv); + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + char *str =3D String_val (strv); + int r; +=20 + NONBLOCKING (r =3D virDomainCoreDump (dom, str, 0)); +- CHECK_ERROR (!r, conn, "virDomainCoreDump"); ++ CHECK_ERROR (!r, "virDomainCoreDump"); +=20 + CAMLreturn (Val_unit); + } +@@ -880,11 +870,10 @@ ocaml_libvirt_domain_suspend (value domv) + CAMLparam1 (domv); +=20 + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + int r; +=20 + NONBLOCKING (r =3D virDomainSuspend (dom)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainSuspend"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainSuspend"); +=20 + CAMLreturn (Val_unit); + } +@@ -899,11 +888,10 @@ ocaml_libvirt_domain_resume (value domv) + CAMLparam1 (domv); +=20 + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + int r; +=20 + NONBLOCKING (r =3D virDomainResume (dom)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainResume"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainResume"); +=20 + CAMLreturn (Val_unit); + } +@@ -918,11 +906,10 @@ ocaml_libvirt_domain_shutdown (value domv) + CAMLparam1 (domv); +=20 + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + int r; +=20 + NONBLOCKING (r =3D virDomainShutdown (dom)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainShutdown"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainShutdown"); +=20 + CAMLreturn (Val_unit); + } +@@ -937,11 +924,10 @@ ocaml_libvirt_domain_reboot (value domv) + CAMLparam1 (domv); +=20 + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + int r; +=20 + NONBLOCKING (r =3D virDomainReboot (dom, 0)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainReboot"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainReboot"); +=20 + CAMLreturn (Val_unit); + } +@@ -961,7 +947,7 @@ ocaml_libvirt_domain_define_xml (value connv, value st= rv) + virDomainPtr r; +=20 + NONBLOCKING (r =3D virDomainDefineXML (conn, str)); +- CHECK_ERROR (!r, conn, "virDomainDefineXML"); ++ CHECK_ERROR (!r, "virDomainDefineXML"); +=20 + rv =3D Val_domain (r, connv); +=20 +@@ -978,11 +964,10 @@ ocaml_libvirt_domain_undefine (value domv) + CAMLparam1 (domv); +=20 + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + int r; +=20 + NONBLOCKING (r =3D virDomainUndefine (dom)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainUndefine"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainUndefine"); +=20 + CAMLreturn (Val_unit); + } +@@ -997,11 +982,10 @@ ocaml_libvirt_domain_create (value domv) + CAMLparam1 (domv); +=20 + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + int r; +=20 + NONBLOCKING (r =3D virDomainCreate (dom)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainCreate"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainCreate"); +=20 + CAMLreturn (Val_unit); + } +@@ -1016,12 +1000,11 @@ ocaml_libvirt_domain_attach_device (value domv, va= lue strv) + CAMLparam2 (domv, strv); +=20 + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + char *str =3D String_val (strv); + int r; +=20 + NONBLOCKING (r =3D virDomainAttachDevice (dom, str)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainAttachDevice"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainAttachDevice"); +=20 + CAMLreturn (Val_unit); + } +@@ -1036,12 +1019,11 @@ ocaml_libvirt_domain_detach_device (value domv, va= lue strv) + CAMLparam2 (domv, strv); +=20 + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + char *str =3D String_val (strv); + int r; +=20 + NONBLOCKING (r =3D virDomainDetachDevice (dom, str)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainDetachDevice"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainDetachDevice"); +=20 + CAMLreturn (Val_unit); + } +@@ -1056,11 +1038,10 @@ ocaml_libvirt_domain_get_autostart (value domv) + CAMLparam1 (domv); +=20 + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + int r, b; +=20 + NONBLOCKING (r =3D virDomainGetAutostart (dom, &b)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainGetAutostart"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainGetAutostart"); +=20 + CAMLreturn (b ? Val_true : Val_false); + } +@@ -1075,13 +1056,12 @@ ocaml_libvirt_domain_set_autostart (value domv, va= lue bv) + CAMLparam2 (domv, bv); +=20 + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + int r, b; +=20 + b =3D bv =3D=3D Val_true ? 1 : 0; +=20 + NONBLOCKING (r =3D virDomainSetAutostart (dom, b)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainSetAutostart"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainSetAutostart"); +=20 + CAMLreturn (Val_unit); + } +@@ -1096,11 +1076,10 @@ ocaml_libvirt_network_free (value netv) + CAMLparam1 (netv); +=20 + virNetworkPtr net =3D Network_val (netv); +- virConnectPtr conn =3D Connect_netv (netv); + int r; +=20 + NONBLOCKING (r =3D virNetworkFree (net)); +- CHECK_ERROR (r =3D=3D -1, conn, "virNetworkFree"); ++ CHECK_ERROR (r =3D=3D -1, "virNetworkFree"); +=20 + /* So that we don't double-free in the finalizer: */ + Network_val (netv) =3D NULL; +@@ -1118,11 +1097,10 @@ ocaml_libvirt_network_destroy (value netv) + CAMLparam1 (netv); +=20 + virNetworkPtr net =3D Network_val (netv); +- virConnectPtr conn =3D Connect_netv (netv); + int r; +=20 + NONBLOCKING (r =3D virNetworkDestroy (net)); +- CHECK_ERROR (r =3D=3D -1, conn, "virNetworkDestroy"); ++ CHECK_ERROR (r =3D=3D -1, "virNetworkDestroy"); +=20 + /* So that we don't double-free in the finalizer: */ + Network_val (netv) =3D NULL; +@@ -1145,7 +1123,7 @@ ocaml_libvirt_network_lookup_by_name (value connv, v= alue strv) + virNetworkPtr r; +=20 + NONBLOCKING (r =3D virNetworkLookupByName (conn, str)); +- CHECK_ERROR (!r, conn, "virNetworkLookupByName"); ++ CHECK_ERROR (!r, "virNetworkLookupByName"); +=20 + rv =3D Val_network (r, connv); +=20 +@@ -1167,7 +1145,7 @@ ocaml_libvirt_network_lookup_by_uuid (value connv, v= alue uuidv) + virNetworkPtr r; +=20 + NONBLOCKING (r =3D virNetworkLookupByUUID (conn, uuid)); +- CHECK_ERROR (!r, conn, "virNetworkLookupByUUID"); ++ CHECK_ERROR (!r, "virNetworkLookupByUUID"); +=20 + rv =3D Val_network (r, connv); +=20 +@@ -1189,7 +1167,7 @@ ocaml_libvirt_network_lookup_by_uuid_string (value c= onnv, value strv) + virNetworkPtr r; +=20 + NONBLOCKING (r =3D virNetworkLookupByUUIDString (conn, str)); +- CHECK_ERROR (!r, conn, "virNetworkLookupByUUIDString"); ++ CHECK_ERROR (!r, "virNetworkLookupByUUIDString"); +=20 + rv =3D Val_network (r, connv); +=20 +@@ -1207,11 +1185,10 @@ ocaml_libvirt_network_get_name (value netv) +=20 + CAMLlocal1 (rv); + virNetworkPtr net =3D Network_val (netv); +- virConnectPtr conn =3D Connect_netv (netv); + const char *r; +=20 + NONBLOCKING (r =3D virNetworkGetName (net)); +- CHECK_ERROR (!r, conn, "virNetworkGetName"); ++ CHECK_ERROR (!r, "virNetworkGetName"); +=20 + rv =3D caml_copy_string (r); + CAMLreturn (rv); +@@ -1228,11 +1205,10 @@ ocaml_libvirt_network_get_xml_desc (value netv) +=20 + CAMLlocal1 (rv); + virNetworkPtr net =3D Network_val (netv); +- virConnectPtr conn =3D Connect_netv (netv); + char *r; +=20 + NONBLOCKING (r =3D virNetworkGetXMLDesc (net, 0)); +- CHECK_ERROR (!r, conn, "virNetworkGetXMLDesc"); ++ CHECK_ERROR (!r, "virNetworkGetXMLDesc"); +=20 + rv =3D caml_copy_string (r); + free (r); +@@ -1250,11 +1226,10 @@ ocaml_libvirt_network_get_bridge_name (value netv) +=20 + CAMLlocal1 (rv); + virNetworkPtr net =3D Network_val (netv); +- virConnectPtr conn =3D Connect_netv (netv); + char *r; +=20 + NONBLOCKING (r =3D virNetworkGetBridgeName (net)); +- CHECK_ERROR (!r, conn, "virNetworkGetBridgeName"); ++ CHECK_ERROR (!r, "virNetworkGetBridgeName"); +=20 + rv =3D caml_copy_string (r); + free (r); +@@ -1272,12 +1247,11 @@ ocaml_libvirt_network_get_uuid (value netv) +=20 + CAMLlocal1 (rv); + virNetworkPtr net =3D Network_val (netv); +- virConnectPtr conn =3D Connect_netv (netv); + unsigned char uuid[VIR_UUID_BUFLEN]; + int r; +=20 + NONBLOCKING (r =3D virNetworkGetUUID (net, uuid)); +- CHECK_ERROR (r =3D=3D -1, conn, "virNetworkGetUUID"); ++ CHECK_ERROR (r =3D=3D -1, "virNetworkGetUUID"); +=20 + /* UUIDs are byte arrays with a fixed length. */ + rv =3D caml_alloc_string (VIR_UUID_BUFLEN); +@@ -1296,12 +1270,11 @@ ocaml_libvirt_network_get_uuid_string (value netv) +=20 + CAMLlocal1 (rv); + virNetworkPtr net =3D Network_val (netv); +- virConnectPtr conn =3D Connect_netv (netv); + char uuid[VIR_UUID_STRING_BUFLEN]; + int r; +=20 + NONBLOCKING (r =3D virNetworkGetUUIDString (net, uuid)); +- CHECK_ERROR (r =3D=3D -1, conn, "virNetworkGetUUIDString"); ++ CHECK_ERROR (r =3D=3D -1, "virNetworkGetUUIDString"); +=20 + rv =3D caml_copy_string (uuid); + CAMLreturn (rv); +@@ -1317,11 +1290,10 @@ ocaml_libvirt_network_undefine (value netv) + CAMLparam1 (netv); +=20 + virNetworkPtr net =3D Network_val (netv); +- virConnectPtr conn =3D Connect_netv (netv); + int r; +=20 + NONBLOCKING (r =3D virNetworkUndefine (net)); +- CHECK_ERROR (r =3D=3D -1, conn, "virNetworkUndefine"); ++ CHECK_ERROR (r =3D=3D -1, "virNetworkUndefine"); +=20 + CAMLreturn (Val_unit); + } +@@ -1341,7 +1313,7 @@ ocaml_libvirt_network_create_xml (value connv, value= strv) + virNetworkPtr r; +=20 + NONBLOCKING (r =3D virNetworkCreateXML (conn, str)); +- CHECK_ERROR (!r, conn, "virNetworkCreateXML"); ++ CHECK_ERROR (!r, "virNetworkCreateXML"); +=20 + rv =3D Val_network (r, connv); +=20 +@@ -1363,7 +1335,7 @@ ocaml_libvirt_network_define_xml (value connv, value= strv) + virNetworkPtr r; +=20 + NONBLOCKING (r =3D virNetworkDefineXML (conn, str)); +- CHECK_ERROR (!r, conn, "virNetworkDefineXML"); ++ CHECK_ERROR (!r, "virNetworkDefineXML"); +=20 + rv =3D Val_network (r, connv); +=20 +@@ -1380,11 +1352,10 @@ ocaml_libvirt_network_create (value netv) + CAMLparam1 (netv); +=20 + virNetworkPtr net =3D Network_val (netv); +- virConnectPtr conn =3D Connect_netv (netv); + int r; +=20 + NONBLOCKING (r =3D virNetworkCreate (net)); +- CHECK_ERROR (r =3D=3D -1, conn, "virNetworkCreate"); ++ CHECK_ERROR (r =3D=3D -1, "virNetworkCreate"); +=20 + CAMLreturn (Val_unit); + } +@@ -1399,11 +1370,10 @@ ocaml_libvirt_network_get_autostart (value netv) + CAMLparam1 (netv); +=20 + virNetworkPtr net =3D Network_val (netv); +- virConnectPtr conn =3D Connect_netv (netv); + int r, b; +=20 + NONBLOCKING (r =3D virNetworkGetAutostart (net, &b)); +- CHECK_ERROR (r =3D=3D -1, conn, "virNetworkGetAutostart"); ++ CHECK_ERROR (r =3D=3D -1, "virNetworkGetAutostart"); +=20 + CAMLreturn (b ? Val_true : Val_false); + } +@@ -1418,13 +1388,12 @@ ocaml_libvirt_network_set_autostart (value netv, v= alue bv) + CAMLparam2 (netv, bv); +=20 + virNetworkPtr net =3D Network_val (netv); +- virConnectPtr conn =3D Connect_netv (netv); + int r, b; +=20 + b =3D bv =3D=3D Val_true ? 1 : 0; +=20 + NONBLOCKING (r =3D virNetworkSetAutostart (net, b)); +- CHECK_ERROR (r =3D=3D -1, conn, "virNetworkSetAutostart"); ++ CHECK_ERROR (r =3D=3D -1, "virNetworkSetAutostart"); +=20 + CAMLreturn (Val_unit); + } +@@ -1439,11 +1408,10 @@ ocaml_libvirt_storage_pool_free (value poolv) + CAMLparam1 (poolv); +=20 + virStoragePoolPtr pool =3D Pool_val (poolv); +- virConnectPtr conn =3D Connect_polv (poolv); + int r; +=20 + NONBLOCKING (r =3D virStoragePoolFree (pool)); +- CHECK_ERROR (r =3D=3D -1, conn, "virStoragePoolFree"); ++ CHECK_ERROR (r =3D=3D -1, "virStoragePoolFree"); +=20 + /* So that we don't double-free in the finalizer: */ + Pool_val (poolv) =3D NULL; +@@ -1461,11 +1429,10 @@ ocaml_libvirt_storage_pool_destroy (value poolv) + CAMLparam1 (poolv); +=20 + virStoragePoolPtr pool =3D Pool_val (poolv); +- virConnectPtr conn =3D Connect_polv (poolv); + int r; +=20 + NONBLOCKING (r =3D virStoragePoolDestroy (pool)); +- CHECK_ERROR (r =3D=3D -1, conn, "virStoragePoolDestroy"); ++ CHECK_ERROR (r =3D=3D -1, "virStoragePoolDestroy"); +=20 + /* So that we don't double-free in the finalizer: */ + Pool_val (poolv) =3D NULL; +@@ -1488,7 +1455,7 @@ ocaml_libvirt_storage_pool_lookup_by_name (value con= nv, value strv) + virStoragePoolPtr r; +=20 + NONBLOCKING (r =3D virStoragePoolLookupByName (conn, str)); +- CHECK_ERROR (!r, conn, "virStoragePoolLookupByName"); ++ CHECK_ERROR (!r, "virStoragePoolLookupByName"); +=20 + rv =3D Val_pool (r, connv); +=20 +@@ -1510,7 +1477,7 @@ ocaml_libvirt_storage_pool_lookup_by_uuid (value con= nv, value uuidv) + virStoragePoolPtr r; +=20 + NONBLOCKING (r =3D virStoragePoolLookupByUUID (conn, uuid)); +- CHECK_ERROR (!r, conn, "virStoragePoolLookupByUUID"); ++ CHECK_ERROR (!r, "virStoragePoolLookupByUUID"); +=20 + rv =3D Val_pool (r, connv); +=20 +@@ -1532,7 +1499,7 @@ ocaml_libvirt_storage_pool_lookup_by_uuid_string (va= lue connv, value strv) + virStoragePoolPtr r; +=20 + NONBLOCKING (r =3D virStoragePoolLookupByUUIDString (conn, str)); +- CHECK_ERROR (!r, conn, "virStoragePoolLookupByUUIDString"); ++ CHECK_ERROR (!r, "virStoragePoolLookupByUUIDString"); +=20 + rv =3D Val_pool (r, connv); +=20 +@@ -1550,11 +1517,10 @@ ocaml_libvirt_storage_pool_get_name (value poolv) +=20 + CAMLlocal1 (rv); + virStoragePoolPtr pool =3D Pool_val (poolv); +- virConnectPtr conn =3D Connect_polv (poolv); + const char *r; +=20 + NONBLOCKING (r =3D virStoragePoolGetName (pool)); +- CHECK_ERROR (!r, conn, "virStoragePoolGetName"); ++ CHECK_ERROR (!r, "virStoragePoolGetName"); +=20 + rv =3D caml_copy_string (r); + CAMLreturn (rv); +@@ -1571,11 +1537,10 @@ ocaml_libvirt_storage_pool_get_xml_desc (value poo= lv) +=20 + CAMLlocal1 (rv); + virStoragePoolPtr pool =3D Pool_val (poolv); +- virConnectPtr conn =3D Connect_polv (poolv); + char *r; +=20 + NONBLOCKING (r =3D virStoragePoolGetXMLDesc (pool, 0)); +- CHECK_ERROR (!r, conn, "virStoragePoolGetXMLDesc"); ++ CHECK_ERROR (!r, "virStoragePoolGetXMLDesc"); +=20 + rv =3D caml_copy_string (r); + free (r); +@@ -1593,12 +1558,11 @@ ocaml_libvirt_storage_pool_get_uuid (value poolv) +=20 + CAMLlocal1 (rv); + virStoragePoolPtr pool =3D Pool_val (poolv); +- virConnectPtr conn =3D Connect_polv (poolv); + unsigned char uuid[VIR_UUID_BUFLEN]; + int r; +=20 + NONBLOCKING (r =3D virStoragePoolGetUUID (pool, uuid)); +- CHECK_ERROR (r =3D=3D -1, conn, "virStoragePoolGetUUID"); ++ CHECK_ERROR (r =3D=3D -1, "virStoragePoolGetUUID"); +=20 + /* UUIDs are byte arrays with a fixed length. */ + rv =3D caml_alloc_string (VIR_UUID_BUFLEN); +@@ -1617,12 +1581,11 @@ ocaml_libvirt_storage_pool_get_uuid_string (value = poolv) +=20 + CAMLlocal1 (rv); + virStoragePoolPtr pool =3D Pool_val (poolv); +- virConnectPtr conn =3D Connect_polv (poolv); + char uuid[VIR_UUID_STRING_BUFLEN]; + int r; +=20 + NONBLOCKING (r =3D virStoragePoolGetUUIDString (pool, uuid)); +- CHECK_ERROR (r =3D=3D -1, conn, "virStoragePoolGetUUIDString"); ++ CHECK_ERROR (r =3D=3D -1, "virStoragePoolGetUUIDString"); +=20 + rv =3D caml_copy_string (uuid); + CAMLreturn (rv); +@@ -1643,7 +1606,7 @@ ocaml_libvirt_storage_pool_create_xml (value connv, = value strv) + virStoragePoolPtr r; +=20 + NONBLOCKING (r =3D virStoragePoolCreateXML (conn, str, 0)); +- CHECK_ERROR (!r, conn, "virStoragePoolCreateXML"); ++ CHECK_ERROR (!r, "virStoragePoolCreateXML"); +=20 + rv =3D Val_pool (r, connv); +=20 +@@ -1665,7 +1628,7 @@ ocaml_libvirt_storage_pool_define_xml (value connv, = value strv) + virStoragePoolPtr r; +=20 + NONBLOCKING (r =3D virStoragePoolDefineXML (conn, str, 0)); +- CHECK_ERROR (!r, conn, "virStoragePoolDefineXML"); ++ CHECK_ERROR (!r, "virStoragePoolDefineXML"); +=20 + rv =3D Val_pool (r, connv); +=20 +@@ -1682,12 +1645,11 @@ ocaml_libvirt_storage_pool_build (value poolv, val= ue iv) + CAMLparam2 (poolv, iv); +=20 + virStoragePoolPtr pool =3D Pool_val (poolv); +- virConnectPtr conn =3D Connect_polv (poolv); + unsigned int i =3D Int_val (iv); + int r; +=20 + NONBLOCKING (r =3D virStoragePoolBuild (pool, i)); +- CHECK_ERROR (r =3D=3D -1, conn, "virStoragePoolBuild"); ++ CHECK_ERROR (r =3D=3D -1, "virStoragePoolBuild"); +=20 + CAMLreturn (Val_unit); + } +@@ -1702,11 +1664,10 @@ ocaml_libvirt_storage_pool_undefine (value poolv) + CAMLparam1 (poolv); +=20 + virStoragePoolPtr pool =3D Pool_val (poolv); +- virConnectPtr conn =3D Connect_polv (poolv); + int r; +=20 + NONBLOCKING (r =3D virStoragePoolUndefine (pool)); +- CHECK_ERROR (r =3D=3D -1, conn, "virStoragePoolUndefine"); ++ CHECK_ERROR (r =3D=3D -1, "virStoragePoolUndefine"); +=20 + CAMLreturn (Val_unit); + } +@@ -1721,11 +1682,10 @@ ocaml_libvirt_storage_pool_create (value poolv) + CAMLparam1 (poolv); +=20 + virStoragePoolPtr pool =3D Pool_val (poolv); +- virConnectPtr conn =3D Connect_polv (poolv); + int r; +=20 + NONBLOCKING (r =3D virStoragePoolCreate (pool, 0)); +- CHECK_ERROR (r =3D=3D -1, conn, "virStoragePoolCreate"); ++ CHECK_ERROR (r =3D=3D -1, "virStoragePoolCreate"); +=20 + CAMLreturn (Val_unit); + } +@@ -1740,12 +1700,11 @@ ocaml_libvirt_storage_pool_delete (value poolv, va= lue iv) + CAMLparam2 (poolv, iv); +=20 + virStoragePoolPtr pool =3D Pool_val (poolv); +- virConnectPtr conn =3D Connect_polv (poolv); + unsigned int i =3D Int_val (iv); + int r; +=20 + NONBLOCKING (r =3D virStoragePoolDelete (pool, i)); +- CHECK_ERROR (r =3D=3D -1, conn, "virStoragePoolDelete"); ++ CHECK_ERROR (r =3D=3D -1, "virStoragePoolDelete"); +=20 + CAMLreturn (Val_unit); + } +@@ -1760,11 +1719,10 @@ ocaml_libvirt_storage_pool_refresh (value poolv) + CAMLparam1 (poolv); +=20 + virStoragePoolPtr pool =3D Pool_val (poolv); +- virConnectPtr conn =3D Connect_polv (poolv); + int r; +=20 + NONBLOCKING (r =3D virStoragePoolRefresh (pool, 0)); +- CHECK_ERROR (r =3D=3D -1, conn, "virStoragePoolRefresh"); ++ CHECK_ERROR (r =3D=3D -1, "virStoragePoolRefresh"); +=20 + CAMLreturn (Val_unit); + } +@@ -1779,11 +1737,10 @@ ocaml_libvirt_storage_pool_get_autostart (value po= olv) + CAMLparam1 (poolv); +=20 + virStoragePoolPtr pool =3D Pool_val (poolv); +- virConnectPtr conn =3D Connect_polv (poolv); + int r, b; +=20 + NONBLOCKING (r =3D virStoragePoolGetAutostart (pool, &b)); +- CHECK_ERROR (r =3D=3D -1, conn, "virStoragePoolGetAutostart"); ++ CHECK_ERROR (r =3D=3D -1, "virStoragePoolGetAutostart"); +=20 + CAMLreturn (b ? Val_true : Val_false); + } +@@ -1798,13 +1755,12 @@ ocaml_libvirt_storage_pool_set_autostart (value po= olv, value bv) + CAMLparam2 (poolv, bv); +=20 + virStoragePoolPtr pool =3D Pool_val (poolv); +- virConnectPtr conn =3D Connect_polv (poolv); + int r, b; +=20 + b =3D bv =3D=3D Val_true ? 1 : 0; +=20 + NONBLOCKING (r =3D virStoragePoolSetAutostart (pool, b)); +- CHECK_ERROR (r =3D=3D -1, conn, "virStoragePoolSetAutostart"); ++ CHECK_ERROR (r =3D=3D -1, "virStoragePoolSetAutostart"); +=20 + CAMLreturn (Val_unit); + } +@@ -1819,11 +1775,10 @@ ocaml_libvirt_storage_pool_num_of_volumes (value p= oolv) + CAMLparam1 (poolv); +=20 + virStoragePoolPtr pool =3D Pool_val (poolv); +- virConnectPtr conn =3D Connect_polv (poolv); + int r; +=20 + NONBLOCKING (r =3D virStoragePoolNumOfVolumes (pool)); +- CHECK_ERROR (r =3D=3D -1, conn, "virStoragePoolNumOfVolumes"); ++ CHECK_ERROR (r =3D=3D -1, "virStoragePoolNumOfVolumes"); +=20 + CAMLreturn (Val_int (r)); + } +@@ -1839,7 +1794,6 @@ ocaml_libvirt_storage_pool_list_volumes (value poolv= , value iv) +=20 + CAMLlocal2 (rv, strv); + virStoragePoolPtr pool =3D Pool_val (poolv); +- virConnectPtr conn =3D Connect_polv (poolv); + int i =3D Int_val (iv); + char *names[i]; + int r; +@@ -1855,7 +1809,7 @@ ocaml_libvirt_storage_pool_list_volumes (value poolv= , value iv) + } +=20 + NONBLOCKING (r =3D virStoragePoolListVolumes (pool, names, i)); +- CHECK_ERROR (r =3D=3D -1, conn, "virStoragePoolListVolumes"); ++ CHECK_ERROR (r =3D=3D -1, "virStoragePoolListVolumes"); +=20 + rv =3D caml_alloc (r, 0); + for (i =3D 0; i < r; ++i) { +@@ -1877,11 +1831,10 @@ ocaml_libvirt_storage_vol_free (value volv) + CAMLparam1 (volv); +=20 + virStorageVolPtr vol =3D Volume_val (volv); +- virConnectPtr conn =3D Connect_volv (volv); + int r; +=20 + NONBLOCKING (r =3D virStorageVolFree (vol)); +- CHECK_ERROR (r =3D=3D -1, conn, "virStorageVolFree"); ++ CHECK_ERROR (r =3D=3D -1, "virStorageVolFree"); +=20 + /* So that we don't double-free in the finalizer: */ + Volume_val (volv) =3D NULL; +@@ -1899,12 +1852,11 @@ ocaml_libvirt_storage_vol_delete (value volv, valu= e iv) + CAMLparam2 (volv, iv); +=20 + virStorageVolPtr vol =3D Volume_val (volv); +- virConnectPtr conn =3D Connect_volv (volv); + unsigned int i =3D Int_val (iv); + int r; +=20 + NONBLOCKING (r =3D virStorageVolDelete (vol, i)); +- CHECK_ERROR (r =3D=3D -1, conn, "virStorageVolDelete"); ++ CHECK_ERROR (r =3D=3D -1, "virStorageVolDelete"); +=20 + CAMLreturn (Val_unit); + } +@@ -1920,12 +1872,11 @@ ocaml_libvirt_storage_vol_lookup_by_name (value po= olv, value strv) +=20 + CAMLlocal2 (rv, connv); + virStoragePoolPtr pool =3D Pool_val (poolv); +- virConnectPtr conn =3D Connect_polv (poolv); + char *str =3D String_val (strv); + virStorageVolPtr r; +=20 + NONBLOCKING (r =3D virStorageVolLookupByName (pool, str)); +- CHECK_ERROR (!r, conn, "virStorageVolLookupByName"); ++ CHECK_ERROR (!r, "virStorageVolLookupByName"); +=20 + connv =3D Field (poolv, 1); + rv =3D Val_volume (r, connv); +@@ -1948,7 +1899,7 @@ ocaml_libvirt_storage_vol_lookup_by_key (value connv= , value strv) + virStorageVolPtr r; +=20 + NONBLOCKING (r =3D virStorageVolLookupByKey (conn, str)); +- CHECK_ERROR (!r, conn, "virStorageVolLookupByKey"); ++ CHECK_ERROR (!r, "virStorageVolLookupByKey"); +=20 + rv =3D Val_volume (r, connv); +=20 +@@ -1970,7 +1921,7 @@ ocaml_libvirt_storage_vol_lookup_by_path (value conn= v, value strv) + virStorageVolPtr r; +=20 + NONBLOCKING (r =3D virStorageVolLookupByPath (conn, str)); +- CHECK_ERROR (!r, conn, "virStorageVolLookupByPath"); ++ CHECK_ERROR (!r, "virStorageVolLookupByPath"); +=20 + rv =3D Val_volume (r, connv); +=20 +@@ -1988,12 +1939,11 @@ ocaml_libvirt_storage_vol_create_xml (value poolv,= value strv) +=20 + CAMLlocal2 (rv, connv); + virStoragePoolPtr pool =3D Pool_val (poolv); +- virConnectPtr conn =3D Connect_polv (poolv); + char *str =3D String_val (strv); + virStorageVolPtr r; +=20 + NONBLOCKING (r =3D virStorageVolCreateXML (pool, str, 0)); +- CHECK_ERROR (!r, conn, "virStorageVolCreateXML"); ++ CHECK_ERROR (!r, "virStorageVolCreateXML"); +=20 + connv =3D Field (poolv, 1); + rv =3D Val_volume (r, connv); +@@ -2012,11 +1962,10 @@ ocaml_libvirt_storage_vol_get_xml_desc (value volv= ) +=20 + CAMLlocal1 (rv); + virStorageVolPtr vol =3D Volume_val (volv); +- virConnectPtr conn =3D Connect_volv (volv); + char *r; +=20 + NONBLOCKING (r =3D virStorageVolGetXMLDesc (vol, 0)); +- CHECK_ERROR (!r, conn, "virStorageVolGetXMLDesc"); ++ CHECK_ERROR (!r, "virStorageVolGetXMLDesc"); +=20 + rv =3D caml_copy_string (r); + free (r); +@@ -2034,11 +1983,10 @@ ocaml_libvirt_storage_vol_get_path (value volv) +=20 + CAMLlocal1 (rv); + virStorageVolPtr vol =3D Volume_val (volv); +- virConnectPtr conn =3D Connect_volv (volv); + char *r; +=20 + NONBLOCKING (r =3D virStorageVolGetPath (vol)); +- CHECK_ERROR (!r, conn, "virStorageVolGetPath"); ++ CHECK_ERROR (!r, "virStorageVolGetPath"); +=20 + rv =3D caml_copy_string (r); + free (r); +@@ -2056,11 +2004,10 @@ ocaml_libvirt_storage_vol_get_key (value volv) +=20 + CAMLlocal1 (rv); + virStorageVolPtr vol =3D Volume_val (volv); +- virConnectPtr conn =3D Connect_volv (volv); + const char *r; +=20 + NONBLOCKING (r =3D virStorageVolGetKey (vol)); +- CHECK_ERROR (!r, conn, "virStorageVolGetKey"); ++ CHECK_ERROR (!r, "virStorageVolGetKey"); +=20 + rv =3D caml_copy_string (r); + CAMLreturn (rv); +@@ -2077,11 +2024,10 @@ ocaml_libvirt_storage_vol_get_name (value volv) +=20 + CAMLlocal1 (rv); + virStorageVolPtr vol =3D Volume_val (volv); +- virConnectPtr conn =3D Connect_volv (volv); + const char *r; +=20 + NONBLOCKING (r =3D virStorageVolGetName (vol)); +- CHECK_ERROR (!r, conn, "virStorageVolGetName"); ++ CHECK_ERROR (!r, "virStorageVolGetName"); +=20 + rv =3D caml_copy_string (r); + CAMLreturn (rv); +@@ -2098,11 +2044,10 @@ ocaml_libvirt_storage_pool_lookup_by_volume (value= volv) +=20 + CAMLlocal2 (rv, connv); + virStorageVolPtr vol =3D Volume_val (volv); +- virConnectPtr conn =3D Connect_volv (volv); + virStoragePoolPtr r; +=20 + NONBLOCKING (r =3D virStoragePoolLookupByVolume (vol)); +- CHECK_ERROR (!r, conn, "virStoragePoolLookupByVolume"); ++ CHECK_ERROR (!r, "virStoragePoolLookupByVolume"); +=20 + connv =3D Field (volv, 1); + rv =3D Val_pool (r, connv); +diff --git a/libvirt/libvirt_c_epilogue.c b/libvirt/libvirt_c_epilogue.c +index 4649724..4972e50 100644 +--- a/libvirt/libvirt_c_epilogue.c ++++ b/libvirt/libvirt_c_epilogue.c +@@ -57,14 +57,14 @@ option_default (value option, value deflt) + #endif +=20 + static void +-_raise_virterror (virConnectPtr conn, const char *fn) ++_raise_virterror (const char *fn) + { + CAMLparam0 (); + CAMLlocal1 (rv); + virErrorPtr errp; + struct _virError err; +=20 +- errp =3D conn ? virConnGetLastError (conn) : virGetLastError (); ++ errp =3D virGetLastError (); +=20 + if (!errp) { + /* Fake a _virError structure. */ +diff --git a/libvirt/libvirt_c_oneoffs.c b/libvirt/libvirt_c_oneoffs.c +index 06b3852..32e5a4b 100644 +--- a/libvirt/libvirt_c_oneoffs.c ++++ b/libvirt/libvirt_c_oneoffs.c +@@ -32,7 +32,7 @@ ocaml_libvirt_get_version (value driverv, value unit) +=20 + typeVer_ptr =3D driver ? &typeVer : NULL; + NONBLOCKING (r =3D virGetVersion (&libVer, driver, typeVer_ptr)); +- CHECK_ERROR (r =3D=3D -1, NULL, "virGetVersion"); ++ CHECK_ERROR (r =3D=3D -1, "virGetVersion"); +=20 + rv =3D caml_alloc_tuple (2); + Store_field (rv, 0, Val_int (libVer)); +@@ -53,7 +53,7 @@ ocaml_libvirt_connect_open (value namev, value unit) + virConnectPtr conn; +=20 + NONBLOCKING (conn =3D virConnectOpen (name)); +- CHECK_ERROR (!conn, NULL, "virConnectOpen"); ++ CHECK_ERROR (!conn, "virConnectOpen"); +=20 + rv =3D Val_connect (conn); +=20 +@@ -69,7 +69,7 @@ ocaml_libvirt_connect_open_readonly (value namev, value = unit) + virConnectPtr conn; +=20 + NONBLOCKING (conn =3D virConnectOpenReadOnly (name)); +- CHECK_ERROR (!conn, NULL, "virConnectOpen"); ++ CHECK_ERROR (!conn, "virConnectOpen"); +=20 + rv =3D Val_connect (conn); +=20 +@@ -85,7 +85,7 @@ ocaml_libvirt_connect_get_version (value connv) + int r; +=20 + NONBLOCKING (r =3D virConnectGetVersion (conn, &hvVer)); +- CHECK_ERROR (r =3D=3D -1, conn, "virConnectGetVersion"); ++ CHECK_ERROR (r =3D=3D -1, "virConnectGetVersion"); +=20 + CAMLreturn (Val_int (hvVer)); + } +@@ -99,7 +99,7 @@ ocaml_libvirt_connect_get_max_vcpus (value connv, value = typev) + int r; +=20 + NONBLOCKING (r =3D virConnectGetMaxVcpus (conn, type)); +- CHECK_ERROR (r =3D=3D -1, conn, "virConnectGetMaxVcpus"); ++ CHECK_ERROR (r =3D=3D -1, "virConnectGetMaxVcpus"); +=20 + CAMLreturn (Val_int (r)); + } +@@ -114,7 +114,7 @@ ocaml_libvirt_connect_get_node_info (value connv) + int r; +=20 + NONBLOCKING (r =3D virNodeGetInfo (conn, &info)); +- CHECK_ERROR (r =3D=3D -1, conn, "virNodeGetInfo"); ++ CHECK_ERROR (r =3D=3D -1, "virNodeGetInfo"); +=20 + rv =3D caml_alloc (8, 0); + v =3D caml_copy_string (info.model); Store_field (rv, 0, v); +@@ -138,7 +138,7 @@ ocaml_libvirt_connect_node_get_free_memory (value conn= v) + unsigned long long r; +=20 + NONBLOCKING (r =3D virNodeGetFreeMemory (conn)); +- CHECK_ERROR (r =3D=3D 0, conn, "virNodeGetFreeMemory"); ++ CHECK_ERROR (r =3D=3D 0, "virNodeGetFreeMemory"); +=20 + rv =3D caml_copy_int64 ((int64_t) r); + CAMLreturn (rv); +@@ -157,7 +157,7 @@ ocaml_libvirt_connect_node_get_cells_free_memory (valu= e connv, + unsigned long long freemems[max]; +=20 + NONBLOCKING (r =3D virNodeGetCellsFreeMemory (conn, freemems, start, ma= x)); +- CHECK_ERROR (r =3D=3D -1, conn, "virNodeGetCellsFreeMemory"); ++ CHECK_ERROR (r =3D=3D -1, "virNodeGetCellsFreeMemory"); +=20 + rv =3D caml_alloc (r, 0); + for (i =3D 0; i < r; ++i) { +@@ -179,7 +179,7 @@ ocaml_libvirt_connect_set_keep_alive(value connv, + int r; +=20 + NONBLOCKING(r =3D virConnectSetKeepAlive(conn, interval, count)); +- CHECK_ERROR (r =3D=3D -1, conn, "virConnectSetKeepAlive"); ++ CHECK_ERROR (r =3D=3D -1, "virConnectSetKeepAlive"); +=20 + CAMLreturn(Val_unit); + } +@@ -190,7 +190,6 @@ ocaml_libvirt_domain_get_id (value domv) + { + CAMLparam1 (domv); + virDomainPtr dom =3D Domain_val (domv); +- /*virConnectPtr conn =3D Connect_domv (domv);*/ + unsigned int r; +=20 + NONBLOCKING (r =3D virDomainGetID (dom)); +@@ -208,11 +207,10 @@ ocaml_libvirt_domain_get_max_memory (value domv) + CAMLparam1 (domv); + CAMLlocal1 (rv); + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + unsigned long r; +=20 + NONBLOCKING (r =3D virDomainGetMaxMemory (dom)); +- CHECK_ERROR (r =3D=3D 0 /* [sic] */, conn, "virDomainGetMaxMemory"); ++ CHECK_ERROR (r =3D=3D 0 /* [sic] */, "virDomainGetMaxMemory"); +=20 + rv =3D caml_copy_int64 (r); + CAMLreturn (rv); +@@ -223,12 +221,11 @@ ocaml_libvirt_domain_set_max_memory (value domv, val= ue memv) + { + CAMLparam2 (domv, memv); + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + unsigned long mem =3D Int64_val (memv); + int r; +=20 + NONBLOCKING (r =3D virDomainSetMaxMemory (dom, mem)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainSetMaxMemory"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainSetMaxMemory"); +=20 + CAMLreturn (Val_unit); + } +@@ -238,12 +235,11 @@ ocaml_libvirt_domain_set_memory (value domv, value m= emv) + { + CAMLparam2 (domv, memv); + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + unsigned long mem =3D Int64_val (memv); + int r; +=20 + NONBLOCKING (r =3D virDomainSetMemory (dom, mem)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainSetMemory"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainSetMemory"); +=20 + CAMLreturn (Val_unit); + } +@@ -254,12 +250,11 @@ ocaml_libvirt_domain_get_info (value domv) + CAMLparam1 (domv); + CAMLlocal2 (rv, v); + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + virDomainInfo info; + int r; +=20 + NONBLOCKING (r =3D virDomainGetInfo (dom, &info)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainGetInfo"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainGetInfo"); +=20 + rv =3D caml_alloc (5, 0); + Store_field (rv, 0, Val_int (info.state)); // These flags are compatibl= e. +@@ -277,12 +272,11 @@ ocaml_libvirt_domain_get_scheduler_type (value domv) + CAMLparam1 (domv); + CAMLlocal2 (rv, strv); + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + char *r; + int nparams; +=20 + NONBLOCKING (r =3D virDomainGetSchedulerType (dom, &nparams)); +- CHECK_ERROR (!r, conn, "virDomainGetSchedulerType"); ++ CHECK_ERROR (!r, "virDomainGetSchedulerType"); +=20 + rv =3D caml_alloc_tuple (2); + strv =3D caml_copy_string (r); Store_field (rv, 0, strv); +@@ -297,13 +291,12 @@ ocaml_libvirt_domain_get_scheduler_parameters (value= domv, value nparamsv) + CAMLparam2 (domv, nparamsv); + CAMLlocal4 (rv, v, v2, v3); + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + int nparams =3D Int_val (nparamsv); + virSchedParameter params[nparams]; + int r, i; +=20 + NONBLOCKING (r =3D virDomainGetSchedulerParameters (dom, params, &npara= ms)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainGetSchedulerParameters"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainGetSchedulerParameters"); +=20 + rv =3D caml_alloc (nparams, 0); + for (i =3D 0; i < nparams; ++i) { +@@ -348,7 +341,6 @@ ocaml_libvirt_domain_set_scheduler_parameters (value d= omv, value paramsv) + CAMLparam2 (domv, paramsv); + CAMLlocal1 (v); + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + int nparams =3D Wosize_val (paramsv); + virSchedParameter params[nparams]; + int r, i; +@@ -391,7 +383,7 @@ ocaml_libvirt_domain_set_scheduler_parameters (value d= omv, value paramsv) + } +=20 + NONBLOCKING (r =3D virDomainSetSchedulerParameters (dom, params, nparam= s)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainSetSchedulerParameters"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainSetSchedulerParameters"); +=20 + CAMLreturn (Val_unit); + } +@@ -401,11 +393,10 @@ ocaml_libvirt_domain_set_vcpus (value domv, value nv= cpusv) + { + CAMLparam2 (domv, nvcpusv); + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + int r, nvcpus =3D Int_val (nvcpusv); +=20 + NONBLOCKING (r =3D virDomainSetVcpus (dom, nvcpus)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainSetVcpus"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainSetVcpus"); +=20 + CAMLreturn (Val_unit); + } +@@ -415,14 +406,13 @@ ocaml_libvirt_domain_pin_vcpu (value domv, value vcp= uv, value cpumapv) + { + CAMLparam3 (domv, vcpuv, cpumapv); + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + int maplen =3D caml_string_length (cpumapv); + unsigned char *cpumap =3D (unsigned char *) String_val (cpumapv); + int vcpu =3D Int_val (vcpuv); + int r; +=20 + NONBLOCKING (r =3D virDomainPinVcpu (dom, vcpu, cpumap, maplen)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainPinVcpu"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainPinVcpu"); +=20 + CAMLreturn (Val_unit); + } +@@ -433,7 +423,6 @@ ocaml_libvirt_domain_get_vcpus (value domv, value maxi= nfov, value maplenv) + CAMLparam3 (domv, maxinfov, maplenv); + CAMLlocal5 (rv, infov, strv, v, v2); + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + int maxinfo =3D Int_val (maxinfov); + int maplen =3D Int_val (maplenv); + virVcpuInfo info[maxinfo]; +@@ -444,7 +433,7 @@ ocaml_libvirt_domain_get_vcpus (value domv, value maxi= nfov, value maplenv) + memset (cpumaps, 0, maxinfo * maplen); +=20 + NONBLOCKING (r =3D virDomainGetVcpus (dom, info, maxinfo, cpumaps, mapl= en)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainPinVcpu"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainPinVcpu"); +=20 + /* Copy the virVcpuInfo structures. */ + infov =3D caml_alloc (maxinfo, 0); +@@ -476,18 +465,17 @@ ocaml_libvirt_domain_get_cpu_stats (value domv) + CAMLlocal5 (cpustats, param_head, param_node, typed_param, typed_param_= value); + CAMLlocal1 (v); + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + virTypedParameterPtr params; + int r, cpu, ncpus, nparams, i, j, pos; + int nr_pcpus; +=20 + /* get number of pcpus */ + NONBLOCKING (nr_pcpus =3D virDomainGetCPUStats(dom, NULL, 0, 0, 0, 0)); +- CHECK_ERROR (nr_pcpus < 0, conn, "virDomainGetCPUStats"); ++ CHECK_ERROR (nr_pcpus < 0, "virDomainGetCPUStats"); +=20 + /* get percpu information */ + NONBLOCKING (nparams =3D virDomainGetCPUStats(dom, NULL, 0, 0, 1, 0)); +- CHECK_ERROR (nparams < 0, conn, "virDomainGetCPUStats"); ++ CHECK_ERROR (nparams < 0, "virDomainGetCPUStats"); +=20 + if ((params =3D malloc(sizeof(*params) * nparams * 128)) =3D=3D NULL) + caml_failwith ("virDomainGetCPUStats: malloc"); +@@ -498,7 +486,7 @@ ocaml_libvirt_domain_get_cpu_stats (value domv) + ncpus =3D nr_pcpus - cpu > 128 ? 128 : nr_pcpus - cpu; +=20 + NONBLOCKING (r =3D virDomainGetCPUStats(dom, params, nparams, cpu, nc= pus, 0)); +- CHECK_ERROR (r < 0, conn, "virDomainGetCPUStats"); ++ CHECK_ERROR (r < 0, "virDomainGetCPUStats"); +=20 + for (i =3D 0; i < ncpus; i++) { + /* list of typed_param: single linked list of param_nodes */ +@@ -579,7 +567,6 @@ ocaml_libvirt_domain_migrate_native (value domv, value= dconnv, value flagsv, val + CAMLxparam2 (optbandwidthv, unitv); + CAMLlocal2 (flagv, rv); + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + virConnectPtr dconn =3D Connect_val (dconnv); + int flags =3D 0; + const char *dname =3D Optstring_val (optdnamev); +@@ -601,7 +588,7 @@ ocaml_libvirt_domain_migrate_native (value domv, value= dconnv, value flagsv, val + bandwidth =3D Int_val (Field (optbandwidthv, 0)); +=20 + NONBLOCKING (r =3D virDomainMigrate (dom, dconn, flags, dname, uri, ban= dwidth)); +- CHECK_ERROR (!r, conn, "virDomainMigrate"); ++ CHECK_ERROR (!r, "virDomainMigrate"); +=20 + rv =3D Val_domain (r, dconnv); +=20 +@@ -622,13 +609,12 @@ ocaml_libvirt_domain_block_stats (value domv, value = pathv) + CAMLparam2 (domv, pathv); + CAMLlocal2 (rv,v); + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + char *path =3D String_val (pathv); + struct _virDomainBlockStats stats; + int r; +=20 + NONBLOCKING (r =3D virDomainBlockStats (dom, path, &stats, sizeof stats= )); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainBlockStats"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainBlockStats"); +=20 + rv =3D caml_alloc (5, 0); + v =3D caml_copy_int64 (stats.rd_req); Store_field (rv, 0, v); +@@ -646,13 +632,12 @@ ocaml_libvirt_domain_interface_stats (value domv, va= lue pathv) + CAMLparam2 (domv, pathv); + CAMLlocal2 (rv,v); + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + char *path =3D String_val (pathv); + struct _virDomainInterfaceStats stats; + int r; +=20 + NONBLOCKING (r =3D virDomainInterfaceStats (dom, path, &stats, sizeof s= tats)); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainInterfaceStats"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainInterfaceStats"); +=20 + rv =3D caml_alloc (8, 0); + v =3D caml_copy_int64 (stats.rx_bytes); Store_field (rv, 0, v); +@@ -673,7 +658,6 @@ ocaml_libvirt_domain_block_peek_native (value domv, va= lue pathv, value offsetv, + CAMLparam5 (domv, pathv, offsetv, sizev, bufferv); + CAMLxparam1 (boffv); + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + const char *path =3D String_val (pathv); + unsigned long long offset =3D Int64_val (offsetv); + size_t size =3D Int_val (sizev); +@@ -687,7 +671,7 @@ ocaml_libvirt_domain_block_peek_native (value domv, va= lue pathv, value offsetv, +=20 + /* NB. not NONBLOCKING because buffer might move (XXX) */ + r =3D virDomainBlockPeek (dom, path, offset, size, buffer+boff, 0); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainBlockPeek"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainBlockPeek"); +=20 + CAMLreturn (Val_unit); + } +@@ -706,7 +690,6 @@ ocaml_libvirt_domain_memory_peek_native (value domv, v= alue flagsv, value offsetv + CAMLxparam1 (boffv); + CAMLlocal1 (flagv); + virDomainPtr dom =3D Domain_val (domv); +- virConnectPtr conn =3D Connect_domv (domv); + int flags =3D 0; + unsigned long long offset =3D Int64_val (offsetv); + size_t size =3D Int_val (sizev); +@@ -728,7 +711,7 @@ ocaml_libvirt_domain_memory_peek_native (value domv, v= alue flagsv, value offsetv +=20 + /* NB. not NONBLOCKING because buffer might move (XXX) */ + r =3D virDomainMemoryPeek (dom, offset, size, buffer+boff, flags); +- CHECK_ERROR (r =3D=3D -1, conn, "virDomainMemoryPeek"); ++ CHECK_ERROR (r =3D=3D -1, "virDomainMemoryPeek"); +=20 + CAMLreturn (Val_unit); + } +@@ -1042,7 +1025,6 @@ CAMLprim value + ocaml_libvirt_event_add_timeout (value connv, value ms, value callback_id= ) + { + CAMLparam3 (connv, ms, callback_id); +- virConnectPtr conn =3D Connect_val (connv); + void *opaque; + virFreeCallback freecb =3D free; + virEventTimeoutCallback cb =3D timeout_callback; +@@ -1055,7 +1037,7 @@ ocaml_libvirt_event_add_timeout (value connv, value = ms, value callback_id) + caml_failwith ("virEventAddTimeout: malloc"); + *((long*)opaque) =3D Int64_val(callback_id); + NONBLOCKING(r =3D virEventAddTimeout(Int_val(ms), cb, opaque, freecb)); +- CHECK_ERROR(r =3D=3D -1, conn, "virEventAddTimeout"); ++ CHECK_ERROR(r =3D=3D -1, "virEventAddTimeout"); +=20 + CAMLreturn(Val_int(r)); + } +@@ -1064,11 +1046,10 @@ CAMLprim value + ocaml_libvirt_event_remove_timeout (value connv, value timer_id) + { + CAMLparam2 (connv, timer_id); +- virConnectPtr conn =3D Connect_val (connv); + int r; +=20 + NONBLOCKING(r =3D virEventRemoveTimeout(Int_val(timer_id))); +- CHECK_ERROR(r =3D=3D -1, conn, "virEventRemoveTimeout"); ++ CHECK_ERROR(r =3D=3D -1, "virEventRemoveTimeout"); +=20 + CAMLreturn(Val_int(r)); + } +@@ -1146,7 +1127,7 @@ ocaml_libvirt_connect_domain_event_register_any(valu= e connv, value domv, value c + caml_failwith ("virConnectDomainEventRegisterAny: malloc"); + *((long*)opaque) =3D Int64_val(callback_id); + NONBLOCKING(r =3D virConnectDomainEventRegisterAny(conn, dom, eventID, = cb, opaque, freecb)); +- CHECK_ERROR(r =3D=3D -1, conn, "virConnectDomainEventRegisterAny"); ++ CHECK_ERROR(r =3D=3D -1, "virConnectDomainEventRegisterAny"); +=20 + CAMLreturn(Val_int(r)); + } +@@ -1157,12 +1138,11 @@ ocaml_libvirt_storage_pool_get_info (value poolv) + CAMLparam1 (poolv); + CAMLlocal2 (rv, v); + virStoragePoolPtr pool =3D Pool_val (poolv); +- virConnectPtr conn =3D Connect_polv (poolv); + virStoragePoolInfo info; + int r; +=20 + NONBLOCKING (r =3D virStoragePoolGetInfo (pool, &info)); +- CHECK_ERROR (r =3D=3D -1, conn, "virStoragePoolGetInfo"); ++ CHECK_ERROR (r =3D=3D -1, "virStoragePoolGetInfo"); +=20 + rv =3D caml_alloc (4, 0); + Store_field (rv, 0, Val_int (info.state)); +@@ -1179,12 +1159,11 @@ ocaml_libvirt_storage_vol_get_info (value volv) + CAMLparam1 (volv); + CAMLlocal2 (rv, v); + virStorageVolPtr vol =3D Volume_val (volv); +- virConnectPtr conn =3D Connect_volv (volv); + virStorageVolInfo info; + int r; +=20 + NONBLOCKING (r =3D virStorageVolGetInfo (vol, &info)); +- CHECK_ERROR (r =3D=3D -1, conn, "virStorageVolGetInfo"); ++ CHECK_ERROR (r =3D=3D -1, "virStorageVolGetInfo"); +=20 + rv =3D caml_alloc (3, 0); + Store_field (rv, 0, Val_int (info.type)); +@@ -1239,6 +1218,12 @@ ocaml_libvirt_virterror_reset_last_conn_error (valu= e connv) +=20 + /*----------------------------------------------------------------------*= / +=20 ++static void ++ignore_errors (void *user_data, virErrorPtr error) ++{ ++ /* do nothing */ ++} ++ + /* Initialise the library. */ + CAMLprim value + ocaml_libvirt_init (value unit) +@@ -1247,8 +1232,9 @@ ocaml_libvirt_init (value unit) + CAMLlocal1 (rv); + int r; +=20 ++ virSetErrorFunc (NULL, ignore_errors); + r =3D virInitialize (); +- CHECK_ERROR (r =3D=3D -1, NULL, "virInitialize"); ++ CHECK_ERROR (r =3D=3D -1, "virInitialize"); +=20 + CAMLreturn (Val_unit); + } +diff --git a/libvirt/libvirt_c_prologue.c b/libvirt/libvirt_c_prologue.c +index 7d9c0f5..bf972e9 100644 +--- a/libvirt/libvirt_c_prologue.c ++++ b/libvirt/libvirt_c_prologue.c +@@ -24,7 +24,7 @@ static char *Optstring_val (value strv); + typedef value (*Val_ptr_t) (void *); + static value Val_opt (void *ptr, Val_ptr_t Val_ptr); + /*static value option_default (value option, value deflt);*/ +-static void _raise_virterror (virConnectPtr conn, const char *fn) Noretur= n; ++static void _raise_virterror (const char *fn) Noreturn; + static void not_supported (const char *fn) Noreturn; + static value Val_virterror (virErrorPtr err); +=20 +@@ -43,8 +43,8 @@ static value Val_virterror (virErrorPtr err); + /* Check error condition from a libvirt function, and automatically raise + * an exception if one is found. + */ +-#define CHECK_ERROR(cond, conn, fn) \ +- do { if (cond) _raise_virterror (conn, fn); } while (0) ++#define CHECK_ERROR(cond, fn) \ ++ do { if (cond) _raise_virterror (fn); } while (0) +=20 + /*----------------------------------------------------------------------*= / +=20 +--=20 +2.3.1 + diff --git a/testing/ocaml-libvirt/0001-Use-C99-standard-int64_t-instead-of= -OCaml-defined-an.patch b/testing/ocaml-libvirt/0001-Use-C99-standard-int64= _t-instead-of-OCaml-defined-an.patch new file mode 100644 index 0000000000..c00a75a103 --- /dev/null +++ b/testing/ocaml-libvirt/0001-Use-C99-standard-int64_t-instead-of-OCaml-= defined-an.patch @@ -0,0 +1,35 @@ +From 21ac993da0a187821e812fe7b5b31a426121a546 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Sat, 30 Aug 2014 19:10:19 +0100 +Subject: [PATCH] Use C99 standard int64_t instead of OCaml defined (and so= on + to go) int64. + +--- + libvirt/libvirt_c_oneoffs.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/libvirt/libvirt_c_oneoffs.c b/libvirt/libvirt_c_oneoffs.c +index 3bb572f..06b3852 100644 +--- a/libvirt/libvirt_c_oneoffs.c ++++ b/libvirt/libvirt_c_oneoffs.c +@@ -140,7 +140,7 @@ ocaml_libvirt_connect_node_get_free_memory (value conn= v) + NONBLOCKING (r =3D virNodeGetFreeMemory (conn)); + CHECK_ERROR (r =3D=3D 0, conn, "virNodeGetFreeMemory"); +=20 +- rv =3D caml_copy_int64 ((int64) r); ++ rv =3D caml_copy_int64 ((int64_t) r); + CAMLreturn (rv); + } +=20 +@@ -161,7 +161,7 @@ ocaml_libvirt_connect_node_get_cells_free_memory (valu= e connv, +=20 + rv =3D caml_alloc (r, 0); + for (i =3D 0; i < r; ++i) { +- iv =3D caml_copy_int64 ((int64) freemems[i]); ++ iv =3D caml_copy_int64 ((int64_t) freemems[i]); + Store_field (rv, i, iv); + } +=20 +--=20 +2.0.4 + diff --git a/testing/ocaml-libvirt/0001-Use-g-warn-error.patch b/testing/oc= aml-libvirt/0001-Use-g-warn-error.patch new file mode 100644 index 0000000000..7c6bf35a54 --- /dev/null +++ b/testing/ocaml-libvirt/0001-Use-g-warn-error.patch @@ -0,0 +1,78 @@ +From 2ba6898b4dc121b00078e36d5416b3caadd5d05e Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Mon, 27 Mar 2017 14:12:50 +0100 +Subject: [PATCH 1/5] Use -g -warn-error. + +Use -g for ocamlopt. ocamlopt has supported generating DWARF +information for quite a long time. + +Also use -warn-error with the same set of warnings as is used +by libguestfs. + +Fix a warning in examples/get_cpu_stats.ml found by enabling +-warn-error. +--- + examples/Makefile.in | 4 ++-- + examples/get_cpu_stats.ml | 2 ++ + libvirt/Makefile.in | 6 +++--- + 3 files changed, 7 insertions(+), 5 deletions(-) + +diff --git a/examples/Makefile.in b/examples/Makefile.in +index 041e382..46006a0 100644 +--- a/examples/Makefile.in ++++ b/examples/Makefile.in +@@ -18,10 +18,10 @@ + OCAMLFIND =3D @OCAMLFIND@ +=20 + OCAMLCPACKAGES :=3D -package unix -I ../libvirt +-OCAMLCFLAGS :=3D -g ++OCAMLCFLAGS :=3D -g -warn-error CDEFLMPSUVYZX-3 + OCAMLCLIBS :=3D -linkpkg + OCAMLOPTPACKAGES :=3D $(OCAMLCPACKAGES) +-OCAMLOPTFLAGS :=3D ++OCAMLOPTFLAGS :=3D -g -warn-error CDEFLMPSUVYZX-3 + OCAMLOPTLIBS :=3D $(OCAMLCLIBS) +=20 + export LIBRARY_PATH=3D../libvirt +diff --git a/examples/get_cpu_stats.ml b/examples/get_cpu_stats.ml +index d7a8d0c..814c85e 100644 +--- a/examples/get_cpu_stats.ml ++++ b/examples/get_cpu_stats.ml +@@ -19,9 +19,11 @@ let () =3D +=20 + let conn =3D C.connect_readonly () in +=20 ++ (* + let nr_pcpus =3D + let info =3D C.get_node_info conn in + C.maxcpus_of_node_info info in ++ *) +=20 + let stats =3D + let dom =3D D.lookup_by_name conn domname in +diff --git a/libvirt/Makefile.in b/libvirt/Makefile.in +index f7c04bb..cf614fc 100644 +--- a/libvirt/Makefile.in ++++ b/libvirt/Makefile.in +@@ -31,15 +31,15 @@ OCAMLMKLIB =3D @OCAMLMKLIB@ +=20 + ifneq ($(OCAMLFIND),) + OCAMLCPACKAGES :=3D -package unix +-OCAMLCFLAGS :=3D -g ++OCAMLCFLAGS :=3D -g -warn-error CDEFLMPSUVYZX-3 + OCAMLCLIBS :=3D -linkpkg + else + OCAMLCINCS :=3D +-OCAMLCFLAGS :=3D -g ++OCAMLCFLAGS :=3D -g -warn-error CDEFLMPSUVYZX-3 + OCAMLCLIBS :=3D unix.cma + endif +=20 +-OCAMLOPTFLAGS :=3D ++OCAMLOPTFLAGS :=3D $(OCAMLCFLAGS) + ifneq ($(OCAMLFIND),) + OCAMLOPTPACKAGES :=3D $(OCAMLCPACKAGES) + OCAMLOPTLIBS :=3D $(OCAMLCLIBS) +--=20 +2.9.3 + diff --git a/testing/ocaml-libvirt/0002-Don-t-bother-checking-return-from-v= irInitialize.patch b/testing/ocaml-libvirt/0002-Don-t-bother-checking-retur= n-from-virInitialize.patch new file mode 100644 index 0000000000..bbf01a6a50 --- /dev/null +++ b/testing/ocaml-libvirt/0002-Don-t-bother-checking-return-from-virIniti= alize.patch @@ -0,0 +1,32 @@ +From 06b24089986523806d386b9e3cfa4fcf5eeb87e6 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Tue, 17 Mar 2015 12:53:29 +0000 +Subject: [PATCH 2/2] Don't bother checking return from virInitialize. + +The Perl bindings don't do this, and it seems that the call can never +fail, or if it does we don't care. +--- + libvirt/libvirt_c_oneoffs.c | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +diff --git a/libvirt/libvirt_c_oneoffs.c b/libvirt/libvirt_c_oneoffs.c +index 32e5a4b..5d82194 100644 +--- a/libvirt/libvirt_c_oneoffs.c ++++ b/libvirt/libvirt_c_oneoffs.c +@@ -1229,12 +1229,9 @@ CAMLprim value + ocaml_libvirt_init (value unit) + { + CAMLparam1 (unit); +- CAMLlocal1 (rv); +- int r; +=20 + virSetErrorFunc (NULL, ignore_errors); +- r =3D virInitialize (); +- CHECK_ERROR (r =3D=3D -1, "virInitialize"); ++ virInitialize (); +=20 + CAMLreturn (Val_unit); + } +--=20 +2.3.1 + diff --git a/testing/ocaml-libvirt/0002-Update-dependencies.patch b/testing= /ocaml-libvirt/0002-Update-dependencies.patch new file mode 100644 index 0000000000..1ba95ea3a6 --- /dev/null +++ b/testing/ocaml-libvirt/0002-Update-dependencies.patch @@ -0,0 +1,44 @@ +From ca9a3227f9937f9cdeb84126f1c74502c9a25047 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Mon, 27 Mar 2017 14:13:47 +0100 +Subject: [PATCH 2/5] Update dependencies. + +--- + examples/.depend | 8 ++++---- + libvirt/.depend | 6 +++--- + 2 files changed, 7 insertions(+), 7 deletions(-) + +diff --git a/examples/.depend b/examples/.depend +index b305b76..b5379d8 100644 +--- a/examples/.depend ++++ b/examples/.depend +@@ -1,8 +1,8 @@ +-node_info.cmo : ../libvirt/libvirt.cmi +-node_info.cmx : ../libvirt/libvirt.cmx +-get_cpu_stats.cmo : ../libvirt/libvirt.cmi +-get_cpu_stats.cmx : ../libvirt/libvirt.cmx + domain_events.cmo : ../libvirt/libvirt.cmi + domain_events.cmx : ../libvirt/libvirt.cmx ++get_cpu_stats.cmo : ../libvirt/libvirt.cmi ++get_cpu_stats.cmx : ../libvirt/libvirt.cmx + list_domains.cmo : ../libvirt/libvirt.cmi + list_domains.cmx : ../libvirt/libvirt.cmx ++node_info.cmo : ../libvirt/libvirt.cmi ++node_info.cmx : ../libvirt/libvirt.cmx +diff --git a/libvirt/.depend b/libvirt/.depend +index 7d32e13..ee1180c 100644 +--- a/libvirt/.depend ++++ b/libvirt/.depend +@@ -1,6 +1,6 @@ +-libvirt_version.cmi : ++libvirt.cmo : libvirt.cmi ++libvirt.cmx : libvirt.cmi + libvirt.cmi : + libvirt_version.cmo : libvirt_version.cmi + libvirt_version.cmx : libvirt_version.cmi +-libvirt.cmo : libvirt.cmi +-libvirt.cmx : libvirt.cmi ++libvirt_version.cmi : +--=20 +2.9.3 + diff --git a/testing/ocaml-libvirt/0003-Add-a-binding-for-virConnectGetAllD= omainStats-RHBZ-1.patch b/testing/ocaml-libvirt/0003-Add-a-binding-for-virC= onnectGetAllDomainStats-RHBZ-1.patch new file mode 100644 index 0000000000..0eb1b28eef --- /dev/null +++ b/testing/ocaml-libvirt/0003-Add-a-binding-for-virConnectGetAllDomainSt= ats-RHBZ-1.patch @@ -0,0 +1,393 @@ +From 380f1e05b244ae4750ca5101b5b5a182dcd0d1fd Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Tue, 28 Mar 2017 10:08:06 +0100 +Subject: [PATCH 3/5] Add a binding for virConnectGetAllDomainStats + (RHBZ#1390171). + +--- + .gitignore | 2 + + Makefile.in | 1 + + examples/.depend | 2 + + examples/Makefile.in | 13 ++++- + examples/get_all_domain_stats.ml | 65 +++++++++++++++++++++ + libvirt/libvirt.ml | 23 ++++++++ + libvirt/libvirt.mli | 28 +++++++++ + libvirt/libvirt_c_oneoffs.c | 119 ++++++++++++++++++++++++++++++++++= ++++- + 8 files changed, 250 insertions(+), 3 deletions(-) + create mode 100644 examples/get_all_domain_stats.ml + +diff --git a/.gitignore b/.gitignore +index 71a245e..366eb29 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -1,3 +1,4 @@ ++.gdb_history + META + ocaml-libvirt-*.tar.gz + ocaml-libvirt-*.exe +@@ -27,6 +28,7 @@ core.* + *~ + libvirt/libvirt_version.ml + examples/domain_events ++examples/get_all_domain_stats + examples/get_cpu_stats + examples/list_domains + examples/node_info +diff --git a/Makefile.in b/Makefile.in +index 3b8b7ec..2605ddd 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -41,6 +41,7 @@ clean: + rm -f examples/node_info + rm -f examples/get_cpu_stats + rm -f examples/domain_events ++ rm -f examples/get_all_domain_stats +=20 + distclean: clean + rm -f config.h config.log config.status configure +diff --git a/examples/.depend b/examples/.depend +index b5379d8..11f2c7c 100644 +--- a/examples/.depend ++++ b/examples/.depend +@@ -1,5 +1,7 @@ + domain_events.cmo : ../libvirt/libvirt.cmi + domain_events.cmx : ../libvirt/libvirt.cmx ++get_all_domain_stats.cmo : ../libvirt/libvirt.cmi ++get_all_domain_stats.cmx : ../libvirt/libvirt.cmx + get_cpu_stats.cmo : ../libvirt/libvirt.cmi + get_cpu_stats.cmx : ../libvirt/libvirt.cmx + list_domains.cmo : ../libvirt/libvirt.cmi +diff --git a/examples/Makefile.in b/examples/Makefile.in +index 46006a0..8530edc 100644 +--- a/examples/Makefile.in ++++ b/examples/Makefile.in +@@ -27,7 +27,8 @@ OCAMLOPTLIBS :=3D $(OCAMLCLIBS) + export LIBRARY_PATH=3D../libvirt + export LD_LIBRARY_PATH=3D../libvirt +=20 +-BYTE_TARGETS :=3D list_domains node_info get_cpu_stats domain_events ++BYTE_TARGETS :=3D list_domains node_info get_cpu_stats \ ++ get_all_domain_stats domain_events + OPT_TARGETS :=3D $(BYTE_TARGETS:%=3D%.opt) +=20 + all: $(BYTE_TARGETS) +@@ -64,6 +65,16 @@ get_cpu_stats.opt: get_cpu_stats.cmx + $(OCAMLOPTPACKAGES) $(OCAMLOPTFLAGS) $(OCAMLOPTLIBS) \ + ../libvirt/mllibvirt.cmxa -o $@ $< +=20 ++get_all_domain_stats: get_all_domain_stats.cmo ++ $(OCAMLFIND) ocamlc \ ++ $(OCAMLCPACKAGES) $(OCAMLCFLAGS) $(OCAMLCLIBS) \ ++ ../libvirt/mllibvirt.cma -o $@ $< ++ ++get_all_domain_stats.opt: get_all_domain_stats.cmx ++ $(OCAMLFIND) ocamlopt \ ++ $(OCAMLOPTPACKAGES) $(OCAMLOPTFLAGS) $(OCAMLOPTLIBS) \ ++ ../libvirt/mllibvirt.cmxa -o $@ $< ++ + domain_events: domain_events.cmo + $(OCAMLFIND) ocamlc \ + $(OCAMLCPACKAGES) $(OCAMLCFLAGS) $(OCAMLCLIBS) \ +diff --git a/examples/get_all_domain_stats.ml b/examples/get_all_domain_st= ats.ml +new file mode 100644 +index 0000000..4375639 +--- /dev/null ++++ b/examples/get_all_domain_stats.ml +@@ -0,0 +1,65 @@ ++(* Example of using Domain.get_all_domain_stats (virConnectGetAllDomainSt= ats). ++ * Usage: get_all_domain_stats ++ * http://libvirt.org/ ++ *) ++ ++open Printf ++ ++module C =3D Libvirt.Connect ++module D =3D Libvirt.Domain ++ ++let print_stats stats =3D ++ try ++ Array.iter ( ++ fun { D.dom =3D dom; D.params =3D params } -> ++ printf "domain %s:\n" (D.get_name dom); ++ Array.iteri ( ++ fun i (field, value) -> ++ printf "\t%-20s =3D " field; ++ (match value with ++ | D.TypedFieldInt32 i -> printf "%ld" i ++ | D.TypedFieldUInt32 i -> printf "%ld" i ++ | D.TypedFieldInt64 i -> printf "%Ld" i ++ | D.TypedFieldUInt64 i -> printf "%Ld" i ++ | D.TypedFieldFloat f -> printf "%g" f ++ | D.TypedFieldBool b -> printf "%b" b ++ | D.TypedFieldString s -> printf "%S" s); ++ printf "\n"; ++ ) params; ++ printf "\n" ++ ) stats ++ with ++ Libvirt.Virterror err -> ++ eprintf "error: %s\n" (Libvirt.Virterror.to_string err) ++ ++let () =3D ++ if Array.length Sys.argv <> 1 then ( ++ eprintf "error: get_all_domain_stats\n"; ++ exit 1 ++ ); ++ ++ let conn =3D C.connect_readonly () in ++ ++ let what_stats =3D [D.StatsCpuTotal; D.StatsInterface; D.StatsBlock] in ++ let flags =3D [D.GetAllDomainsStatsActive; D.GetAllDomainsStatsInactive= ] in ++ ++ let quit =3D ref false in ++ ++ while not !quit do ++ let stats =3D D.get_all_domain_stats conn what_stats flags in ++ ++ if stats <> [||] then print_stats stats ++ else ( ++ printf "no guests found\n"; ++ quit :=3D true ++ ); ++ flush stdout; ++ ++ (* Run the garbage collector which is a good way to check for ++ * memory corruption errors and reference counting issues in ++ * libvirt. You shouldn't do this in ordinary programs. ++ *) ++ Gc.compact (); ++ ++ if not !quit then Unix.sleep 3 ++ done +diff --git a/libvirt/libvirt.ml b/libvirt/libvirt.ml +index 1be023d..ce1878a 100644 +--- a/libvirt/libvirt.ml ++++ b/libvirt/libvirt.ml +@@ -392,6 +392,27 @@ struct + tx_drop : int64; + } +=20 ++ type get_all_domain_stats_flag =3D ++ | GetAllDomainsStatsActive ++ | GetAllDomainsStatsInactive ++ | GetAllDomainsStatsOther ++ | GetAllDomainsStatsPaused ++ | GetAllDomainsStatsPersistent ++ | GetAllDomainsStatsRunning ++ | GetAllDomainsStatsShutoff ++ | GetAllDomainsStatsTransient ++ | GetAllDomainsStatsBacking ++ | GetAllDomainsStatsEnforceStats ++ ++ type stats_type =3D ++ | StatsState | StatsCpuTotal | StatsBalloon | StatsVcpu ++ | StatsInterface | StatsBlock | StatsPerf ++ ++ type 'a domain_stats_record =3D { ++ dom : 'a t; ++ params : typed_param array; ++ } ++ + (* The maximum size for Domain.memory_peek and Domain.block_peek + * supported by libvirt. This may change with different versions + * of libvirt in the future, hence it's a function. +@@ -446,6 +467,8 @@ struct + external block_peek : [>`W] t -> string -> int64 -> int -> string -> in= t -> unit =3D "ocaml_libvirt_domain_block_peek_bytecode" "ocaml_libvirt_dom= ain_block_peek_native" + external memory_peek : [>`W] t -> memory_flag list -> int64 -> int -> s= tring -> int -> unit =3D "ocaml_libvirt_domain_memory_peek_bytecode" "ocaml= _libvirt_domain_memory_peek_native" +=20 ++ external get_all_domain_stats : 'a Connect.t -> stats_type list -> get_= all_domain_stats_flag list -> 'a domain_stats_record array =3D "ocaml_libvi= rt_domain_get_all_domain_stats" ++ + external const : [>`R] t -> ro t =3D "%identity" +=20 + let get_domains conn flags =3D +diff --git a/libvirt/libvirt.mli b/libvirt/libvirt.mli +index 8cfcae2..d1b5992 100644 +--- a/libvirt/libvirt.mli ++++ b/libvirt/libvirt.mli +@@ -478,6 +478,27 @@ sig + tx_drop : int64; + } +=20 ++ type get_all_domain_stats_flag =3D ++ | GetAllDomainsStatsActive ++ | GetAllDomainsStatsInactive ++ | GetAllDomainsStatsOther ++ | GetAllDomainsStatsPaused ++ | GetAllDomainsStatsPersistent ++ | GetAllDomainsStatsRunning ++ | GetAllDomainsStatsShutoff ++ | GetAllDomainsStatsTransient ++ | GetAllDomainsStatsBacking ++ | GetAllDomainsStatsEnforceStats ++ ++ type stats_type =3D ++ | StatsState | StatsCpuTotal | StatsBalloon | StatsVcpu ++ | StatsInterface | StatsBlock | StatsPerf ++ ++ type 'a domain_stats_record =3D { ++ dom : 'a t; ++ params : typed_param array; ++ } ++ + val max_peek : [>`R] t -> int + (** Maximum size supported by the {!block_peek} and {!memory_peek} + functions. If you want to peek more than this then you must +@@ -615,6 +636,13 @@ sig +=20 + See also {!max_peek}. *) +=20 ++ external get_all_domain_stats : 'a Connect.t -> stats_type list -> get_= all_domain_stats_flag list -> 'a domain_stats_record array =3D "ocaml_libvi= rt_domain_get_all_domain_stats" ++ (** [get_all_domain_stats conn stats flags] allows you to read ++ all stats across multiple/all domains in a single call. ++ ++ See the libvirt documentation for ++ [virConnectGetAllDomainStats]. *) ++ + external const : [>`R] t -> ro t =3D "%identity" + (** [const dom] turns a read/write domain handle into a read-only + domain handle. Note that the opposite operation is impossible. +diff --git a/libvirt/libvirt_c_oneoffs.c b/libvirt/libvirt_c_oneoffs.c +index 5d82194..17412f5 100644 +--- a/libvirt/libvirt_c_oneoffs.c ++++ b/libvirt/libvirt_c_oneoffs.c +@@ -1,5 +1,5 @@ + /* OCaml bindings for libvirt. +- * (C) Copyright 2007 Richard W.M. Jones, Red Hat Inc. ++ * (C) Copyright 2007-2017 Richard W.M. Jones, Red Hat Inc. + * http://libvirt.org/ + * + * This library is free software; you can redistribute it and/or +@@ -184,7 +184,6 @@ ocaml_libvirt_connect_set_keep_alive(value connv, + CAMLreturn(Val_unit); + } +=20 +- + CAMLprim value + ocaml_libvirt_domain_get_id (value domv) + { +@@ -560,6 +559,122 @@ ocaml_libvirt_domain_get_cpu_stats (value domv) + CAMLreturn (cpustats); + } +=20 ++value ++ocaml_libvirt_domain_get_all_domain_stats (value connv, ++ value statsv, value flagsv) ++{ ++ CAMLparam3 (connv, statsv, flagsv); ++ CAMLlocal5 (rv, dsv, tpv, v, v1); ++ CAMLlocal1 (v2); ++ virConnectPtr conn =3D Connect_val (connv); ++ virDomainStatsRecordPtr *rstats; ++ unsigned int stats =3D 0, flags =3D 0; ++ int i, j, r; ++ ++ /* Get stats and flags. */ ++ for (; statsv !=3D Val_int (0); statsv =3D Field (statsv, 1)) { ++ v =3D Field (statsv, 0); ++ if (v =3D=3D Val_int (0)) ++ stats |=3D VIR_DOMAIN_STATS_STATE; ++ else if (v =3D=3D Val_int (1)) ++ stats |=3D VIR_DOMAIN_STATS_CPU_TOTAL; ++ else if (v =3D=3D Val_int (2)) ++ stats |=3D VIR_DOMAIN_STATS_BALLOON; ++ else if (v =3D=3D Val_int (3)) ++ stats |=3D VIR_DOMAIN_STATS_VCPU; ++ else if (v =3D=3D Val_int (4)) ++ stats |=3D VIR_DOMAIN_STATS_INTERFACE; ++ else if (v =3D=3D Val_int (5)) ++ stats |=3D VIR_DOMAIN_STATS_BLOCK; ++ else if (v =3D=3D Val_int (6)) ++ stats |=3D VIR_DOMAIN_STATS_PERF; ++ } ++ for (; flagsv !=3D Val_int (0); flagsv =3D Field (flagsv, 1)) { ++ v =3D Field (flagsv, 0); ++ if (v =3D=3D Val_int (0)) ++ flags |=3D VIR_CONNECT_GET_ALL_DOMAINS_STATS_ACTIVE; ++ else if (v =3D=3D Val_int (1)) ++ flags |=3D VIR_CONNECT_GET_ALL_DOMAINS_STATS_INACTIVE; ++ else if (v =3D=3D Val_int (2)) ++ flags |=3D VIR_CONNECT_GET_ALL_DOMAINS_STATS_OTHER; ++ else if (v =3D=3D Val_int (3)) ++ flags |=3D VIR_CONNECT_GET_ALL_DOMAINS_STATS_PAUSED; ++ else if (v =3D=3D Val_int (4)) ++ flags |=3D VIR_CONNECT_GET_ALL_DOMAINS_STATS_PERSISTENT; ++ else if (v =3D=3D Val_int (5)) ++ flags |=3D VIR_CONNECT_GET_ALL_DOMAINS_STATS_RUNNING; ++ else if (v =3D=3D Val_int (6)) ++ flags |=3D VIR_CONNECT_GET_ALL_DOMAINS_STATS_SHUTOFF; ++ else if (v =3D=3D Val_int (7)) ++ flags |=3D VIR_CONNECT_GET_ALL_DOMAINS_STATS_TRANSIENT; ++ else if (v =3D=3D Val_int (8)) ++ flags |=3D VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING; ++ else if (v =3D=3D Val_int (9)) ++ flags |=3D VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS; ++ } ++ ++ NONBLOCKING (r =3D virConnectGetAllDomainStats (conn, stats, &rstats, f= lags)); ++ CHECK_ERROR (r =3D=3D -1, "virConnectGetAllDomainStats"); ++ ++ rv =3D caml_alloc (r, 0); /* domain_stats_record array. */ ++ for (i =3D 0; i < r; ++i) { ++ dsv =3D caml_alloc (2, 0); /* domain_stats_record */ ++ virDomainRef (rstats[i]->dom); ++ Store_field (dsv, 0, Val_domain (rstats[i]->dom, connv)); ++ ++ tpv =3D caml_alloc (rstats[i]->nparams, 0); /* typed_param array */ ++ for (j =3D 0; j < rstats[i]->nparams; ++j) { ++ v2 =3D caml_alloc (2, 0); /* typed_param: field name, value */ ++ Store_field (v2, 0, caml_copy_string (rstats[i]->params[j].field)); ++ ++ switch (rstats[i]->params[j].type) { ++ case VIR_TYPED_PARAM_INT: ++ v1 =3D caml_alloc (1, 0); ++ v =3D caml_copy_int32 (rstats[i]->params[j].value.i); ++ break; ++ case VIR_TYPED_PARAM_UINT: ++ v1 =3D caml_alloc (1, 1); ++ v =3D caml_copy_int32 (rstats[i]->params[j].value.ui); ++ break; ++ case VIR_TYPED_PARAM_LLONG: ++ v1 =3D caml_alloc (1, 2); ++ v =3D caml_copy_int64 (rstats[i]->params[j].value.l); ++ break; ++ case VIR_TYPED_PARAM_ULLONG: ++ v1 =3D caml_alloc (1, 3); ++ v =3D caml_copy_int64 (rstats[i]->params[j].value.ul); ++ break; ++ case VIR_TYPED_PARAM_DOUBLE: ++ v1 =3D caml_alloc (1, 4); ++ v =3D caml_copy_double (rstats[i]->params[j].value.d); ++ break; ++ case VIR_TYPED_PARAM_BOOLEAN: ++ v1 =3D caml_alloc (1, 5); ++ v =3D Val_bool (rstats[i]->params[j].value.b); ++ break; ++ case VIR_TYPED_PARAM_STRING: ++ v1 =3D caml_alloc (1, 6); ++ v =3D caml_copy_string (rstats[i]->params[j].value.s); ++ break; ++ default: ++ virDomainStatsRecordListFree (rstats); ++ caml_failwith ("virConnectGetAllDomainStats: " ++ "unknown parameter type returned"); ++ } ++ Store_field (v1, 0, v); ++ ++ Store_field (v2, 1, v1); ++ Store_field (tpv, j, v2); ++ } ++ ++ Store_field (dsv, 1, tpv); ++ Store_field (rv, i, dsv); ++ } ++ ++ virDomainStatsRecordListFree (rstats); ++ CAMLreturn (rv); ++} ++ + CAMLprim value + ocaml_libvirt_domain_migrate_native (value domv, value dconnv, value flag= sv, value optdnamev, value opturiv, value optbandwidthv, value unitv) + { +--=20 +2.9.3 + diff --git a/testing/ocaml-libvirt/0004-examples-Print-more-stats-in-the-ge= t_all_domain_stat.patch b/testing/ocaml-libvirt/0004-examples-Print-more-st= ats-in-the-get_all_domain_stat.patch new file mode 100644 index 0000000000..a4baded24a --- /dev/null +++ b/testing/ocaml-libvirt/0004-examples-Print-more-stats-in-the-get_all_d= omain_stat.patch @@ -0,0 +1,42 @@ +From 2bb6200934090f34f81d1badb9a55f5a86a7fb32 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Tue, 28 Mar 2017 13:11:09 +0100 +Subject: [PATCH 4/5] examples: Print more stats in the get_all_domain_stat= s.ml + example. + +Updates commit 380f1e05b244ae4750ca5101b5b5a182dcd0d1fd. +--- + examples/get_all_domain_stats.ml | 13 ++++++++++--- + 1 file changed, 10 insertions(+), 3 deletions(-) + +diff --git a/examples/get_all_domain_stats.ml b/examples/get_all_domain_st= ats.ml +index 4375639..cc86da6 100644 +--- a/examples/get_all_domain_stats.ml ++++ b/examples/get_all_domain_stats.ml +@@ -40,13 +40,20 @@ let () =3D +=20 + let conn =3D C.connect_readonly () in +=20 +- let what_stats =3D [D.StatsCpuTotal; D.StatsInterface; D.StatsBlock] in +- let flags =3D [D.GetAllDomainsStatsActive; D.GetAllDomainsStatsInactive= ] in ++ let what =3D [ ++ D.StatsState; ++ D.StatsCpuTotal; ++ D.StatsBalloon; ++ D.StatsVcpu; ++ D.StatsInterface; ++ D.StatsBlock; ++ ] in ++ let who =3D [] in (* empty list means returns all domains *) +=20 + let quit =3D ref false in +=20 + while not !quit do +- let stats =3D D.get_all_domain_stats conn what_stats flags in ++ let stats =3D D.get_all_domain_stats conn what who in +=20 + if stats <> [||] then print_stats stats + else ( +--=20 +2.9.3 + diff --git a/testing/ocaml-libvirt/0005-Change-binding-of-virConnectGetAllD= omainStats-to-ret.patch b/testing/ocaml-libvirt/0005-Change-binding-of-virC= onnectGetAllDomainStats-to-ret.patch new file mode 100644 index 0000000000..955a4ca71b --- /dev/null +++ b/testing/ocaml-libvirt/0005-Change-binding-of-virConnectGetAllDomainSt= ats-to-ret.patch @@ -0,0 +1,127 @@ +From 3169af3337938e18bf9ecc6ce936d644e14ff3de Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Tue, 28 Mar 2017 13:52:51 +0100 +Subject: [PATCH 5/5] Change binding of virConnectGetAllDomainStats to retu= rn + dom UUID. + +The virDomainPtr object returned by this binding isn't a reliable +virDomainPtr object. The only thing we can safely do with it is to +get its UUID. Modify the API correspondingly. + +Updates commit 380f1e05b244ae4750ca5101b5b5a182dcd0d1fd. +--- + examples/get_all_domain_stats.ml | 7 ++++--- + libvirt/libvirt.ml | 6 +++--- + libvirt/libvirt.mli | 6 +++--- + libvirt/libvirt_c_oneoffs.c | 13 +++++++++++-- + 4 files changed, 21 insertions(+), 11 deletions(-) + +diff --git a/examples/get_all_domain_stats.ml b/examples/get_all_domain_st= ats.ml +index cc86da6..be91f77 100644 +--- a/examples/get_all_domain_stats.ml ++++ b/examples/get_all_domain_stats.ml +@@ -8,10 +8,11 @@ open Printf + module C =3D Libvirt.Connect + module D =3D Libvirt.Domain +=20 +-let print_stats stats =3D ++let print_stats conn stats =3D + try + Array.iter ( +- fun { D.dom =3D dom; D.params =3D params } -> ++ fun { D.dom_uuid =3D uuid; D.params =3D params } -> ++ let dom =3D D.lookup_by_uuid conn uuid in + printf "domain %s:\n" (D.get_name dom); + Array.iteri ( + fun i (field, value) -> +@@ -55,7 +56,7 @@ let () =3D + while not !quit do + let stats =3D D.get_all_domain_stats conn what who in +=20 +- if stats <> [||] then print_stats stats ++ if stats <> [||] then print_stats conn stats + else ( + printf "no guests found\n"; + quit :=3D true +diff --git a/libvirt/libvirt.ml b/libvirt/libvirt.ml +index ce1878a..d03a127 100644 +--- a/libvirt/libvirt.ml ++++ b/libvirt/libvirt.ml +@@ -408,8 +408,8 @@ struct + | StatsState | StatsCpuTotal | StatsBalloon | StatsVcpu + | StatsInterface | StatsBlock | StatsPerf +=20 +- type 'a domain_stats_record =3D { +- dom : 'a t; ++ type domain_stats_record =3D { ++ dom_uuid : uuid; + params : typed_param array; + } +=20 +@@ -467,7 +467,7 @@ struct + external block_peek : [>`W] t -> string -> int64 -> int -> string -> in= t -> unit =3D "ocaml_libvirt_domain_block_peek_bytecode" "ocaml_libvirt_dom= ain_block_peek_native" + external memory_peek : [>`W] t -> memory_flag list -> int64 -> int -> s= tring -> int -> unit =3D "ocaml_libvirt_domain_memory_peek_bytecode" "ocaml= _libvirt_domain_memory_peek_native" +=20 +- external get_all_domain_stats : 'a Connect.t -> stats_type list -> get_= all_domain_stats_flag list -> 'a domain_stats_record array =3D "ocaml_libvi= rt_domain_get_all_domain_stats" ++ external get_all_domain_stats : [>`R] Connect.t -> stats_type list -> g= et_all_domain_stats_flag list -> domain_stats_record array =3D "ocaml_libvi= rt_domain_get_all_domain_stats" +=20 + external const : [>`R] t -> ro t =3D "%identity" +=20 +diff --git a/libvirt/libvirt.mli b/libvirt/libvirt.mli +index d1b5992..dc0033b 100644 +--- a/libvirt/libvirt.mli ++++ b/libvirt/libvirt.mli +@@ -494,8 +494,8 @@ sig + | StatsState | StatsCpuTotal | StatsBalloon | StatsVcpu + | StatsInterface | StatsBlock | StatsPerf +=20 +- type 'a domain_stats_record =3D { +- dom : 'a t; ++ type domain_stats_record =3D { ++ dom_uuid : uuid; + params : typed_param array; + } +=20 +@@ -636,7 +636,7 @@ sig +=20 + See also {!max_peek}. *) +=20 +- external get_all_domain_stats : 'a Connect.t -> stats_type list -> get_= all_domain_stats_flag list -> 'a domain_stats_record array =3D "ocaml_libvi= rt_domain_get_all_domain_stats" ++ external get_all_domain_stats : [>`R] Connect.t -> stats_type list -> g= et_all_domain_stats_flag list -> domain_stats_record array =3D "ocaml_libvi= rt_domain_get_all_domain_stats" + (** [get_all_domain_stats conn stats flags] allows you to read + all stats across multiple/all domains in a single call. +=20 +diff --git a/libvirt/libvirt_c_oneoffs.c b/libvirt/libvirt_c_oneoffs.c +index 17412f5..958ba69 100644 +--- a/libvirt/libvirt_c_oneoffs.c ++++ b/libvirt/libvirt_c_oneoffs.c +@@ -570,6 +570,7 @@ ocaml_libvirt_domain_get_all_domain_stats (value connv= , + virDomainStatsRecordPtr *rstats; + unsigned int stats =3D 0, flags =3D 0; + int i, j, r; ++ unsigned char uuid[VIR_UUID_BUFLEN]; +=20 + /* Get stats and flags. */ + for (; statsv !=3D Val_int (0); statsv =3D Field (statsv, 1)) { +@@ -619,8 +620,16 @@ ocaml_libvirt_domain_get_all_domain_stats (value conn= v, + rv =3D caml_alloc (r, 0); /* domain_stats_record array. */ + for (i =3D 0; i < r; ++i) { + dsv =3D caml_alloc (2, 0); /* domain_stats_record */ +- virDomainRef (rstats[i]->dom); +- Store_field (dsv, 0, Val_domain (rstats[i]->dom, connv)); ++ ++ /* Libvirt returns something superficially resembling a ++ * virDomainPtr, but it's not a real virDomainPtr object ++ * (eg. dom->id =3D=3D -1, and its refcount is wrong). The only thin= g ++ * we can safely get from it is the UUID. ++ */ ++ v =3D caml_alloc_string (VIR_UUID_BUFLEN); ++ virDomainGetUUID (rstats[i]->dom, uuid); ++ memcpy (String_val (v), uuid, VIR_UUID_BUFLEN); ++ Store_field (dsv, 0, v); +=20 + tpv =3D caml_alloc (rstats[i]->nparams, 0); /* typed_param array */ + for (j =3D 0; j < rstats[i]->nparams; ++j) { +--=20 +2.9.3 + diff --git a/testing/ocaml-libvirt/APKBUILD b/testing/ocaml-libvirt/APKBUIL= D new file mode 100644 index 0000000000..b0bd940dc9 --- /dev/null +++ b/testing/ocaml-libvirt/APKBUILD @@ -0,0 +1,58 @@ +# Contributor: Fernando Casas Schossow +# Maintainer: Fernando Casas Schossow +pkgname=3Docaml-libvirt +pkgver=3D0.6.1.4 +pkgrel=3D0 +pkgdesc=3D"OCaml binding for libvirt" +url=3D"http://libvirt.org/ocaml/" +arch=3D"all" +license=3D"LGPL-2.1-or-later-WITH-linking-exception" +makedepends=3D"ocaml ocaml-ocamldoc ocaml-findlib-dev libvirt-dev perl gaw= k" +subpackages=3D"$pkgname-dev $pkgname-doc" +source=3D"https://libvirt.org/sources/ocaml/$pkgname-$pkgver.tar.gz + 0001-Use-C99-standard-int64_t-instead-of-OCaml-defined-an.patch + 0001-Add-a-binding-for-virDomainCreateXML.patch + 0001-Suppress-errors-to-stderr-and-use-thread-local-virEr.patch + 0002-Don-t-bother-checking-return-from-virInitialize.patch + 0001-Remove-unused-not_supported-function.patch + 0001-Use-g-warn-error.patch + 0002-Update-dependencies.patch + 0003-Add-a-binding-for-virConnectGetAllDomainStats-RHBZ-1.patch + 0004-examples-Print-more-stats-in-the-get_all_domain_stat.patch + 0005-Change-binding-of-virConnectGetAllDomainStats-to-ret.patch" +builddir=3D"$srcdir/$pkgname-$pkgver" +options=3D"!check" # there is no test suite/unit tests + +build() { + cd "$builddir" + export OCAMLPARAM=3D"safe-string=3D0,_" + ./configure --prefix=3D/usr + make -C libvirt all + make opt +} + +check() { + cd "$builddir" +} + +package() { + cd "$builddir" + export DESTDIR=3D"$pkgdir" + export OCAMLFIND_DESTDIR=3D"$DESTDIR/usr/lib/ocaml" + mkdir -p "$OCAMLFIND_DESTDIR" "$OCAMLFIND_DESTDIR/stublibs" + make install-opt + install -D -m644 COPYING "$pkgdir/usr/share/licenses/$pkgname/COPYING" + install -D -m644 COPYING.LIB "$pkgdir/usr/share/licenses/$pkgname/COPYING= .LIB" +} + +sha512sums=3D"ed081a9b6f1388935e6a2ba0400e15881b3abb81a1079ab7fd88e72392ad= 29a0fd61550d3d7dc00682f283bc181d298af6519d19c3d15cf077988a3d6281d204 ocaml= -libvirt-0.6.1.4.tar.gz +ca1c6503a121ae392c46a37e4b260041a12b692afb7f2da39396f490020fe11b2284ff6fe1= 10eac6fabd01296adf2aa030f598e7349a0984323f7cd1c9fa67b0 0001-Use-C99-standa= rd-int64_t-instead-of-OCaml-defined-an.patch +6404b398da1b41cd1fef41ce597a3d2b1dee44b636a403a9b730e9cec455c87b4bd4fa35ee= a869a12698623d4d9d667f5588032bac4938d4114f606fa499a1e0 0001-Add-a-binding-= for-virDomainCreateXML.patch +e59b4127c2244ef6465090ccf6965f8ca4431e543bd4b8772527b0080af30da9834655fce1= 95b61e860676f9f4747d2d22caf38dc0c2ecd102c4933f0a5da668 0001-Suppress-error= s-to-stderr-and-use-thread-local-virEr.patch +7106aa55357b54409ca982ac60ff1243f4210a12fc3db7e6d355a5f317b947abe11d283ffc= 1c86193e93e6e30bd037f8883079a6dc83da33091adc449a31ddcd 0002-Don-t-bother-c= hecking-return-from-virInitialize.patch +bbc97d03031ef187230607de4830a3b250b8283d52ec0a60a220d165b4af9fe0deeacf43b0= 0c056b4e090d6cf8f6aae8eb26c72e38cfca95df9e85ce0b72fd40 0001-Remove-unused-= not_supported-function.patch +830d93d7cd1dec1fcf3c0f762c61d056d62589972c26904b3711f9739745ab0125b117aff8= 73abd3ff852c8ad03b3e779891d1420c3f21008915b4eb69d977bf 0001-Use-g-warn-err= or.patch +f1dd3862b6c3a5ee04a2d54a885bc0baa053de60cde4ceeb9b70c6de9a8b4bfcac77429bf6= 4400973a2d867bab542ca728438b30f07ac756cd362db454d684c0 0002-Update-depende= ncies.patch +2b9ce951486ada9d700c4560e0d5c069d2b58c70d71ac70ee95900246a53ad6c5b2557fe82= fc45b3f0fcdf7a966c2e1f442cc391758b0c9c6f7e755206e5e2c7 0003-Add-a-binding-= for-virConnectGetAllDomainStats-RHBZ-1.patch +2a2f48cd744d5b697ffded415993aa21aea5b3335abb6dd1d2ae9efeb443ead362b9b69887= 64a0405e96f054d949b2927c0a7316dcb0e41e02b19379a40b8471 0004-examples-Print= -more-stats-in-the-get_all_domain_stat.patch +abfcac22d22be5e2b552f2443244d62663d055d3eb9fd9ee9e82bcf21667d1a868cecc2bc5= eac25097e9faca2ae20bd4ad6c0bb81eb072fa581ffbcd7ec3779b 0005-Change-binding= -of-virConnectGetAllDomainStats-to-ret.patch" --=20 2.20.1 --- Unsubscribe: alpine-aports+unsubscribe@lists.alpinelinux.org Help: alpine-aports+help@lists.alpinelinux.org ---