Commit Graph

32 Commits

Author SHA1 Message Date
Marc-Andre Lureau
267391c8fd protocol: learn to describe fd passing in messages
Add a new type, "unix_fd", used to describe file descriptor sharing via
socket ancillary data (these messages are local only).

The marshaller/demarshaller can't serialize this in memory (consume_fd
implementation is empty), so it is the responsability of the marshaller
user to handle sending and receiving the handles, which are appended at
the end of the message with an extra stream byte (because some Unix
requires sending at least a byte with ancillary data).

Even if there is no fd to send (or if the fd is invalid etc), the
receiver side expects an extra byte anyway.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-14 11:46:16 +00:00
Uri Lublin
1d026b9a71 codegen: ptypes.py: keep attribute names in sets
This patch changes the type of 'valid_attributes' and
'attributes_with_arguments'.
Both of them are list of different strings and are kept in sets.

This was the intention of the original code, but this patch
use a specific set([ strings ]) format, instead of { strings }.

This fixes the build for me on RHEL-6 (python-2.6.6).
Build error is:

File "/home/ulublin/git/spice/spice-common/python_modules/ptypes.py",
line 67
      'end',
           ^
SyntaxError: invalid syntax
2015-08-04 20:10:22 +03:00
Frediano Ziglio
f6506a2563 codegen: Remove old ptr32 attribute
This attribute is not used in code.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2015-07-23 11:22:11 +02:00
Frediano Ziglio
25c48ddd2c codegen: Do some checks on attributes
Verify that the attribute is known. This could help for instance to
avoid some future typo mistakes.
We also now have a list of attributes that we can comment for
documentation purpose.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2015-07-23 11:20:19 +02:00
Frediano Ziglio
6f729cb32c codegen: Reuse code to fix attribute from prototype file
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2015-07-23 11:11:47 +02:00
Alexander Wauck
e919337980 Make spice_codegen.py work on both Python 2 and 3
This is a new version of my previous patch that does not include six.py.
It's still kind of big, but at least it's all spice-common changes now.
There are also a few other fixes that Christophe brought to my attention.
Note that six now needs to be installed on the system (python-six on
Fedora and Debian, six on PyPI).

