[Spice-devel] [PATCH 0/3] spice interface redesign.

Alexander Larsson alexl at redhat.com
Wed Mar 31 05:25:06 PDT 2010


On Tue, 2010-03-30 at 12:10 +0200, Gerd Hoffmann wrote:
> Hi,
> 
> This is a early, RfC patch series for a spice interface redesign.
> For now only VDInterface, CoreInterface and KeyboardInterface are
> touched.  I'm sending them now to gather comments on the general
> direction and design.
> 
> The bits are compile-tested only, I didn't adapt my qemu patches yet.

I like the general gist of this, and we should move towards something
like this. However, I have a somewhat different layout that i'm more
partial to. 

Instead of having an untyped opaque we have a typed pointer for instance
types, then that type has a pointer to the per-type information (i.e.
the static data and vfuncs). Then the instance pointer is used instead
of the opaque value and the "qemu side" object can be extracted either
by just a cast if the instance is the first item in an enclosing struct,
or by using container_of(). Also, id seems to only be used for Qxl, so
we can push it there. This way we don't need to keep track of opaque and
id all the time, so we can drop the SpiceInterfaceState, as all you need
is the instance pointer (and possibly the server pointer).

So, it would look something like this:

struct SpiceBaseInterface {
     const char *type;
     const char *description;
     uint32_t major_version;
     uint32_t minor_version;
};

struct SpiceImplementation {
       SpiceBaseInterface *interface;
};

struct SpiceKeyboard {
       SpiceImplementation parent;
};

struct KeyboardInterface {
    SpiceBaseInterface base;

    void (*push_scan_freg)(SpiceKeyboard *keyboard, uint8_t frag);
    uint8_t (*get_leds)(SpiceKeyboard *keyboard);
};

struct SpiceQxlDevice {
       SpiceImplementation parent;
       int id;
};

struct SpiceQxlInterface {
       SpiceImplementation parent;
       ...
};

int spice_server_add(SpiceServer *s, 
                     SpiceImplementation *implementation)
int spice_server_remove(SpiceServer *s, 
                        SpiceImplementation *implementation);


-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
       alexl at redhat.com            alexander.larsson at gmail.com 
He's a globe-trotting guitar-strumming dwarf with a mysterious suitcase 
handcuffed to his arm. She's a man-hating belly-dancing mercenary from a 
different time and place. They fight crime! 



More information about the Spice-devel mailing list