On 12/21/12 12:53, Paolo Bonzini wrote: > Il 21/12/2012 12:45, Gerd Hoffmann ha scritto: >> On 12/20/12 14:02, Gerd Hoffmann wrote: >>> Hi, >>> >>>> /me wades through the socket code (unix+tcp) right now, which needs some >>>> refactoring to make it fly. >>> >>> Sneak preview attached. Goes on top of the series. >>> Compile tested only so far. >> >> Now that it comes to testing: how does the union look (in josn) at the wire? > > Tests are your friends! (Especially qapi-schema-test.json and > test-qmp-input-visitor.c). Something like this: > > { 'type': 'UserDefA', > 'data': { 'boolean': 'bool' } } > > { 'type': 'UserDefB', > 'data': { 'integer': 'int' } } > > { 'union': 'UserDefUnion', > 'data': { 'a' : 'UserDefA', 'b' : 'UserDefB' } } > > looks like this: > > { 'type': 'b', 'data' : { 'integer': 42 } }
So ... { 'type': 'ChardevDummy', 'data': { } } { 'union': 'ChardevBackend', 'data': { 'file' : 'ChardevFile', 'port' : 'ChardevPort', 'socket' : 'ChardevSocket', 'pty' : 'ChardevDummy', 'null' : 'ChardevDummy' } } { 'command': 'chardev-add', 'data': {'id' : 'str', 'backend' : 'ChardevBackend' }, ... should accept ... {'id': 'test-null', 'backend': {'data': {}, 'type': 'null'}} ... as parameters for chardev-add, no? But I get back ... {u'error': {u'class': u'GenericError', u'desc': u"Invalid parameter 'backend'"}} ... and can't see what is wrong there ... cheers, Gerd