Commit Graph

32 Commits

Author SHA1 Message Date
Frediano Ziglio
d17e7878cb Remove useless typedefs
Just use forward declaration if needed.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2021-08-26 20:59:41 +01:00
Frediano Ziglio
708cd97212 red-parse-qxl: Encapsulate QXL resource management
Reuse code.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-04 13:01:14 +01:00
Frediano Ziglio
b6aa5798b7 red-parse-qxl: Use a base reference class for RedDrawable
Don't code manually reference counting for this structure

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-04 13:01:12 +01:00
Frediano Ziglio
110b97e51e red-parse-qxl: Use a base reference class for RedUpdateCmd
Don't code manually reference counting for this structure

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-04 13:01:10 +01:00
Frediano Ziglio
45f2d94ac3 red-parse-qxl: Use a base reference class for RedMessage
Don't code manually reference counting for this structure

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-04 13:01:09 +01:00
Frediano Ziglio
6eac8cc08f red-parse-qxl: Use a base reference class for RedSurfaceCmd
Don't code manually reference counting for this structure

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-04 13:01:07 +01:00
Frediano Ziglio
1d4fb2fee7 red-parse-qxl: Use a base reference class for RedCursorCmd
Don't code manually reference counting for this structure

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-04 13:01:05 +01:00
Rosen Penev
9462537d24 clang-tidy: fix inconsistent declarations
Found with readability-inconsistent-declaration-parameter-name

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-05-09 11:19:30 +01:00
Frediano Ziglio
e0b395fb68 Declare exported functions as C
Allows to be used by both C and C++ code.
So to leave part of the code in C and part move to C++.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Christophe Fergeau
1c32e68072 qxl: Release QXL resources in red_put_surface_cmd
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-12-06 13:04:03 +00:00
Christophe Fergeau
8669c933ff qxl: Add red_surface_cmd_{new, ref, unref} helpers
Currently, RedWorker is using stack-allocated variables for RedSurfaceCmd.
Surface commands are rare enough that we can dynamically allocate them
instead, and make the API in red-parse-qxl.h consistent with how other
QXL commands are handled.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-12-06 13:03:58 +00:00
Christophe Fergeau
decfe65d73 qxl: Add red_update_cmd_{new, ref, unref} helpers
Currently, RedUpdateCmd are allocated on the stack, and then
initialized/uninitialized with red_{get,put}_update_cmd
This makes the API inconsistent with what is being done for RedDrawable,
RedCursor and RedMessage. QXLUpdateCmd are not occurring very often,
we can dynamically allocate them instead, and get a consistent API.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-12-06 13:03:55 +00:00
Christophe Fergeau
74663be7fc qxl: Release QXL resources in red_put_update_cmd
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-12-06 13:03:52 +00:00
Christophe Fergeau
5840ba2a89 qxl: Add red_message_{new, ref, unref} helpers
Currently, RedMessage are allocated on the stack, and then
initialized/uninitialized with red_{get,put}_message
This makes the API inconsistent with what is being done for RedDrawable
and RedCursor. Since QXLMessage is just a (mostly unused/unsecure) debugging tool,
we can dynamically allocate it instead, and get a consistent API.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-12-06 13:03:49 +00:00
Christophe Fergeau
60c425011c qxl: Release QXL resource in red_put_message
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-12-06 13:03:43 +00:00
Christophe Fergeau
fb3c602d75 qxl: Add red_cursor_cmd_{new, ref, unref} helpers
Currently, the cursor channel is allocating RedCursorCmd instances itself, and then
calling into red-parse-qxl.h to initialize it, and doing something
similar when releasing the data. This commit moves this common code to
red-parse-qxl.[ch]
The ref/unref are not strictly needed, red_cursor_cmd_free() would
currently be enough, but this makes the API consistent with
red_drawable_{new,ref,unref}.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-12-06 13:03:36 +00:00
Christophe Fergeau
179134a4e8 qxl: Make red_{get, put}_drawable static
Rather than needing to call red_drawable_new() and then initialize it
with red_get_drawable(), we can improve slightly red_drawable new so
that red_drawable_{new,ref,unref} is all which is used by code out of
red-parse-qxl.c.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-12-06 13:03:31 +00:00
Christophe Fergeau
7f8228b540 qxl: Move red_drawable_unref/red_drawable_new
RedDrawable really is a RedDrawCmd which is parsed by red-parse-qxl.h
Moreover, red_drawable_ref() is already defined inline in
red-parse-qxl.h, and red_drawable_unref() is declared there too even if
its code is still in red-worker.c
This commit moves them close to the other functions creating/unref'ing
QXL commands parsed by red-parse-qxl.h.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-12-06 13:03:20 +00:00
Christophe Fergeau
b547919190 cursor: Delay release of QXL guest cursor resources
There's an implicit API/ABI contract between QEMU and SPICE that SPICE
will keep the guest QXL resources alive as long as QEMU can hold a
pointer to them. This implicit contract was broken in 1c6e7cf7 "Release
cursor as soon as possible", causing crashes at migration time.
While the proper fix would be in QEMU so that spice-server does not need
to have that kind of knowledge regarding QEMU internal implementation,
this commit reverts to the pre-1c6e7cf7 behaviour to avoid a regression
while QEMU is being fixed.

