[libvirt] [libvirt-python PATCH 1/2] Add support for virDomainGetLaunchSecurityInfo

Erik Skultety posted 2 patches 6 years, 11 months ago
There is a newer version of this series
[libvirt] [libvirt-python PATCH 1/2] Add support for virDomainGetLaunchSecurityInfo
Posted by Erik Skultety 6 years, 11 months ago
Libvirt recently introduced support for getting launch security
parameters, most notably AMD SEV VM memory measurement. This API can't
be generated as it's using typed parameters which we need to allocate.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
---
 generator.py             |  1 +
 libvirt-override-api.xml |  6 ++++++
 libvirt-override.c       | 39 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 46 insertions(+)

diff --git a/generator.py b/generator.py
index b7d96a1..643d1b4 100755
--- a/generator.py
+++ b/generator.py
@@ -489,6 +489,7 @@ skip_impl = (
     'virDomainSetPerfEvents',
     'virDomainGetGuestVcpus',
     'virConnectBaselineHypervisorCPU',
+    'virDomainGetLaunchSecurityInfo',
 )

 lxc_skip_impl = (
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index 36d3577..7137237 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -728,5 +728,11 @@
       <arg name='xmlCPUs' type='const char **' info='array of XML descriptions of CPUs'/>
       <arg name='flags' type='unsigned int' info='bitwise-OR of virConnectBaselineCPUFlags'/>
     </function>
+    <function name='virDomainGetLaunchSecurityInfo' file='python'>
+      <info>Get launch security info for a domain</info>
+     <return type='char *' info='None in case of error, returns a dictionary of params'/>
+      <arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
+     <arg name='flags' type='int' info='unused, always pass 0'/>
+    </function>
   </symbols>
 </api>
diff --git a/libvirt-override.c b/libvirt-override.c
index 2f2c4ff..5de8693 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -9763,6 +9763,42 @@ libvirt_virConnectBaselineHypervisorCPU(PyObject *self ATTRIBUTE_UNUSED,
 #endif /* LIBVIR_CHECK_VERSION(4, 4, 0) */


+#if LIBVIR_CHECK_VERSION(4, 5, 0)
+static PyObject *
+libvirt_virDomainGetLaunchSecurityInfo(PyObject *self ATTRIBUTE_UNUSED,
+                                       PyObject *args)
+{
+    PyObject *pyobj_dom = NULL;
+    PyObject *ret = NULL;
+
+    virDomainPtr dom = NULL;
+    virTypedParameterPtr params = NULL;
+    int nparams = 0;
+    unsigned int flags = 0;
+    int i_retval;
+
+    if (!PyArg_ParseTuple(args, (char *)"OI:virDomainGetLaunchSecurityInfo",
+                          &pyobj_dom, &flags))
+        return NULL;
+    dom = (virDomainPtr) PyvirDomain_Get(pyobj_dom);
+
+    LIBVIRT_BEGIN_ALLOW_THREADS;
+    i_retval = virDomainGetLaunchSecurityInfo(dom, params, nparams, flags);
+    LIBVIRT_END_ALLOW_THREADS;
+
+    if (i_retval < 0) {
+        ret = VIR_PY_NONE;
+        goto cleanup;
+    }
+
+    ret = getPyVirTypedParameter(params, nparams);
+ cleanup:
+    virTypedParamsFree(params, nparams);
+    return ret;
+}
+#endif /* LIBVIR_CHECK_VERSION(4, 5, 0) */
+
+
 /************************************************************************
  *									*
  *			The registration stuff				*
@@ -9999,6 +10035,9 @@ static PyMethodDef libvirtMethods[] = {
 #if LIBVIR_CHECK_VERSION(4, 4, 0)
     {(char *) "virConnectBaselineHypervisorCPU", libvirt_virConnectBaselineHypervisorCPU, METH_VARARGS, NULL},
 #endif /* LIBVIR_CHECK_VERSION(4, 4, 0) */
+#if LIBVIR_CHECK_VERSION(4, 5, 0)
+    {(char *) "virDomainGetLaunchSecurityInfo", libvirt_virDomainGetLaunchSecurityInfo, METH_VARARGS, NULL},
+#endif /* LIBVIR_CHECK_VERSION(4, 5, 0) */
     {NULL, NULL, 0, NULL}
 };

--
2.14.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-python PATCH 1/2] Add support for virDomainGetLaunchSecurityInfo
Posted by Ján Tomko 6 years, 11 months ago
On Tue, Jun 12, 2018 at 04:23:37PM +0200, Erik Skultety wrote:
>Libvirt recently introduced support for getting launch security
>parameters, most notably AMD SEV VM memory measurement. This API can't
>be generated as it's using typed parameters which we need to allocate.
>
>Signed-off-by: Erik Skultety <eskultet@redhat.com>
>---
> generator.py             |  1 +
> libvirt-override-api.xml |  6 ++++++
> libvirt-override.c       | 39 +++++++++++++++++++++++++++++++++++++++
> 3 files changed, 46 insertions(+)
>
>diff --git a/generator.py b/generator.py
>index b7d96a1..643d1b4 100755
>--- a/generator.py
>+++ b/generator.py
>@@ -489,6 +489,7 @@ skip_impl = (
>     'virDomainSetPerfEvents',
>     'virDomainGetGuestVcpus',
>     'virConnectBaselineHypervisorCPU',
>+    'virDomainGetLaunchSecurityInfo',
> )
>
> lxc_skip_impl = (
>diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
>index 36d3577..7137237 100644
>--- a/libvirt-override-api.xml
>+++ b/libvirt-override-api.xml
>@@ -728,5 +728,11 @@
>       <arg name='xmlCPUs' type='const char **' info='array of XML descriptions of CPUs'/>
>       <arg name='flags' type='unsigned int' info='bitwise-OR of virConnectBaselineCPUFlags'/>
>     </function>
>+    <function name='virDomainGetLaunchSecurityInfo' file='python'>
>+      <info>Get launch security info for a domain</info>
>+     <return type='char *' info='None in case of error, returns a dictionary of params'/>

Indentation is off.

>+      <arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
>+     <arg name='flags' type='int' info='unused, always pass 0'/>

Here too.

>+    </function>
>   </symbols>
> </api>
>diff --git a/libvirt-override.c b/libvirt-override.c
>index 2f2c4ff..5de8693 100644
>--- a/libvirt-override.c
>+++ b/libvirt-override.c
>@@ -9763,6 +9763,42 @@ libvirt_virConnectBaselineHypervisorCPU(PyObject *self ATTRIBUTE_UNUSED,
> #endif /* LIBVIR_CHECK_VERSION(4, 4, 0) */
>
>
>+#if LIBVIR_CHECK_VERSION(4, 5, 0)
>+static PyObject *
>+libvirt_virDomainGetLaunchSecurityInfo(PyObject *self ATTRIBUTE_UNUSED,
>+                                       PyObject *args)
>+{
>+    PyObject *pyobj_dom = NULL;
>+    PyObject *ret = NULL;
>+
>+    virDomainPtr dom = NULL;
>+    virTypedParameterPtr params = NULL;
>+    int nparams = 0;
>+    unsigned int flags = 0;
>+    int i_retval;
>+
>+    if (!PyArg_ParseTuple(args, (char *)"OI:virDomainGetLaunchSecurityInfo",
>+                          &pyobj_dom, &flags))
>+        return NULL;
>+    dom = (virDomainPtr) PyvirDomain_Get(pyobj_dom);
>+
>+    LIBVIRT_BEGIN_ALLOW_THREADS;
>+    i_retval = virDomainGetLaunchSecurityInfo(dom, params, nparams, flags);

libvirt-override.c:9786:52: warning: passing argument 2 of ‘virDomainGetLaunchSecurityInfo’ from incompatible pointer type [-Wincompatible-pointer-types]
     i_retval = virDomainGetLaunchSecurityInfo(dom, params, nparams, flags);
                                                    ^~~~~~

Are you sure you tried bulding it against git libvirt?

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-python PATCH 1/2] Add support for virDomainGetLaunchSecurityInfo
Posted by Erik Skultety 6 years, 11 months ago
On Wed, Jun 13, 2018 at 09:02:12AM +0200, Ján Tomko wrote:
> On Tue, Jun 12, 2018 at 04:23:37PM +0200, Erik Skultety wrote:
> > Libvirt recently introduced support for getting launch security
> > parameters, most notably AMD SEV VM memory measurement. This API can't
> > be generated as it's using typed parameters which we need to allocate.
> >
> > Signed-off-by: Erik Skultety <eskultet@redhat.com>
> > ---
> > generator.py             |  1 +
> > libvirt-override-api.xml |  6 ++++++
> > libvirt-override.c       | 39 +++++++++++++++++++++++++++++++++++++++
> > 3 files changed, 46 insertions(+)
> >
> > diff --git a/generator.py b/generator.py
> > index b7d96a1..643d1b4 100755
> > --- a/generator.py
> > +++ b/generator.py
> > @@ -489,6 +489,7 @@ skip_impl = (
> >     'virDomainSetPerfEvents',
> >     'virDomainGetGuestVcpus',
> >     'virConnectBaselineHypervisorCPU',
> > +    'virDomainGetLaunchSecurityInfo',
> > )
> >
> > lxc_skip_impl = (
> > diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
> > index 36d3577..7137237 100644
> > --- a/libvirt-override-api.xml
> > +++ b/libvirt-override-api.xml
> > @@ -728,5 +728,11 @@
> >       <arg name='xmlCPUs' type='const char **' info='array of XML descriptions of CPUs'/>
> >       <arg name='flags' type='unsigned int' info='bitwise-OR of virConnectBaselineCPUFlags'/>
> >     </function>
> > +    <function name='virDomainGetLaunchSecurityInfo' file='python'>
> > +      <info>Get launch security info for a domain</info>
> > +     <return type='char *' info='None in case of error, returns a dictionary of params'/>
>
> Indentation is off.
>
> > +      <arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
> > +     <arg name='flags' type='int' info='unused, always pass 0'/>
>
> Here too.
>
> > +    </function>
> >   </symbols>
> > </api>
> > diff --git a/libvirt-override.c b/libvirt-override.c
> > index 2f2c4ff..5de8693 100644
> > --- a/libvirt-override.c
> > +++ b/libvirt-override.c
> > @@ -9763,6 +9763,42 @@ libvirt_virConnectBaselineHypervisorCPU(PyObject *self ATTRIBUTE_UNUSED,
> > #endif /* LIBVIR_CHECK_VERSION(4, 4, 0) */
> >
> >
> > +#if LIBVIR_CHECK_VERSION(4, 5, 0)
> > +static PyObject *
> > +libvirt_virDomainGetLaunchSecurityInfo(PyObject *self ATTRIBUTE_UNUSED,
> > +                                       PyObject *args)
> > +{
> > +    PyObject *pyobj_dom = NULL;
> > +    PyObject *ret = NULL;
> > +
> > +    virDomainPtr dom = NULL;
> > +    virTypedParameterPtr params = NULL;
> > +    int nparams = 0;
> > +    unsigned int flags = 0;
> > +    int i_retval;
> > +
> > +    if (!PyArg_ParseTuple(args, (char *)"OI:virDomainGetLaunchSecurityInfo",
> > +                          &pyobj_dom, &flags))
> > +        return NULL;
> > +    dom = (virDomainPtr) PyvirDomain_Get(pyobj_dom);
> > +
> > +    LIBVIRT_BEGIN_ALLOW_THREADS;
> > +    i_retval = virDomainGetLaunchSecurityInfo(dom, params, nparams, flags);
>
> libvirt-override.c:9786:52: warning: passing argument 2 of ‘virDomainGetLaunchSecurityInfo’ from incompatible pointer type [-Wincompatible-pointer-types]
>     i_retval = virDomainGetLaunchSecurityInfo(dom, params, nparams, flags);
>                                                    ^~~~~~
>
> Are you sure you tried bulding it against git libvirt?

Sigh...I didn't have a freshly generated libvirt-api.xml in libvirt repo, so
python ignored it, I'll respin shortly

Erik

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