qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Fix qapi code generation fix
@ 2011-12-28 10:26 Avi Kivity
  2012-01-12 14:16 ` Avi Kivity
  2012-01-12 16:54 ` Anthony Liguori
  0 siblings, 2 replies; 3+ messages in thread
From: Avi Kivity @ 2011-12-28 10:26 UTC (permalink / raw)
  To: Anthony Liguori, qemu-devel

The fixes to qapi code generation had multiple bugs:
- the Null class used to drop output was missing some methods
- in some scripts it was never instantiated, leading to a None return,
  which is missing even more methods
- the --source and --header options were swapped

Luckily, all those bugs were hidden by a makefile bug which caused the
old behaviour (with the race) to be invoked.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 Makefile                 |    2 +-
 scripts/qapi-commands.py |   12 ++++--------
 scripts/qapi-types.py    |   12 +++++-------
 scripts/qapi-visit.py    |   12 +++++-------
 4 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/Makefile b/Makefile
index 0838bc4..8118478 100644
--- a/Makefile
+++ b/Makefile
@@ -173,7 +173,7 @@ qapi-dir := $(BUILD_DIR)/qapi-generated
 test-qmp-input-visitor.o test-qmp-output-visitor.o test-qmp-commands.o qemu-ga$(EXESUF): QEMU_CFLAGS += -I $(qapi-dir)
 qemu-ga$(EXESUF): LIBS = $(LIBS_QGA)
 
-gen-out-type = $(subst .,-,$@)
+gen-out-type = $(subst .,-,$(suffix $@))
 
 $(qapi-dir)/test-qapi-types.c $(qapi-dir)/test-qapi-types.h :\
 $(SRC_PATH)/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-types.py
diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index bd7b207..3aabf61 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -399,9 +399,9 @@ for o, a in opts:
     elif o in ("-m", "--middle"):
         middle_mode = True
     elif o in ("-c", "--source"):
-        do_h = True
-    elif o in ("-h", "--header"):
         do_c = True
+    elif o in ("-h", "--header"):
+        do_h = True
 
 if not do_c and not do_h:
     do_c = True
@@ -411,15 +411,11 @@ c_file = output_dir + prefix + c_file
 h_file = output_dir + prefix + h_file
 
 def maybe_open(really, name, opt):
-    class Null(object):
-        def write(self, str):
-            pass
-        def read(self):
-            return ''
     if really:
         return open(name, opt)
     else:
-        return Null()
+        import StringIO
+        return StringIO.StringIO()
 
 try:
     os.makedirs(output_dir)
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index ae644bc..b56225b 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -183,9 +183,9 @@ for o, a in opts:
     elif o in ("-o", "--output-dir"):
         output_dir = a + "/"
     elif o in ("-c", "--source"):
-        do_h = True
-    elif o in ("-h", "--header"):
         do_c = True
+    elif o in ("-h", "--header"):
+        do_h = True
 
 if not do_c and not do_h:
     do_c = True
@@ -201,13 +201,11 @@ except os.error, e:
         raise
 
 def maybe_open(really, name, opt):
-    class Null(object):
-        def write(self, str):
-            pass
-        def read(self):
-            return ''
     if really:
         return open(name, opt)
+    else:
+        import StringIO
+        return StringIO.StringIO()
 
 fdef = maybe_open(do_c, c_file, 'w')
 fdecl = maybe_open(do_h, h_file, 'w')
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index e9d0584..5160d83 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -159,9 +159,9 @@ for o, a in opts:
     elif o in ("-o", "--output-dir"):
         output_dir = a + "/"
     elif o in ("-c", "--source"):
-        do_h = True
-    elif o in ("-h", "--header"):
         do_c = True
+    elif o in ("-h", "--header"):
+        do_h = True
 
 if not do_c and not do_h:
     do_c = True
@@ -177,13 +177,11 @@ except os.error, e:
         raise
 
 def maybe_open(really, name, opt):
-    class Null(object):
-        def write(self, str):
-            pass
-        def read(self):
-            return ''
     if really:
         return open(name, opt)
+    else:
+        import StringIO
+        return StringIO.StringIO()
 
 fdef = maybe_open(do_c, c_file, 'w')
 fdecl = maybe_open(do_h, h_file, 'w')
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] Fix qapi code generation fix
  2011-12-28 10:26 [Qemu-devel] [PATCH] Fix qapi code generation fix Avi Kivity
@ 2012-01-12 14:16 ` Avi Kivity
  2012-01-12 16:54 ` Anthony Liguori
  1 sibling, 0 replies; 3+ messages in thread
From: Avi Kivity @ 2012-01-12 14:16 UTC (permalink / raw)
  To: Anthony Liguori, qemu-devel

On 12/28/2011 12:26 PM, Avi Kivity wrote:
> The fixes to qapi code generation had multiple bugs:
> - the Null class used to drop output was missing some methods
> - in some scripts it was never instantiated, leading to a None return,
>   which is missing even more methods
> - the --source and --header options were swapped
>
> Luckily, all those bugs were hidden by a makefile bug which caused the
> old behaviour (with the race) to be invoked.

