mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
sysinfo: implement the remote protocol
Done by editing the first three files, then running 'make -C src rpcgen', then editing src/remote_protocol-structs to match. * daemon/remote.c (remoteDispatchGetSysinfo): New function. * src/remote/remote_driver.c (remoteGetSysinfo, remote_driver): Client side serialization. * src/remote/remote_protocol.x (remote_get_sysinfo_args) (remote_get_sysinfo_ret): New types. (REMOTE_PROC_GET_SYSINFO): New enum value. * daemon/remote_dispatch_args.h: Regenerate. * daemon/remote_dispatch_prototypes.h: Likewise. * daemon/remote_dispatch_ret.h: Likewise. * daemon/remote_dispatch_table.h: Likewise. * src/remote/remote_protocol.c: Likewise. * src/remote/remote_protocol.h: Likewise. * src/remote_protocol-structs: Likewise.
This commit is contained in:
parent
addee8a096
commit
5c8dedddcc
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* remote.c: handlers for RPC method calls
|
||||
*
|
||||
* Copyright (C) 2007-2010 Red Hat, Inc.
|
||||
* Copyright (C) 2007-2011 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -584,6 +584,29 @@ remoteDispatchGetUri (struct qemud_server *server ATTRIBUTE_UNUSED,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
remoteDispatchGetSysinfo (struct qemud_server *server ATTRIBUTE_UNUSED,
|
||||
struct qemud_client *client ATTRIBUTE_UNUSED,
|
||||
virConnectPtr conn,
|
||||
remote_message_header *hdr ATTRIBUTE_UNUSED,
|
||||
remote_error *rerr,
|
||||
remote_get_sysinfo_args *args,
|
||||
remote_get_sysinfo_ret *ret)
|
||||
{
|
||||
unsigned int flags;
|
||||
char *sysinfo;
|
||||
|
||||
flags = args->flags;
|
||||
sysinfo = virConnectGetSysinfo (conn, flags);
|
||||
if (sysinfo == NULL) {
|
||||
remoteDispatchConnError(rerr, conn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret->sysinfo = sysinfo;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
remoteDispatchGetMaxVcpus (struct qemud_server *server ATTRIBUTE_UNUSED,
|
||||
struct qemud_client *client ATTRIBUTE_UNUSED,
|
||||
|
@ -171,3 +171,4 @@
|
||||
remote_domain_get_vcpus_flags_args val_remote_domain_get_vcpus_flags_args;
|
||||
remote_domain_open_console_args val_remote_domain_open_console_args;
|
||||
remote_domain_is_updated_args val_remote_domain_is_updated_args;
|
||||
remote_get_sysinfo_args val_remote_get_sysinfo_args;
|
||||
|
@ -730,6 +730,14 @@ static int remoteDispatchGetMaxVcpus(
|
||||
remote_error *err,
|
||||
remote_get_max_vcpus_args *args,
|
||||
remote_get_max_vcpus_ret *ret);
|
||||
static int remoteDispatchGetSysinfo(
|
||||
struct qemud_server *server,
|
||||
struct qemud_client *client,
|
||||
virConnectPtr conn,
|
||||
remote_message_header *hdr,
|
||||
remote_error *err,
|
||||
remote_get_sysinfo_args *args,
|
||||
remote_get_sysinfo_ret *ret);
|
||||
static int remoteDispatchGetType(
|
||||
struct qemud_server *server,
|
||||
struct qemud_client *client,
|
||||
|
@ -138,3 +138,4 @@
|
||||
remote_domain_get_memory_parameters_ret val_remote_domain_get_memory_parameters_ret;
|
||||
remote_domain_get_vcpus_flags_ret val_remote_domain_get_vcpus_flags_ret;
|
||||
remote_domain_is_updated_ret val_remote_domain_is_updated_ret;
|
||||
remote_get_sysinfo_ret val_remote_get_sysinfo_ret;
|
||||
|
@ -1017,3 +1017,8 @@
|
||||
.args_filter = (xdrproc_t) xdr_remote_domain_is_updated_args,
|
||||
.ret_filter = (xdrproc_t) xdr_remote_domain_is_updated_ret,
|
||||
},
|
||||
{ /* GetSysinfo => 203 */
|
||||
.fn = (dispatch_fn) remoteDispatchGetSysinfo,
|
||||
.args_filter = (xdrproc_t) xdr_remote_get_sysinfo_args,
|
||||
.ret_filter = (xdrproc_t) xdr_remote_get_sysinfo_ret,
|
||||
},
|
||||
|
@ -1748,6 +1748,31 @@ done:
|
||||
return rv;
|
||||
}
|
||||
|
||||
static char *
|
||||
remoteGetSysinfo (virConnectPtr conn, unsigned int flags)
|
||||
{
|
||||
char *rv = NULL;
|
||||
remote_get_sysinfo_args args;
|
||||
remote_get_sysinfo_ret ret;
|
||||
struct private_data *priv = conn->privateData;
|
||||
|
||||
remoteDriverLock(priv);
|
||||
|
||||
memset (&ret, 0, sizeof ret);
|
||||
args.flags = flags;
|
||||
if (call (conn, priv, 0, REMOTE_PROC_GET_SYSINFO,
|
||||
(xdrproc_t) xdr_remote_get_sysinfo_args, (char *) &args,
|
||||
(xdrproc_t) xdr_remote_get_sysinfo_ret, (char *) &ret) == -1)
|
||||
goto done;
|
||||
|
||||
/* Caller frees this. */
|
||||
rv = ret.sysinfo;
|
||||
|
||||
done:
|
||||
remoteDriverUnlock(priv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int remoteIsSecure(virConnectPtr conn)
|
||||
{
|
||||
int rv = -1;
|
||||
@ -10823,7 +10848,7 @@ static virDriver remote_driver = {
|
||||
remoteGetVersion, /* version */
|
||||
remoteGetLibVersion, /* libvirtVersion */
|
||||
remoteGetHostname, /* getHostname */
|
||||
NULL, /* getSysinfo */
|
||||
remoteGetSysinfo, /* getSysinfo */
|
||||
remoteGetMaxVcpus, /* getMaxVcpus */
|
||||
remoteNodeGetInfo, /* nodeGetInfo */
|
||||
remoteGetCapabilities, /* getCapabilities */
|
||||
|
@ -419,6 +419,24 @@ xdr_remote_get_hostname_ret (XDR *xdrs, remote_get_hostname_ret *objp)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_remote_get_sysinfo_args (XDR *xdrs, remote_get_sysinfo_args *objp)
|
||||
{
|
||||
|
||||
if (!xdr_u_int (xdrs, &objp->flags))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_remote_get_sysinfo_ret (XDR *xdrs, remote_get_sysinfo_ret *objp)
|
||||
{
|
||||
|
||||
if (!xdr_remote_nonnull_string (xdrs, &objp->sysinfo))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_remote_get_uri_ret (XDR *xdrs, remote_get_uri_ret *objp)
|
||||
{
|
||||
|
@ -242,6 +242,16 @@ struct remote_get_hostname_ret {
|
||||
};
|
||||
typedef struct remote_get_hostname_ret remote_get_hostname_ret;
|
||||
|
||||
struct remote_get_sysinfo_args {
|
||||
u_int flags;
|
||||
};
|
||||
typedef struct remote_get_sysinfo_args remote_get_sysinfo_args;
|
||||
|
||||
struct remote_get_sysinfo_ret {
|
||||
remote_nonnull_string sysinfo;
|
||||
};
|
||||
typedef struct remote_get_sysinfo_ret remote_get_sysinfo_ret;
|
||||
|
||||
struct remote_get_uri_ret {
|
||||
remote_nonnull_string uri;
|
||||
};
|
||||
@ -2320,6 +2330,7 @@ enum remote_procedure {
|
||||
REMOTE_PROC_DOMAIN_GET_VCPUS_FLAGS = 200,
|
||||
REMOTE_PROC_DOMAIN_OPEN_CONSOLE = 201,
|
||||
REMOTE_PROC_DOMAIN_IS_UPDATED = 202,
|
||||
REMOTE_PROC_GET_SYSINFO = 203,
|
||||
};
|
||||
typedef enum remote_procedure remote_procedure;
|
||||
|
||||
@ -2384,6 +2395,8 @@ extern bool_t xdr_remote_get_type_ret (XDR *, remote_get_type_ret*);
|
||||
extern bool_t xdr_remote_get_version_ret (XDR *, remote_get_version_ret*);
|
||||
extern bool_t xdr_remote_get_lib_version_ret (XDR *, remote_get_lib_version_ret*);
|
||||
extern bool_t xdr_remote_get_hostname_ret (XDR *, remote_get_hostname_ret*);
|
||||
extern bool_t xdr_remote_get_sysinfo_args (XDR *, remote_get_sysinfo_args*);
|
||||
extern bool_t xdr_remote_get_sysinfo_ret (XDR *, remote_get_sysinfo_ret*);
|
||||
extern bool_t xdr_remote_get_uri_ret (XDR *, remote_get_uri_ret*);
|
||||
extern bool_t xdr_remote_get_max_vcpus_args (XDR *, remote_get_max_vcpus_args*);
|
||||
extern bool_t xdr_remote_get_max_vcpus_ret (XDR *, remote_get_max_vcpus_ret*);
|
||||
@ -2730,6 +2743,8 @@ extern bool_t xdr_remote_get_type_ret ();
|
||||
extern bool_t xdr_remote_get_version_ret ();
|
||||
extern bool_t xdr_remote_get_lib_version_ret ();
|
||||
extern bool_t xdr_remote_get_hostname_ret ();
|
||||
extern bool_t xdr_remote_get_sysinfo_args ();
|
||||
extern bool_t xdr_remote_get_sysinfo_ret ();
|
||||
extern bool_t xdr_remote_get_uri_ret ();
|
||||
extern bool_t xdr_remote_get_max_vcpus_args ();
|
||||
extern bool_t xdr_remote_get_max_vcpus_ret ();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* remote_internal driver and libvirtd. This protocol is
|
||||
* internal and may change at any time.
|
||||
*
|
||||
* Copyright (C) 2006-2010 Red Hat, Inc.
|
||||
* Copyright (C) 2006-2011 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -379,6 +379,14 @@ struct remote_get_hostname_ret {
|
||||
remote_nonnull_string hostname;
|
||||
};
|
||||
|
||||
struct remote_get_sysinfo_args {
|
||||
unsigned int flags;
|
||||
};
|
||||
|
||||
struct remote_get_sysinfo_ret {
|
||||
remote_nonnull_string sysinfo;
|
||||
};
|
||||
|
||||
struct remote_get_uri_ret {
|
||||
remote_nonnull_string uri;
|
||||
};
|
||||
@ -2094,7 +2102,8 @@ enum remote_procedure {
|
||||
REMOTE_PROC_DOMAIN_GET_VCPUS_FLAGS = 200,
|
||||
|
||||
REMOTE_PROC_DOMAIN_OPEN_CONSOLE = 201,
|
||||
REMOTE_PROC_DOMAIN_IS_UPDATED = 202
|
||||
REMOTE_PROC_DOMAIN_IS_UPDATED = 202,
|
||||
REMOTE_PROC_GET_SYSINFO = 203
|
||||
|
||||
/*
|
||||
* Notice how the entries are grouped in sets of 10 ?
|
||||
|
@ -107,6 +107,12 @@ struct remote_get_lib_version_ret {
|
||||
struct remote_get_hostname_ret {
|
||||
remote_nonnull_string hostname;
|
||||
};
|
||||
struct remote_get_sysinfo_args {
|
||||
u_int flags;
|
||||
};
|
||||
struct remote_get_sysinfo_ret {
|
||||
remote_nonnull_string sysinfo;
|
||||
};
|
||||
struct remote_get_uri_ret {
|
||||
remote_nonnull_string uri;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user