On 03/16/2011 09:49 AM, Paolo Bonzini wrote:
On 03/16/2011 03:34 PM, Luiz Capitulino wrote:
+##
+# @put_event:
+#
+# Disconnect a signal. This command is used to disconnect from a
signal based
+# on the handle returned by a signal accessor.
+#
+# @tag: the handle returned by a signal accessor.
+#
+# Returns: Nothing on success.
+# If @tag is not a valid handle, InvalidParameterValue
+#
+# Since: 0.15.0
The name 'signal' (at least today) doesn't make sense on the wire
protocol,
'put_event' probably doesn't make sense in the C library, nor does
'event'.
Another detail is that, event extension is more important than command
extension, because it's probably going to happen. I think it would be
very
bad to add new events just because we wanted to add a new field.
What if events were always passed a single struct, with the first
field being a bitmask saying which (or how many) fields have been filled?
Complex JSON types are represented as structs in QAPI. For fields that
are marked as optional (which any added field has to be), a boolean flag
is always included. Since we always pad structures when we allocate
them (and zero fill), a structure defaults to having optional fields not
specified.
So for an event, you just need to do:
{ 'signal': 'vnc-connected', 'data': { 'client': 'VncClientInfo' } }
And you can add new fields to the VncClientInfo structure as much as
you'd like without worrying about breaking the C ABI.
It is quite ugly to work that way when calling functions, but it's not
too bad when you are writing the callees. And it's the code generator
that writes the function calls in the case of libqmp...
Yes, the code generator deals with all of this stuff. Writing it by
hand would be horrible (which is why we need a libqmp if we want to
write C unit tests).
Regards,
Anthony Liguori
Paolo