This *should* be enough to make spice_codegen.py work on both Python 2
and Python 3.  The major changes are as follows:

 * cStringIO.StringIO -> io.StringIO
 * str vs. unicode updates (io.StringIO doesn't like str)
 * integer division
 * foo.has_key(bar) -> bar in foo
 * import internal_thing -> from . import internal_thing
 * removed from __future__ import with_statement
   (might break Python 2.5?)
 * changed some lambdas to list comprehensions (done by 2to3)
 * cast some_dict.keys() to list where needed (e.g. for sorting)
 * use normal type names with isinstance instead of types.WhateverType

Signed-off-by: Alexander Wauck <awauck@codeweavers.com>
2015-04-01 13:39:03 +02:00
Jonathon Jongsma
f3a47cc903 codegen: Add a --generate-wireshark-dissector option
The wireshark protocol dissector is a bit out-of-date. Several new channel types
and enums have been added.  It would be nice if these values (and the
translation between the value and the name) could be automatically generated so
that updating the dissector was a slightly less manual process.  This patch adds
a commandline switch which generates both the enums and value-name lists in the
format that wireshark expects.
2013-10-23 11:41:43 -05:00
Alon Levy
341f33cbdb python_modules/ptypes.py/EnumBaseType.c_enumname: add missing return to fix broken enums generation
Fixes the resulting enums.h from the invocation of:
./spice_codegen.py --generate-enums spice.proto spice-protocol/spice/enums.h

Right now any enum will contain None as the enum members, with this fix
it will contain the real enum members, i.e. SPICE_FOO.
2012-06-14 13:53:46 +03:00
Christophe Fergeau
0067c31bad allow attributes on channel elements in .proto files
We want to be able to add an @ifdef annotation to optional messages
For example, we want to compile in the smartcard messages only if
libcacard is available
2012-03-20 15:31:30 +01:00
Christophe Fergeau
7f23ab54aa fix copy & paste error in ptypes.py 2012-03-20 15:31:30 +01:00
Hans de Goede
cdb54a8fa5 codegen: Fix enums.h generation
With the new usbredir code we have the new concept of the abstract /
generic spicevmc channel type (which just tunnels data from a qemu chardev),
and we've the usbredir channel, which is the only current user of this.

This was reflected in the protocols enum in spice-protocol.h by a manual
edit done by me, my bad. This patch teaches spice.proto about the relation
between the abstract spicevmc channel and the usbredir channel and
modifies codegen to deal with this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-03-20 15:25:54 +01:00
Marc-André Lureau
bbd93cdb6b python: remove c-ism trailing ; 2012-03-20 15:25:53 +01:00
Marc-André Lureau
d14c99b84f codegen: typedef the protocol enums
Commit 9d5ef9beec in spice-protocol
introduced a typedef manually in the generated enums.h header.

This patch adds them automatically to all enums during enums.h generation.
2012-03-20 15:25:53 +01:00
Alon Levy
005ecaa7d6 spice codegen: fix copy-o, no such variable value 2012-03-20 15:25:50 +01:00
Alexander Larsson
4702feb5b1 Don't send CursorHeader if cursor_flags is NONE 2012-03-20 15:25:49 +01:00
Alexander Larsson
f008b7605d codegen: Allow @to_ptr to make inline structs demarshal as pointers 2012-03-20 15:25:49 +01:00
Alexander Larsson
e6240ee0b0 codegen: Remove unused methos has_pointer() 2012-03-20 15:25:48 +01:00
Alexander Larsson
74f9cd9f73 codegen: No SPICE_ADDRESS types left, drop @c_ptr 2012-03-20 15:25:47 +01:00
Gerd Hoffmann
0ed056da99 Properly parse QXLImage to the new-world SpiceImage
SpiceImage now replaces RedImage and has all image types in it.
All image data are now chunked (and as such not copied when demarshalling).
2012-03-20 15:25:47 +01:00
Alexander Larsson
4a12b9c0dd codegen: support @chunk on non-pointer arrays
This is similar to @as_ptr, but generates a single chunk of data.
2012-03-20 15:25:47 +01:00
Alexander Larsson
5492b3ccae marshaller: Make get_nw_offset() handle deep member references 2012-03-20 15:25:47 +01:00
Alexander Larsson
32481bf381 marshaller: Make @nonnull a propagated attribute
This cleans up some stuff
2012-03-20 15:25:47 +01:00
Alexander Larsson
f22381505d marshaller: Make @c_ptr a propagated attribute
This simplifies some code
2012-03-20 15:25:47 +01:00
Alexander Larsson
fefc89c6c4 marshaller: Add generic way to handle propagating attributes
Also switches @ptr_array to use this
2012-03-20 15:25:47 +01:00
Gerd Hoffmann
6228ae633e Properly parse and marshall SpiceString 2012-03-20 15:25:46 +01:00
Alexander Larsson
6d38c4817f Simplify SpiceLineAttr by removing unsed stuff
Also in new protocol don't send style data if not needed.
2012-03-20 15:25:46 +01:00
Alexander Larsson
02a429e46e Support @marshall to automatically marshall pointers 2012-03-20 15:25:46 +01:00
Alexander Larsson
1d5d5272e2 Make pointers 32bit in new protocol format 2012-03-20 15:25:45 +01:00
Alexander Larsson
db5b8fa673 marshaller: Correctly determine if switches are fixed size
Switches are fixed size only if all cases have the same size *and*
it has a default case or all the valid cases are listed.
2012-03-20 15:25:45 +01:00
Alexander Larsson
32dbd8a6a5 Fix handling of @ptr32 network size 2012-03-20 15:25:45 +01:00
Alexander Larsson
ee944c8314 Add support for @virtual markup in spice protocol
This means the member is not sent on the network at all.
Instead its initialized to the attribute argument when demarshalled.

This is useful for backwards compatibility support.
2012-03-20 15:25:44 +01:00
Alexander Larsson
b1dc7fae2a Initial import of spice protocol description and demarshall generator
The "spice.proto" file describes in detail the networking prototcol
that spice uses and spice_codegen.py can parse this and generate
demarshallers for such network messages.
2012-03-20 15:25:43 +01:00