diff options
author | Erik Skultety <eskultet@redhat.com> | 2015-11-26 15:08:36 +0100 |
---|---|---|
committer | Erik Skultety <eskultet@redhat.com> | 2015-11-30 09:43:46 +0100 |
commit | b32f715d5b94d6ddfc621cbbe6e2e2e92cfd0373 (patch) | |
tree | 667c9554e017042c0c31cecd6ebc731759827258 | |
parent | c4bdff191b8ded6b986c1c38422dede2027e5107 (diff) | |
download | libvirt-b32f715d5b94d6ddfc621cbbe6e2e2e92cfd0373.tar.gz |
admin: introduce virAdmGetVersion
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.
-rw-r--r-- | include/libvirt/libvirt-admin.h | 3 | ||||
-rw-r--r-- | src/libvirt-admin.c | 34 | ||||
-rw-r--r-- | src/libvirt_admin_public.syms | 1 |
3 files changed, 38 insertions, 0 deletions
diff --git a/include/libvirt/libvirt-admin.h b/include/libvirt/libvirt-admin.h index ae033d1ed9..9f012c1ad9 100644 --- a/include/libvirt/libvirt-admin.h +++ b/include/libvirt/libvirt-admin.h @@ -56,6 +56,9 @@ int virAdmConnectClose(virAdmConnectPtr conn); int virAdmConnectRef(virAdmConnectPtr conn); +int virAdmGetVersion(unsigned long long *libVer); + + # ifdef __cplusplus } # endif diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c index 5a4fc4833d..4a2f002ffc 100644 --- a/src/libvirt-admin.c +++ b/src/libvirt-admin.c @@ -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; +} diff --git a/src/libvirt_admin_public.syms b/src/libvirt_admin_public.syms index d9e3c0b1b9..5e774c2c58 100644 --- a/src/libvirt_admin_public.syms +++ b/src/libvirt_admin_public.syms @@ -15,4 +15,5 @@ LIBVIRT_ADMIN_1.3.0 { virAdmConnectOpen; virAdmConnectClose; virAdmConnectRef; + virAdmGetVersion; }; |