Pings.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] Fix qapi code generation fix
  2011-12-28 10:26 [Qemu-devel] [PATCH] Fix qapi code generation fix Avi Kivity
  2012-01-12 14:16 ` Avi Kivity
@ 2012-01-12 16:54 ` Anthony Liguori
  1 sibling, 0 replies; 3+ messages in thread
From: Anthony Liguori @ 2012-01-12 16:54 UTC (permalink / raw)
  To: Avi Kivity; +Cc: qemu-devel

On 12/28/2011 04:26 AM, Avi Kivity wrote:
> The fixes to qapi code generation had multiple bugs:
> - the Null class used to drop output was missing some methods
> - in some scripts it was never instantiated, leading to a None return,
>    which is missing even more methods
> - the --source and --header options were swapped
>
> Luckily, all those bugs were hidden by a makefile bug which caused the
> old behaviour (with the race) to be invoked.
>
> Signed-off-by: Avi Kivity<avi@redhat.com>

Applied.  Thanks.

Regards,

Anthony Liguori

> ---
>   Makefile                 |    2 +-
>   scripts/qapi-commands.py |   12 ++++--------
>   scripts/qapi-types.py    |   12 +++++-------
>   scripts/qapi-visit.py    |   12 +++++-------
>   4 files changed, 15 insertions(+), 23 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 0838bc4..8118478 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -173,7 +173,7 @@ qapi-dir := $(BUILD_DIR)/qapi-generated
>   test-qmp-input-visitor.o test-qmp-output-visitor.o test-qmp-commands.o qemu-ga$(EXESUF): QEMU_CFLAGS += -I $(qapi-dir)
>   qemu-ga$(EXESUF): LIBS = $(LIBS_QGA)
>
> -gen-out-type = $(subst .,-,$@)
> +gen-out-type = $(subst .,-,$(suffix $@))
>
>   $(qapi-dir)/test-qapi-types.c $(qapi-dir)/test-qapi-types.h :\
>   $(SRC_PATH)/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-types.py
> diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
> index bd7b207..3aabf61 100644
> --- a/scripts/qapi-commands.py
> +++ b/scripts/qapi-commands.py
> @@ -399,9 +399,9 @@ for o, a in opts:
>       elif o in ("-m", "--middle"):
>           middle_mode = True
>       elif o in ("-c", "--source"):
> -        do_h = True
> -    elif o in ("-h", "--header"):
>           do_c = True
> +    elif o in ("-h", "--header"):
> +        do_h = True
>
>   if not do_c and not do_h:
>       do_c = True
> @@ -411,15 +411,11 @@ c_file = output_dir + prefix + c_file
>   h_file = output_dir + prefix + h_file
>
>   def maybe_open(really, name, opt):
> -    class Null(object):
> -        def write(self, str):
> -            pass
> -        def read(self):
> -            return ''
>       if really:
>           return open(name, opt)
>       else:
> -        return Null()
> +        import StringIO
> +        return StringIO.StringIO()
>
>   try:
>       os.makedirs(output_dir)
> diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
> index ae644bc..b56225b 100644
> --- a/scripts/qapi-types.py
> +++ b/scripts/qapi-types.py
> @@ -183,9 +183,9 @@ for o, a in opts:
>       elif o in ("-o", "--output-dir"):
>           output_dir = a + "/"
>       elif o in ("-c", "--source"):
> -        do_h = True
> -    elif o in ("-h", "--header"):
>           do_c = True
> +    elif o in ("-h", "--header"):
> +        do_h = True
>
>   if not do_c and not do_h:
>       do_c = True
> @@ -201,13 +201,11 @@ except os.error, e:
>           raise
>
>   def maybe_open(really, name, opt):
> -    class Null(object):
> -        def write(self, str):
> -            pass
> -        def read(self):
> -            return ''
>       if really:
>           return open(name, opt)
> +    else:
> +        import StringIO
> +        return StringIO.StringIO()
>
>   fdef = maybe_open(do_c, c_file, 'w')
>   fdecl = maybe_open(do_h, h_file, 'w')
> diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
> index e9d0584..5160d83 100644
> --- a/scripts/qapi-visit.py
> +++ b/scripts/qapi-visit.py
> @@ -159,9 +159,9 @@ for o, a in opts:
>       elif o in ("-o", "--output-dir"):
>           output_dir = a + "/"
>       elif o in ("-c", "--source"):
> -        do_h = True
> -    elif o in ("-h", "--header"):
>           do_c = True
> +    elif o in ("-h", "--header"):
> +        do_h = True
>
>   if not do_c and not do_h:
>       do_c = True
> @@ -177,13 +177,11 @@ except os.error, e:
>           raise
>
>   def maybe_open(really, name, opt):
> -    class Null(object):
> -        def write(self, str):
> -            pass
> -        def read(self):
> -            return ''
>       if really:
>           return open(name, opt)
> +    else:
> +        import StringIO
> +        return StringIO.StringIO()
>
>   fdef = maybe_open(do_c, c_file, 'w')
>   fdecl = maybe_open(do_h, h_file, 'w')

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-01-12 16:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-28 10:26 [Qemu-devel] [PATCH] Fix qapi code generation fix Avi Kivity
2012-01-12 14:16 ` Avi Kivity
2012-01-12 16:54 ` Anthony Liguori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).