Re: [libvirt] [PATCH 1/1] python: add python binding for Perf API

2016-03-31 Thread Ren, Qiaowei

> -Original Message-
> From: Michal Privoznik [mailto:mpriv...@redhat.com]
> Sent: Thursday, March 31, 2016 10:04 PM
> To: Ren, Qiaowei; libvir-list@redhat.com
> Subject: Re: [libvirt] [PATCH 1/1] python: add python binding for Perf API
> 
> On 31.03.2016 08:16, Michal Privoznik wrote:
> > On 30.03.2016 04:13, Qiaowei Ren wrote:
> >> This patch adds the python binding for virDomainSetPerfEvents and
> >> virDomainSetPerfEvents API.
> >>
> >> Signed-off-by: Qiaowei Ren 
> >> ---
> >>  generator.py |  2 ++
> >>  libvirt-override-api.xml | 11 ++
> >>  libvirt-override.c   | 93
> 
> >>  3 files changed, 106 insertions(+)
> >>
> 
> I had to do couple of more tweaks than originally intended. But this is now
> pushed.
> 
Thanks, Michal!

- Qiaowei



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


Re: [libvirt] [PATCH 1/1] python: add python binding for Perf API

2016-03-31 Thread Michal Privoznik
On 31.03.2016 08:16, Michal Privoznik wrote:
> On 30.03.2016 04:13, Qiaowei Ren wrote:
>> This patch adds the python binding for virDomainSetPerfEvents and
>> virDomainSetPerfEvents API.
>>
>> Signed-off-by: Qiaowei Ren 
>> ---
>>  generator.py |  2 ++
>>  libvirt-override-api.xml | 11 ++
>>  libvirt-override.c   | 93 
>> 
>>  3 files changed, 106 insertions(+)
>>

I had to do couple of more tweaks than originally intended. But this is
now pushed.

Michal

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


Re: [libvirt] [PATCH 1/1] python: add python binding for Perf API

