[PATCH v4 2/8] perf: implement the remote protocol for perf event

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add remote support for perf event.

Signed-off-by: Qiaowei Ren <qiaowei.ren@xxxxxxxxx>
---
 daemon/remote.c              | 47 ++++++++++++++++++++++++++++++++++++++++++++
 src/remote/remote_driver.c   | 39 ++++++++++++++++++++++++++++++++++++
 src/remote/remote_protocol.x | 30 +++++++++++++++++++++++++++-
 src/remote_protocol-structs  | 18 +++++++++++++++++
 4 files changed, 133 insertions(+), 1 deletion(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 370f442..46d2933 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -2842,6 +2842,53 @@ remoteDispatchNodeGetMemoryStats(virNetServerPtr server ATTRIBUTE_UNUSED,
 }
 
 static int
+remoteDispatchDomainGetPerfEvents(virNetServerPtr server ATTRIBUTE_UNUSED,
+                                  virNetServerClientPtr client ATTRIBUTE_UNUSED,
+                                  virNetMessagePtr msg ATTRIBUTE_UNUSED,
+                                  virNetMessageErrorPtr rerr,
+                                  remote_domain_get_perf_events_args *args,
+                                  remote_domain_get_perf_events_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 (virDomainGetPerfEvents(dom, &params, &nparams) < 0)
+        goto cleanup;
+
+    if (nparams > REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+        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);
+    virObjectUnref(dom);
+    return rv;
+}
+
+static int
 remoteDispatchDomainGetBlockJobInfo(virNetServerPtr server ATTRIBUTE_UNUSED,
                                     virNetServerClientPtr client ATTRIBUTE_UNUSED,
                                     virNetMessagePtr msg ATTRIBUTE_UNUSED,
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index d9d7ec8..7927ff5 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -2037,6 +2037,43 @@ remoteDomainGetNumaParameters(virDomainPtr domain,
 }
 
 static int
+remoteDomainGetPerfEvents(virDomainPtr domain,
+                          virTypedParameterPtr *params,
+                          int *nparams)
+{
+    int rv = -1;
+    remote_domain_get_perf_events_args args;
+    remote_domain_get_perf_events_ret ret;
+    struct private_data *priv = domain->conn->privateData;
+
+    remoteDriverLock(priv);
+
+    make_nonnull_domain(&args.dom, domain);
+
+    memset(&ret, 0, sizeof(ret));
+    if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_PERF_EVENTS,
+             (xdrproc_t) xdr_remote_domain_get_perf_events_args, (char *) &args,
+             (xdrproc_t) xdr_remote_domain_get_perf_events_ret, (char *) &ret) == -1)
+        goto done;
+
+    if (remoteDeserializeTypedParameters(ret.params.params_val,
+                                         ret.params.params_len,
+                                         REMOTE_DOMAIN_PERF_EVENTS_MAX,
+                                         params,
+                                         nparams) < 0)
+        goto cleanup;
+
+    rv = 0;
+
+ cleanup:
+    xdr_free((xdrproc_t) xdr_remote_domain_get_perf_events_ret,
+             (char *) &ret);
+ done:
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
+static int
 remoteDomainGetBlkioParameters(virDomainPtr domain,
                                virTypedParameterPtr params, int *nparams,
                                unsigned int flags)
@@ -8286,6 +8323,8 @@ static virHypervisorDriver hypervisor_driver = {
     .domainGetMemoryParameters = remoteDomainGetMemoryParameters, /* 0.8.5 */
     .domainSetBlkioParameters = remoteDomainSetBlkioParameters, /* 0.9.0 */
     .domainGetBlkioParameters = remoteDomainGetBlkioParameters, /* 0.9.0 */
+    .domainGetPerfEvents = remoteDomainGetPerfEvents, /* 1.3.2 */
+    .domainSetPerfEvents = remoteDomainSetPerfEvents, /* 1.3.2 */
     .domainGetInfo = remoteDomainGetInfo, /* 0.3.0 */
     .domainGetState = remoteDomainGetState, /* 0.9.2 */
     .domainGetControlInfo = remoteDomainGetControlInfo, /* 0.9.3 */
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index bfdbce7..8b2218e 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -109,6 +109,9 @@ const REMOTE_DOMAIN_BLOCK_IO_TUNE_PARAMETERS_MAX = 16;
 /* Upper limit on list of numa parameters. */
 const REMOTE_DOMAIN_NUMA_PARAMETERS_MAX = 16;
 
+/* Upper limit on list of perf events. */
+const REMOTE_DOMAIN_PERF_EVENTS_MAX = 64;
+
 /* Upper limit on block copy tunable parameters. */
 const REMOTE_DOMAIN_BLOCK_COPY_PARAMETERS_MAX = 16;
 
@@ -628,6 +631,19 @@ struct remote_domain_get_numa_parameters_ret {
     int nparams;
 };
 
+struct remote_domain_set_perf_events_args {
+    remote_nonnull_domain dom;
+    remote_typed_param params<REMOTE_DOMAIN_PERF_EVENTS_MAX>;
+};
+
+struct remote_domain_get_perf_events_args {
+    remote_nonnull_domain dom;
+};
+
+struct remote_domain_get_perf_events_ret {
+    remote_typed_param params<REMOTE_DOMAIN_PERF_EVENTS_MAX>;
+};
+
 struct remote_domain_block_stats_args {
     remote_nonnull_domain dom;
     remote_nonnull_string path;
@@ -5706,5 +5722,17 @@ enum remote_procedure {
      * @generate: both
      * @acl: none
      */
-    REMOTE_PROC_DOMAIN_EVENT_CALLBACK_MIGRATION_ITERATION = 359
+    REMOTE_PROC_DOMAIN_EVENT_CALLBACK_MIGRATION_ITERATION = 359,
+
+    /**
+     * @generate: none
+     * @acl: domain:read
+     */
+    REMOTE_PROC_DOMAIN_GET_PERF_EVENTS = 360,
+
+    /**
+     * @generate: both
+     * @acl: domain:write
+     */
+    REMOTE_PROC_DOMAIN_SET_PERF_EVENTS = 361
 };
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index dff54e8..662d8f0 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -304,6 +304,22 @@ struct remote_domain_get_numa_parameters_ret {
         } params;
         int                        nparams;
 };
+struct remote_domain_set_perf_events_args {
+        remote_nonnull_domain      dom;
+        struct {
+                u_int              params_len;
+                remote_typed_param * params_val;
+        } params;
+};
+struct remote_domain_get_perf_events_args {
+        remote_nonnull_domain      dom;
+};
+struct remote_domain_get_perf_events_ret {
+        struct {
+                u_int              params_len;
+                remote_typed_param * params_val;
+        } params;
+};
 struct remote_domain_block_stats_args {
         remote_nonnull_domain      dom;
         remote_nonnull_string      path;
@@ -3057,4 +3073,6 @@ enum remote_procedure {
         REMOTE_PROC_DOMAIN_SET_USER_PASSWORD = 357,
         REMOTE_PROC_DOMAIN_RENAME = 358,
         REMOTE_PROC_DOMAIN_EVENT_CALLBACK_MIGRATION_ITERATION = 359,
+        REMOTE_PROC_DOMAIN_GET_PERF_EVENTS = 360,
+        REMOTE_PROC_DOMAIN_SET_PERF_EVENTS = 361,
 };
-- 
1.9.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]