char: move CharBackend handling in char-fe unit
Move all the frontend struct and methods to a seperate unit. This avoids accidentally mixing backend and frontend calls, and helps with readabilty. Make qemu_chr_replay() a macro shared by both char and char-fe. Export qemu_chr_write(), and use a macro for qemu_chr_write_all() (nb: yes, CharBackend is for char frontend :) Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
This commit is contained in:
parent
c90e9392ef
commit
4d43a603c7
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "sysemu/rng.h"
|
#include "sysemu/rng.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "qapi/qmp/qerror.h"
|
#include "qapi/qmp/qerror.h"
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
chardev-obj-y += char.o
|
chardev-obj-y += char.o
|
||||||
chardev-obj-$(CONFIG_WIN32) += char-console.o
|
chardev-obj-$(CONFIG_WIN32) += char-console.o
|
||||||
chardev-obj-$(CONFIG_POSIX) += char-fd.o
|
chardev-obj-$(CONFIG_POSIX) += char-fd.o
|
||||||
|
chardev-obj-y += char-fe.o
|
||||||
chardev-obj-y += char-file.o
|
chardev-obj-y += char-file.o
|
||||||
chardev-obj-y += char-io.o
|
chardev-obj-y += char-io.o
|
||||||
chardev-obj-y += char-mux.o
|
chardev-obj-y += char-mux.o
|
||||||
|
358
chardev/char-fe.c
Normal file
358
chardev/char-fe.c
Normal file
@ -0,0 +1,358 @@
|
|||||||
|
/*
|
||||||
|
* QEMU System Emulator
|
||||||
|
*
|
||||||
|
* Copyright (c) 2003-2008 Fabrice Bellard
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
#include "qemu/osdep.h"
|
||||||
|
#include "qemu/error-report.h"
|
||||||
|
#include "qapi/error.h"
|
||||||
|
#include "qapi-visit.h"
|
||||||
|
#include "sysemu/replay.h"
|
||||||
|
|
||||||
|
#include "chardev/char-fe.h"
|
||||||
|
#include "chardev/char-io.h"
|
||||||
|
#include "chardev/char-mux.h"
|
||||||
|
|
||||||
|
int qemu_chr_fe_write(CharBackend *be, const uint8_t *buf, int len)
|
||||||
|
{
|
||||||
|
Chardev *s = be->chr;
|
||||||
|
|
||||||
|
if (!s) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return qemu_chr_write(s, buf, len, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
int qemu_chr_fe_write_all(CharBackend *be, const uint8_t *buf, int len)
|
||||||
|
{
|
||||||
|
Chardev *s = be->chr;
|
||||||
|
|
||||||
|
if (!s) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return qemu_chr_write(s, buf, len, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
int qemu_chr_fe_read_all(CharBackend *be, uint8_t *buf, int len)
|
||||||
|
{
|
||||||
|
Chardev *s = be->chr;
|
||||||
|
int offset = 0, counter = 10;
|
||||||
|
int res;
|
||||||
|
|
||||||
|
if (!s || !CHARDEV_GET_CLASS(s)->chr_sync_read) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (qemu_chr_replay(s) && replay_mode == REPLAY_MODE_PLAY) {
|
||||||
|
return replay_char_read_all_load(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (offset < len) {
|
||||||
|
retry:
|
||||||
|
res = CHARDEV_GET_CLASS(s)->chr_sync_read(s, buf + offset,
|
||||||
|
len - offset);
|
||||||
|
if (res == -1 && errno == EAGAIN) {
|
||||||
|
g_usleep(100);
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res < 0) {
|
||||||
|
if (qemu_chr_replay(s) && replay_mode == REPLAY_MODE_RECORD) {
|
||||||
|
replay_char_read_all_save_error(res);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
offset += res;
|
||||||
|
|
||||||
|
if (!counter--) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (qemu_chr_replay(s) && replay_mode == REPLAY_MODE_RECORD) {
|
||||||
|
replay_char_read_all_save_buf(buf, offset);
|
||||||
|
}
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
int qemu_chr_fe_ioctl(CharBackend *be, int cmd, void *arg)
|
||||||
|
{
|
||||||
|
Chardev *s = be->chr;
|
||||||
|
int res;
|
||||||
|
|
||||||
|
if (!s || !CHARDEV_GET_CLASS(s)->chr_ioctl || qemu_chr_replay(s)) {
|
||||||
|
res = -ENOTSUP;
|
||||||
|
} else {
|
||||||
|
res = CHARDEV_GET_CLASS(s)->chr_ioctl(s, cmd, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int qemu_chr_fe_get_msgfd(CharBackend *be)
|
||||||
|
{
|
||||||
|
Chardev *s = be->chr;
|
||||||
|
int fd;
|
||||||
|
int res = (qemu_chr_fe_get_msgfds(be, &fd, 1) == 1) ? fd : -1;
|
||||||
|
if (s && qemu_chr_replay(s)) {
|
||||||
|
error_report("Replay: get msgfd is not supported "
|
||||||
|
"for serial devices yet");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int qemu_chr_fe_get_msgfds(CharBackend *be, int *fds, int len)
|
||||||
|
{
|
||||||
|
Chardev *s = be->chr;
|
||||||
|
|
||||||
|
if (!s) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CHARDEV_GET_CLASS(s)->get_msgfds ?
|
||||||
|
CHARDEV_GET_CLASS(s)->get_msgfds(s, fds, len) : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int qemu_chr_fe_set_msgfds(CharBackend *be, int *fds, int num)
|
||||||
|
{
|
||||||
|
Chardev *s = be->chr;
|
||||||
|
|
||||||
|
if (!s) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CHARDEV_GET_CLASS(s)->set_msgfds ?
|
||||||
|
CHARDEV_GET_CLASS(s)->set_msgfds(s, fds, num) : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void qemu_chr_fe_accept_input(CharBackend *be)
|
||||||
|
{
|
||||||
|
Chardev *s = be->chr;
|
||||||
|
|
||||||
|
if (!s) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CHARDEV_GET_CLASS(s)->chr_accept_input) {
|
||||||
|
CHARDEV_GET_CLASS(s)->chr_accept_input(s);
|
||||||
|
}
|
||||||
|
qemu_notify_event();
|
||||||
|
}
|
||||||
|
|
||||||
|
void qemu_chr_fe_printf(CharBackend *be, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
char buf[CHR_READ_BUF_LEN];
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||||
|
/* XXX this blocks entire thread. Rewrite to use
|
||||||
|
* qemu_chr_fe_write and background I/O callbacks */
|
||||||
|
qemu_chr_fe_write_all(be, (uint8_t *)buf, strlen(buf));
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
Chardev *qemu_chr_fe_get_driver(CharBackend *be)
|
||||||
|
{
|
||||||
|
return be->chr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool qemu_chr_fe_init(CharBackend *b, Chardev *s, Error **errp)
|
||||||
|
{
|
||||||
|
int tag = 0;
|
||||||
|
|
||||||
|
if (CHARDEV_IS_MUX(s)) {
|
||||||
|
MuxChardev *d = MUX_CHARDEV(s);
|
||||||
|
|
||||||
|
if (d->mux_cnt >= MAX_MUX) {
|
||||||
|
goto unavailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
d->backends[d->mux_cnt] = b;
|
||||||
|
tag = d->mux_cnt++;
|
||||||
|
} else if (s->be) {
|
||||||
|
goto unavailable;
|
||||||
|
} else {
|
||||||
|
s->be = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
b->fe_open = false;
|
||||||
|
b->tag = tag;
|
||||||
|
b->chr = s;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
unavailable:
|
||||||
|
error_setg(errp, QERR_DEVICE_IN_USE, s->label);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void qemu_chr_fe_deinit(CharBackend *b)
|
||||||
|
{
|
||||||
|
assert(b);
|
||||||
|
|
||||||
|
if (b->chr) {
|
||||||
|
qemu_chr_fe_set_handlers(b, NULL, NULL, NULL, NULL, NULL, true);
|
||||||
|
if (b->chr->be == b) {
|
||||||
|
b->chr->be = NULL;
|
||||||
|
}
|
||||||
|
if (CHARDEV_IS_MUX(b->chr)) {
|
||||||
|
MuxChardev *d = MUX_CHARDEV(b->chr);
|
||||||
|
d->backends[b->tag] = NULL;
|
||||||
|
}
|
||||||
|
b->chr = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void qemu_chr_fe_set_handlers(CharBackend *b,
|
||||||
|
IOCanReadHandler *fd_can_read,
|
||||||
|
IOReadHandler *fd_read,
|
||||||
|
IOEventHandler *fd_event,
|
||||||
|
void *opaque,
|
||||||
|
GMainContext *context,
|
||||||
|
bool set_open)
|
||||||
|
{
|
||||||
|
Chardev *s;
|
||||||
|
ChardevClass *cc;
|
||||||
|
int fe_open;
|
||||||
|
|
||||||
|
s = b->chr;
|
||||||
|
if (!s) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cc = CHARDEV_GET_CLASS(s);
|
||||||
|
if (!opaque && !fd_can_read && !fd_read && !fd_event) {
|
||||||
|
fe_open = 0;
|
||||||
|
remove_fd_in_watch(s);
|
||||||
|
} else {
|
||||||
|
fe_open = 1;
|
||||||
|
}
|
||||||
|
b->chr_can_read = fd_can_read;
|
||||||
|
b->chr_read = fd_read;
|
||||||
|
b->chr_event = fd_event;
|
||||||
|
b->opaque = opaque;
|
||||||
|
if (cc->chr_update_read_handler) {
|
||||||
|
cc->chr_update_read_handler(s, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (set_open) {
|
||||||
|
qemu_chr_fe_set_open(b, fe_open);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fe_open) {
|
||||||
|
qemu_chr_fe_take_focus(b);
|
||||||
|
/* We're connecting to an already opened device, so let's make sure we
|
||||||
|
also get the open event */
|
||||||
|
if (s->be_open) {
|
||||||
|
qemu_chr_be_event(s, CHR_EVENT_OPENED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CHARDEV_IS_MUX(s)) {
|
||||||
|
mux_chr_set_handlers(s, context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void qemu_chr_fe_take_focus(CharBackend *b)
|
||||||
|
{
|
||||||
|
if (!b->chr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CHARDEV_IS_MUX(b->chr)) {
|
||||||
|
mux_set_focus(b->chr, b->tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int qemu_chr_fe_wait_connected(CharBackend *be, Error **errp)
|
||||||
|
{
|
||||||
|
if (!be->chr) {
|
||||||
|
error_setg(errp, "missing associated backend");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return qemu_chr_wait_connected(be->chr, errp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void qemu_chr_fe_set_echo(CharBackend *be, bool echo)
|
||||||
|
{
|
||||||
|
Chardev *chr = be->chr;
|
||||||
|
|
||||||
|
if (chr && CHARDEV_GET_CLASS(chr)->chr_set_echo) {
|
||||||
|
CHARDEV_GET_CLASS(chr)->chr_set_echo(chr, echo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void qemu_chr_fe_set_open(CharBackend *be, int fe_open)
|
||||||
|
{
|
||||||
|
Chardev *chr = be->chr;
|
||||||
|
|
||||||
|
if (!chr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (be->fe_open == fe_open) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
be->fe_open = fe_open;
|
||||||
|
if (CHARDEV_GET_CLASS(chr)->chr_set_fe_open) {
|
||||||
|
CHARDEV_GET_CLASS(chr)->chr_set_fe_open(chr, fe_open);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
guint qemu_chr_fe_add_watch(CharBackend *be, GIOCondition cond,
|
||||||
|
GIOFunc func, void *user_data)
|
||||||
|
{
|
||||||
|
Chardev *s = be->chr;
|
||||||
|
GSource *src;
|
||||||
|
guint tag;
|
||||||
|
|
||||||
|
if (!s || CHARDEV_GET_CLASS(s)->chr_add_watch == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
src = CHARDEV_GET_CLASS(s)->chr_add_watch(s, cond);
|
||||||
|
if (!src) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_source_set_callback(src, (GSourceFunc)func, user_data, NULL);
|
||||||
|
tag = g_source_attach(src, NULL);
|
||||||
|
g_source_unref(src);
|
||||||
|
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
void qemu_chr_fe_disconnect(CharBackend *be)
|
||||||
|
{
|
||||||
|
Chardev *chr = be->chr;
|
||||||
|
|
||||||
|
if (chr && CHARDEV_GET_CLASS(chr)->chr_disconnect) {
|
||||||
|
CHARDEV_GET_CLASS(chr)->chr_disconnect(chr);
|
||||||
|
}
|
||||||
|
}
|
343
chardev/char.c
343
chardev/char.c
@ -22,7 +22,6 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "qemu-common.h"
|
|
||||||
#include "qemu/cutils.h"
|
#include "qemu/cutils.h"
|
||||||
#include "monitor/monitor.h"
|
#include "monitor/monitor.h"
|
||||||
#include "sysemu/sysemu.h"
|
#include "sysemu/sysemu.h"
|
||||||
@ -35,9 +34,6 @@
|
|||||||
#include "qemu/help_option.h"
|
#include "qemu/help_option.h"
|
||||||
|
|
||||||
#include "chardev/char-mux.h"
|
#include "chardev/char-mux.h"
|
||||||
#include "chardev/char-io.h"
|
|
||||||
#include "chardev/char-parallel.h"
|
|
||||||
#include "chardev/char-serial.h"
|
|
||||||
|
|
||||||
/***********************************************************/
|
/***********************************************************/
|
||||||
/* character device */
|
/* character device */
|
||||||
@ -129,13 +125,7 @@ static int qemu_chr_fe_write_buffer(Chardev *s,
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool qemu_chr_replay(Chardev *chr)
|
int qemu_chr_write(Chardev *s, const uint8_t *buf, int len, bool write_all)
|
||||||
{
|
|
||||||
return qemu_chr_has_feature(chr, QEMU_CHAR_FEATURE_REPLAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int qemu_chr_write(Chardev *s, const uint8_t *buf, int len,
|
|
||||||
bool write_all)
|
|
||||||
{
|
{
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int res;
|
int res;
|
||||||
@ -159,94 +149,6 @@ static int qemu_chr_write(Chardev *s, const uint8_t *buf, int len,
|
|||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
int qemu_chr_write_all(Chardev *s, const uint8_t *buf, int len)
|
|
||||||
{
|
|
||||||
return qemu_chr_write(s, buf, len, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
int qemu_chr_fe_write(CharBackend *be, const uint8_t *buf, int len)
|
|
||||||
{
|
|
||||||
Chardev *s = be->chr;
|
|
||||||
|
|
||||||
if (!s) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return qemu_chr_write(s, buf, len, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
int qemu_chr_fe_write_all(CharBackend *be, const uint8_t *buf, int len)
|
|
||||||
{
|
|
||||||
Chardev *s = be->chr;
|
|
||||||
|
|
||||||
if (!s) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return qemu_chr_write(s, buf, len, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
int qemu_chr_fe_read_all(CharBackend *be, uint8_t *buf, int len)
|
|
||||||
{
|
|
||||||
Chardev *s = be->chr;
|
|
||||||
int offset = 0, counter = 10;
|
|
||||||
int res;
|
|
||||||
|
|
||||||
if (!s || !CHARDEV_GET_CLASS(s)->chr_sync_read) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (qemu_chr_replay(s) && replay_mode == REPLAY_MODE_PLAY) {
|
|
||||||
return replay_char_read_all_load(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (offset < len) {
|
|
||||||
retry:
|
|
||||||
res = CHARDEV_GET_CLASS(s)->chr_sync_read(s, buf + offset,
|
|
||||||
len - offset);
|
|
||||||
if (res == -1 && errno == EAGAIN) {
|
|
||||||
g_usleep(100);
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (res == 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (res < 0) {
|
|
||||||
if (qemu_chr_replay(s) && replay_mode == REPLAY_MODE_RECORD) {
|
|
||||||
replay_char_read_all_save_error(res);
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
offset += res;
|
|
||||||
|
|
||||||
if (!counter--) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (qemu_chr_replay(s) && replay_mode == REPLAY_MODE_RECORD) {
|
|
||||||
replay_char_read_all_save_buf(buf, offset);
|
|
||||||
}
|
|
||||||
return offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
int qemu_chr_fe_ioctl(CharBackend *be, int cmd, void *arg)
|
|
||||||
{
|
|
||||||
Chardev *s = be->chr;
|
|
||||||
int res;
|
|
||||||
|
|
||||||
if (!s || !CHARDEV_GET_CLASS(s)->chr_ioctl || qemu_chr_replay(s)) {
|
|
||||||
res = -ENOTSUP;
|
|
||||||
} else {
|
|
||||||
res = CHARDEV_GET_CLASS(s)->chr_ioctl(s, cmd, arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
int qemu_chr_be_can_write(Chardev *s)
|
int qemu_chr_be_can_write(Chardev *s)
|
||||||
{
|
{
|
||||||
CharBackend *be = s->be;
|
CharBackend *be = s->be;
|
||||||
@ -279,75 +181,12 @@ void qemu_chr_be_write(Chardev *s, uint8_t *buf, int len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int qemu_chr_fe_get_msgfd(CharBackend *be)
|
|
||||||
{
|
|
||||||
Chardev *s = be->chr;
|
|
||||||
int fd;
|
|
||||||
int res = (qemu_chr_fe_get_msgfds(be, &fd, 1) == 1) ? fd : -1;
|
|
||||||
if (s && qemu_chr_replay(s)) {
|
|
||||||
error_report("Replay: get msgfd is not supported "
|
|
||||||
"for serial devices yet");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
int qemu_chr_fe_get_msgfds(CharBackend *be, int *fds, int len)
|
|
||||||
{
|
|
||||||
Chardev *s = be->chr;
|
|
||||||
|
|
||||||
if (!s) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return CHARDEV_GET_CLASS(s)->get_msgfds ?
|
|
||||||
CHARDEV_GET_CLASS(s)->get_msgfds(s, fds, len) : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int qemu_chr_fe_set_msgfds(CharBackend *be, int *fds, int num)
|
|
||||||
{
|
|
||||||
Chardev *s = be->chr;
|
|
||||||
|
|
||||||
if (!s) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return CHARDEV_GET_CLASS(s)->set_msgfds ?
|
|
||||||
CHARDEV_GET_CLASS(s)->set_msgfds(s, fds, num) : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int qemu_chr_add_client(Chardev *s, int fd)
|
int qemu_chr_add_client(Chardev *s, int fd)
|
||||||
{
|
{
|
||||||
return CHARDEV_GET_CLASS(s)->chr_add_client ?
|
return CHARDEV_GET_CLASS(s)->chr_add_client ?
|
||||||
CHARDEV_GET_CLASS(s)->chr_add_client(s, fd) : -1;
|
CHARDEV_GET_CLASS(s)->chr_add_client(s, fd) : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qemu_chr_fe_accept_input(CharBackend *be)
|
|
||||||
{
|
|
||||||
Chardev *s = be->chr;
|
|
||||||
|
|
||||||
if (!s) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CHARDEV_GET_CLASS(s)->chr_accept_input) {
|
|
||||||
CHARDEV_GET_CLASS(s)->chr_accept_input(s);
|
|
||||||
}
|
|
||||||
qemu_notify_event();
|
|
||||||
}
|
|
||||||
|
|
||||||
void qemu_chr_fe_printf(CharBackend *be, const char *fmt, ...)
|
|
||||||
{
|
|
||||||
char buf[CHR_READ_BUF_LEN];
|
|
||||||
va_list ap;
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsnprintf(buf, sizeof(buf), fmt, ap);
|
|
||||||
/* XXX this blocks entire thread. Rewrite to use
|
|
||||||
* qemu_chr_fe_write and background I/O callbacks */
|
|
||||||
qemu_chr_fe_write_all(be, (uint8_t *)buf, strlen(buf));
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void qemu_char_open(Chardev *chr, ChardevBackend *backend,
|
static void qemu_char_open(Chardev *chr, ChardevBackend *backend,
|
||||||
bool *be_opened, Error **errp)
|
bool *be_opened, Error **errp)
|
||||||
{
|
{
|
||||||
@ -459,40 +298,6 @@ static Notifier muxes_realize_notify = {
|
|||||||
.notify = muxes_realize_done,
|
.notify = muxes_realize_done,
|
||||||
};
|
};
|
||||||
|
|
||||||
Chardev *qemu_chr_fe_get_driver(CharBackend *be)
|
|
||||||
{
|
|
||||||
return be->chr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool qemu_chr_fe_init(CharBackend *b, Chardev *s, Error **errp)
|
|
||||||
{
|
|
||||||
int tag = 0;
|
|
||||||
|
|
||||||
if (CHARDEV_IS_MUX(s)) {
|
|
||||||
MuxChardev *d = MUX_CHARDEV(s);
|
|
||||||
|
|
||||||
if (d->mux_cnt >= MAX_MUX) {
|
|
||||||
goto unavailable;
|
|
||||||
}
|
|
||||||
|
|
||||||
d->backends[d->mux_cnt] = b;
|
|
||||||
tag = d->mux_cnt++;
|
|
||||||
} else if (s->be) {
|
|
||||||
goto unavailable;
|
|
||||||
} else {
|
|
||||||
s->be = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
b->fe_open = false;
|
|
||||||
b->tag = tag;
|
|
||||||
b->chr = s;
|
|
||||||
return true;
|
|
||||||
|
|
||||||
unavailable:
|
|
||||||
error_setg(errp, QERR_DEVICE_IN_USE, s->label);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool qemu_chr_is_busy(Chardev *s)
|
static bool qemu_chr_is_busy(Chardev *s)
|
||||||
{
|
{
|
||||||
if (CHARDEV_IS_MUX(s)) {
|
if (CHARDEV_IS_MUX(s)) {
|
||||||
@ -503,84 +308,6 @@ static bool qemu_chr_is_busy(Chardev *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void qemu_chr_fe_deinit(CharBackend *b)
|
|
||||||
{
|
|
||||||
assert(b);
|
|
||||||
|
|
||||||
if (b->chr) {
|
|
||||||
qemu_chr_fe_set_handlers(b, NULL, NULL, NULL, NULL, NULL, true);
|
|
||||||
if (b->chr->be == b) {
|
|
||||||
b->chr->be = NULL;
|
|
||||||
}
|
|
||||||
if (CHARDEV_IS_MUX(b->chr)) {
|
|
||||||
MuxChardev *d = MUX_CHARDEV(b->chr);
|
|
||||||
d->backends[b->tag] = NULL;
|
|
||||||
}
|
|
||||||
b->chr = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void qemu_chr_fe_set_handlers(CharBackend *b,
|
|
||||||
IOCanReadHandler *fd_can_read,
|
|
||||||
IOReadHandler *fd_read,
|
|
||||||
IOEventHandler *fd_event,
|
|
||||||
void *opaque,
|
|
||||||
GMainContext *context,
|
|
||||||
bool set_open)
|
|
||||||
{
|
|
||||||
Chardev *s;
|
|
||||||
ChardevClass *cc;
|
|
||||||
int fe_open;
|
|
||||||
|
|
||||||
s = b->chr;
|
|
||||||
if (!s) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
cc = CHARDEV_GET_CLASS(s);
|
|
||||||
if (!opaque && !fd_can_read && !fd_read && !fd_event) {
|
|
||||||
fe_open = 0;
|
|
||||||
remove_fd_in_watch(s);
|
|
||||||
} else {
|
|
||||||
fe_open = 1;
|
|
||||||
}
|
|
||||||
b->chr_can_read = fd_can_read;
|
|
||||||
b->chr_read = fd_read;
|
|
||||||
b->chr_event = fd_event;
|
|
||||||
b->opaque = opaque;
|
|
||||||
if (cc->chr_update_read_handler) {
|
|
||||||
cc->chr_update_read_handler(s, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (set_open) {
|
|
||||||
qemu_chr_fe_set_open(b, fe_open);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fe_open) {
|
|
||||||
qemu_chr_fe_take_focus(b);
|
|
||||||
/* We're connecting to an already opened device, so let's make sure we
|
|
||||||
also get the open event */
|
|
||||||
if (s->be_open) {
|
|
||||||
qemu_chr_be_event(s, CHR_EVENT_OPENED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CHARDEV_IS_MUX(s)) {
|
|
||||||
mux_chr_set_handlers(s, context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void qemu_chr_fe_take_focus(CharBackend *b)
|
|
||||||
{
|
|
||||||
if (!b->chr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CHARDEV_IS_MUX(b->chr)) {
|
|
||||||
mux_set_focus(b->chr, b->tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int qemu_chr_wait_connected(Chardev *chr, Error **errp)
|
int qemu_chr_wait_connected(Chardev *chr, Error **errp)
|
||||||
{
|
{
|
||||||
ChardevClass *cc = CHARDEV_GET_CLASS(chr);
|
ChardevClass *cc = CHARDEV_GET_CLASS(chr);
|
||||||
@ -592,16 +319,6 @@ int qemu_chr_wait_connected(Chardev *chr, Error **errp)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int qemu_chr_fe_wait_connected(CharBackend *be, Error **errp)
|
|
||||||
{
|
|
||||||
if (!be->chr) {
|
|
||||||
error_setg(errp, "missing associated backend");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return qemu_chr_wait_connected(be->chr, errp);
|
|
||||||
}
|
|
||||||
|
|
||||||
QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename)
|
QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename)
|
||||||
{
|
{
|
||||||
char host[65], port[33], width[8], height[8];
|
char host[65], port[33], width[8], height[8];
|
||||||
@ -978,64 +695,6 @@ Chardev *qemu_chr_new(const char *label, const char *filename)
|
|||||||
return chr;
|
return chr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qemu_chr_fe_set_echo(CharBackend *be, bool echo)
|
|
||||||
{
|
|
||||||
Chardev *chr = be->chr;
|
|
||||||
|
|
||||||
if (chr && CHARDEV_GET_CLASS(chr)->chr_set_echo) {
|
|
||||||
CHARDEV_GET_CLASS(chr)->chr_set_echo(chr, echo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void qemu_chr_fe_set_open(CharBackend *be, int fe_open)
|
|
||||||
{
|
|
||||||
Chardev *chr = be->chr;
|
|
||||||
|
|
||||||
if (!chr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (be->fe_open == fe_open) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
be->fe_open = fe_open;
|
|
||||||
if (CHARDEV_GET_CLASS(chr)->chr_set_fe_open) {
|
|
||||||
CHARDEV_GET_CLASS(chr)->chr_set_fe_open(chr, fe_open);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
guint qemu_chr_fe_add_watch(CharBackend *be, GIOCondition cond,
|
|
||||||
GIOFunc func, void *user_data)
|
|
||||||
{
|
|
||||||
Chardev *s = be->chr;
|
|
||||||
GSource *src;
|
|
||||||
guint tag;
|
|
||||||
|
|
||||||
if (!s || CHARDEV_GET_CLASS(s)->chr_add_watch == NULL) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
src = CHARDEV_GET_CLASS(s)->chr_add_watch(s, cond);
|
|
||||||
if (!src) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_source_set_callback(src, (GSourceFunc)func, user_data, NULL);
|
|
||||||
tag = g_source_attach(src, NULL);
|
|
||||||
g_source_unref(src);
|
|
||||||
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
void qemu_chr_fe_disconnect(CharBackend *be)
|
|
||||||
{
|
|
||||||
Chardev *chr = be->chr;
|
|
||||||
|
|
||||||
if (chr && CHARDEV_GET_CLASS(chr)->chr_disconnect) {
|
|
||||||
CHARDEV_GET_CLASS(chr)->chr_disconnect(chr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int qmp_query_chardev_foreach(Object *obj, void *data)
|
static int qmp_query_chardev_foreach(Object *obj, void *data)
|
||||||
{
|
{
|
||||||
Chardev *chr = CHARDEV(obj);
|
Chardev *chr = CHARDEV(obj);
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#else
|
#else
|
||||||
#include "monitor/monitor.h"
|
#include "monitor/monitor.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char.h"
|
||||||
|
#include "chardev/char-fe.h"
|
||||||
#include "sysemu/sysemu.h"
|
#include "sysemu/sysemu.h"
|
||||||
#include "exec/gdbstub.h"
|
#include "exec/gdbstub.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include "hw/arm/omap.h"
|
#include "hw/arm/omap.h"
|
||||||
#include "sysemu/sysemu.h"
|
#include "sysemu/sysemu.h"
|
||||||
#include "qemu/timer.h"
|
#include "qemu/timer.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "hw/block/flash.h"
|
#include "hw/block/flash.h"
|
||||||
#include "hw/arm/soc_dma.h"
|
#include "hw/arm/soc_dma.h"
|
||||||
#include "hw/sysbus.h"
|
#include "hw/sysbus.h"
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#include "hw/char/serial.h"
|
#include "hw/char/serial.h"
|
||||||
#include "hw/i2c/i2c.h"
|
#include "hw/i2c/i2c.h"
|
||||||
#include "hw/ssi/ssi.h"
|
#include "hw/ssi/ssi.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "sysemu/block-backend.h"
|
#include "sysemu/block-backend.h"
|
||||||
#include "sysemu/blockdev.h"
|
#include "sysemu/blockdev.h"
|
||||||
#include "qemu/cutils.h"
|
#include "qemu/cutils.h"
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "strongarm.h"
|
#include "strongarm.h"
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
#include "hw/arm/arm.h"
|
#include "hw/arm/arm.h"
|
||||||
|
#include "chardev/char-fe.h"
|
||||||
#include "chardev/char-serial.h"
|
#include "chardev/char-serial.h"
|
||||||
#include "sysemu/sysemu.h"
|
#include "sysemu/sysemu.h"
|
||||||
#include "hw/ssi/ssi.h"
|
#include "hw/ssi/ssi.h"
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "hw/sysbus.h"
|
#include "hw/sysbus.h"
|
||||||
|
#include "chardev/char-fe.h"
|
||||||
#include "chardev/char-serial.h"
|
#include "chardev/char-serial.h"
|
||||||
#include "qemu/timer.h"
|
#include "qemu/timer.h"
|
||||||
#include "qemu/log.h"
|
#include "qemu/log.h"
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "hw/hw.h"
|
#include "hw/hw.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "hw/isa/isa.h"
|
#include "hw/isa/isa.h"
|
||||||
#include "hw/i386/pc.h"
|
#include "hw/i386/pc.h"
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "hw/hw.h"
|
#include "hw/hw.h"
|
||||||
#include "hw/sysbus.h"
|
#include "hw/sysbus.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "qemu/log.h"
|
#include "qemu/log.h"
|
||||||
|
|
||||||
#include "hw/char/digic-uart.h"
|
#include "hw/char/digic-uart.h"
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "hw/hw.h"
|
#include "hw/hw.h"
|
||||||
#include "hw/sysbus.h"
|
#include "hw/sysbus.h"
|
||||||
#include "hw/char/escc.h"
|
#include "hw/char/escc.h"
|
||||||
|
#include "chardev/char-fe.h"
|
||||||
#include "chardev/char-serial.h"
|
#include "chardev/char-serial.h"
|
||||||
#include "ui/console.h"
|
#include "ui/console.h"
|
||||||
#include "ui/input.h"
|
#include "ui/input.h"
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "hw/sysbus.h"
|
#include "hw/sysbus.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "qemu/log.h"
|
#include "qemu/log.h"
|
||||||
|
|
||||||
#define D(x)
|
#define D(x)
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "hw/sysbus.h"
|
#include "hw/sysbus.h"
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
#include "sysemu/sysemu.h"
|
#include "sysemu/sysemu.h"
|
||||||
|
#include "chardev/char-fe.h"
|
||||||
#include "chardev/char-serial.h"
|
#include "chardev/char-serial.h"
|
||||||
|
|
||||||
#include "hw/arm/exynos4210.h"
|
#include "hw/arm/exynos4210.h"
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "hw/sysbus.h"
|
#include "hw/sysbus.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
|
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "hw/ipack/ipack.h"
|
#include "hw/ipack/ipack.h"
|
||||||
#include "qemu/bitops.h"
|
#include "qemu/bitops.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
|
|
||||||
/* #define DEBUG_IPOCTAL */
|
/* #define DEBUG_IPOCTAL */
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "hw/hw.h"
|
#include "hw/hw.h"
|
||||||
#include "hw/sysbus.h"
|
#include "hw/sysbus.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
|
|
||||||
#include "hw/char/lm32_juart.h"
|
#include "hw/char/lm32_juart.h"
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include "hw/hw.h"
|
#include "hw/hw.h"
|
||||||
#include "hw/sysbus.h"
|
#include "hw/sysbus.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include "hw/hw.h"
|
#include "hw/hw.h"
|
||||||
#include "hw/sysbus.h"
|
#include "hw/sysbus.h"
|
||||||
#include "hw/m68k/mcf.h"
|
#include "hw/m68k/mcf.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "exec/address-spaces.h"
|
#include "exec/address-spaces.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include "hw/hw.h"
|
#include "hw/hw.h"
|
||||||
#include "hw/sysbus.h"
|
#include "hw/sysbus.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "hw/hw.h"
|
#include "hw/hw.h"
|
||||||
#include "chardev/char-parallel.h"
|
#include "chardev/char-parallel.h"
|
||||||
|
#include "chardev/char-fe.h"
|
||||||
#include "hw/isa/isa.h"
|
#include "hw/isa/isa.h"
|
||||||
#include "hw/i386/pc.h"
|
#include "hw/i386/pc.h"
|
||||||
#include "sysemu/sysemu.h"
|
#include "sysemu/sysemu.h"
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "hw/sysbus.h"
|
#include "hw/sysbus.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "qemu/log.h"
|
#include "qemu/log.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#include "hw/qdev.h"
|
#include "hw/qdev.h"
|
||||||
#include "qemu/thread.h"
|
#include "qemu/thread.h"
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
|
|
||||||
#include "hw/s390x/sclp.h"
|
#include "hw/s390x/sclp.h"
|
||||||
#include "hw/s390x/event-facility.h"
|
#include "hw/s390x/event-facility.h"
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "hw/s390x/sclp.h"
|
#include "hw/s390x/sclp.h"
|
||||||
#include "hw/s390x/event-facility.h"
|
#include "hw/s390x/event-facility.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
|
|
||||||
typedef struct ASCIIConsoleData {
|
typedef struct ASCIIConsoleData {
|
||||||
EventBufferHeader ebh;
|
EventBufferHeader ebh;
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "hw/hw.h"
|
#include "hw/hw.h"
|
||||||
#include "hw/sh4/sh.h"
|
#include "hw/sh4/sh.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "exec/address-spaces.h"
|
#include "exec/address-spaces.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "qemu-common.h"
|
#include "qemu-common.h"
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "hw/qdev.h"
|
#include "hw/qdev.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "hw/ppc/spapr.h"
|
#include "hw/ppc/spapr.h"
|
||||||
#include "hw/ppc/spapr_vio.h"
|
#include "hw/ppc/spapr_vio.h"
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "hw/s390x/3270-ccw.h"
|
#include "hw/s390x/3270-ccw.h"
|
||||||
|
|
||||||
/* Enough spaces for different window sizes. */
|
/* Enough spaces for different window sizes. */
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
#include "hw/virtio/virtio-serial.h"
|
#include "hw/virtio/virtio-serial.h"
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "hw/hw.h"
|
#include "hw/hw.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "hw/xen/xen_backend.h"
|
#include "hw/xen/xen_backend.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "hw/sysbus.h"
|
#include "hw/sysbus.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
|
|
||||||
#define DUART(x)
|
#define DUART(x)
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "hw/block/block.h"
|
#include "hw/block/block.h"
|
||||||
#include "net/hub.h"
|
#include "net/hub.h"
|
||||||
#include "qapi/visitor.h"
|
#include "qapi/visitor.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "sysemu/iothread.h"
|
#include "sysemu/iothread.h"
|
||||||
|
|
||||||
static void get_pointer(Object *obj, Visitor *v, Property *prop,
|
static void get_pointer(Object *obj, Visitor *v, Property *prop,
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "qemu/timer.h"
|
#include "qemu/timer.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "sysemu/sysemu.h"
|
#include "sysemu/sysemu.h"
|
||||||
#include "hw/ipmi/ipmi.h"
|
#include "hw/ipmi/ipmi.h"
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
#include "qemu/event_notifier.h"
|
#include "qemu/event_notifier.h"
|
||||||
#include "qom/object_interfaces.h"
|
#include "qom/object_interfaces.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "sysemu/hostmem.h"
|
#include "sysemu/hostmem.h"
|
||||||
#include "sysemu/qtest.h"
|
#include "sysemu/qtest.h"
|
||||||
#include "qapi/visitor.h"
|
#include "qapi/visitor.h"
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
#include "qemu/sockets.h"
|
#include "qemu/sockets.h"
|
||||||
#include "ccid.h"
|
#include "ccid.h"
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "hw/usb.h"
|
#include "hw/usb.h"
|
||||||
#include "hw/usb/desc.h"
|
#include "hw/usb/desc.h"
|
||||||
#include "chardev/char-serial.h"
|
#include "chardev/char-serial.h"
|
||||||
|
#include "chardev/char-fe.h"
|
||||||
|
|
||||||
//#define DEBUG_Serial
|
//#define DEBUG_Serial
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#include "qapi/qmp/qerror.h"
|
#include "qapi/qmp/qerror.h"
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
#include "qemu/iov.h"
|
#include "qemu/iov.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
|
|
||||||
#include <usbredirparser.h>
|
#include <usbredirparser.h>
|
||||||
#include <usbredirfilter.h>
|
#include <usbredirfilter.h>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include "hw/virtio/vhost.h"
|
#include "hw/virtio/vhost.h"
|
||||||
#include "hw/virtio/vhost-backend.h"
|
#include "hw/virtio/vhost-backend.h"
|
||||||
#include "hw/virtio/virtio-net.h"
|
#include "hw/virtio/virtio-net.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "sysemu/kvm.h"
|
#include "sysemu/kvm.h"
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
#include "qemu/sockets.h"
|
#include "qemu/sockets.h"
|
||||||
|
249
include/chardev/char-fe.h
Normal file
249
include/chardev/char-fe.h
Normal file
@ -0,0 +1,249 @@
|
|||||||
|
#ifndef QEMU_CHAR_FE_H
|
||||||
|
#define QEMU_CHAR_FE_H
|
||||||
|
|
||||||
|
#include "chardev/char.h"
|
||||||
|
|
||||||
|
typedef void IOEventHandler(void *opaque, int event);
|
||||||
|
|
||||||
|
/* This is the backend as seen by frontend, the actual backend is
|
||||||
|
* Chardev */
|
||||||
|
struct CharBackend {
|
||||||
|
Chardev *chr;
|
||||||
|
IOEventHandler *chr_event;
|
||||||
|
IOCanReadHandler *chr_can_read;
|
||||||
|
IOReadHandler *chr_read;
|
||||||
|
void *opaque;
|
||||||
|
int tag;
|
||||||
|
int fe_open;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @qemu_chr_fe_init:
|
||||||
|
*
|
||||||
|
* Initializes a front end for the given CharBackend and
|
||||||
|
* Chardev. Call qemu_chr_fe_deinit() to remove the association and
|
||||||
|
* release the driver.
|
||||||
|
*
|
||||||
|
* Returns: false on error.
|
||||||
|
*/
|
||||||
|
bool qemu_chr_fe_init(CharBackend *b, Chardev *s, Error **errp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @qemu_chr_fe_deinit:
|
||||||
|
*
|
||||||
|
* Dissociate the CharBackend from the Chardev.
|
||||||
|
*
|
||||||
|
* Safe to call without associated Chardev.
|
||||||
|
*/
|
||||||
|
void qemu_chr_fe_deinit(CharBackend *b);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @qemu_chr_fe_get_driver:
|
||||||
|
*
|
||||||
|
* Returns the driver associated with a CharBackend or NULL if no
|
||||||
|
* associated Chardev.
|
||||||
|
*/
|
||||||
|
Chardev *qemu_chr_fe_get_driver(CharBackend *be);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @qemu_chr_fe_set_handlers:
|
||||||
|
* @b: a CharBackend
|
||||||
|
* @fd_can_read: callback to get the amount of data the frontend may
|
||||||
|
* receive
|
||||||
|
* @fd_read: callback to receive data from char
|
||||||
|
* @fd_event: event callback
|
||||||
|
* @opaque: an opaque pointer for the callbacks
|
||||||
|
* @context: a main loop context or NULL for the default
|
||||||
|
* @set_open: whether to call qemu_chr_fe_set_open() implicitely when
|
||||||
|
* any of the handler is non-NULL
|
||||||
|
*
|
||||||
|
* Set the front end char handlers. The front end takes the focus if
|
||||||
|
* any of the handler is non-NULL.
|
||||||
|
*
|
||||||
|
* Without associated Chardev, nothing is changed.
|
||||||
|
*/
|
||||||
|
void qemu_chr_fe_set_handlers(CharBackend *b,
|
||||||
|
IOCanReadHandler *fd_can_read,
|
||||||
|
IOReadHandler *fd_read,
|
||||||
|
IOEventHandler *fd_event,
|
||||||
|
void *opaque,
|
||||||
|
GMainContext *context,
|
||||||
|
bool set_open);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @qemu_chr_fe_take_focus:
|
||||||
|
*
|
||||||
|
* Take the focus (if the front end is muxed).
|
||||||
|
*
|
||||||
|
* Without associated Chardev, nothing is changed.
|
||||||
|
*/
|
||||||
|
void qemu_chr_fe_take_focus(CharBackend *b);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @qemu_chr_fe_accept_input:
|
||||||
|
*
|
||||||
|
* Notify that the frontend is ready to receive data
|
||||||
|
*/
|
||||||
|
void qemu_chr_fe_accept_input(CharBackend *be);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @qemu_chr_fe_disconnect:
|
||||||
|
*
|
||||||
|
* Close a fd accpeted by character backend.
|
||||||
|
* Without associated Chardev, do nothing.
|
||||||
|
*/
|
||||||
|
void qemu_chr_fe_disconnect(CharBackend *be);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @qemu_chr_fe_wait_connected:
|
||||||
|
*
|
||||||
|
* Wait for characted backend to be connected, return < 0 on error or
|
||||||
|
* if no assicated Chardev.
|
||||||
|
*/
|
||||||
|
int qemu_chr_fe_wait_connected(CharBackend *be, Error **errp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @qemu_chr_fe_set_echo:
|
||||||
|
*
|
||||||
|
* Ask the backend to override its normal echo setting. This only really
|
||||||
|
* applies to the stdio backend and is used by the QMP server such that you
|
||||||
|
* can see what you type if you try to type QMP commands.
|
||||||
|
* Without associated Chardev, do nothing.
|
||||||
|
*
|
||||||
|
* @echo true to enable echo, false to disable echo
|
||||||
|
*/
|
||||||
|
void qemu_chr_fe_set_echo(CharBackend *be, bool echo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @qemu_chr_fe_set_open:
|
||||||
|
*
|
||||||
|
* Set character frontend open status. This is an indication that the
|
||||||
|
* front end is ready (or not) to begin doing I/O.
|
||||||
|
* Without associated Chardev, do nothing.
|
||||||
|
*/
|
||||||
|
void qemu_chr_fe_set_open(CharBackend *be, int fe_open);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @qemu_chr_fe_printf:
|
||||||
|
*
|
||||||
|
* Write to a character backend using a printf style interface. This
|
||||||
|
* function is thread-safe. It does nothing without associated
|
||||||
|
* Chardev.
|
||||||
|
*
|
||||||
|
* @fmt see #printf
|
||||||
|
*/
|
||||||
|
void qemu_chr_fe_printf(CharBackend *be, const char *fmt, ...)
|
||||||
|
GCC_FMT_ATTR(2, 3);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @qemu_chr_fe_add_watch:
|
||||||
|
*
|
||||||
|
* If the backend is connected, create and add a #GSource that fires
|
||||||
|
* when the given condition (typically G_IO_OUT|G_IO_HUP or G_IO_HUP)
|
||||||
|
* is active; return the #GSource's tag. If it is disconnected,
|
||||||
|
* or without associated Chardev, return 0.
|
||||||
|
*
|
||||||
|
* @cond the condition to poll for
|
||||||
|
* @func the function to call when the condition happens
|
||||||
|
* @user_data the opaque pointer to pass to @func
|
||||||
|
*
|
||||||
|
* Returns: the source tag
|
||||||
|
*/
|
||||||
|
guint qemu_chr_fe_add_watch(CharBackend *be, GIOCondition cond,
|
||||||
|
GIOFunc func, void *user_data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @qemu_chr_fe_write:
|
||||||
|
*
|
||||||
|
* Write data to a character backend from the front end. This function
|
||||||
|
* will send data from the front end to the back end. This function
|
||||||
|
* is thread-safe.
|
||||||
|
*
|
||||||
|
* @buf the data
|
||||||
|
* @len the number of bytes to send
|
||||||
|
*
|
||||||
|
* Returns: the number of bytes consumed (0 if no assicated Chardev)
|
||||||
|
*/
|
||||||
|
int qemu_chr_fe_write(CharBackend *be, const uint8_t *buf, int len);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @qemu_chr_fe_write_all:
|
||||||
|
*
|
||||||
|
* Write data to a character backend from the front end. This function will
|
||||||
|
* send data from the front end to the back end. Unlike @qemu_chr_fe_write,
|
||||||
|
* this function will block if the back end cannot consume all of the data
|
||||||
|
* attempted to be written. This function is thread-safe.
|
||||||
|
*
|
||||||
|
* @buf the data
|
||||||
|
* @len the number of bytes to send
|
||||||
|
*
|
||||||
|
* Returns: the number of bytes consumed (0 if no assicated Chardev)
|
||||||
|
*/
|
||||||
|
int qemu_chr_fe_write_all(CharBackend *be, const uint8_t *buf, int len);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @qemu_chr_fe_read_all:
|
||||||
|
*
|
||||||
|
* Read data to a buffer from the back end.
|
||||||
|
*
|
||||||
|
* @buf the data buffer
|
||||||
|
* @len the number of bytes to read
|
||||||
|
*
|
||||||
|
* Returns: the number of bytes read (0 if no assicated Chardev)
|
||||||
|
*/
|
||||||
|
int qemu_chr_fe_read_all(CharBackend *be, uint8_t *buf, int len);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @qemu_chr_fe_ioctl:
|
||||||
|
*
|
||||||
|
* Issue a device specific ioctl to a backend. This function is thread-safe.
|
||||||
|
*
|
||||||
|
* @cmd see CHR_IOCTL_*
|
||||||
|
* @arg the data associated with @cmd
|
||||||
|
*
|
||||||
|
* Returns: if @cmd is not supported by the backend or there is no
|
||||||
|
* associated Chardev, -ENOTSUP, otherwise the return
|
||||||
|
* value depends on the semantics of @cmd
|
||||||
|
*/
|
||||||
|
int qemu_chr_fe_ioctl(CharBackend *be, int cmd, void *arg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @qemu_chr_fe_get_msgfd:
|
||||||
|
*
|
||||||
|
* For backends capable of fd passing, return the latest file descriptor passed
|
||||||
|
* by a client.
|
||||||
|
*
|
||||||
|
* Returns: -1 if fd passing isn't supported or there is no pending file
|
||||||
|
* descriptor. If a file descriptor is returned, subsequent calls to
|
||||||
|
* this function will return -1 until a client sends a new file
|
||||||
|
* descriptor.
|
||||||
|
*/
|
||||||
|
int qemu_chr_fe_get_msgfd(CharBackend *be);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @qemu_chr_fe_get_msgfds:
|
||||||
|
*
|
||||||
|
* For backends capable of fd passing, return the number of file received
|
||||||
|
* descriptors and fills the fds array up to num elements
|
||||||
|
*
|
||||||
|
* Returns: -1 if fd passing isn't supported or there are no pending file
|
||||||
|
* descriptors. If file descriptors are returned, subsequent calls to
|
||||||
|
* this function will return -1 until a client sends a new set of file
|
||||||
|
* descriptors.
|
||||||
|
*/
|
||||||
|
int qemu_chr_fe_get_msgfds(CharBackend *be, int *fds, int num);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @qemu_chr_fe_set_msgfds:
|
||||||
|
*
|
||||||
|
* For backends capable of fd passing, set an array of fds to be passed with
|
||||||
|
* the next send operation.
|
||||||
|
* A subsequent call to this function before calling a write function will
|
||||||
|
* result in overwriting the fd array with the new value without being send.
|
||||||
|
* Upon writing the message the fd array is freed.
|
||||||
|
*
|
||||||
|
* Returns: -1 if fd passing isn't supported or no associated Chardev.
|
||||||
|
*/
|
||||||
|
int qemu_chr_fe_set_msgfds(CharBackend *be, int *fds, int num);
|
||||||
|
|
||||||
|
#endif /* QEMU_CHAR_FE_H */
|
@ -25,6 +25,7 @@
|
|||||||
#define CHAR_MUX_H
|
#define CHAR_MUX_H
|
||||||
|
|
||||||
#include "chardev/char.h"
|
#include "chardev/char.h"
|
||||||
|
#include "chardev/char-fe.h"
|
||||||
|
|
||||||
extern bool muxes_realized;
|
extern bool muxes_realized;
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#define IAC 255
|
#define IAC 255
|
||||||
|
|
||||||
/* character device */
|
/* character device */
|
||||||
|
typedef struct CharBackend CharBackend;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CHR_EVENT_BREAK, /* serial break char */
|
CHR_EVENT_BREAK, /* serial break char */
|
||||||
@ -27,8 +28,6 @@ typedef enum {
|
|||||||
|
|
||||||
#define CHR_READ_BUF_LEN 4096
|
#define CHR_READ_BUF_LEN 4096
|
||||||
|
|
||||||
typedef void IOEventHandler(void *opaque, int event);
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
/* Whether the chardev peer is able to close and
|
/* Whether the chardev peer is able to close and
|
||||||
* reopen the data channel, thus requiring support
|
* reopen the data channel, thus requiring support
|
||||||
@ -44,17 +43,7 @@ typedef enum {
|
|||||||
QEMU_CHAR_FEATURE_LAST,
|
QEMU_CHAR_FEATURE_LAST,
|
||||||
} ChardevFeature;
|
} ChardevFeature;
|
||||||
|
|
||||||
/* This is the backend as seen by frontend, the actual backend is
|
#define qemu_chr_replay(chr) qemu_chr_has_feature(chr, QEMU_CHAR_FEATURE_REPLAY)
|
||||||
* Chardev */
|
|
||||||
typedef struct CharBackend {
|
|
||||||
Chardev *chr;
|
|
||||||
IOEventHandler *chr_event;
|
|
||||||
IOCanReadHandler *chr_can_read;
|
|
||||||
IOReadHandler *chr_read;
|
|
||||||
void *opaque;
|
|
||||||
int tag;
|
|
||||||
int fe_open;
|
|
||||||
} CharBackend;
|
|
||||||
|
|
||||||
struct Chardev {
|
struct Chardev {
|
||||||
Object parent_obj;
|
Object parent_obj;
|
||||||
@ -103,15 +92,6 @@ void qemu_chr_parse_common(QemuOpts *opts, ChardevCommon *backend);
|
|||||||
*/
|
*/
|
||||||
Chardev *qemu_chr_new(const char *label, const char *filename);
|
Chardev *qemu_chr_new(const char *label, const char *filename);
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @qemu_chr_fe_disconnect:
|
|
||||||
*
|
|
||||||
* Close a fd accpeted by character backend.
|
|
||||||
* Without associated Chardev, do nothing.
|
|
||||||
*/
|
|
||||||
void qemu_chr_fe_disconnect(CharBackend *be);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @qemu_chr_cleanup:
|
* @qemu_chr_cleanup:
|
||||||
*
|
*
|
||||||
@ -119,14 +99,6 @@ void qemu_chr_fe_disconnect(CharBackend *be);
|
|||||||
*/
|
*/
|
||||||
void qemu_chr_cleanup(void);
|
void qemu_chr_cleanup(void);
|
||||||
|
|
||||||
/**
|
|
||||||
* @qemu_chr_fe_wait_connected:
|
|
||||||
*
|
|
||||||
* Wait for characted backend to be connected, return < 0 on error or
|
|
||||||
* if no assicated Chardev.
|
|
||||||
*/
|
|
||||||
int qemu_chr_fe_wait_connected(CharBackend *be, Error **errp);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @qemu_chr_new_noreplay:
|
* @qemu_chr_new_noreplay:
|
||||||
*
|
*
|
||||||
@ -141,150 +113,6 @@ int qemu_chr_fe_wait_connected(CharBackend *be, Error **errp);
|
|||||||
*/
|
*/
|
||||||
Chardev *qemu_chr_new_noreplay(const char *label, const char *filename);
|
Chardev *qemu_chr_new_noreplay(const char *label, const char *filename);
|
||||||
|
|
||||||
/**
|
|
||||||
* @qemu_chr_fe_set_echo:
|
|
||||||
*
|
|
||||||
* Ask the backend to override its normal echo setting. This only really
|
|
||||||
* applies to the stdio backend and is used by the QMP server such that you
|
|
||||||
* can see what you type if you try to type QMP commands.
|
|
||||||
* Without associated Chardev, do nothing.
|
|
||||||
*
|
|
||||||
* @echo true to enable echo, false to disable echo
|
|
||||||
*/
|
|
||||||
void qemu_chr_fe_set_echo(CharBackend *be, bool echo);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @qemu_chr_fe_set_open:
|
|
||||||
*
|
|
||||||
* Set character frontend open status. This is an indication that the
|
|
||||||
* front end is ready (or not) to begin doing I/O.
|
|
||||||
* Without associated Chardev, do nothing.
|
|
||||||
*/
|
|
||||||
void qemu_chr_fe_set_open(CharBackend *be, int fe_open);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @qemu_chr_fe_printf:
|
|
||||||
*
|
|
||||||
* Write to a character backend using a printf style interface. This
|
|
||||||
* function is thread-safe. It does nothing without associated
|
|
||||||
* Chardev.
|
|
||||||
*
|
|
||||||
* @fmt see #printf
|
|
||||||
*/
|
|
||||||
void qemu_chr_fe_printf(CharBackend *be, const char *fmt, ...)
|
|
||||||
GCC_FMT_ATTR(2, 3);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @qemu_chr_fe_add_watch:
|
|
||||||
*
|
|
||||||
* If the backend is connected, create and add a #GSource that fires
|
|
||||||
* when the given condition (typically G_IO_OUT|G_IO_HUP or G_IO_HUP)
|
|
||||||
* is active; return the #GSource's tag. If it is disconnected,
|
|
||||||
* or without associated Chardev, return 0.
|
|
||||||
*
|
|
||||||
* @cond the condition to poll for
|
|
||||||
* @func the function to call when the condition happens
|
|
||||||
* @user_data the opaque pointer to pass to @func
|
|
||||||
*
|
|
||||||
* Returns: the source tag
|
|
||||||
*/
|
|
||||||
guint qemu_chr_fe_add_watch(CharBackend *be, GIOCondition cond,
|
|
||||||
GIOFunc func, void *user_data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @qemu_chr_fe_write:
|
|
||||||
*
|
|
||||||
* Write data to a character backend from the front end. This function
|
|
||||||
* will send data from the front end to the back end. This function
|
|
||||||
* is thread-safe.
|
|
||||||
*
|
|
||||||
* @buf the data
|
|
||||||
* @len the number of bytes to send
|
|
||||||
*
|
|
||||||
* Returns: the number of bytes consumed (0 if no assicated Chardev)
|
|
||||||
*/
|
|
||||||
int qemu_chr_fe_write(CharBackend *be, const uint8_t *buf, int len);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @qemu_chr_fe_write_all:
|
|
||||||
*
|
|
||||||
* Write data to a character backend from the front end. This function will
|
|
||||||
* send data from the front end to the back end. Unlike @qemu_chr_fe_write,
|
|
||||||
* this function will block if the back end cannot consume all of the data
|
|
||||||
* attempted to be written. This function is thread-safe.
|
|
||||||
*
|
|
||||||
* @buf the data
|
|
||||||
* @len the number of bytes to send
|
|
||||||
*
|
|
||||||
* Returns: the number of bytes consumed (0 if no assicated Chardev)
|
|
||||||
*/
|
|
||||||
int qemu_chr_fe_write_all(CharBackend *be, const uint8_t *buf, int len);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @qemu_chr_fe_read_all:
|
|
||||||
*
|
|
||||||
* Read data to a buffer from the back end.
|
|
||||||
*
|
|
||||||
* @buf the data buffer
|
|
||||||
* @len the number of bytes to read
|
|
||||||
*
|
|
||||||
* Returns: the number of bytes read (0 if no assicated Chardev)
|
|
||||||
*/
|
|
||||||
int qemu_chr_fe_read_all(CharBackend *be, uint8_t *buf, int len);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @qemu_chr_fe_ioctl:
|
|
||||||
*
|
|
||||||
* Issue a device specific ioctl to a backend. This function is thread-safe.
|
|
||||||
*
|
|
||||||
* @cmd see CHR_IOCTL_*
|
|
||||||
* @arg the data associated with @cmd
|
|
||||||
*
|
|
||||||
* Returns: if @cmd is not supported by the backend or there is no
|
|
||||||
* associated Chardev, -ENOTSUP, otherwise the return
|
|
||||||
* value depends on the semantics of @cmd
|
|
||||||
*/
|
|
||||||
int qemu_chr_fe_ioctl(CharBackend *be, int cmd, void *arg);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @qemu_chr_fe_get_msgfd:
|
|
||||||
*
|
|
||||||
* For backends capable of fd passing, return the latest file descriptor passed
|
|
||||||
* by a client.
|
|
||||||
*
|
|
||||||
* Returns: -1 if fd passing isn't supported or there is no pending file
|
|
||||||
* descriptor. If a file descriptor is returned, subsequent calls to
|
|
||||||
* this function will return -1 until a client sends a new file
|
|
||||||
* descriptor.
|
|
||||||
*/
|
|
||||||
int qemu_chr_fe_get_msgfd(CharBackend *be);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @qemu_chr_fe_get_msgfds:
|
|
||||||
*
|
|
||||||
* For backends capable of fd passing, return the number of file received
|
|
||||||
* descriptors and fills the fds array up to num elements
|
|
||||||
*
|
|
||||||
* Returns: -1 if fd passing isn't supported or there are no pending file
|
|
||||||
* descriptors. If file descriptors are returned, subsequent calls to
|
|
||||||
* this function will return -1 until a client sends a new set of file
|
|
||||||
* descriptors.
|
|
||||||
*/
|
|
||||||
int qemu_chr_fe_get_msgfds(CharBackend *be, int *fds, int num);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @qemu_chr_fe_set_msgfds:
|
|
||||||
*
|
|
||||||
* For backends capable of fd passing, set an array of fds to be passed with
|
|
||||||
* the next send operation.
|
|
||||||
* A subsequent call to this function before calling a write function will
|
|
||||||
* result in overwriting the fd array with the new value without being send.
|
|
||||||
* Upon writing the message the fd array is freed.
|
|
||||||
*
|
|
||||||
* Returns: -1 if fd passing isn't supported or no associated Chardev.
|
|
||||||
*/
|
|
||||||
int qemu_chr_fe_set_msgfds(CharBackend *be, int *fds, int num);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @qemu_chr_be_can_write:
|
* @qemu_chr_be_can_write:
|
||||||
*
|
*
|
||||||
@ -328,69 +156,6 @@ void qemu_chr_be_write_impl(Chardev *s, uint8_t *buf, int len);
|
|||||||
*/
|
*/
|
||||||
void qemu_chr_be_event(Chardev *s, int event);
|
void qemu_chr_be_event(Chardev *s, int event);
|
||||||
|
|
||||||
/**
|
|
||||||
* @qemu_chr_fe_init:
|
|
||||||
*
|
|
||||||
* Initializes a front end for the given CharBackend and
|
|
||||||
* Chardev. Call qemu_chr_fe_deinit() to remove the association and
|
|
||||||
* release the driver.
|
|
||||||
*
|
|
||||||
* Returns: false on error.
|
|
||||||
*/
|
|
||||||
bool qemu_chr_fe_init(CharBackend *b, Chardev *s, Error **errp);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @qemu_chr_fe_get_driver:
|
|
||||||
*
|
|
||||||
* Returns the driver associated with a CharBackend or NULL if no
|
|
||||||
* associated Chardev.
|
|
||||||
*/
|
|
||||||
Chardev *qemu_chr_fe_get_driver(CharBackend *be);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @qemu_chr_fe_deinit:
|
|
||||||
*
|
|
||||||
* Dissociate the CharBackend from the Chardev.
|
|
||||||
*
|
|
||||||
* Safe to call without associated Chardev.
|
|
||||||
*/
|
|
||||||
void qemu_chr_fe_deinit(CharBackend *b);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @qemu_chr_fe_set_handlers:
|
|
||||||
* @b: a CharBackend
|
|
||||||
* @fd_can_read: callback to get the amount of data the frontend may
|
|
||||||
* receive
|
|
||||||
* @fd_read: callback to receive data from char
|
|
||||||
* @fd_event: event callback
|
|
||||||
* @opaque: an opaque pointer for the callbacks
|
|
||||||
* @context: a main loop context or NULL for the default
|
|
||||||
* @set_open: whether to call qemu_chr_fe_set_open() implicitely when
|
|
||||||
* any of the handler is non-NULL
|
|
||||||
*
|
|
||||||
* Set the front end char handlers. The front end takes the focus if
|
|
||||||
* any of the handler is non-NULL.
|
|
||||||
*
|
|
||||||
* Without associated Chardev, nothing is changed.
|
|
||||||
*/
|
|
||||||
void qemu_chr_fe_set_handlers(CharBackend *b,
|
|
||||||
IOCanReadHandler *fd_can_read,
|
|
||||||
IOReadHandler *fd_read,
|
|
||||||
IOEventHandler *fd_event,
|
|
||||||
void *opaque,
|
|
||||||
GMainContext *context,
|
|
||||||
bool set_open);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @qemu_chr_fe_take_focus:
|
|
||||||
*
|
|
||||||
* Take the focus (if the front end is muxed).
|
|
||||||
*
|
|
||||||
* Without associated Chardev, nothing is changed.
|
|
||||||
*/
|
|
||||||
void qemu_chr_fe_take_focus(CharBackend *b);
|
|
||||||
|
|
||||||
void qemu_chr_fe_accept_input(CharBackend *be);
|
|
||||||
int qemu_chr_add_client(Chardev *s, int fd);
|
int qemu_chr_add_client(Chardev *s, int fd);
|
||||||
Chardev *qemu_chr_find(const char *name);
|
Chardev *qemu_chr_find(const char *name);
|
||||||
|
|
||||||
@ -399,7 +164,8 @@ bool qemu_chr_has_feature(Chardev *chr,
|
|||||||
void qemu_chr_set_feature(Chardev *chr,
|
void qemu_chr_set_feature(Chardev *chr,
|
||||||
ChardevFeature feature);
|
ChardevFeature feature);
|
||||||
QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename);
|
QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename);
|
||||||
int qemu_chr_write_all(Chardev *s, const uint8_t *buf, int len);
|
int qemu_chr_write(Chardev *s, const uint8_t *buf, int len, bool write_all);
|
||||||
|
#define qemu_chr_write_all(s, buf, len) qemu_chr_write(s, buf, len, true)
|
||||||
int qemu_chr_wait_connected(Chardev *chr, Error **errp);
|
int qemu_chr_wait_connected(Chardev *chr, Error **errp);
|
||||||
|
|
||||||
#define TYPE_CHARDEV "chardev"
|
#define TYPE_CHARDEV "chardev"
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#define BCM2835_AUX_H
|
#define BCM2835_AUX_H
|
||||||
|
|
||||||
#include "hw/sysbus.h"
|
#include "hw/sysbus.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
|
|
||||||
#define TYPE_BCM2835_AUX "bcm2835-aux"
|
#define TYPE_BCM2835_AUX "bcm2835-aux"
|
||||||
#define BCM2835_AUX(obj) OBJECT_CHECK(BCM2835AuxState, (obj), TYPE_BCM2835_AUX)
|
#define BCM2835_AUX(obj) OBJECT_CHECK(BCM2835AuxState, (obj), TYPE_BCM2835_AUX)
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#ifndef CADENCE_UART_H
|
#ifndef CADENCE_UART_H
|
||||||
|
|
||||||
#include "hw/sysbus.h"
|
#include "hw/sysbus.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "qemu/timer.h"
|
#include "qemu/timer.h"
|
||||||
|
|
||||||
#define CADENCE_UART_RX_FIFO_SIZE 16
|
#define CADENCE_UART_RX_FIFO_SIZE 16
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define HW_CHAR_DIGIC_UART_H
|
#define HW_CHAR_DIGIC_UART_H
|
||||||
|
|
||||||
#include "hw/sysbus.h"
|
#include "hw/sysbus.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
|
|
||||||
#define TYPE_DIGIC_UART "digic-uart"
|
#define TYPE_DIGIC_UART "digic-uart"
|
||||||
#define DIGIC_UART(obj) \
|
#define DIGIC_UART(obj) \
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define IMX_SERIAL_H
|
#define IMX_SERIAL_H
|
||||||
|
|
||||||
#include "hw/sysbus.h"
|
#include "hw/sysbus.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
|
|
||||||
#define TYPE_IMX_SERIAL "imx.serial"
|
#define TYPE_IMX_SERIAL "imx.serial"
|
||||||
#define IMX_SERIAL(obj) OBJECT_CHECK(IMXSerialState, (obj), TYPE_IMX_SERIAL)
|
#define IMX_SERIAL(obj) OBJECT_CHECK(IMXSerialState, (obj), TYPE_IMX_SERIAL)
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#include "hw/hw.h"
|
#include "hw/hw.h"
|
||||||
#include "sysemu/sysemu.h"
|
#include "sysemu/sysemu.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "exec/memory.h"
|
#include "exec/memory.h"
|
||||||
#include "qemu/fifo8.h"
|
#include "qemu/fifo8.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char.h"
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#define HW_STM32F2XX_USART_H
|
#define HW_STM32F2XX_USART_H
|
||||||
|
|
||||||
#include "hw/sysbus.h"
|
#include "hw/sysbus.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "hw/hw.h"
|
#include "hw/hw.h"
|
||||||
|
|
||||||
#define USART_SR 0x00
|
#define USART_SR 0x00
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
#include "exec/gdbstub.h"
|
#include "exec/gdbstub.h"
|
||||||
#include "net/net.h"
|
#include "net/net.h"
|
||||||
#include "net/slirp.h"
|
#include "net/slirp.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "ui/qemu-spice.h"
|
#include "ui/qemu-spice.h"
|
||||||
#include "sysemu/numa.h"
|
#include "sysemu/numa.h"
|
||||||
#include "monitor/monitor.h"
|
#include "monitor/monitor.h"
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include "qom/object.h"
|
#include "qom/object.h"
|
||||||
#include "qemu/typedefs.h"
|
#include "qemu/typedefs.h"
|
||||||
#include "net/queue.h"
|
#include "net/queue.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "qemu/sockets.h"
|
#include "qemu/sockets.h"
|
||||||
#include "qapi-visit.h"
|
#include "qapi-visit.h"
|
||||||
#include "net/colo.h"
|
#include "net/colo.h"
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "qemu/main-loop.h"
|
#include "qemu/main-loop.h"
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "qemu/iov.h"
|
#include "qemu/iov.h"
|
||||||
#include "qemu/sockets.h"
|
#include "qemu/sockets.h"
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include "qemu/sockets.h"
|
#include "qemu/sockets.h"
|
||||||
#include "slirp/libslirp.h"
|
#include "slirp/libslirp.h"
|
||||||
#include "slirp/ip6.h"
|
#include "slirp/ip6.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "sysemu/sysemu.h"
|
#include "sysemu/sysemu.h"
|
||||||
#include "qemu/cutils.h"
|
#include "qemu/cutils.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include "clients.h"
|
#include "clients.h"
|
||||||
#include "net/vhost_net.h"
|
#include "net/vhost_net.h"
|
||||||
#include "net/vhost-user.h"
|
#include "net/vhost-user.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "qemu/config-file.h"
|
#include "qemu/config-file.h"
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
#include "qmp-commands.h"
|
#include "qmp-commands.h"
|
||||||
|
2
qtest.c
2
qtest.c
@ -17,7 +17,7 @@
|
|||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "sysemu/qtest.h"
|
#include "sysemu/qtest.h"
|
||||||
#include "hw/qdev.h"
|
#include "hw/qdev.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "exec/ioport.h"
|
#include "exec/ioport.h"
|
||||||
#include "exec/memory.h"
|
#include "exec/memory.h"
|
||||||
#include "hw/irq.h"
|
#include "hw/irq.h"
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include "qemu-common.h"
|
#include "qemu-common.h"
|
||||||
#include "qemu/timer.h"
|
#include "qemu/timer.h"
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "slirp.h"
|
#include "slirp.h"
|
||||||
#include "hw/hw.h"
|
#include "hw/hw.h"
|
||||||
#include "qemu/cutils.h"
|
#include "qemu/cutils.h"
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "qemu-common.h"
|
#include "qemu-common.h"
|
||||||
#include "qemu/config-file.h"
|
#include "qemu/config-file.h"
|
||||||
#include "qemu/sockets.h"
|
#include "qemu/sockets.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "sysemu/sysemu.h"
|
#include "sysemu/sysemu.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "qom/qom-qobject.h"
|
#include "qom/qom-qobject.h"
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include "qemu/option.h"
|
#include "qemu/option.h"
|
||||||
#include "qemu/range.h"
|
#include "qemu/range.h"
|
||||||
#include "qemu/sockets.h"
|
#include "qemu/sockets.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "sysemu/sysemu.h"
|
#include "sysemu/sysemu.h"
|
||||||
#include "libqos/libqos.h"
|
#include "libqos/libqos.h"
|
||||||
#include "libqos/pci-pc.h"
|
#include "libqos/pci-pc.h"
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "hw/qdev-core.h"
|
#include "hw/qdev-core.h"
|
||||||
#include "qemu/timer.h"
|
#include "qemu/timer.h"
|
||||||
#include "qmp-commands.h"
|
#include "qmp-commands.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char-fe.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
#include "exec/memory.h"
|
#include "exec/memory.h"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user