mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
admin: Add virAdmConnectLookupServer
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@redhat.com>
This commit is contained in:
parent
cce90a459a
commit
b9a3ce95ce
@ -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);
|
||||
}
|
||||
|
@ -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__ */
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
};
|
||||
|
@ -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,
|
||||
};
|
||||
|
@ -639,3 +639,38 @@ virAdmConnectListServers(virAdmConnectPtr conn,
|
||||
virDispatchError(NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* virAdmConnectLookupServer:
|
||||
* @conn: daemon connection reference
|
||||
* @name: name of the server too lookup
|
||||
* @flags: extra flags; not used yet, so callers should always pass 0
|
||||
*
|
||||
* Try to lookup a server on the given daemon based on @name.
|
||||
*
|
||||
* virAdmServerFree() should be used to free the resources after the
|
||||
* server object is no longer needed.
|
||||
*
|
||||
* Returns the requested server or NULL in case of failure. If the
|
||||
* server cannot be found, then VIR_ERR_NO_SERVER error is raised.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -24,4 +24,5 @@ LIBVIRT_ADMIN_1.3.0 {
|
||||
virAdmConnectListServers;
|
||||
virAdmServerGetName;
|
||||
virAdmServerFree;
|
||||
virAdmConnectLookupServer;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user