diff mbox

[RFC,v4,27/29] qapi: Change Netdev into a flat union

Message ID 55FBD347.4020401@cn.fujitsu.com
State New
Headers show

Commit Message

Yang Hongyang Sept. 18, 2015, 9:03 a.m. UTC
On 09/18/2015 04:11 AM, Eric Blake wrote:
> On 09/17/2015 08:34 AM, Eric Blake wrote:
>
>>>
>>> I apply Markus's v8 patch and this series, make check will fail:
>>> TEST: tests/virtio-net-test... (pid=23648)
>>>    /x86_64/virtio/net/pci/basic:                                        qemu-system-x86_64: -netdev socket,fd=6,id=hs0: Invalid parameter 'fd'
>>
>> Oh dear. I guess I was focused on 'make check-qapi-schema', and forgot
>> to test the rest of the suite.  The bug is most likely in my patches,
>> and will be fixed by the time I post v5, now that you've pointed it out
>> to me.
>
> Fix is simple: add this patch to your build:
>
> https://lists.gnu.org/archive/html/qemu-devel/2015-09/msg01650.html
>
> I've rebased my git repo accordingly for now, and will post v5 later on
> (I'm still working on other improvements, and may reshuffle patches
> before actually getting to v5).
>
> git fetch git://repo.or.cz/qemu/ericb.git qapi
> http://repo.or.cz/qemu/ericb.git/shortlog/refs/heads/qapi

I have to add a workaround in my previous netfilter v9 patchset(v10 and later
changed to QOM, so it won't have the problem) to get flat union work. Seems that
you have already fixed it.


>

Comments

Eric Blake Sept. 18, 2015, 12:29 p.m. UTC | #1
On 09/18/2015 03:03 AM, Yang Hongyang wrote:

>> Fix is simple: add this patch to your build:
>>
>> https://lists.gnu.org/archive/html/qemu-devel/2015-09/msg01650.html
>>
>> I've rebased my git repo accordingly for now, and will post v5 later on
>> (I'm still working on other improvements, and may reshuffle patches
>> before actually getting to v5).
>>
>> git fetch git://repo.or.cz/qemu/ericb.git qapi
>> http://repo.or.cz/qemu/ericb.git/shortlog/refs/heads/qapi
> 
> I have to add a workaround in my previous netfilter v9 patchset(v10 and
> later
> changed to QOM, so it won't have the problem) to get flat union work.
> Seems that
> you have already fixed it.

Rather, Zoltán found it, and I just realized why it was important.  Your
alternative is a bit simpler in implementation, though.

> 
> diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
> index 7ae33b3..1271fab 100644
> --- a/qapi/opts-visitor.c
> +++ b/qapi/opts-visitor.c
> @@ -186,6 +186,20 @@ opts_end_struct(Visitor *v, Error **errp)
>  }
> 
> 
> +static void opts_start_implicit_struct(Visitor *v, void **obj,
> +                                       size_t size, Error **errp)
> +{
> +    if (obj) {
> +        *obj = g_malloc0(size);
> +    }
> +}
> +
> +
> +static void opts_end_implicit_struct(Visitor *v, Error **errp)
> +{
> +}
> +
> +
>  static GQueue *
>  lookup_distinct(const OptsVisitor *ov, const char *name, Error **errp)
>  {
> @@ -507,6 +521,8 @@ opts_visitor_new(const QemuOpts *opts)
> 
>      ov->visitor.start_struct = &opts_start_struct;
>      ov->visitor.end_struct   = &opts_end_struct;
> +    ov->visitor.start_implicit_struct = &opts_start_implicit_struct;
> +    ov->visitor.end_implicit_struct = &opts_end_implicit_struct;
> 
>      ov->visitor.start_list = &opts_start_list;
>      ov->visitor.next_list  = &opts_next_list;
> 
>>
>
diff mbox

Patch

diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
index 7ae33b3..1271fab 100644
--- a/qapi/opts-visitor.c
+++ b/qapi/opts-visitor.c
@@ -186,6 +186,20 @@  opts_end_struct(Visitor *v, Error **errp)
  }


+static void opts_start_implicit_struct(Visitor *v, void **obj,
+                                       size_t size, Error **errp)
+{
+    if (obj) {
+        *obj = g_malloc0(size);
+    }
+}
+
+
+static void opts_end_implicit_struct(Visitor *v, Error **errp)
+{
+}
+
+
  static GQueue *
  lookup_distinct(const OptsVisitor *ov, const char *name, Error **errp)
  {
@@ -507,6 +521,8 @@  opts_visitor_new(const QemuOpts *opts)

      ov->visitor.start_struct = &opts_start_struct;
      ov->visitor.end_struct   = &opts_end_struct;
+    ov->visitor.start_implicit_struct = &opts_start_implicit_struct;
+    ov->visitor.end_implicit_struct = &opts_end_implicit_struct;

      ov->visitor.start_list = &opts_start_list;
      ov->visitor.next_list  = &opts_next_list;