It does not have a suffix ByName because there are no other means of looking up the server and since the name is known, this should be the preferred one. Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx> --- daemon/admin_server.c | 10 ++++++++++ daemon/admin_server.h | 5 +++++ include/libvirt/libvirt-admin.h | 4 ++++ src/admin/admin_protocol.x | 16 +++++++++++++++- src/admin_protocol-structs | 8 ++++++++ src/libvirt-admin.c | 36 ++++++++++++++++++++++++++++++++++++ src/libvirt_admin_private.syms | 2 ++ src/libvirt_admin_public.syms | 1 + 8 files changed, 81 insertions(+), 1 deletion(-) diff --git a/daemon/admin_server.c b/daemon/admin_server.c index 6eabbe4ae6d5..1d16bc9e9379 100644 --- a/daemon/admin_server.c +++ b/daemon/admin_server.c @@ -56,3 +56,13 @@ adminConnectListServers(virNetDaemonPtr dmn, cleanup: return ret; } + +virNetServerPtr +adminConnectLookupServer(virNetDaemonPtr dmn, + const char *name, + unsigned int flags) +{ + virCheckFlags(flags, NULL); + + return virNetDaemonGetServer(dmn, name); +} diff --git a/daemon/admin_server.h b/daemon/admin_server.h index b77653f6c384..9d0adf02c7ad 100644 --- a/daemon/admin_server.h +++ b/daemon/admin_server.h @@ -25,9 +25,14 @@ # define __LIBVIRTD_ADMIN_SERVER_H__ # include "rpc/virnetdaemon.h" +# include "rpc/virnetserver.h" int adminConnectListServers(virNetDaemonPtr dmn, virNetServerPtr **servers, unsigned int flags); +virNetServerPtr adminConnectLookupServer(virNetDaemonPtr dmn, + const char *name, + unsigned int flags); + #endif /* __LIBVIRTD_ADMIN_SERVER_H__ */ diff --git a/include/libvirt/libvirt-admin.h b/include/libvirt/libvirt-admin.h index e9ec3941023a..25bcbf47ddeb 100644 --- a/include/libvirt/libvirt-admin.h +++ b/include/libvirt/libvirt-admin.h @@ -106,6 +106,10 @@ int virAdmConnectUnregisterCloseCallback(virAdmConnectPtr conn, const char *virAdmServerGetName(virAdmServerPtr srv); +virAdmServerPtr virAdmConnectLookupServer(virAdmConnectPtr conn, + const char *name, + unsigned int flags); + # ifdef __cplusplus } # endif diff --git a/src/admin/admin_protocol.x b/src/admin/admin_protocol.x index 205bfe8f7a52..6590980ce1ca 100644 --- a/src/admin/admin_protocol.x +++ b/src/admin/admin_protocol.x @@ -65,6 +65,15 @@ struct admin_connect_list_servers_ret { /* insert@1 */ unsigned int ret; }; +struct admin_connect_lookup_server_args { + admin_nonnull_string name; + unsigned int flags; +}; + +struct admin_connect_lookup_server_ret { + admin_nonnull_server srv; +}; + /* Define the program number, protocol version and procedure numbers here. */ const ADMIN_PROGRAM = 0x06900690; const ADMIN_PROTOCOL_VERSION = 1; @@ -105,5 +114,10 @@ enum admin_procedure { /** * @generate: both */ - ADMIN_PROC_CONNECT_LIST_SERVERS = 4 + ADMIN_PROC_CONNECT_LIST_SERVERS = 4, + + /** + * @generate: both + */ + ADMIN_PROC_CONNECT_LOOKUP_SERVER = 5 }; diff --git a/src/admin_protocol-structs b/src/admin_protocol-structs index 8f2633ae7ce2..d8aca0617147 100644 --- a/src/admin_protocol-structs +++ b/src/admin_protocol-structs @@ -19,9 +19,17 @@ struct admin_connect_list_servers_ret { } servers; u_int ret; }; +struct admin_connect_lookup_server_args { + admin_nonnull_string name; + u_int flags; +}; +struct admin_connect_lookup_server_ret { + admin_nonnull_server srv; +}; enum admin_procedure { ADMIN_PROC_CONNECT_OPEN = 1, ADMIN_PROC_CONNECT_CLOSE = 2, ADMIN_PROC_CONNECT_GET_LIB_VERSION = 3, ADMIN_PROC_CONNECT_LIST_SERVERS = 4, + ADMIN_PROC_CONNECT_LOOKUP_SERVER = 5, }; diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c index add4fcc3576a..7a7bebf7d6c9 100644 --- a/src/libvirt-admin.c +++ b/src/libvirt-admin.c @@ -639,3 +639,39 @@ virAdmConnectListServers(virAdmConnectPtr conn, virDispatchError(NULL); return -1; } + +/** + * virAdmConnectLookupServer: + * @conn: daemon connection reference + * @name: name of the server too lookup + * @flags: unused, must be 0 + * + * Collect list of all servers provided by daemon the client is connected to. + * + * Returns the number of servers available on daemon side or -1 in case of a + * failure, setting @servers to NULL. There is a guaranteed extra element set + * to NULL in the @servers list returned to make the iteration easier, excluding + * this extra element from the final count. + * Caller is responsible to call virAdmServerFree() on each list element, + * followed by freeing @servers. + */ +virAdmServerPtr +virAdmConnectLookupServer(virAdmConnectPtr conn, + const char *name, + unsigned int flags) +{ + virAdmServerPtr ret = NULL; + + VIR_DEBUG("conn=%p, name=%s, flags=%x", conn, NULLSTR(name), flags); + virResetLastError(); + + virCheckAdmConnectGoto(conn, cleanup); + virCheckNonNullArgGoto(name, cleanup); + virCheckFlagsGoto(0, cleanup); + + ret = remoteAdminConnectLookupServer(conn, name, flags); + cleanup: + if (!ret) + virDispatchError(NULL); + return ret; +} diff --git a/src/libvirt_admin_private.syms b/src/libvirt_admin_private.syms index f22137bcc6af..268f1e6f2fdd 100644 --- a/src/libvirt_admin_private.syms +++ b/src/libvirt_admin_private.syms @@ -9,6 +9,8 @@ xdr_admin_connect_get_lib_version_ret; xdr_admin_connect_list_servers_args; xdr_admin_connect_list_servers_ret; +xdr_admin_connect_lookup_server_args; +xdr_admin_connect_lookup_server_ret; xdr_admin_connect_open_args; # datatypes.h diff --git a/src/libvirt_admin_public.syms b/src/libvirt_admin_public.syms index 52ff2dc1b411..58d085e1f118 100644 --- a/src/libvirt_admin_public.syms +++ b/src/libvirt_admin_public.syms @@ -24,4 +24,5 @@ LIBVIRT_ADMIN_1.3.0 { virAdmConnectListServers; virAdmServerGetName; virAdmServerFree; + virAdmConnectLookupServer; }; -- 2.7.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list