On Fri, Nov 06, 2015 at 12:46:25PM +0100, Erik Skultety wrote:
Introduce a new API to get libvirt version. It is worth noting, that
libvirt-admin and libvirt share the same version number. Unfortunately,
our existing API isn't generic enough to be used with virAdmConnectPtr
as well. Also this patch wires up this API to the virt-admin client
as a generic cmdVersion command.
---
daemon/admin_server.c | 9 ++++++
include/libvirt/libvirt-admin.h | 3 ++
po/POTFILES.in | 1 +
src/admin/admin_protocol.x | 11 ++++++-
src/admin_protocol-structs | 4 +++
src/libvirt-admin.c | 31 +++++++++++++++++++
src/libvirt_admin_private.syms | 1 +
src/libvirt_admin_public.syms | 1 +
src/rpc/gendispatch.pl | 11 +++++--
tools/virt-admin.c | 67 +++++++++++++++++++++++++++++++++++++++++
10 files changed, 135 insertions(+), 4 deletions(-)
diff --git a/daemon/admin_server.c b/daemon/admin_server.c
index 712a44b..189091e 100644
--- a/daemon/admin_server.c
+++ b/daemon/admin_server.c
@@ -114,4 +114,13 @@ adminDispatchConnectClose(virNetServerPtr server ATTRIBUTE_UNUSED,
return 0;
}
+static int
+adminConnectGetLibVersion(virNetDaemonPtr dmn ATTRIBUTE_UNUSED,
+ unsigned long long *libVer)
+{
+ if (libVer)
+ *libVer = LIBVIR_VERSION_NUMBER;
+ return 0;
+}
+
#include "admin_dispatch.h"
diff --git a/include/libvirt/libvirt-admin.h b/include/libvirt/libvirt-admin.h
index 5f9841c..e5f840c 100644
--- a/include/libvirt/libvirt-admin.h
+++ b/include/libvirt/libvirt-admin.h
@@ -58,6 +58,9 @@ int virAdmConnectIsAlive(virAdmConnectPtr conn);
char *virAdmConnectGetURI(virAdmConnectPtr conn);
+int virAdmConnectGetLibVersion(virAdmConnectPtr conn,
+ unsigned long long *libVer);
+
/**
* virAdmConnectCloseFunc:
* @conn: virAdmConnect connection
diff --git a/po/POTFILES.in b/po/POTFILES.in
index d0840f4..e165a08 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,3 +1,4 @@
+daemon/admin_dispatch.h
daemon/admin_server.c
daemon/libvirtd-config.c
daemon/libvirtd.c
diff --git a/src/admin/admin_protocol.x b/src/admin/admin_protocol.x
index d0ca1a3..878983d 100644
--- a/src/admin/admin_protocol.x
+++ b/src/admin/admin_protocol.x
@@ -41,6 +41,10 @@ struct admin_connect_open_args {
unsigned int flags;
};
+struct admin_connect_get_lib_version_ret {
+ unsigned hyper libVer;
+};
+
/* Define the program number, protocol version and procedure numbers here. */
const ADMIN_PROGRAM = 0x06900690;
const ADMIN_PROTOCOL_VERSION = 1;
@@ -71,5 +75,10 @@ enum admin_procedure {
/**
* @generate: none
*/
- ADMIN_PROC_CONNECT_CLOSE = 2
+ ADMIN_PROC_CONNECT_CLOSE = 2,
+
+ /**
+ * @generate: both
+ */
+ ADMIN_PROC_CONNECT_GET_LIB_VERSION = 3
I was wondering why 'connect' is here, it does not necessarily relate
to connection and makes the name long, we could start using 'daemon'
instead as that is what we'll need to add anyway. Also 'lib' seems
unnecessary here.
Otherwise looks fine.