]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
admin: introduce virAdmGetVersion
authorErik Skultety <eskultet@redhat.com>
Thu, 26 Nov 2015 14:08:36 +0000 (15:08 +0100)
committerErik Skultety <eskultet@redhat.com>
Mon, 30 Nov 2015 08:43:46 +0000 (09:43 +0100)
Unfortunately, client side version retrieval API virGetVersion uses
one-time initialization (due to the fact we might not have initialized the
library by calling connect prior to this) which is not completely compatible
with admin initialization. This API is rather simplistic and reimplementing
it for admin might be the preferred method of reusing it. Note that even though
the method will be reimplemented, the version number is still the same for both
the libvirt and libvirt-admin library.

include/libvirt/libvirt-admin.h
src/libvirt-admin.c
src/libvirt_admin_public.syms

index ae033d1ed94874c36135a310f806a05f64740196..9f012c1ad9f93ce42091b924ac31bca48dda96b0 100644 (file)
@@ -56,6 +56,9 @@ int virAdmConnectClose(virAdmConnectPtr conn);
 
 int virAdmConnectRef(virAdmConnectPtr conn);
 
+int virAdmGetVersion(unsigned long long *libVer);
+
+
 # ifdef __cplusplus
 }
 # endif
index 5a4fc4833ddff4215e0a954a5c1d8506b20861f5..4a2f002ffc428fc3fc8a89396072f5dc5cd9ae76 100644 (file)
@@ -386,3 +386,37 @@ virAdmConnectRef(virAdmConnectPtr conn)
 
     return 0;
 }
+
+/**
+ * virAdmGetVersion:
+ * @libVer: where to store the library version
+ *
+ * Provides version information. @libVer is the version of the library and will
+ * allways be set unless an error occurs in which case an error code and a
+ * generic message will be returned. @libVer format is as follows:
+ * major * 1,000,000 + minor * 1,000 + release.
+ *
+ * NOTE: To get the remote side library version use virAdmConnectGetLibVersion
+ * instead.
+ *
+ * Returns 0 on success, -1 in case of an error.
+ */
+int
+virAdmGetVersion(unsigned long long *libVer)
+{
+    if (virAdmInitialize() < 0)
+        goto error;
+
+    VIR_DEBUG("libVer=%p", libVer);
+
+    virResetLastError();
+    if (!libVer)
+        goto error;
+    *libVer = LIBVIR_VERSION_NUMBER;
+
+    return 0;
+
+ error:
+    virDispatchError(NULL);
+    return -1;
+}
index d9e3c0b1b988b1134e59e30b5b0cfc96e6993827..5e774c2c5893feea0ac41c7bc0b838b2674f0c12 100644 (file)
@@ -15,4 +15,5 @@ LIBVIRT_ADMIN_1.3.0 {
         virAdmConnectOpen;
         virAdmConnectClose;
         virAdmConnectRef;
+        virAdmGetVersion;
 };