[libvirt] [python PATCH] generator.py: add mapping for VIR_DOMAIN_QEMU_AGENT_COMMAND_*

Pavel Hrdina posted 1 patch 1 week ago
Failed in applying to current master (apply log)
generator.py | 6 ++++++
1 file changed, 6 insertions(+)

[libvirt] [python PATCH] generator.py: add mapping for VIR_DOMAIN_QEMU_AGENT_COMMAND_*

Posted by Pavel Hrdina 1 week ago
Libvirt commit <95f5ac9ae52455e9da47afc95fa31c9456ac27ae> changed the
VIR_DOMAIN_QEMU_AGENT_COMMAND_* enum values to use different enum values
instead of direct numbers.  We need to translate it back.

Traceback (most recent call last):
  File "generator.py", line 2143, in <module>
    qemuBuildWrappers(sys.argv[1])
  File "generator.py", line 2008, in qemuBuildWrappers
    items.sort(key=lambda i: (int(i[1]), i[0]))
  File "generator.py", line 2008, in <lambda>
    items.sort(key=lambda i: (int(i[1]), i[0]))
ValueError: invalid literal for int() with base 10: 'VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK'

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 generator.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/generator.py b/generator.py
index 913dab8..3352521 100755
--- a/generator.py
+++ b/generator.py
@@ -261,6 +261,12 @@ def lxc_enum(type, name, value):
 def qemu_enum(type, name, value):
     if type not in qemu_enums:
         qemu_enums[type] = {}
+    if value == 'VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK':
+        value = -2
+    elif value == 'VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_DEFAULT':
+        value = -1
+    elif value == 'VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_NOWAIT':
+        value = 0
     if onlyOverrides and name not in qemu_enums[type]:
         return
     qemu_enums[type][name] = value
-- 
2.23.0

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

Re: [libvirt] [python PATCH] generator.py: add mapping for VIR_DOMAIN_QEMU_AGENT_COMMAND_*

Posted by Peter Krempa 1 week ago
On Thu, Nov 28, 2019 at 09:38:18 +0100, Pavel Hrdina wrote:
> Libvirt commit <95f5ac9ae52455e9da47afc95fa31c9456ac27ae> changed the
> VIR_DOMAIN_QEMU_AGENT_COMMAND_* enum values to use different enum values
> instead of direct numbers.  We need to translate it back.
> 
> Traceback (most recent call last):
>   File "generator.py", line 2143, in <module>
>     qemuBuildWrappers(sys.argv[1])
>   File "generator.py", line 2008, in qemuBuildWrappers
>     items.sort(key=lambda i: (int(i[1]), i[0]))
>   File "generator.py", line 2008, in <lambda>
>     items.sort(key=lambda i: (int(i[1]), i[0]))
> ValueError: invalid literal for int() with base 10: 'VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK'
> 
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  generator.py | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/generator.py b/generator.py
> index 913dab8..3352521 100755
> --- a/generator.py
> +++ b/generator.py
> @@ -261,6 +261,12 @@ def lxc_enum(type, name, value):
>  def qemu_enum(type, name, value):
>      if type not in qemu_enums:
>          qemu_enums[type] = {}
> +    if value == 'VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK':

These are not qemu specific. Shouldn't this go into 'enum' ?

> +        value = -2
> +    elif value == 'VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_DEFAULT':
> +        value = -1
> +    elif value == 'VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_NOWAIT':
> +        value = 0
>      if onlyOverrides and name not in qemu_enums[type]:
>          return
>      qemu_enums[type][name] = value
> -- 
> 2.23.0
> 
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [python PATCH] generator.py: add mapping for VIR_DOMAIN_QEMU_AGENT_COMMAND_*

