This is also adding new ACL permission to check 'set_time'.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
daemon/remote.c | 50 ++++++++++++++++++++++++++++++++++++++++++++
src/access/viraccessperm.c | 2 +-
src/access/viraccessperm.h | 7 ++++++-
src/remote/remote_driver.c | 47 +++++++++++++++++++++++++++++++++++++++++
src/remote/remote_protocol.x | 32 +++++++++++++++++++++++++++-
src/remote_protocol-structs | 20 ++++++++++++++++++
6 files changed, 155 insertions(+), 3 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 8476961..be4d125 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -6078,6 +6078,56 @@ qemuDispatchConnectDomainMonitorEventDeregister(virNetServerPtr
server ATTRIBUTE
}
+static int
+remoteDispatchDomainGetTime(virNetServerPtr server ATTRIBUTE_UNUSED,
+ virNetServerClientPtr client,
+ virNetMessagePtr msg ATTRIBUTE_UNUSED,
+ virNetMessageErrorPtr rerr,
+ remote_domain_get_time_args *args,
+ remote_domain_get_time_ret *ret)
+{
+ virDomainPtr dom = NULL;
+ virTypedParameterPtr params = NULL;
+ int nparams = 0;
+ int rv = -1;
+ struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
+
+ if (!priv->conn) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ goto cleanup;
+ }
+
+ if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ goto cleanup;
+
+ if (virDomainGetTime(dom, ¶ms, &nparams, args->flags) < 0)
+ goto cleanup;
+
+ if (nparams > REMOTE_DOMAIN_TIME_MAX) {
+ virReportError(VIR_ERR_RPC,
+ _("Too many time fields '%d' for limit
'%d'"),
+ nparams, REMOTE_DOMAIN_TIME_MAX);
+ goto cleanup;
+ }
+
+ if (remoteSerializeTypedParameters(params, nparams,
+ &ret->params.params_val,
+ &ret->params.params_len,
+ 0) < 0)
+ goto cleanup;
+
+ rv = 0;
+
+ cleanup:
+ if (rv < 0)
+ virNetMessageSaveError(rerr);
+ virTypedParamsFree(params, nparams);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
+}
+
+
/*----- Helpers. -----*/
/* get_nonnull_domain and get_nonnull_network turn an on-wire
diff --git a/src/access/viraccessperm.c b/src/access/viraccessperm.c
index d517c66..bbcb6c1 100644
--- a/src/access/viraccessperm.c
+++ b/src/access/viraccessperm.c
@@ -42,7 +42,7 @@ VIR_ENUM_IMPL(virAccessPermDomain,
"init_control", "inject_nmi", "send_input",
"send_signal", "fs_trim",
"block_read", "block_write", "mem_read",
"open_graphics", "open_device",
"screenshot",
- "open_namespace");
+ "open_namespace", "set_time");
VIR_ENUM_IMPL(virAccessPermInterface,
VIR_ACCESS_PERM_INTERFACE_LAST,
diff --git a/src/access/viraccessperm.h b/src/access/viraccessperm.h
index 6d14f05..6fa0f01 100644
--- a/src/access/viraccessperm.h
+++ b/src/access/viraccessperm.h
@@ -282,13 +282,18 @@ typedef enum {
*/
VIR_ACCESS_PERM_DOMAIN_SCREENSHOT, /* Trigger a screen shot */
-
/**
* @desc: Open domain namespace
* @message: Opening domain namespaces requires authorization
*/
VIR_ACCESS_PERM_DOMAIN_OPEN_NAMESPACE,
+ /**
+ * @desc: Write domain time
+ * @message: Setting the domain time requires authorization
+ */
+ VIR_ACCESS_PERM_DOMAIN_SET_TIME,
+
VIR_ACCESS_PERM_DOMAIN_LAST,
} virAccessPermDomain;
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index ed7dde6..ae84bd1 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -7468,6 +7468,51 @@ remoteDomainCreateWithFiles(virDomainPtr dom,
}
+static int
+remoteDomainGetTime(virDomainPtr dom,
+ virTypedParameterPtr *params,
+ int *nparams,
+ unsigned int flags)
+{
+ int rv = -1;
+ remote_domain_get_time_args args;
+ remote_domain_get_time_ret ret;
+ struct private_data *priv = dom->conn->privateData;
+
+ remoteDriverLock(priv);
+
+ make_nonnull_domain(&args.dom, dom);
+ args.flags = flags;
+
+ memset(&ret, 0, sizeof(ret));
+ if (call(dom->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_TIME,
+ (xdrproc_t) xdr_remote_domain_get_time_args, (char *) &args,
+ (xdrproc_t) xdr_remote_domain_get_time_ret, (char *) &ret) == -1)
+ goto done;
+
+ if (ret.params.params_len > REMOTE_DOMAIN_TIME_MAX) {
+ virReportError(VIR_ERR_RPC,
+ _("Too many time fields '%d' for limit
'%d'"),
+ ret.params.params_len,
+ REMOTE_DOMAIN_TIME_MAX);
+ goto cleanup;
+ }
+
+ if (remoteDeserializeTypedParameters(ret.params.params_val,
+ ret.params.params_len,
+ 0, params, nparams) < 0)
+ goto cleanup;
+
+ rv = 0;
+ cleanup:
+ xdr_free((xdrproc_t) xdr_remote_domain_get_time_ret, (char *) &ret);
+
+ done:
+ remoteDriverUnlock(priv);
+ return rv;
+}
+
+
/* get_nonnull_domain and get_nonnull_network turn an on-wire
* (name, uuid) pair into virDomainPtr or virNetworkPtr object.
* These can return NULL if underlying memory allocations fail,
@@ -7800,6 +7845,8 @@ static virDriver remote_driver = {
.domainMigrateFinish3Params = remoteDomainMigrateFinish3Params, /* 1.1.0 */
.domainMigrateConfirm3Params = remoteDomainMigrateConfirm3Params, /* 1.1.0 */
.connectGetCPUModelNames = remoteConnectGetCPUModelNames, /* 1.1.3 */
+ .domainGetTime = remoteDomainGetTime, /* 1.2.4 */
+ .domainSetTime = remoteDomainSetTime, /* 1.2.4 */
};
static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 6c445cc..9551c6b 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -235,6 +235,9 @@ const REMOTE_DOMAIN_JOB_STATS_MAX = 64;
/* Upper limit on number of CPU models */
const REMOTE_CONNECT_CPU_MODELS_MAX = 8192;
+/* Upper limit on number of get/set time parameters */
+const REMOTE_DOMAIN_TIME_MAX = 64;
+
/* UUID. VIR_UUID_BUFLEN definition comes from libvirt.h */
typedef opaque remote_uuid[VIR_UUID_BUFLEN];
@@ -2852,6 +2855,21 @@ struct remote_domain_fstrim_args {
unsigned int flags;
};
+struct remote_domain_get_time_args {
+ remote_nonnull_domain dom;
+ unsigned int flags;
+};
+
+struct remote_domain_get_time_ret {
+ remote_typed_param params<REMOTE_DOMAIN_TIME_MAX>;
+};
+
+struct remote_domain_set_time_args {
+ remote_nonnull_domain dom;
+ remote_typed_param params<REMOTE_DOMAIN_TIME_MAX>;
+ unsigned int flags;
+};
+
struct remote_domain_migrate_begin3_params_args {
remote_nonnull_domain dom;
remote_typed_param params<REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX>;
@@ -5275,5 +5293,17 @@ enum remote_procedure {
* @generate: both
* @acl: domain:core_dump
*/
- REMOTE_PROC_DOMAIN_CORE_DUMP_WITH_FORMAT = 334
+ REMOTE_PROC_DOMAIN_CORE_DUMP_WITH_FORMAT = 334,
+
+ /**
+ * @generate: none
+ * @acl: domain:read
+ */
+ REMOTE_PROC_DOMAIN_GET_TIME = 335,
+
+ /**
+ * @generate: both
+ * @acl: domain:set_time
+ */
+ REMOTE_PROC_DOMAIN_SET_TIME = 336
};
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 456d0da..fcad3d2 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -2290,6 +2290,24 @@ struct remote_domain_fstrim_args {
uint64_t minimum;
u_int flags;
};
+struct remote_domain_get_time_args {
+ remote_nonnull_domain dom;
+ u_int flags;
+};
+struct remote_domain_get_time_ret {
+ struct {
+ u_int params_len;
+ remote_typed_param * params_val;
+ } params;
+};
+struct remote_domain_set_time_args {
+ remote_nonnull_domain dom;
+ struct {
+ u_int params_len;
+ remote_typed_param * params_val;
+ } params;
+ u_int flags;
+};
struct remote_domain_migrate_begin3_params_args {
remote_nonnull_domain dom;
struct {
@@ -2762,4 +2780,6 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_EVENT_CALLBACK_PMSUSPEND_DISK = 332,
REMOTE_PROC_DOMAIN_EVENT_CALLBACK_DEVICE_REMOVED = 333,
REMOTE_PROC_DOMAIN_CORE_DUMP_WITH_FORMAT = 334,
+ REMOTE_PROC_DOMAIN_GET_TIME = 335,
+ REMOTE_PROC_DOMAIN_SET_TIME = 336,
};
--
1.9.0