Skip to content

Commit 78e3e1d

Browse files
committed
chardev: add some comments about the class methods
Signed-off-by: Marc-André Lureau <[email protected]> Reviewed-by: Daniel P. Berrangé <[email protected]> Message-Id: <[email protected]>
1 parent 5eed493 commit 78e3e1d

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

include/chardev/char.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,24 +254,57 @@ struct ChardevClass {
254254

255255
bool internal; /* TODO: eventually use TYPE_USER_CREATABLE */
256256
bool supports_yank;
257+
258+
/* parse command line options and populate QAPI @backend */
257259
void (*parse)(QemuOpts *opts, ChardevBackend *backend, Error **errp);
258260

261+
/* called after construction, open/starts the backend */
259262
void (*open)(Chardev *chr, ChardevBackend *backend,
260263
bool *be_opened, Error **errp);
261264

265+
/* write buf to the backend */
262266
int (*chr_write)(Chardev *s, const uint8_t *buf, int len);
267+
268+
/*
269+
* Read from the backend (blocking). A typical front-end will instead rely
270+
* on chr_can_read/chr_read being called when polling/looping.
271+
*/
263272
int (*chr_sync_read)(Chardev *s, const uint8_t *buf, int len);
273+
274+
/* create a watch on the backend */
264275
GSource *(*chr_add_watch)(Chardev *s, GIOCondition cond);
276+
277+
/* update the backend internal sources */
265278
void (*chr_update_read_handler)(Chardev *s);
279+
280+
/* send an ioctl to the backend */
266281
int (*chr_ioctl)(Chardev *s, int cmd, void *arg);
282+
283+
/* get ancillary-received fds during last read */
267284
int (*get_msgfds)(Chardev *s, int* fds, int num);
285+
286+
/* set ancillary fds to be sent with next write */
268287
int (*set_msgfds)(Chardev *s, int *fds, int num);
288+
289+
/* accept the given fd */
269290
int (*chr_add_client)(Chardev *chr, int fd);
291+
292+
/* wait for a connection */
270293
int (*chr_wait_connected)(Chardev *chr, Error **errp);
294+
295+
/* disconnect a connection */
271296
void (*chr_disconnect)(Chardev *chr);
297+
298+
/* called by frontend when it can read */
272299
void (*chr_accept_input)(Chardev *chr);
300+
301+
/* set terminal echo */
273302
void (*chr_set_echo)(Chardev *chr, bool echo);
303+
304+
/* notify the backend of frontend open state */
274305
void (*chr_set_fe_open)(Chardev *chr, int fe_open);
306+
307+
/* handle various events */
275308
void (*chr_be_event)(Chardev *s, QEMUChrEvent event);
276309
};
277310

0 commit comments

Comments
 (0)