2016-03-30 Thread Michal Privoznik
On 30.03.2016 04:13, Qiaowei Ren wrote:
> This patch adds the python binding for virDomainSetPerfEvents and
> virDomainSetPerfEvents API.
> 
> Signed-off-by: Qiaowei Ren 
> ---
>  generator.py |  2 ++
>  libvirt-override-api.xml | 11 ++
>  libvirt-override.c   | 93 
> 
>  3 files changed, 106 insertions(+)
> 
> diff --git a/generator.py b/generator.py
> index d9ae17e..fb6a493 100755
> --- a/generator.py
> +++ b/generator.py
> @@ -433,6 +433,8 @@ skip_impl = (
>  'virDomainGetMemoryParameters',
>  'virDomainSetNumaParameters',
>  'virDomainGetNumaParameters',
> +'virDomainSetPerfEvents',
> +'virDomainGetPerfEvents',
>  'virDomainGetVcpus',
>  'virDomainPinVcpu',
>  'virDomainPinVcpuFlags',
> diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
> index 1a0e314..54b45f7 100644
> --- a/libvirt-override-api.xml
> +++ b/libvirt-override-api.xml
> @@ -344,6 +344,17 @@
>
>
>  
> +
> +  Enable or disable the particular list of perf events
> +  
> +  
> +  
> +
> +
> +  Get all perf events setting.
> +  
> +  
> +
>  
>Change the bandwidth tunables for a interface device
>
> diff --git a/libvirt-override.c b/libvirt-override.c
> index ce36280..11ef15e 100644
> --- a/libvirt-override.c
> +++ b/libvirt-override.c
> @@ -1059,6 +1059,97 @@ libvirt_virDomainGetNumaParameters(PyObject *self 
> ATTRIBUTE_UNUSED,
>  }
>  
>  static PyObject *
> +libvirt_virDomainSetPerfEvents(PyObject *self ATTRIBUTE_UNUSED,
> +   PyObject *args)
> +{
> +virDomainPtr domain;
> +PyObject *pyobj_domain, *info;
> +PyObject *ret = NULL;
> +int i_retval;
> +int nparams = 0;
> +Py_ssize_t size = 0;
> +virTypedParameterPtr params = NULL, new_params = NULL;
> +
> +if (!PyArg_ParseTuple(args,
> +  (char *)"OO:virDomainSetNumaParameters",
> +  &pyobj_domain, &info))
> +return NULL;
> +domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
> +
> +if ((size = PyDict_Size(info)) < 0)
> +return NULL;
> +
> +if (size == 0) {
> +PyErr_Format(PyExc_LookupError,
> + "Need non-empty dictionary to set attributes");
> +return NULL;
> +}
> +
> +LIBVIRT_BEGIN_ALLOW_THREADS;
> +i_retval = virDomainGetPerfEvents(domain, ¶ms, &nparams);
> +LIBVIRT_END_ALLOW_THREADS;
> +
> +if (i_retval < 0)
> +return VIR_PY_INT_FAIL;
> +
> +if (nparams == 0) {
> +PyErr_Format(PyExc_LookupError,
> + "Domain has no settable attributes");
> +return NULL;
> +}
> +
> +new_params = setPyVirTypedParameter(info, params, nparams);
> +if (!new_params)
> +goto cleanup;
> +
> +LIBVIRT_BEGIN_ALLOW_THREADS;
> +i_retval = virDomainSetPerfEvents(domain, new_params, size);
> +LIBVIRT_END_ALLOW_THREADS;
> +
> +if (i_retval < 0) {
> +ret = VIR_PY_INT_FAIL;
> +goto cleanup;
> +}
> +
> +ret = VIR_PY_INT_SUCCESS;
> +
> + cleanup:
> +virTypedParamsFree(params, nparams);
> +virTypedParamsFree(new_params, size);
> +return ret;
> +}
> +
> +static PyObject *
> +libvirt_virDomainGetPerfEvents(PyObject *self ATTRIBUTE_UNUSED,
> +   PyObject *args)
> +{
> +PyObject *pyobj_domain;
> +virDomainPtr domain;
> +virTypedParameterPtr params = NULL;
> +int nparams = 0;
> +PyObject *dict = NULL;
> +int rc;
> +
> +if (!PyArg_ParseTuple(args, (char *) "O:virDomainGetPerfEvents",
> +  &pyobj_domain))
> +return NULL;
> +domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
> +
> +LIBVIRT_BEGIN_ALLOW_THREADS;
> +rc = virDomainGetPerfEvents(domain, ¶ms, &nparams);
> +LIBVIRT_END_ALLOW_THREADS;
> +if (rc < 0)
> +return VIR_PY_NONE;
> +
> +if (!(dict = getPyVirTypedParameter(params, nparams)))
> +goto cleanup;
> +
> + cleanup:
> +virTypedParamsFree(params, nparams);
> +return dict;
> +}
> +
> +static PyObject *
>  libvirt_virDomainSetInterfaceParameters(PyObject *self ATTRIBUTE_UNUSED,
>  PyObject *args)
>  {
> @@ -8686,6 +8777,8 @@ static PyMethodDef libvirtMethods[] = {
>  {(char *) "virDomainGetMemoryParameters", 
> libvirt_virDomainGetMemoryParameters, METH_VARARGS, NULL},
>  {(char *) "virDomainSetNumaParameters", 
> libvirt_virDomainSetNumaParameters, METH_VARARGS, NULL},
>  {(char *) "virDomainGetNumaParameters", 
> libvirt_virDomainGetNumaParameters, METH_VARARGS, NULL},
> +{(char *) "virDomainSetPerfEvents", libvirt_virDomainSetPerfEvents, 
> METH_VARARGS, NULL},
> +{(char *) "virDomainGetPerfEvents", libvirt_virDomainGetPerfEvents, 
> METH_VARARGS, NULL},
>  {(char *) "virDomainSetInterfaceParameters", 
> libvirt_virDomainS

[libvirt] [PATCH 1/1] python: add python binding for Perf API

2016-03-29 Thread Qiaowei Ren
This patch adds the python binding for virDomainSetPerfEvents and
virDomainSetPerfEvents API.

Signed-off-by: Qiaowei Ren 
---
 generator.py |  2 ++
 libvirt-override-api.xml | 11 ++
 libvirt-override.c   | 93 
 3 files changed, 106 insertions(+)

diff --git a/generator.py b/generator.py
index d9ae17e..fb6a493 100755
--- a/generator.py
+++ b/generator.py
@@ -433,6 +433,8 @@ skip_impl = (
 'virDomainGetMemoryParameters',
 'virDomainSetNumaParameters',
 'virDomainGetNumaParameters',
+'virDomainSetPerfEvents',
+'virDomainGetPerfEvents',
 'virDomainGetVcpus',
 'virDomainPinVcpu',
 'virDomainPinVcpuFlags',
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index 1a0e314..54b45f7 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -344,6 +344,17 @@
   
   
 
+
+  Enable or disable the particular list of perf events
+  
+  
+  
+
+
+  Get all perf events setting.
+  
+  
+
 
   Change the bandwidth tunables for a interface device
   
diff --git a/libvirt-override.c b/libvirt-override.c
index ce36280..11ef15e 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -1059,6 +1059,97 @@ libvirt_virDomainGetNumaParameters(PyObject *self 
ATTRIBUTE_UNUSED,
 }
 
 static PyObject *
+libvirt_virDomainSetPerfEvents(PyObject *self ATTRIBUTE_UNUSED,
+   PyObject *args)
+{
+virDomainPtr domain;
+PyObject *pyobj_domain, *info;
+PyObject *ret = NULL;
+int i_retval;
+int nparams = 0;
+Py_ssize_t size = 0;
+virTypedParameterPtr params = NULL, new_params = NULL;
+
+if (!PyArg_ParseTuple(args,
+  (char *)"OO:virDomainSetNumaParameters",
+  &pyobj_domain, &info))
+return NULL;
+domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+if ((size = PyDict_Size(info)) < 0)
+return NULL;
+
+if (size == 0) {
+PyErr_Format(PyExc_LookupError,
+ "Need non-empty dictionary to set attributes");
+return NULL;
+}
+
+LIBVIRT_BEGIN_ALLOW_THREADS;
+i_retval = virDomainGetPerfEvents(domain, ¶ms, &nparams);
+LIBVIRT_END_ALLOW_THREADS;
+
+if (i_retval < 0)
+return VIR_PY_INT_FAIL;
+
+if (nparams == 0) {
+PyErr_Format(PyExc_LookupError,
+ "Domain has no settable attributes");
+return NULL;
+}
+
+new_params = setPyVirTypedParameter(info, params, nparams);
+if (!new_params)
+goto cleanup;
+
+LIBVIRT_BEGIN_ALLOW_THREADS;
+i_retval = virDomainSetPerfEvents(domain, new_params, size);
+LIBVIRT_END_ALLOW_THREADS;
+
+if (i_retval < 0) {
+ret = VIR_PY_INT_FAIL;
+goto cleanup;
+}
+
+ret = VIR_PY_INT_SUCCESS;
+
+ cleanup:
+virTypedParamsFree(params, nparams);
+virTypedParamsFree(new_params, size);
+return ret;
+}
+
+static PyObject *
+libvirt_virDomainGetPerfEvents(PyObject *self ATTRIBUTE_UNUSED,
+   PyObject *args)
+{
+PyObject *pyobj_domain;
+virDomainPtr domain;
+virTypedParameterPtr params = NULL;
+int nparams = 0;
+PyObject *dict = NULL;
+int rc;
+
+if (!PyArg_ParseTuple(args, (char *) "O:virDomainGetPerfEvents",
+  &pyobj_domain))
+return NULL;
+domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+LIBVIRT_BEGIN_ALLOW_THREADS;
+rc = virDomainGetPerfEvents(domain, ¶ms, &nparams);
+LIBVIRT_END_ALLOW_THREADS;
+if (rc < 0)
+return VIR_PY_NONE;
+
+if (!(dict = getPyVirTypedParameter(params, nparams)))
+goto cleanup;
+
+ cleanup:
+virTypedParamsFree(params, nparams);
+return dict;
+}
+
+static PyObject *
 libvirt_virDomainSetInterfaceParameters(PyObject *self ATTRIBUTE_UNUSED,
 PyObject *args)
 {
@@ -8686,6 +8777,8 @@ static PyMethodDef libvirtMethods[] = {
 {(char *) "virDomainGetMemoryParameters", 
libvirt_virDomainGetMemoryParameters, METH_VARARGS, NULL},
 {(char *) "virDomainSetNumaParameters", 
libvirt_virDomainSetNumaParameters, METH_VARARGS, NULL},
 {(char *) "virDomainGetNumaParameters", 
libvirt_virDomainGetNumaParameters, METH_VARARGS, NULL},
+{(char *) "virDomainSetPerfEvents", libvirt_virDomainSetPerfEvents, 
METH_VARARGS, NULL},
+{(char *) "virDomainGetPerfEvents", libvirt_virDomainGetPerfEvents, 
METH_VARARGS, NULL},
 {(char *) "virDomainSetInterfaceParameters", 
libvirt_virDomainSetInterfaceParameters, METH_VARARGS, NULL},
 {(char *) "virDomainGetInterfaceParameters", 
libvirt_virDomainGetInterfaceParameters, METH_VARARGS, NULL},
 {(char *) "virDomainGetVcpus", libvirt_virDomainGetVcpus, METH_VARARGS, 
NULL},
-- 
1.9.1

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