This version of the fix is based on a suggestion from Frediano Ziglio.

https://bugzilla.redhat.com/show_bug.cgi?id=1540919

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-04-16 11:46:01 +02:00
Frediano Ziglio
48e7f4c999 red-parse-qxl: Remove unused device_data field
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-04-10 13:52:10 +01:00
Christophe Fergeau
7e1ebc87b3 red-parse-qxl: Change int/1/0 to bool/true/false
The red_get_* methods in red-parse-qxl.c return a boolean, even though
their return type is an int, and they return 1/0. This commit changes
this to the more explicit bool/true/false.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-05-02 11:30:43 +02:00
Christophe Fergeau
bc5326b1ce Unify header guards
This changes the header guards in all .h files to follow this format:

/*
 * Licensing block
 */

/* ... */

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-03-30 18:17:20 +01:00
Frediano Ziglio
1b15983415 Make QXLMessage handling safe
The QXLMessage has no size so potentially a guest could give an
address that cause the string to overflow out of the video memory.
The current solution is to parse the message, release the resources
associated without printing the message from the client.
This also considering that the QXLMessage usage was deprecated
a while ago (I don't know exactly when).
This patches limit the string to 100000 characters (guest can feed
so much logs in other way) and limit to video memory.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-11-09 16:43:40 +00:00
Jonathon Jongsma
96e94c6f32 Convert RedChannel hierarchy to GObject
Acked-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-10-25 11:32:13 -05:00
Frediano Ziglio
790d8f3e53 factor out red_validate_surface function to validate surface parameters
Make possible to reuse it outside red-parse-qxl.c.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-06-08 09:59:31 +01:00
Frediano Ziglio
8782bb3211 Make some function static
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-24 13:39:48 +01:00
Frediano Ziglio
4585fa9cbd unify header include order
Use this style for include headers inside headers:

  #include <system_headers.h>
  #include <no_spice_no_system_libraries.h>
  #include <spice_protocol.h>
  #include <spice_common.h>

  #include "spice_server.h"

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-12 11:02:54 +01:00
Frediano Ziglio
51bd316ce5 make RedDataChunk structure private inside red-parse-qxl.c
The structure is strictly used by the parser only, no reason to make it
public.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-02-16 13:13:00 +00:00
Christophe Fergeau
8091df87b3 red-parse-qxl: Use QXLReleaseInfoExt instead of QXLReleaseInfo
This should allow to avoid moving the group_id separately from the QXL
commands all over the code.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-15 12:29:15 +00:00
Christophe Fergeau
650ef63782 Add group_id to RedDrawable
Storing a QXLReleaseInfoExt rather than a QXLReleaseInfo in RedDrawable
gives us a place to store group_id for free. Since we are building a
QXLReleaseInfoExt from QXLReleaseInfo and group_id when destroying a
RedDrawable instance, this is a move in the right direction.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-15 12:29:06 +00:00
Christophe Fergeau
7b3bdbfdda Add QXLInstance member to RedDrawable
This allows to get rid of the DisplayChannel parameter to
red_drawable_unref()

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-15 12:29:04 +00:00
Frediano Ziglio
525cd67be7 server: rename files
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-03 23:54:32 +00:00