qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Amos Kong <akong@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>, eblake@redhat.com
Cc: "Anthony Liguori" <aliguori@us.ibm.com>,
	qemu-devel@nongnu.org, "Stefan Hajnoczi" <stefanha@gmail.com>,
	"Michael Roth" <mdroth@linux.vnet.ibm.com>,
	"Luiz Capitulino" <lcapitulino@redhat.com>,
	"Lluís Vilanova" <vilanova@ac.upc.edu>
Subject: Re: [Qemu-devel] [qapi] Cannot use list of strings
Date: Tue, 16 Apr 2013 18:13:22 +0800	[thread overview]
Message-ID: <20130416101322.GA9337@t430s.nay.redhat.com> (raw)
In-Reply-To: <516D11E0.3000700@redhat.com>

On Tue, Apr 16, 2013 at 10:54:56AM +0200, Paolo Bonzini wrote:
> Il 16/04/2013 10:49, Stefan Hajnoczi ha scritto:
> >> > Tried using a list of strings as an argument to a command, but the generated
> >> > code references the 'strList' type, which does not exist.
> >> > 
> >> > Is a specialized version for "['str']" missing, or should I define my own type
> >> > with a single field of 'str' type?
> > akong just hit this too.

That thread: http://marc.info/?l=qemu-devel&m=136572276530702&w=3

> > I think it's a question for aliguori, luiz, or mdroth.
> 
> Laszlo defined and used String for this purpose:

Eric said String list contains additional JSON structure.
At least, it works.

===================== using StringList
    '*unicast':        ['String'],
    '*multicast':      ['String']

{
    "return": [
        {
            "name": "virtio-net-pci.0", 
            "multicast": [
                {
                    "str": "01:80:c2:00:00:21"
                }, 
                {
                    "str": "00:00:00:00:00:00"
                }
            ]
        }, 
        ....
    ]
}
======================== using strList
    '*unicast':        ['str'],
    '*multicast':      ['str']

Eric, is it expected format?

{
    "return": [
        {
            "name": "virtio-net-pci.0", 
            "multicast": [
                    "str": "01:80:c2:00:00:21",
                    "str": "00:00:00:00:00:00"
            ]
        },
        ....
    ]
}
========================

I changed qapi scripts to define struct, struct list,
visit/free functions for 'str'. But it conflicts with
existed str functions. I hadn't find a solution.

Do we need to defind strList & visit functions in qapi-core files?
not generated by scripts.


diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 9e19920..5167d85 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -282,6 +282,10 @@ fdecl.write(mcgen('''
 exprs = parse_schema(sys.stdin)
 exprs = filter(lambda expr: not expr.has_key('gen'), exprs)

+ret = "\n"
+ret += generate_fwd_struct('str', {'str': 'str'})
+fdecl.write(ret)
+
 for expr in exprs:
     ret = "\n"
     if expr.has_key('type'):
@@ -319,6 +323,15 @@ for expr in exprs:
         continue
     fdecl.write(ret)

+ret = "\n"
+ret += generate_struct('str', "", {'str': 'str'}) + "\n"
+ret += generate_type_cleanup_decl('str' + "List")
+fdef.write(generate_type_cleanup('str' + "List") + "\n")
+ret += generate_type_cleanup_decl('str')
+fdef.write(generate_type_cleanup('str') + "\n")
+
+fdecl.write(ret)
+
 fdecl.write('''
 #endif
 ''')
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index a276540..089dda7 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -354,6 +354,13 @@ for expr in exprs:
         ret += generate_enum_declaration(expr['enum'], expr['data'])
         fdecl.write(ret)

+ret = generate_visit_struct('str', {'str': 'str'})
+ret += generate_visit_list('str', {'str': 'str'})
+fdef.write(ret)
+
+ret = generate_declaration('str', {'str': 'str'})
+fdecl.write(ret)
+
 fdecl.write('''
 #endif
 ''')

 
> ##
> # @String
> #
> # A fat type wrapping 'str', to be embedded in lists.
> #
> # Since 1.2
> ##
> { 'type': 'String',
>   'data': {
>     'str': 'str' } }

-- 
			Amos.

  reply	other threads:[~2013-04-16 10:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-15 20:04 [Qemu-devel] [qapi] Cannot use list of strings Lluís Vilanova
2013-04-15 21:07 ` Lluís Vilanova
2013-04-16  8:49 ` Stefan Hajnoczi
2013-04-16  8:54   ` Paolo Bonzini
2013-04-16 10:13     ` Amos Kong [this message]
2013-04-16 12:36       ` Eric Blake
2013-04-16 10:46     ` Lluís Vilanova
2013-04-16 14:50   ` mdroth
2013-04-17  8:33     ` Amos Kong
2013-04-19  5:26       ` [Qemu-devel] [RFC PATCH] qapi: introduce strList and visit_type_strList() (was Re: [qapi] Cannot use list of strings) Amos Kong
2013-04-24 16:08         ` [Qemu-devel] [PATCH v2] qapi: add struct strList and visit_type_strList() Amos Kong
2013-04-24 16:11           ` Paolo Bonzini
2013-04-24 16:48             ` Amos Kong
2013-04-24 16:46           ` mdroth
2013-04-26 10:12             ` Amos Kong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130416101322.GA9337@t430s.nay.redhat.com \
    --to=akong@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=eblake@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=vilanova@ac.upc.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).