Posted by Pavel Hrdina 1 week ago
On Thu, Nov 28, 2019 at 10:44:31AM +0100, Peter Krempa wrote:
> On Thu, Nov 28, 2019 at 09:38:18 +0100, Pavel Hrdina wrote:
> > Libvirt commit <95f5ac9ae52455e9da47afc95fa31c9456ac27ae> changed the
> > VIR_DOMAIN_QEMU_AGENT_COMMAND_* enum values to use different enum values
> > instead of direct numbers.  We need to translate it back.
> > 
> > Traceback (most recent call last):
> >   File "generator.py", line 2143, in <module>
> >     qemuBuildWrappers(sys.argv[1])
> >   File "generator.py", line 2008, in qemuBuildWrappers
> >     items.sort(key=lambda i: (int(i[1]), i[0]))
> >   File "generator.py", line 2008, in <lambda>
> >     items.sort(key=lambda i: (int(i[1]), i[0]))
> > ValueError: invalid literal for int() with base 10: 'VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK'
> > 
> > Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> > ---
> >  generator.py | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/generator.py b/generator.py
> > index 913dab8..3352521 100755
> > --- a/generator.py
> > +++ b/generator.py
> > @@ -261,6 +261,12 @@ def lxc_enum(type, name, value):
> >  def qemu_enum(type, name, value):
> >      if type not in qemu_enums:
> >          qemu_enums[type] = {}
> > +    if value == 'VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK':
> 
> These are not qemu specific. Shouldn't this go into 'enum' ?

They are defined in include/libvirt/libvirt-domain.h but used in
include/libvirt/libvirt-qemu.h for
virDomainQemuAgentCommandTimeoutValues enum.

The issue here is that the generator.py parses libvirt-qemu-api.xml
where the value for VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK is
VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK so we need to translate that
value to corresponding number.  Ideally the generator.py would figure
out this automatically by looking into libvirt-api.xml but that would
require rewriting it.

Pavel

> 
> > +        value = -2
> > +    elif value == 'VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_DEFAULT':
> > +        value = -1
> > +    elif value == 'VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_NOWAIT':
> > +        value = 0
> >      if onlyOverrides and name not in qemu_enums[type]:
> >          return
> >      qemu_enums[type][name] = value
> > -- 
> > 2.23.0
> > 
> > --
> > libvir-list mailing list
> > libvir-list@redhat.com
> > https://www.redhat.com/mailman/listinfo/libvir-list


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

Re: [libvirt] [python PATCH] generator.py: add mapping for VIR_DOMAIN_QEMU_AGENT_COMMAND_*

Posted by Peter Krempa 1 week ago
On Thu, Nov 28, 2019 at 10:50:38 +0100, Pavel Hrdina wrote:
> On Thu, Nov 28, 2019 at 10:44:31AM +0100, Peter Krempa wrote:
> > On Thu, Nov 28, 2019 at 09:38:18 +0100, Pavel Hrdina wrote:
> > > Libvirt commit <95f5ac9ae52455e9da47afc95fa31c9456ac27ae> changed the
> > > VIR_DOMAIN_QEMU_AGENT_COMMAND_* enum values to use different enum values
> > > instead of direct numbers.  We need to translate it back.
> > > 
> > > Traceback (most recent call last):
> > >   File "generator.py", line 2143, in <module>
> > >     qemuBuildWrappers(sys.argv[1])
> > >   File "generator.py", line 2008, in qemuBuildWrappers
> > >     items.sort(key=lambda i: (int(i[1]), i[0]))
> > >   File "generator.py", line 2008, in <lambda>
> > >     items.sort(key=lambda i: (int(i[1]), i[0]))
> > > ValueError: invalid literal for int() with base 10: 'VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK'
> > > 
> > > Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> > > ---
> > >  generator.py | 6 ++++++
> > >  1 file changed, 6 insertions(+)
> > > 
> > > diff --git a/generator.py b/generator.py
> > > index 913dab8..3352521 100755
> > > --- a/generator.py
> > > +++ b/generator.py
> > > @@ -261,6 +261,12 @@ def lxc_enum(type, name, value):
> > >  def qemu_enum(type, name, value):
> > >      if type not in qemu_enums:
> > >          qemu_enums[type] = {}
> > > +    if value == 'VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK':
> > 
> > These are not qemu specific. Shouldn't this go into 'enum' ?
> 
> They are defined in include/libvirt/libvirt-domain.h but used in
> include/libvirt/libvirt-qemu.h for
> virDomainQemuAgentCommandTimeoutValues enum.
> 
> The issue here is that the generator.py parses libvirt-qemu-api.xml
> where the value for VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK is
> VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK so we need to translate that
> value to corresponding number.  Ideally the generator.py would figure
> out this automatically by looking into libvirt-api.xml but that would
> require rewriting it.

Oh, that's stupid. I guess I don't care that much. Since this fixes the
problem:

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list