Re: [libvirt] [PATCH 4/8] perf: implement the remote protocol for perf event

2015-11-25 Thread Jiri Denemark
On Wed, Nov 25, 2015 at 01:22:22 +, Ren, Qiaowei wrote:
> 
> > -Original Message-
> > From: Jiri Denemark [mailto:jdene...@redhat.com]
> > Sent: Tuesday, November 24, 2015 5:43 PM
> > To: Ren, Qiaowei
> > Cc: libvir-list@redhat.com
> > Subject: Re: [libvirt] [PATCH 4/8] perf: implement the remote protocol for 
> > perf
> > event
> > 
> > On Tue, Nov 17, 2015 at 16:00:44 +0800, Qiaowei Ren wrote:
> > > Add remote support for perf event.
> > >
> > > Signed-off-by: Qiaowei Ren <qiaowei@intel.com>
> > > ---
> > >  daemon/remote.c  | 60
> > 
> > >  src/remote/remote_driver.c   | 49
> > 
> > >  src/remote/remote_protocol.x | 32 ++-
> > > src/remote_protocol-structs  | 20 +++
> > >  4 files changed, 160 insertions(+), 1 deletion(-)
> > 
> > This will need to be changed to match the new style of the API. But, since 
> > you
> > are adding a new API, would you mind creating a patch for libvirt-python to 
> > add
> > this new API to python bindings?
> > 
> 
> Sure. The patch for libvirt-python should be also sent this maillist with 
> this series, right?

Well, it's a different repository so sending it in the same series might
be a bit tricky. So it's up to you if you send it in one series or send
it as a separate patch. And yes, they should all be sent to this mailing
list.

Jirka

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


Re: [libvirt] [PATCH 4/8] perf: implement the remote protocol for perf event

2015-11-24 Thread Ren, Qiaowei

> -Original Message-
> From: Jiri Denemark [mailto:jdene...@redhat.com]
> Sent: Tuesday, November 24, 2015 5:43 PM
> To: Ren, Qiaowei
> Cc: libvir-list@redhat.com
> Subject: Re: [libvirt] [PATCH 4/8] perf: implement the remote protocol for 
> perf
> event
> 
> On Tue, Nov 17, 2015 at 16:00:44 +0800, Qiaowei Ren wrote:
> > Add remote support for perf event.
> >
> > Signed-off-by: Qiaowei Ren <qiaowei@intel.com>
> > ---
> >  daemon/remote.c  | 60
> 
> >  src/remote/remote_driver.c   | 49
> 
> >  src/remote/remote_protocol.x | 32 ++-
> > src/remote_protocol-structs  | 20 +++
> >  4 files changed, 160 insertions(+), 1 deletion(-)
> 
> This will need to be changed to match the new style of the API. But, since you
> are adding a new API, would you mind creating a patch for libvirt-python to 
> add
> this new API to python bindings?
> 

Sure. The patch for libvirt-python should be also sent this maillist with this 
series, right?

Thanks,
Qiaowei 


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


Re: [libvirt] [PATCH 4/8] perf: implement the remote protocol for perf event

2015-11-24 Thread Jiri Denemark
On Tue, Nov 17, 2015 at 16:00:44 +0800, Qiaowei Ren wrote:
> Add remote support for perf event.
> 
> Signed-off-by: Qiaowei Ren 
> ---
>  daemon/remote.c  | 60 
> 
>  src/remote/remote_driver.c   | 49 
>  src/remote/remote_protocol.x | 32 ++-
>  src/remote_protocol-structs  | 20 +++
>  4 files changed, 160 insertions(+), 1 deletion(-)

This will need to be changed to match the new style of the API. But,
since you are adding a new API, would you mind creating a patch for
libvirt-python to add this new API to python bindings?

Jirka

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


[libvirt] [PATCH 4/8] perf: implement the remote protocol for perf event

2015-11-17 Thread Qiaowei Ren
Add remote support for perf event.

Signed-off-by: Qiaowei Ren 
---
 daemon/remote.c  | 60 
 src/remote/remote_driver.c   | 49 
 src/remote/remote_protocol.x | 32 ++-
 src/remote_protocol-structs  | 20 +++
 4 files changed, 160 insertions(+), 1 deletion(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 3a3eb09..68a319c 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -2810,6 +2810,66 @@ 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 (args->nparams > REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX) {
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+goto cleanup;
+}
+if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0)
+goto cleanup;
+nparams = args->nparams;
+
+if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+goto cleanup;
+
+if (virDomainGetPerfEvents(dom, params, ) < 0)
+goto cleanup;
+
+/* In this case, we need to send back the number of parameters
+ * supported
+ */
+if (args->nparams == 0) {
+ret->nparams = nparams;
+goto success;
+}
+
+if (remoteSerializeTypedParameters(params, nparams,
+   >params.params_val,
+   >params.params_len,
+   0) < 0)
+goto cleanup;
+
+ success:
+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 a1dd640..30297c7 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -2028,6 +2028,53 @@ 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(, domain);
+args.nparams = *nparams;
+
+memset(, 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 *) 
,
+ (xdrproc_t) xdr_remote_domain_get_perf_events_ret, (char *) ) 
== -1)
+goto done;
+
+/* Handle the case when the caller does not know the number of parameters
+ * and is asking for the number of parameters supported
+ */
+if (*nparams == 0) {
+*nparams = ret.nparams;
+rv = 0;
+goto cleanup;
+}
+
+if (remoteDeserializeTypedParameters(ret.params.params_val,
+ ret.params.params_len,
+ REMOTE_DOMAIN_NUMA_PARAMETERS_MAX,
+ ,
+ nparams) < 0)
+goto cleanup;
+
+rv = 0;
+
+ cleanup:
+xdr_free((xdrproc_t) xdr_remote_domain_get_perf_events_ret,
+ (char *) );
+ done:
+remoteDriverUnlock(priv);
+return rv;
+}
+
+static int
 remoteDomainGetBlkioParameters(virDomainPtr domain,
virTypedParameterPtr params, int *nparams,
unsigned int flags)
@@ -8253,6 +8300,8 @@ static virHypervisorDriver hypervisor_driver = {
 .domainGetMemoryParameters = remoteDomainGetMemoryParameters, /* 0.8.5 */
 .domainSetBlkioParameters = remoteDomainSetBlkioParameters, /* 0.9.0 */
 .domainGetBlkioParameters = remoteDomainGetBlkioParameters, /* 0.9.0 */
+