introduce new watch api

This patch adds a new file handle watch interface to libspice, featuring
three callbacks:

  (1) watch_add() -- create a new file watch.
  (2) watch_update_mask() -- change event mask.  spice frequently
                             enables/disables write notification.
  (3) watch_remove() -- remove a file watch.

libspice users must implement these functions to allow libspice
monitoring file handles.

The old interface (set_file_handlers) doesn't explicitly express the
lifecycle of a watch.  Also it maps 1:1 to a qemu-internal function.
In case the way qemu implements file watches changes (someone sayed
QemuIONotifier?) this will break horribly.  Beside that it is very
bad style.

Follwing patches will switch over users one by one to the new interface
and finally zap the old one.
This commit is contained in:
Gerd Hoffmann 2010-03-25 23:26:56 +01:00
parent 91f747ea1d
commit 4c67874a6d

View File

@ -68,6 +68,12 @@ typedef void (*vd_interface_change_notifier_t)(void *opaque, VDInterface *interf
VDInterfaceChangeType change);
typedef void (*timer_callback_t)(void *opaque);
#define SPICE_WATCH_EVENT_READ (1 << 0)
#define SPICE_WATCH_EVENT_WRITE (1 << 1)
typedef struct SpiceWatch SpiceWatch;
typedef void (*SpiceWatchFunc)(int fd, int event, void *opaque);
struct CoreInterface {
VDInterface base;
@ -80,6 +86,11 @@ struct CoreInterface {
void (*on_read)(void *),
void (*on_write)(void *),
void *opaque);
SpiceWatch *(*watch_add)(int fd, int event_mask, SpiceWatchFunc func, void *opaque);
void (*watch_update_mask)(SpiceWatch *watch, int event_mask);
void (*watch_remove)(SpiceWatch *watch);
};
#define VD_INTERFACE_QXL "qxl"