char: rename CharBackend->CharFrontend
The actual backend is "Chardev", CharBackend is the frontend side of it (whatever talks to the backend), let's rename it for readability. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Link: https://lore.kernel.org/r/20251022074612.1258413-1-marcandre.lureau@redhat.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
dc72ba5dc4
commit
1b21518f73
89 changed files with 428 additions and 429 deletions
|
|
@ -46,7 +46,7 @@ struct CryptoDevBackendVhostUser {
|
||||||
CryptoDevBackend parent_obj;
|
CryptoDevBackend parent_obj;
|
||||||
|
|
||||||
VhostUserState vhost_user;
|
VhostUserState vhost_user;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
char *chr_name;
|
char *chr_name;
|
||||||
bool opened;
|
bool opened;
|
||||||
CryptoDevBackendVhost *vhost_crypto[MAX_CRYPTO_QUEUE_NUM];
|
CryptoDevBackendVhost *vhost_crypto[MAX_CRYPTO_QUEUE_NUM];
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(RngEgd, RNG_EGD)
|
||||||
struct RngEgd {
|
struct RngEgd {
|
||||||
RngBackend parent;
|
RngBackend parent;
|
||||||
|
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
char *chr_name;
|
char *chr_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ struct TPMEmulator {
|
||||||
TPMBackend parent;
|
TPMBackend parent;
|
||||||
|
|
||||||
TPMEmulatorOptions *options;
|
TPMEmulatorOptions *options;
|
||||||
CharBackend ctrl_chr;
|
CharFrontend ctrl_chr;
|
||||||
QIOChannel *data_ioc;
|
QIOChannel *data_ioc;
|
||||||
TPMVersion tpm_version;
|
TPMVersion tpm_version;
|
||||||
uint32_t caps; /* capabilities of the TPM */
|
uint32_t caps; /* capabilities of the TPM */
|
||||||
|
|
@ -126,7 +126,7 @@ static int tpm_emulator_ctrlcmd(TPMEmulator *tpm, unsigned long cmd, void *msg,
|
||||||
size_t msg_len_in, size_t msg_len_out_err,
|
size_t msg_len_in, size_t msg_len_out_err,
|
||||||
size_t msg_len_out_total)
|
size_t msg_len_out_total)
|
||||||
{
|
{
|
||||||
CharBackend *dev = &tpm->ctrl_chr;
|
CharFrontend *dev = &tpm->ctrl_chr;
|
||||||
uint32_t cmd_no = cpu_to_be32(cmd);
|
uint32_t cmd_no = cpu_to_be32(cmd);
|
||||||
ssize_t n = sizeof(uint32_t) + msg_len_in;
|
ssize_t n = sizeof(uint32_t) + msg_len_in;
|
||||||
ptm_res res;
|
ptm_res res;
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,9 @@
|
||||||
#include "chardev/char-io.h"
|
#include "chardev/char-io.h"
|
||||||
#include "chardev-internal.h"
|
#include "chardev-internal.h"
|
||||||
|
|
||||||
int qemu_chr_fe_write(CharBackend *be, const uint8_t *buf, int len)
|
int qemu_chr_fe_write(CharFrontend *c, const uint8_t *buf, int len)
|
||||||
{
|
{
|
||||||
Chardev *s = be->chr;
|
Chardev *s = c->chr;
|
||||||
|
|
||||||
if (!s) {
|
if (!s) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -41,9 +41,9 @@ int qemu_chr_fe_write(CharBackend *be, const uint8_t *buf, int len)
|
||||||
return qemu_chr_write(s, buf, len, false);
|
return qemu_chr_write(s, buf, len, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int qemu_chr_fe_write_all(CharBackend *be, const uint8_t *buf, int len)
|
int qemu_chr_fe_write_all(CharFrontend *c, const uint8_t *buf, int len)
|
||||||
{
|
{
|
||||||
Chardev *s = be->chr;
|
Chardev *s = c->chr;
|
||||||
|
|
||||||
if (!s) {
|
if (!s) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -52,9 +52,9 @@ int qemu_chr_fe_write_all(CharBackend *be, const uint8_t *buf, int len)
|
||||||
return qemu_chr_write(s, buf, len, true);
|
return qemu_chr_write(s, buf, len, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int qemu_chr_fe_read_all(CharBackend *be, uint8_t *buf, int len)
|
int qemu_chr_fe_read_all(CharFrontend *c, uint8_t *buf, int len)
|
||||||
{
|
{
|
||||||
Chardev *s = be->chr;
|
Chardev *s = c->chr;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
|
@ -95,9 +95,9 @@ int qemu_chr_fe_read_all(CharBackend *be, uint8_t *buf, int len)
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
int qemu_chr_fe_ioctl(CharBackend *be, int cmd, void *arg)
|
int qemu_chr_fe_ioctl(CharFrontend *c, int cmd, void *arg)
|
||||||
{
|
{
|
||||||
Chardev *s = be->chr;
|
Chardev *s = c->chr;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (!s || !CHARDEV_GET_CLASS(s)->chr_ioctl || qemu_chr_replay(s)) {
|
if (!s || !CHARDEV_GET_CLASS(s)->chr_ioctl || qemu_chr_replay(s)) {
|
||||||
|
|
@ -109,11 +109,11 @@ int qemu_chr_fe_ioctl(CharBackend *be, int cmd, void *arg)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int qemu_chr_fe_get_msgfd(CharBackend *be)
|
int qemu_chr_fe_get_msgfd(CharFrontend *c)
|
||||||
{
|
{
|
||||||
Chardev *s = be->chr;
|
Chardev *s = c->chr;
|
||||||
int fd;
|
int fd;
|
||||||
int res = (qemu_chr_fe_get_msgfds(be, &fd, 1) == 1) ? fd : -1;
|
int res = (qemu_chr_fe_get_msgfds(c, &fd, 1) == 1) ? fd : -1;
|
||||||
if (s && qemu_chr_replay(s)) {
|
if (s && qemu_chr_replay(s)) {
|
||||||
error_report("Replay: get msgfd is not supported "
|
error_report("Replay: get msgfd is not supported "
|
||||||
"for serial devices yet");
|
"for serial devices yet");
|
||||||
|
|
@ -122,9 +122,9 @@ int qemu_chr_fe_get_msgfd(CharBackend *be)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int qemu_chr_fe_get_msgfds(CharBackend *be, int *fds, int len)
|
int qemu_chr_fe_get_msgfds(CharFrontend *c, int *fds, int len)
|
||||||
{
|
{
|
||||||
Chardev *s = be->chr;
|
Chardev *s = c->chr;
|
||||||
|
|
||||||
if (!s) {
|
if (!s) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -134,9 +134,9 @@ int qemu_chr_fe_get_msgfds(CharBackend *be, int *fds, int len)
|
||||||
CHARDEV_GET_CLASS(s)->get_msgfds(s, fds, len) : -1;
|
CHARDEV_GET_CLASS(s)->get_msgfds(s, fds, len) : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int qemu_chr_fe_set_msgfds(CharBackend *be, int *fds, int num)
|
int qemu_chr_fe_set_msgfds(CharFrontend *c, int *fds, int num)
|
||||||
{
|
{
|
||||||
Chardev *s = be->chr;
|
Chardev *s = c->chr;
|
||||||
|
|
||||||
if (!s) {
|
if (!s) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -146,9 +146,9 @@ int qemu_chr_fe_set_msgfds(CharBackend *be, int *fds, int num)
|
||||||
CHARDEV_GET_CLASS(s)->set_msgfds(s, fds, num) : -1;
|
CHARDEV_GET_CLASS(s)->set_msgfds(s, fds, num) : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qemu_chr_fe_accept_input(CharBackend *be)
|
void qemu_chr_fe_accept_input(CharFrontend *c)
|
||||||
{
|
{
|
||||||
Chardev *s = be->chr;
|
Chardev *s = c->chr;
|
||||||
|
|
||||||
if (!s) {
|
if (!s) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -160,7 +160,7 @@ void qemu_chr_fe_accept_input(CharBackend *be)
|
||||||
qemu_notify_event();
|
qemu_notify_event();
|
||||||
}
|
}
|
||||||
|
|
||||||
void qemu_chr_fe_printf(CharBackend *be, const char *fmt, ...)
|
void qemu_chr_fe_printf(CharFrontend *c, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
char buf[CHR_READ_BUF_LEN];
|
char buf[CHR_READ_BUF_LEN];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
@ -168,28 +168,28 @@ void qemu_chr_fe_printf(CharBackend *be, const char *fmt, ...)
|
||||||
vsnprintf(buf, sizeof(buf), fmt, ap);
|
vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||||
/* XXX this blocks entire thread. Rewrite to use
|
/* XXX this blocks entire thread. Rewrite to use
|
||||||
* qemu_chr_fe_write and background I/O callbacks */
|
* qemu_chr_fe_write and background I/O callbacks */
|
||||||
qemu_chr_fe_write_all(be, (uint8_t *)buf, strlen(buf));
|
qemu_chr_fe_write_all(c, (uint8_t *)buf, strlen(buf));
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
Chardev *qemu_chr_fe_get_driver(CharBackend *be)
|
Chardev *qemu_chr_fe_get_driver(CharFrontend *c)
|
||||||
{
|
{
|
||||||
/* this is unsafe for the users that support chardev hotswap */
|
/* this is unsafe for the users that support chardev hotswap */
|
||||||
assert(be->chr_be_change == NULL);
|
assert(c->chr_be_change == NULL);
|
||||||
return be->chr;
|
return c->chr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool qemu_chr_fe_backend_connected(CharBackend *be)
|
bool qemu_chr_fe_backend_connected(CharFrontend *c)
|
||||||
{
|
{
|
||||||
return !!be->chr;
|
return !!c->chr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool qemu_chr_fe_backend_open(CharBackend *be)
|
bool qemu_chr_fe_backend_open(CharFrontend *c)
|
||||||
{
|
{
|
||||||
return be->chr && be->chr->be_open;
|
return c->chr && c->chr->be_open;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool qemu_chr_fe_init(CharBackend *b, Chardev *s, Error **errp)
|
bool qemu_chr_fe_init(CharFrontend *c, Chardev *s, Error **errp)
|
||||||
{
|
{
|
||||||
unsigned int tag = 0;
|
unsigned int tag = 0;
|
||||||
|
|
||||||
|
|
@ -197,49 +197,49 @@ bool qemu_chr_fe_init(CharBackend *b, Chardev *s, Error **errp)
|
||||||
if (CHARDEV_IS_MUX(s)) {
|
if (CHARDEV_IS_MUX(s)) {
|
||||||
MuxChardev *d = MUX_CHARDEV(s);
|
MuxChardev *d = MUX_CHARDEV(s);
|
||||||
|
|
||||||
if (!mux_chr_attach_frontend(d, b, &tag, errp)) {
|
if (!mux_chr_attach_frontend(d, c, &tag, errp)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (s->be) {
|
} else if (s->fe) {
|
||||||
error_setg(errp, "chardev '%s' is already in use", s->label);
|
error_setg(errp, "chardev '%s' is already in use", s->label);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
s->be = b;
|
s->fe = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
b->fe_is_open = false;
|
c->fe_is_open = false;
|
||||||
b->tag = tag;
|
c->tag = tag;
|
||||||
b->chr = s;
|
c->chr = s;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qemu_chr_fe_deinit(CharBackend *b, bool del)
|
void qemu_chr_fe_deinit(CharFrontend *c, bool del)
|
||||||
{
|
{
|
||||||
assert(b);
|
assert(c);
|
||||||
|
|
||||||
if (b->chr) {
|
if (c->chr) {
|
||||||
qemu_chr_fe_set_handlers(b, NULL, NULL, NULL, NULL, NULL, NULL, true);
|
qemu_chr_fe_set_handlers(c, NULL, NULL, NULL, NULL, NULL, NULL, true);
|
||||||
if (b->chr->be == b) {
|
if (c->chr->fe == c) {
|
||||||
b->chr->be = NULL;
|
c->chr->fe = NULL;
|
||||||
}
|
}
|
||||||
if (CHARDEV_IS_MUX(b->chr)) {
|
if (CHARDEV_IS_MUX(c->chr)) {
|
||||||
MuxChardev *d = MUX_CHARDEV(b->chr);
|
MuxChardev *d = MUX_CHARDEV(c->chr);
|
||||||
mux_chr_detach_frontend(d, b->tag);
|
mux_chr_detach_frontend(d, c->tag);
|
||||||
}
|
}
|
||||||
if (del) {
|
if (del) {
|
||||||
Object *obj = OBJECT(b->chr);
|
Object *obj = OBJECT(c->chr);
|
||||||
if (obj->parent) {
|
if (obj->parent) {
|
||||||
object_unparent(obj);
|
object_unparent(obj);
|
||||||
} else {
|
} else {
|
||||||
object_unref(obj);
|
object_unref(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
b->chr = NULL;
|
c->chr = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void qemu_chr_fe_set_handlers_full(CharBackend *b,
|
void qemu_chr_fe_set_handlers_full(CharFrontend *c,
|
||||||
IOCanReadHandler *fd_can_read,
|
IOCanReadHandler *fd_can_read,
|
||||||
IOReadHandler *fd_read,
|
IOReadHandler *fd_read,
|
||||||
IOEventHandler *fd_event,
|
IOEventHandler *fd_event,
|
||||||
|
|
@ -252,7 +252,7 @@ void qemu_chr_fe_set_handlers_full(CharBackend *b,
|
||||||
Chardev *s;
|
Chardev *s;
|
||||||
bool fe_open;
|
bool fe_open;
|
||||||
|
|
||||||
s = b->chr;
|
s = c->chr;
|
||||||
if (!s) {
|
if (!s) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -263,20 +263,20 @@ void qemu_chr_fe_set_handlers_full(CharBackend *b,
|
||||||
} else {
|
} else {
|
||||||
fe_open = true;
|
fe_open = true;
|
||||||
}
|
}
|
||||||
b->chr_can_read = fd_can_read;
|
c->chr_can_read = fd_can_read;
|
||||||
b->chr_read = fd_read;
|
c->chr_read = fd_read;
|
||||||
b->chr_event = fd_event;
|
c->chr_event = fd_event;
|
||||||
b->chr_be_change = be_change;
|
c->chr_be_change = be_change;
|
||||||
b->opaque = opaque;
|
c->opaque = opaque;
|
||||||
|
|
||||||
qemu_chr_be_update_read_handlers(s, context);
|
qemu_chr_be_update_read_handlers(s, context);
|
||||||
|
|
||||||
if (set_open) {
|
if (set_open) {
|
||||||
qemu_chr_fe_set_open(b, fe_open);
|
qemu_chr_fe_set_open(c, fe_open);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fe_open) {
|
if (fe_open) {
|
||||||
qemu_chr_fe_take_focus(b);
|
qemu_chr_fe_take_focus(c);
|
||||||
/* We're connecting to an already opened device, so let's make sure we
|
/* We're connecting to an already opened device, so let's make sure we
|
||||||
also get the open event */
|
also get the open event */
|
||||||
if (sync_state && s->be_open) {
|
if (sync_state && s->be_open) {
|
||||||
|
|
@ -285,7 +285,7 @@ void qemu_chr_fe_set_handlers_full(CharBackend *b,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void qemu_chr_fe_set_handlers(CharBackend *b,
|
void qemu_chr_fe_set_handlers(CharFrontend *c,
|
||||||
IOCanReadHandler *fd_can_read,
|
IOCanReadHandler *fd_can_read,
|
||||||
IOReadHandler *fd_read,
|
IOReadHandler *fd_read,
|
||||||
IOEventHandler *fd_event,
|
IOEventHandler *fd_event,
|
||||||
|
|
@ -294,62 +294,62 @@ void qemu_chr_fe_set_handlers(CharBackend *b,
|
||||||
GMainContext *context,
|
GMainContext *context,
|
||||||
bool set_open)
|
bool set_open)
|
||||||
{
|
{
|
||||||
qemu_chr_fe_set_handlers_full(b, fd_can_read, fd_read, fd_event, be_change,
|
qemu_chr_fe_set_handlers_full(c, fd_can_read, fd_read, fd_event, be_change,
|
||||||
opaque, context, set_open,
|
opaque, context, set_open,
|
||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qemu_chr_fe_take_focus(CharBackend *b)
|
void qemu_chr_fe_take_focus(CharFrontend *c)
|
||||||
{
|
{
|
||||||
if (!b->chr) {
|
if (!c->chr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CHARDEV_IS_MUX(b->chr)) {
|
if (CHARDEV_IS_MUX(c->chr)) {
|
||||||
mux_set_focus(b->chr, b->tag);
|
mux_set_focus(c->chr, c->tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int qemu_chr_fe_wait_connected(CharBackend *be, Error **errp)
|
int qemu_chr_fe_wait_connected(CharFrontend *c, Error **errp)
|
||||||
{
|
{
|
||||||
if (!be->chr) {
|
if (!c->chr) {
|
||||||
error_setg(errp, "missing associated backend");
|
error_setg(errp, "missing associated backend");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return qemu_chr_wait_connected(be->chr, errp);
|
return qemu_chr_wait_connected(c->chr, errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qemu_chr_fe_set_echo(CharBackend *be, bool echo)
|
void qemu_chr_fe_set_echo(CharFrontend *c, bool echo)
|
||||||
{
|
{
|
||||||
Chardev *chr = be->chr;
|
Chardev *chr = c->chr;
|
||||||
|
|
||||||
if (chr && CHARDEV_GET_CLASS(chr)->chr_set_echo) {
|
if (chr && CHARDEV_GET_CLASS(chr)->chr_set_echo) {
|
||||||
CHARDEV_GET_CLASS(chr)->chr_set_echo(chr, echo);
|
CHARDEV_GET_CLASS(chr)->chr_set_echo(chr, echo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void qemu_chr_fe_set_open(CharBackend *be, bool is_open)
|
void qemu_chr_fe_set_open(CharFrontend *c, bool is_open)
|
||||||
{
|
{
|
||||||
Chardev *chr = be->chr;
|
Chardev *chr = c->chr;
|
||||||
|
|
||||||
if (!chr) {
|
if (!chr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (be->fe_is_open == is_open) {
|
if (c->fe_is_open == is_open) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
be->fe_is_open = is_open;
|
c->fe_is_open = is_open;
|
||||||
if (CHARDEV_GET_CLASS(chr)->chr_set_fe_open) {
|
if (CHARDEV_GET_CLASS(chr)->chr_set_fe_open) {
|
||||||
CHARDEV_GET_CLASS(chr)->chr_set_fe_open(chr, is_open);
|
CHARDEV_GET_CLASS(chr)->chr_set_fe_open(chr, is_open);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
guint qemu_chr_fe_add_watch(CharBackend *be, GIOCondition cond,
|
guint qemu_chr_fe_add_watch(CharFrontend *c, GIOCondition cond,
|
||||||
FEWatchFunc func, void *user_data)
|
FEWatchFunc func, void *user_data)
|
||||||
{
|
{
|
||||||
Chardev *s = be->chr;
|
Chardev *s = c->chr;
|
||||||
GSource *src;
|
GSource *src;
|
||||||
guint tag;
|
guint tag;
|
||||||
|
|
||||||
|
|
@ -369,9 +369,9 @@ guint qemu_chr_fe_add_watch(CharBackend *be, GIOCondition cond,
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qemu_chr_fe_disconnect(CharBackend *be)
|
void qemu_chr_fe_disconnect(CharFrontend *c)
|
||||||
{
|
{
|
||||||
Chardev *chr = be->chr;
|
Chardev *chr = c->chr;
|
||||||
|
|
||||||
if (chr && CHARDEV_GET_CLASS(chr)->chr_disconnect) {
|
if (chr && CHARDEV_GET_CLASS(chr)->chr_disconnect) {
|
||||||
CHARDEV_GET_CLASS(chr)->chr_disconnect(chr);
|
CHARDEV_GET_CLASS(chr)->chr_disconnect(chr);
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ static int hub_chr_write(Chardev *chr, const uint8_t *buf, int len)
|
||||||
d->be_eagain_ind = -1;
|
d->be_eagain_ind = -1;
|
||||||
|
|
||||||
for (i = 0; i < d->be_cnt; i++) {
|
for (i = 0; i < d->be_cnt; i++) {
|
||||||
if (!d->backends[i].be.chr->be_open) {
|
if (!d->backends[i].fe.chr->be_open) {
|
||||||
/* Skip closed backend */
|
/* Skip closed backend */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -64,7 +64,7 @@ static int hub_chr_write(Chardev *chr, const uint8_t *buf, int len)
|
||||||
ret = MIN(written, ret);
|
ret = MIN(written, ret);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
r = qemu_chr_fe_write(&d->backends[i].be, buf, len);
|
r = qemu_chr_fe_write(&d->backends[i].fe, buf, len);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
if (errno == EAGAIN) {
|
if (errno == EAGAIN) {
|
||||||
/* Set index and expect to be called soon on watch wake up */
|
/* Set index and expect to be called soon on watch wake up */
|
||||||
|
|
@ -84,7 +84,7 @@ static int hub_chr_write(Chardev *chr, const uint8_t *buf, int len)
|
||||||
static int hub_chr_can_read(void *opaque)
|
static int hub_chr_can_read(void *opaque)
|
||||||
{
|
{
|
||||||
HubCharBackend *backend = opaque;
|
HubCharBackend *backend = opaque;
|
||||||
CharBackend *fe = backend->hub->parent.be;
|
CharFrontend *fe = backend->hub->parent.fe;
|
||||||
|
|
||||||
if (fe && fe->chr_can_read) {
|
if (fe && fe->chr_can_read) {
|
||||||
return fe->chr_can_read(fe->opaque);
|
return fe->chr_can_read(fe->opaque);
|
||||||
|
|
@ -96,7 +96,7 @@ static int hub_chr_can_read(void *opaque)
|
||||||
static void hub_chr_read(void *opaque, const uint8_t *buf, int size)
|
static void hub_chr_read(void *opaque, const uint8_t *buf, int size)
|
||||||
{
|
{
|
||||||
HubCharBackend *backend = opaque;
|
HubCharBackend *backend = opaque;
|
||||||
CharBackend *fe = backend->hub->parent.be;
|
CharFrontend *fe = backend->hub->parent.fe;
|
||||||
|
|
||||||
if (fe && fe->chr_read) {
|
if (fe && fe->chr_read) {
|
||||||
fe->chr_read(fe->opaque, buf, size);
|
fe->chr_read(fe->opaque, buf, size);
|
||||||
|
|
@ -107,7 +107,7 @@ static void hub_chr_event(void *opaque, QEMUChrEvent event)
|
||||||
{
|
{
|
||||||
HubCharBackend *backend = opaque;
|
HubCharBackend *backend = opaque;
|
||||||
HubChardev *d = backend->hub;
|
HubChardev *d = backend->hub;
|
||||||
CharBackend *fe = d->parent.be;
|
CharFrontend *fe = d->parent.fe;
|
||||||
|
|
||||||
if (event == CHR_EVENT_OPENED) {
|
if (event == CHR_EVENT_OPENED) {
|
||||||
/*
|
/*
|
||||||
|
|
@ -147,7 +147,7 @@ static GSource *hub_chr_add_watch(Chardev *s, GIOCondition cond)
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(d->be_eagain_ind < d->be_cnt);
|
assert(d->be_eagain_ind < d->be_cnt);
|
||||||
chr = qemu_chr_fe_get_driver(&d->backends[d->be_eagain_ind].be);
|
chr = qemu_chr_fe_get_driver(&d->backends[d->be_eagain_ind].fe);
|
||||||
cc = CHARDEV_GET_CLASS(chr);
|
cc = CHARDEV_GET_CLASS(chr);
|
||||||
if (!cc->chr_add_watch) {
|
if (!cc->chr_add_watch) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -167,7 +167,7 @@ static bool hub_chr_attach_chardev(HubChardev *d, Chardev *chr,
|
||||||
d->parent.label);
|
d->parent.label);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ret = qemu_chr_fe_init(&d->backends[d->be_cnt].be, chr, errp);
|
ret = qemu_chr_fe_init(&d->backends[d->be_cnt].fe, chr, errp);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
d->backends[d->be_cnt].hub = d;
|
d->backends[d->be_cnt].hub = d;
|
||||||
d->backends[d->be_cnt].be_ind = d->be_cnt;
|
d->backends[d->be_cnt].be_ind = d->be_cnt;
|
||||||
|
|
@ -183,7 +183,7 @@ static void char_hub_finalize(Object *obj)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < d->be_cnt; i++) {
|
for (i = 0; i < d->be_cnt; i++) {
|
||||||
qemu_chr_fe_deinit(&d->backends[i].be, false);
|
qemu_chr_fe_deinit(&d->backends[i].fe, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -193,7 +193,7 @@ static void hub_chr_update_read_handlers(Chardev *chr)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < d->be_cnt; i++) {
|
for (i = 0; i < d->be_cnt; i++) {
|
||||||
qemu_chr_fe_set_handlers_full(&d->backends[i].be,
|
qemu_chr_fe_set_handlers_full(&d->backends[i].fe,
|
||||||
hub_chr_can_read,
|
hub_chr_can_read,
|
||||||
hub_chr_read,
|
hub_chr_read,
|
||||||
hub_chr_event,
|
hub_chr_event,
|
||||||
|
|
|
||||||
|
|
@ -128,10 +128,10 @@ static void mux_print_help(Chardev *chr)
|
||||||
static void mux_chr_send_event(MuxChardev *d, unsigned int mux_nr,
|
static void mux_chr_send_event(MuxChardev *d, unsigned int mux_nr,
|
||||||
QEMUChrEvent event)
|
QEMUChrEvent event)
|
||||||
{
|
{
|
||||||
CharBackend *be = d->backends[mux_nr];
|
CharFrontend *fe = d->frontends[mux_nr];
|
||||||
|
|
||||||
if (be && be->chr_event) {
|
if (fe && fe->chr_event) {
|
||||||
be->chr_event(be->opaque, event);
|
fe->chr_event(fe->opaque, event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -200,11 +200,11 @@ static void mux_chr_accept_input(Chardev *chr)
|
||||||
{
|
{
|
||||||
MuxChardev *d = MUX_CHARDEV(chr);
|
MuxChardev *d = MUX_CHARDEV(chr);
|
||||||
int m = d->focus;
|
int m = d->focus;
|
||||||
CharBackend *be = d->backends[m];
|
CharFrontend *fe = d->frontends[m];
|
||||||
|
|
||||||
while (be && d->prod[m] != d->cons[m] &&
|
while (fe && d->prod[m] != d->cons[m] &&
|
||||||
be->chr_can_read && be->chr_can_read(be->opaque)) {
|
fe->chr_can_read && fe->chr_can_read(fe->opaque)) {
|
||||||
be->chr_read(be->opaque,
|
fe->chr_read(fe->opaque,
|
||||||
&d->buffer[m][d->cons[m]++ & MUX_BUFFER_MASK], 1);
|
&d->buffer[m][d->cons[m]++ & MUX_BUFFER_MASK], 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -213,14 +213,14 @@ static int mux_chr_can_read(void *opaque)
|
||||||
{
|
{
|
||||||
MuxChardev *d = MUX_CHARDEV(opaque);
|
MuxChardev *d = MUX_CHARDEV(opaque);
|
||||||
int m = d->focus;
|
int m = d->focus;
|
||||||
CharBackend *be = d->backends[m];
|
CharFrontend *fe = d->frontends[m];
|
||||||
|
|
||||||
if ((d->prod[m] - d->cons[m]) < MUX_BUFFER_SIZE) {
|
if ((d->prod[m] - d->cons[m]) < MUX_BUFFER_SIZE) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (be && be->chr_can_read) {
|
if (fe && fe->chr_can_read) {
|
||||||
return be->chr_can_read(be->opaque);
|
return fe->chr_can_read(fe->opaque);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -231,7 +231,7 @@ static void mux_chr_read(void *opaque, const uint8_t *buf, int size)
|
||||||
Chardev *chr = CHARDEV(opaque);
|
Chardev *chr = CHARDEV(opaque);
|
||||||
MuxChardev *d = MUX_CHARDEV(opaque);
|
MuxChardev *d = MUX_CHARDEV(opaque);
|
||||||
int m = d->focus;
|
int m = d->focus;
|
||||||
CharBackend *be = d->backends[m];
|
CharFrontend *fe = d->frontends[m];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
mux_chr_accept_input(opaque);
|
mux_chr_accept_input(opaque);
|
||||||
|
|
@ -239,9 +239,9 @@ static void mux_chr_read(void *opaque, const uint8_t *buf, int size)
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
if (mux_proc_byte(chr, d, buf[i])) {
|
if (mux_proc_byte(chr, d, buf[i])) {
|
||||||
if (d->prod[m] == d->cons[m] &&
|
if (d->prod[m] == d->cons[m] &&
|
||||||
be && be->chr_can_read &&
|
fe && fe->chr_can_read &&
|
||||||
be->chr_can_read(be->opaque)) {
|
fe->chr_can_read(fe->opaque)) {
|
||||||
be->chr_read(be->opaque, &buf[i], 1);
|
fe->chr_read(fe->opaque, &buf[i], 1);
|
||||||
} else {
|
} else {
|
||||||
d->buffer[m][d->prod[m]++ & MUX_BUFFER_MASK] = buf[i];
|
d->buffer[m][d->prod[m]++ & MUX_BUFFER_MASK] = buf[i];
|
||||||
}
|
}
|
||||||
|
|
@ -289,9 +289,9 @@ static void char_mux_finalize(Object *obj)
|
||||||
|
|
||||||
bit = -1;
|
bit = -1;
|
||||||
while ((bit = find_next_bit(&d->mux_bitset, MAX_MUX, bit + 1)) < MAX_MUX) {
|
while ((bit = find_next_bit(&d->mux_bitset, MAX_MUX, bit + 1)) < MAX_MUX) {
|
||||||
CharBackend *be = d->backends[bit];
|
CharFrontend *be = d->frontends[bit];
|
||||||
be->chr = NULL;
|
be->chr = NULL;
|
||||||
d->backends[bit] = NULL;
|
d->frontends[bit] = NULL;
|
||||||
}
|
}
|
||||||
d->mux_bitset = 0;
|
d->mux_bitset = 0;
|
||||||
qemu_chr_fe_deinit(&d->chr, false);
|
qemu_chr_fe_deinit(&d->chr, false);
|
||||||
|
|
@ -311,7 +311,7 @@ static void mux_chr_update_read_handlers(Chardev *chr)
|
||||||
chr->gcontext, true, false);
|
chr->gcontext, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mux_chr_attach_frontend(MuxChardev *d, CharBackend *b,
|
bool mux_chr_attach_frontend(MuxChardev *d, CharFrontend *c,
|
||||||
unsigned int *tag, Error **errp)
|
unsigned int *tag, Error **errp)
|
||||||
{
|
{
|
||||||
unsigned int bit;
|
unsigned int bit;
|
||||||
|
|
@ -328,7 +328,7 @@ bool mux_chr_attach_frontend(MuxChardev *d, CharBackend *b,
|
||||||
}
|
}
|
||||||
|
|
||||||
d->mux_bitset |= (1ul << bit);
|
d->mux_bitset |= (1ul << bit);
|
||||||
d->backends[bit] = b;
|
d->frontends[bit] = c;
|
||||||
*tag = bit;
|
*tag = bit;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -341,7 +341,7 @@ bool mux_chr_detach_frontend(MuxChardev *d, unsigned int tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
d->mux_bitset &= ~(1ul << tag);
|
d->mux_bitset &= ~(1ul << tag);
|
||||||
d->backends[tag] = NULL;
|
d->frontends[tag] = NULL;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -357,7 +357,7 @@ void mux_set_focus(Chardev *chr, unsigned int focus)
|
||||||
}
|
}
|
||||||
|
|
||||||
d->focus = focus;
|
d->focus = focus;
|
||||||
chr->be = d->backends[focus];
|
chr->fe = d->frontends[focus];
|
||||||
mux_chr_send_event(d, d->focus, CHR_EVENT_MUX_IN);
|
mux_chr_send_event(d, d->focus, CHR_EVENT_MUX_IN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,13 +53,13 @@ Object *get_chardevs_root(void)
|
||||||
|
|
||||||
static void chr_be_event(Chardev *s, QEMUChrEvent event)
|
static void chr_be_event(Chardev *s, QEMUChrEvent event)
|
||||||
{
|
{
|
||||||
CharBackend *be = s->be;
|
CharFrontend *fe = s->fe;
|
||||||
|
|
||||||
if (!be || !be->chr_event) {
|
if (!fe || !fe->chr_event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
be->chr_event(be->opaque, event);
|
fe->chr_event(fe->opaque, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qemu_chr_be_event(Chardev *s, QEMUChrEvent event)
|
void qemu_chr_be_event(Chardev *s, QEMUChrEvent event)
|
||||||
|
|
@ -197,21 +197,21 @@ int qemu_chr_write(Chardev *s, const uint8_t *buf, int len, bool write_all)
|
||||||
|
|
||||||
int qemu_chr_be_can_write(Chardev *s)
|
int qemu_chr_be_can_write(Chardev *s)
|
||||||
{
|
{
|
||||||
CharBackend *be = s->be;
|
CharFrontend *fe = s->fe;
|
||||||
|
|
||||||
if (!be || !be->chr_can_read) {
|
if (!fe || !fe->chr_can_read) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return be->chr_can_read(be->opaque);
|
return fe->chr_can_read(fe->opaque);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qemu_chr_be_write_impl(Chardev *s, const uint8_t *buf, int len)
|
void qemu_chr_be_write_impl(Chardev *s, const uint8_t *buf, int len)
|
||||||
{
|
{
|
||||||
CharBackend *be = s->be;
|
CharFrontend *fe = s->fe;
|
||||||
|
|
||||||
if (be && be->chr_read) {
|
if (fe && fe->chr_read) {
|
||||||
be->chr_read(be->opaque, buf, len);
|
fe->chr_read(fe->opaque, buf, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -307,8 +307,8 @@ static void char_finalize(Object *obj)
|
||||||
{
|
{
|
||||||
Chardev *chr = CHARDEV(obj);
|
Chardev *chr = CHARDEV(obj);
|
||||||
|
|
||||||
if (chr->be) {
|
if (chr->fe) {
|
||||||
chr->be->chr = NULL;
|
chr->fe->chr = NULL;
|
||||||
}
|
}
|
||||||
g_free(chr->filename);
|
g_free(chr->filename);
|
||||||
g_free(chr->label);
|
g_free(chr->label);
|
||||||
|
|
@ -335,7 +335,7 @@ static bool qemu_chr_is_busy(Chardev *s)
|
||||||
MuxChardev *d = MUX_CHARDEV(s);
|
MuxChardev *d = MUX_CHARDEV(s);
|
||||||
return d->mux_bitset != 0;
|
return d->mux_bitset != 0;
|
||||||
} else {
|
} else {
|
||||||
return s->be != NULL;
|
return s->fe != NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -798,7 +798,7 @@ static int qmp_query_chardev_foreach(Object *obj, void *data)
|
||||||
|
|
||||||
value->label = g_strdup(chr->label);
|
value->label = g_strdup(chr->label);
|
||||||
value->filename = g_strdup(chr->filename);
|
value->filename = g_strdup(chr->filename);
|
||||||
value->frontend_open = chr->be && chr->be->fe_is_open;
|
value->frontend_open = chr->fe && chr->fe->fe_is_open;
|
||||||
|
|
||||||
QAPI_LIST_PREPEND(*list, value);
|
QAPI_LIST_PREPEND(*list, value);
|
||||||
|
|
||||||
|
|
@ -1112,7 +1112,7 @@ err:
|
||||||
ChardevReturn *qmp_chardev_change(const char *id, ChardevBackend *backend,
|
ChardevReturn *qmp_chardev_change(const char *id, ChardevBackend *backend,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
CharBackend *be;
|
CharFrontend *fe;
|
||||||
const ChardevClass *cc, *cc_new;
|
const ChardevClass *cc, *cc_new;
|
||||||
Chardev *chr, *chr_new;
|
Chardev *chr, *chr_new;
|
||||||
bool closed_sent = false;
|
bool closed_sent = false;
|
||||||
|
|
@ -1136,14 +1136,14 @@ ChardevReturn *qmp_chardev_change(const char *id, ChardevBackend *backend,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
be = chr->be;
|
fe = chr->fe;
|
||||||
if (!be) {
|
if (!fe) {
|
||||||
/* easy case */
|
/* easy case */
|
||||||
object_unparent(OBJECT(chr));
|
object_unparent(OBJECT(chr));
|
||||||
return qmp_chardev_add(id, backend, errp);
|
return qmp_chardev_add(id, backend, errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!be->chr_be_change) {
|
if (!fe->chr_be_change) {
|
||||||
error_setg(errp, "Chardev user does not support chardev hotswap");
|
error_setg(errp, "Chardev user does not support chardev hotswap");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -1171,13 +1171,13 @@ ChardevReturn *qmp_chardev_change(const char *id, ChardevBackend *backend,
|
||||||
closed_sent = true;
|
closed_sent = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
chr->be = NULL;
|
chr->fe = NULL;
|
||||||
qemu_chr_fe_init(be, chr_new, &error_abort);
|
qemu_chr_fe_init(fe, chr_new, &error_abort);
|
||||||
|
|
||||||
if (be->chr_be_change(be->opaque) < 0) {
|
if (fe->chr_be_change(fe->opaque) < 0) {
|
||||||
error_setg(errp, "Chardev '%s' change failed", chr_new->label);
|
error_setg(errp, "Chardev '%s' change failed", chr_new->label);
|
||||||
chr_new->be = NULL;
|
chr_new->fe = NULL;
|
||||||
qemu_chr_fe_init(be, chr, &error_abort);
|
qemu_chr_fe_init(fe, chr, &error_abort);
|
||||||
if (closed_sent) {
|
if (closed_sent) {
|
||||||
qemu_chr_be_event(chr, CHR_EVENT_OPENED);
|
qemu_chr_be_event(chr, CHR_EVENT_OPENED);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,9 @@
|
||||||
struct MuxChardev {
|
struct MuxChardev {
|
||||||
Chardev parent;
|
Chardev parent;
|
||||||
/* Linked frontends */
|
/* Linked frontends */
|
||||||
CharBackend *backends[MAX_MUX];
|
CharFrontend *frontends[MAX_MUX];
|
||||||
/* Linked backend */
|
/* frontend of the underlying muxed chardev */
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
unsigned long mux_bitset;
|
unsigned long mux_bitset;
|
||||||
int focus;
|
int focus;
|
||||||
bool term_got_escape;
|
bool term_got_escape;
|
||||||
|
|
@ -64,8 +64,8 @@ typedef struct HubCharBackend HubCharBackend;
|
||||||
* `hub->backends` array
|
* `hub->backends` array
|
||||||
*/
|
*/
|
||||||
struct HubCharBackend {
|
struct HubCharBackend {
|
||||||
HubChardev *hub;
|
HubChardev *hub;
|
||||||
CharBackend be;
|
CharFrontend fe;
|
||||||
unsigned int be_ind;
|
unsigned int be_ind;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -108,7 +108,7 @@ DECLARE_INSTANCE_CHECKER(HubChardev, HUB_CHARDEV,
|
||||||
#define CHARDEV_IS_HUB(chr) \
|
#define CHARDEV_IS_HUB(chr) \
|
||||||
object_dynamic_cast(OBJECT(chr), TYPE_CHARDEV_HUB)
|
object_dynamic_cast(OBJECT(chr), TYPE_CHARDEV_HUB)
|
||||||
|
|
||||||
bool mux_chr_attach_frontend(MuxChardev *d, CharBackend *b,
|
bool mux_chr_attach_frontend(MuxChardev *d, CharFrontend *c,
|
||||||
unsigned int *tag, Error **errp);
|
unsigned int *tag, Error **errp);
|
||||||
bool mux_chr_detach_frontend(MuxChardev *d, unsigned int tag);
|
bool mux_chr_detach_frontend(MuxChardev *d, unsigned int tag);
|
||||||
void mux_set_focus(Chardev *chr, unsigned int focus);
|
void mux_set_focus(Chardev *chr, unsigned int focus);
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
/* System emulation specific state */
|
/* System emulation specific state */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
Chardev *mon_chr;
|
Chardev *mon_chr;
|
||||||
} GDBSystemState;
|
} GDBSystemState;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -927,7 +927,7 @@ struct StrongARMUARTState {
|
||||||
SysBusDevice parent_obj;
|
SysBusDevice parent_obj;
|
||||||
|
|
||||||
MemoryRegion iomem;
|
MemoryRegion iomem;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
qemu_irq irq;
|
qemu_irq irq;
|
||||||
|
|
||||||
uint8_t utcr0;
|
uint8_t utcr0;
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(ISADebugconState, ISA_DEBUGCON_DEVICE)
|
||||||
|
|
||||||
typedef struct DebugconState {
|
typedef struct DebugconState {
|
||||||
MemoryRegion io;
|
MemoryRegion io;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
uint32_t readback;
|
uint32_t readback;
|
||||||
} DebugconState;
|
} DebugconState;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ struct Exynos4210UartState {
|
||||||
QEMUTimer *fifo_timeout_timer;
|
QEMUTimer *fifo_timeout_timer;
|
||||||
uint64_t wordtime; /* word time in ns */
|
uint64_t wordtime; /* word time in ns */
|
||||||
|
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
qemu_irq irq;
|
qemu_irq irq;
|
||||||
qemu_irq dmairq;
|
qemu_irq dmairq;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ struct UART {
|
||||||
MemoryRegion iomem;
|
MemoryRegion iomem;
|
||||||
qemu_irq irq;
|
qemu_irq irq;
|
||||||
|
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
|
|
||||||
/* registers */
|
/* registers */
|
||||||
uint32_t status;
|
uint32_t status;
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ typedef struct SCC2698Block SCC2698Block;
|
||||||
|
|
||||||
struct SCC2698Channel {
|
struct SCC2698Channel {
|
||||||
IPOctalState *ipoctal;
|
IPOctalState *ipoctal;
|
||||||
CharBackend dev;
|
CharFrontend dev;
|
||||||
bool rx_enabled;
|
bool rx_enabled;
|
||||||
uint8_t mr[2];
|
uint8_t mr[2];
|
||||||
uint8_t mr_idx;
|
uint8_t mr_idx;
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ struct mcf_uart_state {
|
||||||
int tx_enabled;
|
int tx_enabled;
|
||||||
int rx_enabled;
|
int rx_enabled;
|
||||||
qemu_irq irq;
|
qemu_irq irq;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TYPE_MCF_UART "mcf-uart"
|
#define TYPE_MCF_UART "mcf-uart"
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ typedef struct OprtnsCommand {
|
||||||
|
|
||||||
struct SCLPConsoleLM {
|
struct SCLPConsoleLM {
|
||||||
SCLPEvent event;
|
SCLPEvent event;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
bool echo; /* immediate echo of input if true */
|
bool echo; /* immediate echo of input if true */
|
||||||
uint32_t write_errors; /* errors writing to char layer */
|
uint32_t write_errors; /* errors writing to char layer */
|
||||||
uint32_t length; /* length of byte stream in buffer */
|
uint32_t length; /* length of byte stream in buffer */
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ typedef struct ASCIIConsoleData {
|
||||||
|
|
||||||
struct SCLPConsole {
|
struct SCLPConsole {
|
||||||
SCLPEvent event;
|
SCLPEvent event;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
uint8_t iov[SIZE_BUFFER_VT220];
|
uint8_t iov[SIZE_BUFFER_VT220];
|
||||||
uint32_t iov_sclp; /* offset in buf for SCLP read operation */
|
uint32_t iov_sclp; /* offset in buf for SCLP read operation */
|
||||||
uint32_t iov_bs; /* offset in buf for char layer read operation */
|
uint32_t iov_bs; /* offset in buf for char layer read operation */
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ struct SHSerialState {
|
||||||
int flags;
|
int flags;
|
||||||
int rtrg;
|
int rtrg;
|
||||||
|
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
QEMUTimer fifo_timeout_timer;
|
QEMUTimer fifo_timeout_timer;
|
||||||
uint64_t etu; /* Elementary Time Unit (ns) */
|
uint64_t etu; /* Elementary Time Unit (ns) */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
struct SpaprVioVty {
|
struct SpaprVioVty {
|
||||||
SpaprVioDevice sdev;
|
SpaprVioDevice sdev;
|
||||||
CharBackend chardev;
|
CharFrontend chardev;
|
||||||
uint32_t in, out;
|
uint32_t in, out;
|
||||||
uint8_t buf[VTERM_BUFSIZE];
|
uint8_t buf[VTERM_BUFSIZE];
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
struct Terminal3270 {
|
struct Terminal3270 {
|
||||||
EmulatedCcw3270Device cdev;
|
EmulatedCcw3270Device cdev;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
uint8_t inv[INPUT_BUFFER_SIZE];
|
uint8_t inv[INPUT_BUFFER_SIZE];
|
||||||
uint8_t outv[OUTPUT_BUFFER_SIZE];
|
uint8_t outv[OUTPUT_BUFFER_SIZE];
|
||||||
int in_len;
|
int in_len;
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ DECLARE_INSTANCE_CHECKER(VirtConsole, VIRTIO_CONSOLE,
|
||||||
struct VirtConsole {
|
struct VirtConsole {
|
||||||
VirtIOSerialPort parent_obj;
|
VirtIOSerialPort parent_obj;
|
||||||
|
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
guint watch;
|
guint watch;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ struct XenConsole {
|
||||||
char *fe_path;
|
char *fe_path;
|
||||||
unsigned int ring_ref;
|
unsigned int ring_ref;
|
||||||
void *sring;
|
void *sring;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
int backlog;
|
int backlog;
|
||||||
};
|
};
|
||||||
typedef struct XenConsole XenConsole;
|
typedef struct XenConsole XenConsole;
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ struct XilinxUARTLite {
|
||||||
|
|
||||||
EndianMode model_endianness;
|
EndianMode model_endianness;
|
||||||
MemoryRegion mmio;
|
MemoryRegion mmio;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
qemu_irq irq;
|
qemu_irq irq;
|
||||||
|
|
||||||
uint8_t rx_fifo[8];
|
uint8_t rx_fifo[8];
|
||||||
|
|
|
||||||
|
|
@ -258,10 +258,10 @@ const PropertyInfo qdev_prop_drive_iothread = {
|
||||||
static void get_chr(Object *obj, Visitor *v, const char *name, void *opaque,
|
static void get_chr(Object *obj, Visitor *v, const char *name, void *opaque,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
CharBackend *be = object_field_prop_ptr(obj, opaque);
|
CharFrontend *fe = object_field_prop_ptr(obj, opaque);
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
p = g_strdup(be->chr && be->chr->label ? be->chr->label : "");
|
p = g_strdup(fe->chr && fe->chr->label ? fe->chr->label : "");
|
||||||
visit_type_str(v, name, &p, errp);
|
visit_type_str(v, name, &p, errp);
|
||||||
g_free(p);
|
g_free(p);
|
||||||
}
|
}
|
||||||
|
|
@ -271,7 +271,7 @@ static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,
|
||||||
{
|
{
|
||||||
ERRP_GUARD();
|
ERRP_GUARD();
|
||||||
const Property *prop = opaque;
|
const Property *prop = opaque;
|
||||||
CharBackend *be = object_field_prop_ptr(obj, prop);
|
CharFrontend *fe = object_field_prop_ptr(obj, prop);
|
||||||
Chardev *s;
|
Chardev *s;
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
|
|
@ -283,13 +283,13 @@ static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,
|
||||||
* TODO Should this really be an error? If no, the old value
|
* TODO Should this really be an error? If no, the old value
|
||||||
* needs to be released before we store the new one.
|
* needs to be released before we store the new one.
|
||||||
*/
|
*/
|
||||||
if (!check_prop_still_unset(obj, name, be->chr, str, false, errp)) {
|
if (!check_prop_still_unset(obj, name, fe->chr, str, false, errp)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!*str) {
|
if (!*str) {
|
||||||
g_free(str);
|
g_free(str);
|
||||||
be->chr = NULL;
|
fe->chr = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -297,7 +297,7 @@ static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,
|
||||||
if (s == NULL) {
|
if (s == NULL) {
|
||||||
error_setg(errp, "Property '%s.%s' can't find value '%s'",
|
error_setg(errp, "Property '%s.%s' can't find value '%s'",
|
||||||
object_get_typename(obj), name, str);
|
object_get_typename(obj), name, str);
|
||||||
} else if (!qemu_chr_fe_init(be, s, errp)) {
|
} else if (!qemu_chr_fe_init(fe, s, errp)) {
|
||||||
error_prepend(errp, "Property '%s.%s' can't take value '%s': ",
|
error_prepend(errp, "Property '%s.%s' can't take value '%s': ",
|
||||||
object_get_typename(obj), name, str);
|
object_get_typename(obj), name, str);
|
||||||
}
|
}
|
||||||
|
|
@ -307,9 +307,9 @@ static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,
|
||||||
static void release_chr(Object *obj, const char *name, void *opaque)
|
static void release_chr(Object *obj, const char *name, void *opaque)
|
||||||
{
|
{
|
||||||
const Property *prop = opaque;
|
const Property *prop = opaque;
|
||||||
CharBackend *be = object_field_prop_ptr(obj, prop);
|
CharFrontend *fe = object_field_prop_ptr(obj, prop);
|
||||||
|
|
||||||
qemu_chr_fe_deinit(be, false);
|
qemu_chr_fe_deinit(fe, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const PropertyInfo qdev_prop_chr = {
|
const PropertyInfo qdev_prop_chr = {
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ static void io_cpu_write(void *opaque, hwaddr addr,
|
||||||
ch = val;
|
ch = val;
|
||||||
debugout = serial_hd(0);
|
debugout = serial_hd(0);
|
||||||
if (debugout) {
|
if (debugout) {
|
||||||
qemu_chr_fe_write_all(debugout->be, &ch, 1);
|
qemu_chr_fe_write_all(debugout->fe, &ch, 1);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "%c", ch);
|
fprintf(stderr, "%c", ch);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(IPMIBmcExtern, IPMI_BMC_EXTERN)
|
||||||
struct IPMIBmcExtern {
|
struct IPMIBmcExtern {
|
||||||
IPMIBmc parent;
|
IPMIBmc parent;
|
||||||
|
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
|
|
||||||
bool connected;
|
bool connected;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ struct BostonState {
|
||||||
SerialMM *uart;
|
SerialMM *uart;
|
||||||
Clock *cpuclk;
|
Clock *cpuclk;
|
||||||
|
|
||||||
CharBackend lcd_display;
|
CharFrontend lcd_display;
|
||||||
char lcd_content[8];
|
char lcd_content[8];
|
||||||
bool lcd_inited;
|
bool lcd_inited;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ typedef struct {
|
||||||
uint32_t i2coe;
|
uint32_t i2coe;
|
||||||
uint32_t i2cout;
|
uint32_t i2cout;
|
||||||
uint32_t i2csel;
|
uint32_t i2csel;
|
||||||
CharBackend display;
|
CharFrontend display;
|
||||||
char display_text[9];
|
char display_text[9];
|
||||||
SerialMM *uart;
|
SerialMM *uart;
|
||||||
bool display_inited;
|
bool display_inited;
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ struct IVShmemState {
|
||||||
|
|
||||||
/* exactly one of these two may be set */
|
/* exactly one of these two may be set */
|
||||||
HostMemoryBackend *hostmem; /* with interrupts */
|
HostMemoryBackend *hostmem; /* with interrupts */
|
||||||
CharBackend server_chr; /* without interrupts */
|
CharFrontend server_chr; /* without interrupts */
|
||||||
|
|
||||||
/* registers */
|
/* registers */
|
||||||
uint32_t intrmask;
|
uint32_t intrmask;
|
||||||
|
|
|
||||||
|
|
@ -623,7 +623,7 @@ static uint64_t qtest_rtas_call(char *cmd, uint32_t nargs, uint64_t args,
|
||||||
return H_PARAMETER;
|
return H_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool spapr_qtest_callback(CharBackend *chr, gchar **words)
|
static bool spapr_qtest_callback(CharFrontend *chr, gchar **words)
|
||||||
{
|
{
|
||||||
if (strcmp(words[0], "rtas") == 0) {
|
if (strcmp(words[0], "rtas") == 0) {
|
||||||
uint64_t res, args, ret;
|
uint64_t res, args, ret;
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ static void csr_call(char *cmd, uint64_t cpu_num, int csrno, uint64_t *val)
|
||||||
g_assert(ret == RISCV_EXCP_NONE);
|
g_assert(ret == RISCV_EXCP_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool csr_qtest_callback(CharBackend *chr, gchar **words)
|
static bool csr_qtest_callback(CharFrontend *chr, gchar **words)
|
||||||
{
|
{
|
||||||
if (strcmp(words[0], "csr") == 0) {
|
if (strcmp(words[0], "csr") == 0) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ typedef struct PassthruState PassthruState;
|
||||||
|
|
||||||
struct PassthruState {
|
struct PassthruState {
|
||||||
CCIDCardState base;
|
CCIDCardState base;
|
||||||
CharBackend cs;
|
CharFrontend cs;
|
||||||
uint8_t vscard_in_data[VSCARD_IN_SIZE];
|
uint8_t vscard_in_data[VSCARD_IN_SIZE];
|
||||||
uint32_t vscard_in_pos;
|
uint32_t vscard_in_pos;
|
||||||
uint32_t vscard_in_hdr;
|
uint32_t vscard_in_hdr;
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ struct USBSerialState {
|
||||||
uint8_t xoff;
|
uint8_t xoff;
|
||||||
QEMUSerialSetParams params;
|
QEMUSerialSetParams params;
|
||||||
int latency; /* ms */
|
int latency; /* ms */
|
||||||
CharBackend cs;
|
CharFrontend cs;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TYPE_USB_SERIAL "usb-serial-dev"
|
#define TYPE_USB_SERIAL "usb-serial-dev"
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ struct PacketIdQueue {
|
||||||
struct USBRedirDevice {
|
struct USBRedirDevice {
|
||||||
USBDevice dev;
|
USBDevice dev;
|
||||||
/* Properties */
|
/* Properties */
|
||||||
CharBackend cs;
|
CharFrontend cs;
|
||||||
bool enable_streams;
|
bool enable_streams;
|
||||||
bool suppress_remote_wake;
|
bool suppress_remote_wake;
|
||||||
bool in_write;
|
bool in_write;
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ unsigned int vhost_get_free_memslots(void)
|
||||||
return UINT_MAX;
|
return UINT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool vhost_user_init(VhostUserState *user, CharBackend *chr, Error **errp)
|
bool vhost_user_init(VhostUserState *user, CharFrontend *chr, Error **errp)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -275,7 +275,7 @@ struct scrub_regions {
|
||||||
static int vhost_user_read_header(struct vhost_dev *dev, VhostUserMsg *msg)
|
static int vhost_user_read_header(struct vhost_dev *dev, VhostUserMsg *msg)
|
||||||
{
|
{
|
||||||
struct vhost_user *u = dev->opaque;
|
struct vhost_user *u = dev->opaque;
|
||||||
CharBackend *chr = u->user->chr;
|
CharFrontend *chr = u->user->chr;
|
||||||
uint8_t *p = (uint8_t *) msg;
|
uint8_t *p = (uint8_t *) msg;
|
||||||
int r, size = VHOST_USER_HDR_SIZE;
|
int r, size = VHOST_USER_HDR_SIZE;
|
||||||
|
|
||||||
|
|
@ -303,7 +303,7 @@ static int vhost_user_read_header(struct vhost_dev *dev, VhostUserMsg *msg)
|
||||||
static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
|
static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
|
||||||
{
|
{
|
||||||
struct vhost_user *u = dev->opaque;
|
struct vhost_user *u = dev->opaque;
|
||||||
CharBackend *chr = u->user->chr;
|
CharFrontend *chr = u->user->chr;
|
||||||
uint8_t *p = (uint8_t *) msg;
|
uint8_t *p = (uint8_t *) msg;
|
||||||
int r, size;
|
int r, size;
|
||||||
|
|
||||||
|
|
@ -383,7 +383,7 @@ static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg,
|
||||||
int *fds, int fd_num)
|
int *fds, int fd_num)
|
||||||
{
|
{
|
||||||
struct vhost_user *u = dev->opaque;
|
struct vhost_user *u = dev->opaque;
|
||||||
CharBackend *chr = u->user->chr;
|
CharFrontend *chr = u->user->chr;
|
||||||
int ret, size = VHOST_USER_HDR_SIZE + msg->hdr.size;
|
int ret, size = VHOST_USER_HDR_SIZE + msg->hdr.size;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -1680,7 +1680,7 @@ int vhost_user_get_shared_object(struct vhost_dev *dev, unsigned char *uuid,
|
||||||
int *dmabuf_fd)
|
int *dmabuf_fd)
|
||||||
{
|
{
|
||||||
struct vhost_user *u = dev->opaque;
|
struct vhost_user *u = dev->opaque;
|
||||||
CharBackend *chr = u->user->chr;
|
CharFrontend *chr = u->user->chr;
|
||||||
int ret;
|
int ret;
|
||||||
VhostUserMsg msg = {
|
VhostUserMsg msg = {
|
||||||
.hdr.request = VHOST_USER_GET_SHARED_OBJECT,
|
.hdr.request = VHOST_USER_GET_SHARED_OBJECT,
|
||||||
|
|
@ -1721,7 +1721,7 @@ vhost_user_backend_handle_shared_object_lookup(struct vhost_user *u,
|
||||||
VhostUserPayload *payload)
|
VhostUserPayload *payload)
|
||||||
{
|
{
|
||||||
QemuUUID uuid;
|
QemuUUID uuid;
|
||||||
CharBackend *chr = u->user->chr;
|
CharFrontend *chr = u->user->chr;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
int dmabuf_fd = -1;
|
int dmabuf_fd = -1;
|
||||||
int fd_num = 0;
|
int fd_num = 0;
|
||||||
|
|
@ -2004,7 +2004,7 @@ static int vhost_user_postcopy_advise(struct vhost_dev *dev, Error **errp)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_LINUX
|
#ifdef CONFIG_LINUX
|
||||||
struct vhost_user *u = dev->opaque;
|
struct vhost_user *u = dev->opaque;
|
||||||
CharBackend *chr = u->user->chr;
|
CharFrontend *chr = u->user->chr;
|
||||||
int ufd;
|
int ufd;
|
||||||
int ret;
|
int ret;
|
||||||
VhostUserMsg msg = {
|
VhostUserMsg msg = {
|
||||||
|
|
@ -2670,7 +2670,7 @@ static int vhost_user_get_inflight_fd(struct vhost_dev *dev,
|
||||||
int fd;
|
int fd;
|
||||||
int ret;
|
int ret;
|
||||||
struct vhost_user *u = dev->opaque;
|
struct vhost_user *u = dev->opaque;
|
||||||
CharBackend *chr = u->user->chr;
|
CharFrontend *chr = u->user->chr;
|
||||||
VhostUserMsg msg = {
|
VhostUserMsg msg = {
|
||||||
.hdr.request = VHOST_USER_GET_INFLIGHT_FD,
|
.hdr.request = VHOST_USER_GET_INFLIGHT_FD,
|
||||||
.hdr.flags = VHOST_USER_VERSION,
|
.hdr.flags = VHOST_USER_VERSION,
|
||||||
|
|
@ -2761,7 +2761,7 @@ static void vhost_user_state_destroy(gpointer data)
|
||||||
vhost_user_host_notifier_remove(n, NULL, true);
|
vhost_user_host_notifier_remove(n, NULL, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool vhost_user_init(VhostUserState *user, CharBackend *chr, Error **errp)
|
bool vhost_user_init(VhostUserState *user, CharFrontend *chr, Error **errp)
|
||||||
{
|
{
|
||||||
if (user->chr) {
|
if (user->chr) {
|
||||||
error_setg(errp, "Cannot initialize vhost-user state");
|
error_setg(errp, "Cannot initialize vhost-user state");
|
||||||
|
|
@ -2787,7 +2787,7 @@ void vhost_user_cleanup(VhostUserState *user)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
vu_async_close_fn cb;
|
vu_async_close_fn cb;
|
||||||
DeviceState *dev;
|
DeviceState *dev;
|
||||||
CharBackend *cd;
|
CharFrontend *cd;
|
||||||
struct vhost_dev *vhost;
|
struct vhost_dev *vhost;
|
||||||
} VhostAsyncCallback;
|
} VhostAsyncCallback;
|
||||||
|
|
||||||
|
|
@ -2806,7 +2806,7 @@ static void vhost_user_async_close_bh(void *opaque)
|
||||||
* purposes.
|
* purposes.
|
||||||
*/
|
*/
|
||||||
void vhost_user_async_close(DeviceState *d,
|
void vhost_user_async_close(DeviceState *d,
|
||||||
CharBackend *chardev, struct vhost_dev *vhost,
|
CharFrontend *chardev, struct vhost_dev *vhost,
|
||||||
vu_async_close_fn cb)
|
vu_async_close_fn cb)
|
||||||
{
|
{
|
||||||
if (!runstate_check(RUN_STATE_SHUTDOWN)) {
|
if (!runstate_check(RUN_STATE_SHUTDOWN)) {
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,12 @@ typedef void IOEventHandler(void *opaque, QEMUChrEvent event);
|
||||||
typedef int BackendChangeHandler(void *opaque);
|
typedef int BackendChangeHandler(void *opaque);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct CharBackend - back end as seen by front end
|
* struct CharFrontend - Chardev as seen by front end
|
||||||
* @fe_is_open: the front end is ready for IO
|
* @fe_is_open: the front end is ready for IO
|
||||||
*
|
*
|
||||||
* The actual backend is Chardev
|
* The actual backend is Chardev
|
||||||
*/
|
*/
|
||||||
struct CharBackend {
|
struct CharFrontend {
|
||||||
Chardev *chr;
|
Chardev *chr;
|
||||||
IOEventHandler *chr_event;
|
IOEventHandler *chr_event;
|
||||||
IOCanReadHandler *chr_can_read;
|
IOCanReadHandler *chr_can_read;
|
||||||
|
|
@ -27,53 +27,52 @@ struct CharBackend {
|
||||||
/**
|
/**
|
||||||
* qemu_chr_fe_init:
|
* qemu_chr_fe_init:
|
||||||
*
|
*
|
||||||
* Initializes a front end for the given CharBackend and
|
* Initializes the frontend @c for the given Chardev backend @s. Call
|
||||||
* Chardev. Call qemu_chr_fe_deinit() to remove the association and
|
* qemu_chr_fe_deinit() to remove the association and release the backend.
|
||||||
* release the driver.
|
|
||||||
*
|
*
|
||||||
* Returns: false on error.
|
* Returns: false on error.
|
||||||
*/
|
*/
|
||||||
bool qemu_chr_fe_init(CharBackend *b, Chardev *s, Error **errp);
|
bool qemu_chr_fe_init(CharFrontend *c, Chardev *be, Error **errp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemu_chr_fe_deinit:
|
* qemu_chr_fe_deinit:
|
||||||
* @b: a CharBackend
|
* @c: a CharFrontend
|
||||||
* @del: if true, delete the chardev backend
|
* @del: if true, delete the chardev backend
|
||||||
*
|
*
|
||||||
* Dissociate the CharBackend from the Chardev.
|
* Dissociate the CharFrontend from the Chardev.
|
||||||
*
|
*
|
||||||
* Safe to call without associated Chardev.
|
* Safe to call without associated Chardev.
|
||||||
*/
|
*/
|
||||||
void qemu_chr_fe_deinit(CharBackend *b, bool del);
|
void qemu_chr_fe_deinit(CharFrontend *c, bool del);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemu_chr_fe_get_driver:
|
* qemu_chr_fe_get_driver:
|
||||||
*
|
*
|
||||||
* Returns: the driver associated with a CharBackend or NULL if no
|
* Returns: the driver associated with a CharFrontend or NULL if no
|
||||||
* associated Chardev.
|
* associated Chardev.
|
||||||
* Note: avoid this function as the driver should never be accessed directly,
|
* Note: avoid this function as the driver should never be accessed directly,
|
||||||
* especially by the frontends that support chardevice hotswap.
|
* especially by the frontends that support chardevice hotswap.
|
||||||
* Consider qemu_chr_fe_backend_connected() to check for driver existence
|
* Consider qemu_chr_fe_backend_connected() to check for driver existence
|
||||||
*/
|
*/
|
||||||
Chardev *qemu_chr_fe_get_driver(CharBackend *be);
|
Chardev *qemu_chr_fe_get_driver(CharFrontend *c);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemu_chr_fe_backend_connected:
|
* qemu_chr_fe_backend_connected:
|
||||||
*
|
*
|
||||||
* Returns: true if there is a chardevice associated with @be.
|
* Returns: true if there is a backend associated with @c.
|
||||||
*/
|
*/
|
||||||
bool qemu_chr_fe_backend_connected(CharBackend *be);
|
bool qemu_chr_fe_backend_connected(CharFrontend *c);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemu_chr_fe_backend_open:
|
* qemu_chr_fe_backend_open:
|
||||||
*
|
*
|
||||||
* Returns: true if chardevice associated with @be is open.
|
* Returns: true if the backend associated with @c is open.
|
||||||
*/
|
*/
|
||||||
bool qemu_chr_fe_backend_open(CharBackend *be);
|
bool qemu_chr_fe_backend_open(CharFrontend *c);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemu_chr_fe_set_handlers_full:
|
* qemu_chr_fe_set_handlers_full:
|
||||||
* @b: a CharBackend
|
* @c: a CharFrontend
|
||||||
* @fd_can_read: callback to get the amount of data the frontend may
|
* @fd_can_read: callback to get the amount of data the frontend may
|
||||||
* receive
|
* receive
|
||||||
* @fd_read: callback to receive data from char
|
* @fd_read: callback to receive data from char
|
||||||
|
|
@ -91,7 +90,7 @@ bool qemu_chr_fe_backend_open(CharBackend *be);
|
||||||
*
|
*
|
||||||
* Without associated Chardev, nothing is changed.
|
* Without associated Chardev, nothing is changed.
|
||||||
*/
|
*/
|
||||||
void qemu_chr_fe_set_handlers_full(CharBackend *b,
|
void qemu_chr_fe_set_handlers_full(CharFrontend *c,
|
||||||
IOCanReadHandler *fd_can_read,
|
IOCanReadHandler *fd_can_read,
|
||||||
IOReadHandler *fd_read,
|
IOReadHandler *fd_read,
|
||||||
IOEventHandler *fd_event,
|
IOEventHandler *fd_event,
|
||||||
|
|
@ -106,7 +105,7 @@ void qemu_chr_fe_set_handlers_full(CharBackend *b,
|
||||||
*
|
*
|
||||||
* Version of qemu_chr_fe_set_handlers_full() with sync_state = true.
|
* Version of qemu_chr_fe_set_handlers_full() with sync_state = true.
|
||||||
*/
|
*/
|
||||||
void qemu_chr_fe_set_handlers(CharBackend *b,
|
void qemu_chr_fe_set_handlers(CharFrontend *c,
|
||||||
IOCanReadHandler *fd_can_read,
|
IOCanReadHandler *fd_can_read,
|
||||||
IOReadHandler *fd_read,
|
IOReadHandler *fd_read,
|
||||||
IOEventHandler *fd_event,
|
IOEventHandler *fd_event,
|
||||||
|
|
@ -122,14 +121,14 @@ void qemu_chr_fe_set_handlers(CharBackend *b,
|
||||||
*
|
*
|
||||||
* Without associated Chardev, nothing is changed.
|
* Without associated Chardev, nothing is changed.
|
||||||
*/
|
*/
|
||||||
void qemu_chr_fe_take_focus(CharBackend *b);
|
void qemu_chr_fe_take_focus(CharFrontend *c);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemu_chr_fe_accept_input:
|
* qemu_chr_fe_accept_input:
|
||||||
*
|
*
|
||||||
* Notify that the frontend is ready to receive data
|
* Notify that the frontend is ready to receive data
|
||||||
*/
|
*/
|
||||||
void qemu_chr_fe_accept_input(CharBackend *be);
|
void qemu_chr_fe_accept_input(CharFrontend *c);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemu_chr_fe_disconnect:
|
* qemu_chr_fe_disconnect:
|
||||||
|
|
@ -137,7 +136,7 @@ void qemu_chr_fe_accept_input(CharBackend *be);
|
||||||
* Close a fd accepted by character backend.
|
* Close a fd accepted by character backend.
|
||||||
* Without associated Chardev, do nothing.
|
* Without associated Chardev, do nothing.
|
||||||
*/
|
*/
|
||||||
void qemu_chr_fe_disconnect(CharBackend *be);
|
void qemu_chr_fe_disconnect(CharFrontend *c);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemu_chr_fe_wait_connected:
|
* qemu_chr_fe_wait_connected:
|
||||||
|
|
@ -145,7 +144,7 @@ void qemu_chr_fe_disconnect(CharBackend *be);
|
||||||
* Wait for character backend to be connected, return < 0 on error or
|
* Wait for character backend to be connected, return < 0 on error or
|
||||||
* if no associated Chardev.
|
* if no associated Chardev.
|
||||||
*/
|
*/
|
||||||
int qemu_chr_fe_wait_connected(CharBackend *be, Error **errp);
|
int qemu_chr_fe_wait_connected(CharFrontend *c, Error **errp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemu_chr_fe_set_echo:
|
* qemu_chr_fe_set_echo:
|
||||||
|
|
@ -156,17 +155,17 @@ int qemu_chr_fe_wait_connected(CharBackend *be, Error **errp);
|
||||||
* can see what you type if you try to type QMP commands.
|
* can see what you type if you try to type QMP commands.
|
||||||
* Without associated Chardev, do nothing.
|
* Without associated Chardev, do nothing.
|
||||||
*/
|
*/
|
||||||
void qemu_chr_fe_set_echo(CharBackend *be, bool echo);
|
void qemu_chr_fe_set_echo(CharFrontend *c, bool echo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemu_chr_fe_set_open:
|
* qemu_chr_fe_set_open:
|
||||||
* @be: a CharBackend
|
* @c: a CharFrontend
|
||||||
* @is_open: the front end open status
|
* @is_open: the front end open status
|
||||||
*
|
*
|
||||||
* This is an indication that the front end is ready (or not) to begin
|
* This is an indication that the front end is ready (or not) to begin
|
||||||
* doing I/O. Without associated Chardev, do nothing.
|
* doing I/O. Without associated Chardev, do nothing.
|
||||||
*/
|
*/
|
||||||
void qemu_chr_fe_set_open(CharBackend *be, bool is_open);
|
void qemu_chr_fe_set_open(CharFrontend *c, bool is_open);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemu_chr_fe_printf:
|
* qemu_chr_fe_printf:
|
||||||
|
|
@ -176,7 +175,7 @@ void qemu_chr_fe_set_open(CharBackend *be, bool is_open);
|
||||||
* function is thread-safe. It does nothing without associated
|
* function is thread-safe. It does nothing without associated
|
||||||
* Chardev.
|
* Chardev.
|
||||||
*/
|
*/
|
||||||
void qemu_chr_fe_printf(CharBackend *be, const char *fmt, ...)
|
void qemu_chr_fe_printf(CharFrontend *c, const char *fmt, ...)
|
||||||
G_GNUC_PRINTF(2, 3);
|
G_GNUC_PRINTF(2, 3);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -215,7 +214,7 @@ typedef gboolean (*FEWatchFunc)(void *do_not_use, GIOCondition condition, void *
|
||||||
*
|
*
|
||||||
* Returns: the source tag
|
* Returns: the source tag
|
||||||
*/
|
*/
|
||||||
guint qemu_chr_fe_add_watch(CharBackend *be, GIOCondition cond,
|
guint qemu_chr_fe_add_watch(CharFrontend *c, GIOCondition cond,
|
||||||
FEWatchFunc func, void *user_data);
|
FEWatchFunc func, void *user_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -230,7 +229,7 @@ guint qemu_chr_fe_add_watch(CharBackend *be, GIOCondition cond,
|
||||||
* Returns: the number of bytes consumed (0 if no associated Chardev)
|
* Returns: the number of bytes consumed (0 if no associated Chardev)
|
||||||
* or -1 on error.
|
* or -1 on error.
|
||||||
*/
|
*/
|
||||||
int qemu_chr_fe_write(CharBackend *be, const uint8_t *buf, int len);
|
int qemu_chr_fe_write(CharFrontend *c, const uint8_t *buf, int len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemu_chr_fe_write_all:
|
* qemu_chr_fe_write_all:
|
||||||
|
|
@ -245,7 +244,7 @@ int qemu_chr_fe_write(CharBackend *be, const uint8_t *buf, int len);
|
||||||
* Returns: the number of bytes consumed (0 if no associated Chardev)
|
* Returns: the number of bytes consumed (0 if no associated Chardev)
|
||||||
* or -1 on error.
|
* or -1 on error.
|
||||||
*/
|
*/
|
||||||
int qemu_chr_fe_write_all(CharBackend *be, const uint8_t *buf, int len);
|
int qemu_chr_fe_write_all(CharFrontend *c, const uint8_t *buf, int len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemu_chr_fe_read_all:
|
* qemu_chr_fe_read_all:
|
||||||
|
|
@ -257,7 +256,7 @@ int qemu_chr_fe_write_all(CharBackend *be, const uint8_t *buf, int len);
|
||||||
* Returns: the number of bytes read (0 if no associated Chardev)
|
* Returns: the number of bytes read (0 if no associated Chardev)
|
||||||
* or -1 on error.
|
* or -1 on error.
|
||||||
*/
|
*/
|
||||||
int qemu_chr_fe_read_all(CharBackend *be, uint8_t *buf, int len);
|
int qemu_chr_fe_read_all(CharFrontend *c, uint8_t *buf, int len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemu_chr_fe_ioctl:
|
* qemu_chr_fe_ioctl:
|
||||||
|
|
@ -270,7 +269,7 @@ int qemu_chr_fe_read_all(CharBackend *be, uint8_t *buf, int len);
|
||||||
* associated Chardev, -ENOTSUP, otherwise the return
|
* associated Chardev, -ENOTSUP, otherwise the return
|
||||||
* value depends on the semantics of @cmd
|
* value depends on the semantics of @cmd
|
||||||
*/
|
*/
|
||||||
int qemu_chr_fe_ioctl(CharBackend *be, int cmd, void *arg);
|
int qemu_chr_fe_ioctl(CharFrontend *c, int cmd, void *arg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemu_chr_fe_get_msgfd:
|
* qemu_chr_fe_get_msgfd:
|
||||||
|
|
@ -283,7 +282,7 @@ int qemu_chr_fe_ioctl(CharBackend *be, int cmd, void *arg);
|
||||||
* this function will return -1 until a client sends a new file
|
* this function will return -1 until a client sends a new file
|
||||||
* descriptor.
|
* descriptor.
|
||||||
*/
|
*/
|
||||||
int qemu_chr_fe_get_msgfd(CharBackend *be);
|
int qemu_chr_fe_get_msgfd(CharFrontend *c);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemu_chr_fe_get_msgfds:
|
* qemu_chr_fe_get_msgfds:
|
||||||
|
|
@ -296,7 +295,7 @@ int qemu_chr_fe_get_msgfd(CharBackend *be);
|
||||||
* this function will return -1 until a client sends a new set of file
|
* this function will return -1 until a client sends a new set of file
|
||||||
* descriptors.
|
* descriptors.
|
||||||
*/
|
*/
|
||||||
int qemu_chr_fe_get_msgfds(CharBackend *be, int *fds, int num);
|
int qemu_chr_fe_get_msgfds(CharFrontend *c, int *fds, int num);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemu_chr_fe_set_msgfds:
|
* qemu_chr_fe_set_msgfds:
|
||||||
|
|
@ -309,6 +308,6 @@ int qemu_chr_fe_get_msgfds(CharBackend *be, int *fds, int num);
|
||||||
*
|
*
|
||||||
* Returns: -1 if fd passing isn't supported or no associated Chardev.
|
* Returns: -1 if fd passing isn't supported or no associated Chardev.
|
||||||
*/
|
*/
|
||||||
int qemu_chr_fe_set_msgfds(CharBackend *be, int *fds, int num);
|
int qemu_chr_fe_set_msgfds(CharFrontend *c, int *fds, int num);
|
||||||
|
|
||||||
#endif /* QEMU_CHAR_FE_H */
|
#endif /* QEMU_CHAR_FE_H */
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
#define IAC 255
|
#define IAC 255
|
||||||
|
|
||||||
/* character device */
|
/* character device */
|
||||||
typedef struct CharBackend CharBackend;
|
typedef struct CharFrontend CharFrontend;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CHR_EVENT_BREAK, /* serial break char */
|
CHR_EVENT_BREAK, /* serial break char */
|
||||||
|
|
@ -60,7 +60,7 @@ struct Chardev {
|
||||||
Object parent_obj;
|
Object parent_obj;
|
||||||
|
|
||||||
QemuMutex chr_write_lock;
|
QemuMutex chr_write_lock;
|
||||||
CharBackend *be;
|
CharFrontend *fe;
|
||||||
char *label;
|
char *label;
|
||||||
char *filename;
|
char *filename;
|
||||||
int logfd;
|
int logfd;
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ struct AVRUsartState {
|
||||||
/* <public> */
|
/* <public> */
|
||||||
MemoryRegion mmio;
|
MemoryRegion mmio;
|
||||||
|
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
|
|
||||||
bool enabled;
|
bool enabled;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ struct BCM2835AuxState {
|
||||||
/*< public >*/
|
/*< public >*/
|
||||||
|
|
||||||
MemoryRegion iomem;
|
MemoryRegion iomem;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
qemu_irq irq;
|
qemu_irq irq;
|
||||||
|
|
||||||
uint8_t read_fifo[BCM2835_AUX_RX_FIFO_LEN];
|
uint8_t read_fifo[BCM2835_AUX_RX_FIFO_LEN];
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ struct CadenceUARTState {
|
||||||
uint32_t rx_count;
|
uint32_t rx_count;
|
||||||
uint32_t tx_count;
|
uint32_t tx_count;
|
||||||
uint64_t char_tx_time;
|
uint64_t char_tx_time;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
qemu_irq irq;
|
qemu_irq irq;
|
||||||
QEMUTimer *fifo_trigger_handle;
|
QEMUTimer *fifo_trigger_handle;
|
||||||
Clock *refclk;
|
Clock *refclk;
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ struct CMSDKAPBUART {
|
||||||
|
|
||||||
/*< public >*/
|
/*< public >*/
|
||||||
MemoryRegion iomem;
|
MemoryRegion iomem;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
qemu_irq txint;
|
qemu_irq txint;
|
||||||
qemu_irq rxint;
|
qemu_irq rxint;
|
||||||
qemu_irq txovrint;
|
qemu_irq txovrint;
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ struct DigicUartState {
|
||||||
/*< public >*/
|
/*< public >*/
|
||||||
|
|
||||||
MemoryRegion regs_region;
|
MemoryRegion regs_region;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
|
|
||||||
uint32_t reg_rx;
|
uint32_t reg_rx;
|
||||||
uint32_t reg_st;
|
uint32_t reg_st;
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ typedef struct ESCCChannelState {
|
||||||
uint32_t reg;
|
uint32_t reg;
|
||||||
uint8_t wregs[ESCC_SERIAL_REGS], rregs[ESCC_SERIAL_REGS];
|
uint8_t wregs[ESCC_SERIAL_REGS], rregs[ESCC_SERIAL_REGS];
|
||||||
ESCCSERIOQueue queue;
|
ESCCSERIOQueue queue;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
int e0_mode, led_mode, caps_lock_mode, num_lock_mode;
|
int e0_mode, led_mode, caps_lock_mode, num_lock_mode;
|
||||||
int disabled;
|
int disabled;
|
||||||
int clock;
|
int clock;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ struct GoldfishTTYState {
|
||||||
|
|
||||||
MemoryRegion iomem;
|
MemoryRegion iomem;
|
||||||
qemu_irq irq;
|
qemu_irq irq;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
|
|
||||||
uint32_t data_len;
|
uint32_t data_len;
|
||||||
uint64_t data_ptr;
|
uint64_t data_ptr;
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ struct IbexUartState {
|
||||||
|
|
||||||
Clock *f_clk;
|
Clock *f_clk;
|
||||||
|
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
qemu_irq tx_watermark;
|
qemu_irq tx_watermark;
|
||||||
qemu_irq rx_watermark;
|
qemu_irq rx_watermark;
|
||||||
qemu_irq tx_empty;
|
qemu_irq tx_empty;
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ struct IMXSerialState {
|
||||||
uint32_t ucr4;
|
uint32_t ucr4;
|
||||||
|
|
||||||
qemu_irq irq;
|
qemu_irq irq;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ struct Max78000UartState {
|
||||||
|
|
||||||
Fifo8 rx_fifo;
|
Fifo8 rx_fifo;
|
||||||
|
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
qemu_irq irq;
|
qemu_irq irq;
|
||||||
};
|
};
|
||||||
#endif /* HW_STM32F2XX_USART_H */
|
#endif /* HW_STM32F2XX_USART_H */
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ struct NRF51UARTState {
|
||||||
SysBusDevice parent_obj;
|
SysBusDevice parent_obj;
|
||||||
|
|
||||||
MemoryRegion iomem;
|
MemoryRegion iomem;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
qemu_irq irq;
|
qemu_irq irq;
|
||||||
guint watch_tag;
|
guint watch_tag;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ typedef struct ParallelState {
|
||||||
uint8_t control;
|
uint8_t control;
|
||||||
qemu_irq irq;
|
qemu_irq irq;
|
||||||
int irq_pending;
|
int irq_pending;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
int hw_driver;
|
int hw_driver;
|
||||||
int epp_timeout;
|
int epp_timeout;
|
||||||
uint32_t last_read_offset; /* For debugging */
|
uint32_t last_read_offset; /* For debugging */
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ struct PL011State {
|
||||||
int read_pos;
|
int read_pos;
|
||||||
int read_count;
|
int read_count;
|
||||||
int read_trigger;
|
int read_trigger;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
qemu_irq irq[6];
|
qemu_irq irq[6];
|
||||||
Clock *clk;
|
Clock *clk;
|
||||||
bool migrate_clk;
|
bool migrate_clk;
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ struct RSCIState {
|
||||||
|
|
||||||
MemoryRegion memory;
|
MemoryRegion memory;
|
||||||
QEMUTimer timer;
|
QEMUTimer timer;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
qemu_irq irq[SCI_NR_IRQ];
|
qemu_irq irq[SCI_NR_IRQ];
|
||||||
|
|
||||||
uint8_t smr;
|
uint8_t smr;
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ typedef struct HTIFState {
|
||||||
hwaddr fromhost_offset;
|
hwaddr fromhost_offset;
|
||||||
MemoryRegion mmio;
|
MemoryRegion mmio;
|
||||||
|
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
uint64_t pending_read;
|
uint64_t pending_read;
|
||||||
} HTIFState;
|
} HTIFState;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ struct SerialState {
|
||||||
it can be reset while reading iir */
|
it can be reset while reading iir */
|
||||||
int thr_ipending;
|
int thr_ipending;
|
||||||
qemu_irq irq;
|
qemu_irq irq;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
int last_break_enable;
|
int last_break_enable;
|
||||||
uint32_t baudbase;
|
uint32_t baudbase;
|
||||||
uint32_t tsr_retry;
|
uint32_t tsr_retry;
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ typedef struct {
|
||||||
uint32_t uart_iq_cycles;
|
uint32_t uart_iq_cycles;
|
||||||
uint32_t uart_rx_threshold;
|
uint32_t uart_rx_threshold;
|
||||||
|
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
} ShaktiUartState;
|
} ShaktiUartState;
|
||||||
|
|
||||||
#endif /* HW_SHAKTI_UART_H */
|
#endif /* HW_SHAKTI_UART_H */
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ struct SiFiveUARTState {
|
||||||
/*< public >*/
|
/*< public >*/
|
||||||
qemu_irq irq;
|
qemu_irq irq;
|
||||||
MemoryRegion mmio;
|
MemoryRegion mmio;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
|
|
||||||
uint32_t txfifo;
|
uint32_t txfifo;
|
||||||
uint32_t ie;
|
uint32_t ie;
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ struct STM32F2XXUsartState {
|
||||||
uint32_t usart_cr3;
|
uint32_t usart_cr3;
|
||||||
uint32_t usart_gtpr;
|
uint32_t usart_gtpr;
|
||||||
|
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
qemu_irq irq;
|
qemu_irq irq;
|
||||||
};
|
};
|
||||||
#endif /* HW_STM32F2XX_USART_H */
|
#endif /* HW_STM32F2XX_USART_H */
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ struct Stm32l4x5UsartBaseState {
|
||||||
uint32_t tdr;
|
uint32_t tdr;
|
||||||
|
|
||||||
Clock *clk;
|
Clock *clk;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
qemu_irq irq;
|
qemu_irq irq;
|
||||||
guint watch_tag;
|
guint watch_tag;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ struct IvshmemFTState {
|
||||||
QTAILQ_HEAD(, IvshmemPeer) peer;
|
QTAILQ_HEAD(, IvshmemPeer) peer;
|
||||||
IvshmemPeer own;
|
IvshmemPeer own;
|
||||||
|
|
||||||
CharBackend server_chr;
|
CharFrontend server_chr;
|
||||||
|
|
||||||
/* IRQ */
|
/* IRQ */
|
||||||
qemu_irq irq;
|
qemu_irq irq;
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ extern const PropertyInfo qdev_prop_virtio_gpu_output_list;
|
||||||
DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t)
|
DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t)
|
||||||
|
|
||||||
#define DEFINE_PROP_CHR(_n, _s, _f) \
|
#define DEFINE_PROP_CHR(_n, _s, _f) \
|
||||||
DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharBackend)
|
DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharFrontend)
|
||||||
#define DEFINE_PROP_NETDEV(_n, _s, _f) \
|
#define DEFINE_PROP_NETDEV(_n, _s, _f) \
|
||||||
DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, NICPeers)
|
DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, NICPeers)
|
||||||
#define DEFINE_PROP_DRIVE(_n, _s, _f) \
|
#define DEFINE_PROP_DRIVE(_n, _s, _f) \
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ struct VHostUserBase {
|
||||||
VirtIODevice parent_obj;
|
VirtIODevice parent_obj;
|
||||||
|
|
||||||
/* Properties */
|
/* Properties */
|
||||||
CharBackend chardev;
|
CharFrontend chardev;
|
||||||
uint16_t virtio_id;
|
uint16_t virtio_id;
|
||||||
uint32_t num_vqs;
|
uint32_t num_vqs;
|
||||||
uint32_t vq_size; /* can't exceed VIRTIO_QUEUE_MAX */
|
uint32_t vq_size; /* can't exceed VIRTIO_QUEUE_MAX */
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(VHostUserBlk, VHOST_USER_BLK)
|
||||||
|
|
||||||
struct VHostUserBlk {
|
struct VHostUserBlk {
|
||||||
VirtIODevice parent_obj;
|
VirtIODevice parent_obj;
|
||||||
CharBackend chardev;
|
CharFrontend chardev;
|
||||||
int32_t bootindex;
|
int32_t bootindex;
|
||||||
struct virtio_blk_config blkcfg;
|
struct virtio_blk_config blkcfg;
|
||||||
uint16_t num_queues;
|
uint16_t num_queues;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
OBJECT_DECLARE_SIMPLE_TYPE(VHostUserFS, VHOST_USER_FS)
|
OBJECT_DECLARE_SIMPLE_TYPE(VHostUserFS, VHOST_USER_FS)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
CharBackend chardev;
|
CharFrontend chardev;
|
||||||
char *tag;
|
char *tag;
|
||||||
uint16_t num_request_queues;
|
uint16_t num_request_queues;
|
||||||
uint16_t queue_size;
|
uint16_t queue_size;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(VHostUserSCMI, VHOST_USER_SCMI);
|
||||||
|
|
||||||
struct VHostUserSCMI {
|
struct VHostUserSCMI {
|
||||||
VirtIODevice parent;
|
VirtIODevice parent;
|
||||||
CharBackend chardev;
|
CharFrontend chardev;
|
||||||
struct vhost_virtqueue *vhost_vqs;
|
struct vhost_virtqueue *vhost_vqs;
|
||||||
struct vhost_dev vhost_dev;
|
struct vhost_dev vhost_dev;
|
||||||
VhostUserState vhost_user;
|
VhostUserState vhost_user;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
OBJECT_DECLARE_SIMPLE_TYPE(VHostUserVSock, VHOST_USER_VSOCK)
|
OBJECT_DECLARE_SIMPLE_TYPE(VHostUserVSock, VHOST_USER_VSOCK)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
CharBackend chardev;
|
CharFrontend chardev;
|
||||||
} VHostUserVSockConf;
|
} VHostUserVSockConf;
|
||||||
|
|
||||||
struct VHostUserVSock {
|
struct VHostUserVSock {
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ typedef struct VhostUserHostNotifier {
|
||||||
* @memory_slots:
|
* @memory_slots:
|
||||||
*/
|
*/
|
||||||
typedef struct VhostUserState {
|
typedef struct VhostUserState {
|
||||||
CharBackend *chr;
|
CharFrontend *chr;
|
||||||
GPtrArray *notifiers;
|
GPtrArray *notifiers;
|
||||||
int memory_slots;
|
int memory_slots;
|
||||||
bool supports_config;
|
bool supports_config;
|
||||||
|
|
@ -82,7 +82,7 @@ typedef struct VhostUserState {
|
||||||
*
|
*
|
||||||
* Return: true on success, false on error while setting errp.
|
* Return: true on success, false on error while setting errp.
|
||||||
*/
|
*/
|
||||||
bool vhost_user_init(VhostUserState *user, CharBackend *chr, Error **errp);
|
bool vhost_user_init(VhostUserState *user, CharFrontend *chr, Error **errp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* vhost_user_cleanup() - cleanup state
|
* vhost_user_cleanup() - cleanup state
|
||||||
|
|
@ -96,7 +96,7 @@ void vhost_user_cleanup(VhostUserState *user);
|
||||||
/**
|
/**
|
||||||
* vhost_user_async_close() - cleanup vhost-user post connection drop
|
* vhost_user_async_close() - cleanup vhost-user post connection drop
|
||||||
* @d: DeviceState for the associated device (passed to callback)
|
* @d: DeviceState for the associated device (passed to callback)
|
||||||
* @chardev: the CharBackend associated with the connection
|
* @chardev: the CharFrontend associated with the connection
|
||||||
* @vhost: the common vhost device
|
* @vhost: the common vhost device
|
||||||
* @cb: the user callback function to complete the clean-up
|
* @cb: the user callback function to complete the clean-up
|
||||||
*
|
*
|
||||||
|
|
@ -108,7 +108,7 @@ void vhost_user_cleanup(VhostUserState *user);
|
||||||
typedef void (*vu_async_close_fn)(DeviceState *cb);
|
typedef void (*vu_async_close_fn)(DeviceState *cb);
|
||||||
|
|
||||||
void vhost_user_async_close(DeviceState *d,
|
void vhost_user_async_close(DeviceState *d,
|
||||||
CharBackend *chardev, struct vhost_dev *vhost,
|
CharFrontend *chardev, struct vhost_dev *vhost,
|
||||||
vu_async_close_fn cb);
|
vu_async_close_fn cb);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -257,7 +257,7 @@ struct VhostUserGPU {
|
||||||
|
|
||||||
VhostUserBackend *vhost;
|
VhostUserBackend *vhost;
|
||||||
int vhost_gpu_fd; /* closed by the chardev */
|
int vhost_gpu_fd; /* closed by the chardev */
|
||||||
CharBackend vhost_chr;
|
CharFrontend vhost_chr;
|
||||||
QemuDmaBuf *dmabuf[VIRTIO_GPU_MAX_SCANOUTS];
|
QemuDmaBuf *dmabuf[VIRTIO_GPU_MAX_SCANOUTS];
|
||||||
bool backend_blocked;
|
bool backend_blocked;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ struct VirtIOSCSIConf {
|
||||||
uint32_t cmd_per_lun;
|
uint32_t cmd_per_lun;
|
||||||
char *vhostfd;
|
char *vhostfd;
|
||||||
char *wwpn;
|
char *wwpn;
|
||||||
CharBackend chardev;
|
CharFrontend chardev;
|
||||||
uint32_t boot_tpgt;
|
uint32_t boot_tpgt;
|
||||||
IOThread *iothread;
|
IOThread *iothread;
|
||||||
IOThreadVirtQueueMappingList *iothread_vq_mapping_list;
|
IOThreadVirtQueueMappingList *iothread_vq_mapping_list;
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ static inline bool qtest_enabled(void)
|
||||||
return qtest_allowed;
|
return qtest_allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void G_GNUC_PRINTF(2, 3) qtest_sendf(CharBackend *chr, const char *fmt, ...);
|
void G_GNUC_PRINTF(2, 3) qtest_sendf(CharFrontend *chr, const char *fmt, ...);
|
||||||
void qtest_set_command_cb(bool (*pc_cb)(CharBackend *chr, gchar **words));
|
void qtest_set_command_cb(bool (*pc_cb)(CharFrontend *chr, gchar **words));
|
||||||
bool qtest_driver(void);
|
bool qtest_driver(void);
|
||||||
|
|
||||||
void qtest_server_init(const char *qtest_chrdev, const char *qtest_log, Error **errp);
|
void qtest_server_init(const char *qtest_chrdev, const char *qtest_log, Error **errp);
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ struct VhostUserBackend {
|
||||||
Object parent;
|
Object parent;
|
||||||
|
|
||||||
char *chr_name;
|
char *chr_name;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
VhostUserState vhost_user;
|
VhostUserState vhost_user;
|
||||||
struct vhost_dev dev;
|
struct vhost_dev dev;
|
||||||
VirtIODevice *vdev;
|
VirtIODevice *vdev;
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ typedef struct HMPCommand {
|
||||||
} HMPCommand;
|
} HMPCommand;
|
||||||
|
|
||||||
struct Monitor {
|
struct Monitor {
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
int suspend_cnt; /* Needs to be accessed atomically */
|
int suspend_cnt; /* Needs to be accessed atomically */
|
||||||
bool is_qmp;
|
bool is_qmp;
|
||||||
bool skip_flush;
|
bool skip_flush;
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ static uint32_t max_queue_size;
|
||||||
typedef struct SendCo {
|
typedef struct SendCo {
|
||||||
Coroutine *co;
|
Coroutine *co;
|
||||||
struct CompareState *s;
|
struct CompareState *s;
|
||||||
CharBackend *chr;
|
CharFrontend *chr;
|
||||||
GQueue send_list;
|
GQueue send_list;
|
||||||
bool notify_remote_frame;
|
bool notify_remote_frame;
|
||||||
bool done;
|
bool done;
|
||||||
|
|
@ -108,10 +108,10 @@ struct CompareState {
|
||||||
char *sec_indev;
|
char *sec_indev;
|
||||||
char *outdev;
|
char *outdev;
|
||||||
char *notify_dev;
|
char *notify_dev;
|
||||||
CharBackend chr_pri_in;
|
CharFrontend chr_pri_in;
|
||||||
CharBackend chr_sec_in;
|
CharFrontend chr_sec_in;
|
||||||
CharBackend chr_out;
|
CharFrontend chr_out;
|
||||||
CharBackend chr_notify_dev;
|
CharFrontend chr_notify_dev;
|
||||||
SocketReadState pri_rs;
|
SocketReadState pri_rs;
|
||||||
SocketReadState sec_rs;
|
SocketReadState sec_rs;
|
||||||
SocketReadState notify_rs;
|
SocketReadState notify_rs;
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@ struct MirrorState {
|
||||||
NetFilterState parent_obj;
|
NetFilterState parent_obj;
|
||||||
char *indev;
|
char *indev;
|
||||||
char *outdev;
|
char *outdev;
|
||||||
CharBackend chr_in;
|
CharFrontend chr_in;
|
||||||
CharBackend chr_out;
|
CharFrontend chr_out;
|
||||||
SocketReadState rs;
|
SocketReadState rs;
|
||||||
bool vnet_hdr;
|
bool vnet_hdr;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ typedef struct NetPasstState {
|
||||||
/* vhost user */
|
/* vhost user */
|
||||||
VhostUserState *vhost_user;
|
VhostUserState *vhost_user;
|
||||||
VHostNetState *vhost_net;
|
VHostNetState *vhost_net;
|
||||||
CharBackend vhost_chr;
|
CharFrontend vhost_chr;
|
||||||
guint vhost_watch;
|
guint vhost_watch;
|
||||||
uint64_t acked_features;
|
uint64_t acked_features;
|
||||||
bool started;
|
bool started;
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ struct slirp_config_str {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GuestFwd {
|
struct GuestFwd {
|
||||||
CharBackend hd;
|
CharFrontend hd;
|
||||||
struct in_addr server;
|
struct in_addr server;
|
||||||
int port;
|
int port;
|
||||||
Slirp *slirp;
|
Slirp *slirp;
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ static const int user_feature_bits[] = {
|
||||||
|
|
||||||
typedef struct NetVhostUserState {
|
typedef struct NetVhostUserState {
|
||||||
NetClientState nc;
|
NetClientState nc;
|
||||||
CharBackend chr; /* only queue index 0 */
|
CharFrontend chr; /* only queue index 0 */
|
||||||
VhostUserState *vhost_user;
|
VhostUserState *vhost_user;
|
||||||
VHostNetState *vhost_net;
|
VHostNetState *vhost_net;
|
||||||
guint watch;
|
guint watch;
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ include!(concat!(env!("OUT_DIR"), "/bindings.inc.rs"));
|
||||||
// BQL is taken, either directly or via `BqlCell` and `BqlRefCell`.
|
// BQL is taken, either directly or via `BqlCell` and `BqlRefCell`.
|
||||||
// When bindings for character devices are introduced, this can be
|
// When bindings for character devices are introduced, this can be
|
||||||
// moved to the Opaque<> wrapper in src/chardev.rs.
|
// moved to the Opaque<> wrapper in src/chardev.rs.
|
||||||
unsafe impl Send for CharBackend {}
|
unsafe impl Send for CharFrontend {}
|
||||||
unsafe impl Sync for CharBackend {}
|
unsafe impl Sync for CharFrontend {}
|
||||||
|
|
||||||
// SAFETY: this is a pure data struct
|
// SAFETY: this is a pure data struct
|
||||||
unsafe impl Send for CoalescedMemoryRange {}
|
unsafe impl Send for CoalescedMemoryRange {}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ include!(concat!(env!("OUT_DIR"), "/bindings.inc.rs"));
|
||||||
// BQL is taken, either directly or via `BqlCell` and `BqlRefCell`.
|
// BQL is taken, either directly or via `BqlCell` and `BqlRefCell`.
|
||||||
// When bindings for character devices are introduced, this can be
|
// When bindings for character devices are introduced, this can be
|
||||||
// moved to the Opaque<> wrapper in src/chardev.rs.
|
// moved to the Opaque<> wrapper in src/chardev.rs.
|
||||||
unsafe impl Send for CharBackend {}
|
unsafe impl Send for CharFrontend {}
|
||||||
unsafe impl Sync for CharBackend {}
|
unsafe impl Sync for CharFrontend {}
|
||||||
|
|
||||||
unsafe impl Zeroable for CharBackend {}
|
unsafe impl Zeroable for CharFrontend {}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
//!
|
//!
|
||||||
//! Character devices in QEMU can run under the big QEMU lock or in a separate
|
//! Character devices in QEMU can run under the big QEMU lock or in a separate
|
||||||
//! `GMainContext`. Here we only support the former, because the bindings
|
//! `GMainContext`. Here we only support the former, because the bindings
|
||||||
//! enforce that the BQL is taken whenever the functions in [`CharBackend`] are
|
//! enforce that the BQL is taken whenever the functions in [`CharFrontend`] are
|
||||||
//! called.
|
//! called.
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
|
|
@ -32,25 +32,25 @@ pub struct Chardev(Opaque<bindings::Chardev>);
|
||||||
pub type ChardevClass = bindings::ChardevClass;
|
pub type ChardevClass = bindings::ChardevClass;
|
||||||
pub type Event = bindings::QEMUChrEvent;
|
pub type Event = bindings::QEMUChrEvent;
|
||||||
|
|
||||||
/// A safe wrapper around [`bindings::CharBackend`], denoting the character
|
/// A safe wrapper around [`bindings::CharFrontend`], denoting the character
|
||||||
/// back-end that is used for example by a device. Compared to the
|
/// back-end that is used for example by a device. Compared to the
|
||||||
/// underlying C struct it adds BQL protection, and is marked as pinned
|
/// underlying C struct it adds BQL protection, and is marked as pinned
|
||||||
/// because the QOM object ([`bindings::Chardev`]) contains a pointer to
|
/// because the QOM object ([`bindings::Chardev`]) contains a pointer to
|
||||||
/// the `CharBackend`.
|
/// the `CharFrontend`.
|
||||||
pub struct CharBackend {
|
pub struct CharFrontend {
|
||||||
inner: BqlRefCell<bindings::CharBackend>,
|
inner: BqlRefCell<bindings::CharFrontend>,
|
||||||
_pin: PhantomPinned,
|
_pin: PhantomPinned,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CharBackendMut<'a>(BqlRefMut<'a, bindings::CharBackend>);
|
pub struct CharFrontendMut<'a>(BqlRefMut<'a, bindings::CharFrontend>);
|
||||||
|
|
||||||
impl Write for CharBackendMut<'_> {
|
impl Write for CharFrontendMut<'_> {
|
||||||
fn flush(&mut self) -> io::Result<()> {
|
fn flush(&mut self) -> io::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
||||||
let chr: &mut bindings::CharBackend = &mut self.0;
|
let chr: &mut bindings::CharFrontend = &mut self.0;
|
||||||
|
|
||||||
let len = buf.len().try_into().unwrap();
|
let len = buf.len().try_into().unwrap();
|
||||||
let r = unsafe { bindings::qemu_chr_fe_write(addr_of_mut!(*chr), buf.as_ptr(), len) };
|
let r = unsafe { bindings::qemu_chr_fe_write(addr_of_mut!(*chr), buf.as_ptr(), len) };
|
||||||
|
|
@ -58,7 +58,7 @@ impl Write for CharBackendMut<'_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
|
fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
|
||||||
let chr: &mut bindings::CharBackend = &mut self.0;
|
let chr: &mut bindings::CharFrontend = &mut self.0;
|
||||||
|
|
||||||
let len = buf.len().try_into().unwrap();
|
let len = buf.len().try_into().unwrap();
|
||||||
let r = unsafe { bindings::qemu_chr_fe_write_all(addr_of_mut!(*chr), buf.as_ptr(), len) };
|
let r = unsafe { bindings::qemu_chr_fe_write_all(addr_of_mut!(*chr), buf.as_ptr(), len) };
|
||||||
|
|
@ -72,7 +72,7 @@ impl Write for CharBackendMut<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Debug for CharBackend {
|
impl Debug for CharFrontend {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
// SAFETY: accessed just to print the values
|
// SAFETY: accessed just to print the values
|
||||||
let chr = self.inner.as_ptr();
|
let chr = self.inner.as_ptr();
|
||||||
|
|
@ -81,13 +81,13 @@ impl Debug for CharBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: use something like PinnedDrop from the pinned_init crate
|
// FIXME: use something like PinnedDrop from the pinned_init crate
|
||||||
impl Drop for CharBackend {
|
impl Drop for CharFrontend {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
self.disable_handlers();
|
self.disable_handlers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CharBackend {
|
impl CharFrontend {
|
||||||
/// Enable the front-end's character device handlers, if there is an
|
/// Enable the front-end's character device handlers, if there is an
|
||||||
/// associated `Chardev`.
|
/// associated `Chardev`.
|
||||||
pub fn enable_handlers<
|
pub fn enable_handlers<
|
||||||
|
|
@ -198,7 +198,7 @@ impl CharBackend {
|
||||||
/// the big QEMU lock while the character device is borrowed, as
|
/// the big QEMU lock while the character device is borrowed, as
|
||||||
/// that might cause C code to write to the character device.
|
/// that might cause C code to write to the character device.
|
||||||
pub fn borrow_mut(&self) -> impl Write + '_ {
|
pub fn borrow_mut(&self) -> impl Write + '_ {
|
||||||
CharBackendMut(self.inner.borrow_mut())
|
CharFrontendMut(self.inner.borrow_mut())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send a continuous stream of zero bits on the line if `enabled` is
|
/// Send a continuous stream of zero bits on the line if `enabled` is
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
use std::{ffi::CStr, mem::size_of};
|
use std::{ffi::CStr, mem::size_of};
|
||||||
|
|
||||||
use bql::BqlRefCell;
|
use bql::BqlRefCell;
|
||||||
use chardev::{CharBackend, Chardev, Event};
|
use chardev::{CharFrontend, Chardev, Event};
|
||||||
use common::{static_assert, uninit_field_mut};
|
use common::{static_assert, uninit_field_mut};
|
||||||
use hwcore::{
|
use hwcore::{
|
||||||
Clock, ClockEvent, DeviceImpl, DeviceMethods, DeviceState, IRQState, InterruptSource,
|
Clock, ClockEvent, DeviceImpl, DeviceMethods, DeviceState, IRQState, InterruptSource,
|
||||||
|
|
@ -106,7 +106,7 @@ pub struct PL011State {
|
||||||
pub iomem: MemoryRegion,
|
pub iomem: MemoryRegion,
|
||||||
#[doc(alias = "chr")]
|
#[doc(alias = "chr")]
|
||||||
#[property(rename = "chardev")]
|
#[property(rename = "chardev")]
|
||||||
pub char_backend: CharBackend,
|
pub char_frontend: CharFrontend,
|
||||||
pub regs: BqlRefCell<PL011Registers>,
|
pub regs: BqlRefCell<PL011Registers>,
|
||||||
/// QEMU interrupts
|
/// QEMU interrupts
|
||||||
///
|
///
|
||||||
|
|
@ -240,7 +240,7 @@ impl PL011Registers {
|
||||||
}
|
}
|
||||||
let update = (self.line_control.send_break() != new_val.send_break()) && {
|
let update = (self.line_control.send_break() != new_val.send_break()) && {
|
||||||
let break_enable = new_val.send_break();
|
let break_enable = new_val.send_break();
|
||||||
let _ = device.char_backend.send_break(break_enable);
|
let _ = device.char_frontend.send_break(break_enable);
|
||||||
self.loopback_break(break_enable)
|
self.loopback_break(break_enable)
|
||||||
};
|
};
|
||||||
self.line_control = new_val;
|
self.line_control = new_val;
|
||||||
|
|
@ -561,7 +561,7 @@ impl PL011State {
|
||||||
trace::trace_pl011_read(offset, result, c"");
|
trace::trace_pl011_read(offset, result, c"");
|
||||||
if update_irq {
|
if update_irq {
|
||||||
self.update();
|
self.update();
|
||||||
self.char_backend.accept_input();
|
self.char_frontend.accept_input();
|
||||||
}
|
}
|
||||||
result.into()
|
result.into()
|
||||||
}
|
}
|
||||||
|
|
@ -579,7 +579,7 @@ impl PL011State {
|
||||||
let ch: [u8; 1] = [value as u8];
|
let ch: [u8; 1] = [value as u8];
|
||||||
// XXX this blocks entire thread. Rewrite to use
|
// XXX this blocks entire thread. Rewrite to use
|
||||||
// qemu_chr_fe_write and background I/O callbacks
|
// qemu_chr_fe_write and background I/O callbacks
|
||||||
let _ = self.char_backend.write_all(&ch);
|
let _ = self.char_frontend.write_all(&ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
update_irq = self.regs.borrow_mut().write(field, value as u32, self);
|
update_irq = self.regs.borrow_mut().write(field, value as u32, self);
|
||||||
|
|
@ -645,7 +645,7 @@ impl PL011State {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn realize(&self) -> util::Result<()> {
|
fn realize(&self) -> util::Result<()> {
|
||||||
self.char_backend
|
self.char_frontend
|
||||||
.enable_handlers(self, Self::can_receive, Self::receive, Self::event);
|
.enable_handlers(self, Self::can_receive, Self::receive, Self::event);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ impl_qdev_prop!(u64, qdev_prop_uint64, qdev_prop_bit64);
|
||||||
impl_qdev_prop!(usize, qdev_prop_usize);
|
impl_qdev_prop!(usize, qdev_prop_usize);
|
||||||
impl_qdev_prop!(i32, qdev_prop_int32);
|
impl_qdev_prop!(i32, qdev_prop_int32);
|
||||||
impl_qdev_prop!(i64, qdev_prop_int64);
|
impl_qdev_prop!(i64, qdev_prop_int64);
|
||||||
impl_qdev_prop!(chardev::CharBackend, qdev_prop_chr);
|
impl_qdev_prop!(chardev::CharFrontend, qdev_prop_chr);
|
||||||
|
|
||||||
/// Trait to define device properties.
|
/// Trait to define device properties.
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
/* Access to this structure is protected by the BQL */
|
/* Access to this structure is protected by the BQL */
|
||||||
typedef struct SemihostingConsole {
|
typedef struct SemihostingConsole {
|
||||||
CharBackend backend;
|
CharFrontend frontend;
|
||||||
Chardev *chr;
|
Chardev *chr;
|
||||||
GSList *sleeping_cpus;
|
GSList *sleeping_cpus;
|
||||||
bool got;
|
bool got;
|
||||||
|
|
@ -122,8 +122,8 @@ void qemu_semihosting_console_init(Chardev *chr)
|
||||||
console.chr = chr;
|
console.chr = chr;
|
||||||
if (chr) {
|
if (chr) {
|
||||||
fifo8_create(&console.fifo, FIFO_SIZE);
|
fifo8_create(&console.fifo, FIFO_SIZE);
|
||||||
qemu_chr_fe_init(&console.backend, chr, &error_abort);
|
qemu_chr_fe_init(&console.frontend, chr, &error_abort);
|
||||||
qemu_chr_fe_set_handlers(&console.backend,
|
qemu_chr_fe_set_handlers(&console.frontend,
|
||||||
console_can_read,
|
console_can_read,
|
||||||
console_read,
|
console_read,
|
||||||
NULL, NULL, &console,
|
NULL, NULL, &console,
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ struct QTest {
|
||||||
bool has_machine_link;
|
bool has_machine_link;
|
||||||
char *chr_name;
|
char *chr_name;
|
||||||
Chardev *chr;
|
Chardev *chr;
|
||||||
CharBackend qtest_chr;
|
CharFrontend qtest_chr;
|
||||||
char *log;
|
char *log;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -293,20 +293,20 @@ static void G_GNUC_PRINTF(1, 2) qtest_log_send(const char *fmt, ...)
|
||||||
static void qtest_server_char_be_send(void *opaque, const char *str)
|
static void qtest_server_char_be_send(void *opaque, const char *str)
|
||||||
{
|
{
|
||||||
size_t len = strlen(str);
|
size_t len = strlen(str);
|
||||||
CharBackend* chr = (CharBackend *)opaque;
|
CharFrontend* chr = (CharFrontend *)opaque;
|
||||||
qemu_chr_fe_write_all(chr, (uint8_t *)str, len);
|
qemu_chr_fe_write_all(chr, (uint8_t *)str, len);
|
||||||
if (qtest_log_fp && qtest_opened) {
|
if (qtest_log_fp && qtest_opened) {
|
||||||
fprintf(qtest_log_fp, "%s", str);
|
fprintf(qtest_log_fp, "%s", str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qtest_send(CharBackend *chr, const char *str)
|
static void qtest_send(CharFrontend *chr, const char *str)
|
||||||
{
|
{
|
||||||
qtest_log_timestamp();
|
qtest_log_timestamp();
|
||||||
qtest_server_send(qtest_server_send_opaque, str);
|
qtest_server_send(qtest_server_send_opaque, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qtest_sendf(CharBackend *chr, const char *fmt, ...)
|
void qtest_sendf(CharFrontend *chr, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
gchar *buffer;
|
gchar *buffer;
|
||||||
|
|
@ -324,16 +324,16 @@ static void qtest_irq_handler(void *opaque, int n, int level)
|
||||||
qemu_set_irq(old_irq, level);
|
qemu_set_irq(old_irq, level);
|
||||||
|
|
||||||
if (irq_levels[n] != level) {
|
if (irq_levels[n] != level) {
|
||||||
CharBackend *chr = &qtest->qtest_chr;
|
CharFrontend *chr = &qtest->qtest_chr;
|
||||||
irq_levels[n] = level;
|
irq_levels[n] = level;
|
||||||
qtest_sendf(chr, "IRQ %s %d\n",
|
qtest_sendf(chr, "IRQ %s %d\n",
|
||||||
level ? "raise" : "lower", n);
|
level ? "raise" : "lower", n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool (*process_command_cb)(CharBackend *chr, gchar **words);
|
static bool (*process_command_cb)(CharFrontend *chr, gchar **words);
|
||||||
|
|
||||||
void qtest_set_command_cb(bool (*pc_cb)(CharBackend *chr, gchar **words))
|
void qtest_set_command_cb(bool (*pc_cb)(CharFrontend *chr, gchar **words))
|
||||||
{
|
{
|
||||||
assert(!process_command_cb); /* Switch to a list if we need more than one */
|
assert(!process_command_cb); /* Switch to a list if we need more than one */
|
||||||
|
|
||||||
|
|
@ -349,7 +349,7 @@ static void qtest_install_gpio_out_intercept(DeviceState *dev, const char *name,
|
||||||
*disconnected = qdev_intercept_gpio_out(dev, icpt, name, n);
|
*disconnected = qdev_intercept_gpio_out(dev, icpt, name, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qtest_process_command(CharBackend *chr, gchar **words)
|
static void qtest_process_command(CharFrontend *chr, gchar **words)
|
||||||
{
|
{
|
||||||
const gchar *command;
|
const gchar *command;
|
||||||
|
|
||||||
|
|
@ -757,7 +757,7 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
|
||||||
* Process as much of @inbuf as we can in newline terminated chunks.
|
* Process as much of @inbuf as we can in newline terminated chunks.
|
||||||
* Remove the processed commands from @inbuf as we go.
|
* Remove the processed commands from @inbuf as we go.
|
||||||
*/
|
*/
|
||||||
static void qtest_process_inbuf(CharBackend *chr, GString *inbuf)
|
static void qtest_process_inbuf(CharFrontend *chr, GString *inbuf)
|
||||||
{
|
{
|
||||||
char *end;
|
char *end;
|
||||||
|
|
||||||
|
|
@ -773,7 +773,7 @@ static void qtest_process_inbuf(CharBackend *chr, GString *inbuf)
|
||||||
|
|
||||||
static void qtest_read(void *opaque, const uint8_t *buf, int size)
|
static void qtest_read(void *opaque, const uint8_t *buf, int size)
|
||||||
{
|
{
|
||||||
CharBackend *chr = opaque;
|
CharFrontend *chr = opaque;
|
||||||
|
|
||||||
g_string_append_len(inbuf, (const gchar *)buf, size);
|
g_string_append_len(inbuf, (const gchar *)buf, size);
|
||||||
qtest_process_inbuf(chr, inbuf);
|
qtest_process_inbuf(chr, inbuf);
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ void HELPER(rfi_r)(CPUHPPAState *env)
|
||||||
*/
|
*/
|
||||||
void HELPER(diag_console_output)(CPUHPPAState *env)
|
void HELPER(diag_console_output)(CPUHPPAState *env)
|
||||||
{
|
{
|
||||||
CharBackend *serial_backend;
|
CharFrontend *fe;
|
||||||
Chardev *serial_port;
|
Chardev *serial_port;
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
|
|
||||||
|
|
@ -145,14 +145,14 @@ void HELPER(diag_console_output)(CPUHPPAState *env)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get serial_backend for the serial port */
|
/* get the frontend for the serial port */
|
||||||
serial_backend = serial_port->be;
|
fe = serial_port->fe;
|
||||||
if (!serial_backend ||
|
if (!fe ||
|
||||||
!qemu_chr_fe_backend_connected(serial_backend)) {
|
!qemu_chr_fe_backend_connected(fe)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
c = (unsigned char)env->gr[26];
|
c = (unsigned char)env->gr[26];
|
||||||
qemu_chr_fe_write(serial_backend, &c, sizeof(c));
|
qemu_chr_fe_write(fe, &c, sizeof(c));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1598,7 +1598,7 @@ static void kvm_riscv_handle_sbi_dbcn(CPUState *cs, struct kvm_run *run)
|
||||||
buf = g_malloc0(num_bytes);
|
buf = g_malloc0(num_bytes);
|
||||||
|
|
||||||
if (run->riscv_sbi.function_id == SBI_EXT_DBCN_CONSOLE_READ) {
|
if (run->riscv_sbi.function_id == SBI_EXT_DBCN_CONSOLE_READ) {
|
||||||
ret = qemu_chr_fe_read_all(serial_hd(0)->be, buf, num_bytes);
|
ret = qemu_chr_fe_read_all(serial_hd(0)->fe, buf, num_bytes);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
error_report("SBI_EXT_DBCN_CONSOLE_READ: error when "
|
error_report("SBI_EXT_DBCN_CONSOLE_READ: error when "
|
||||||
"reading chardev");
|
"reading chardev");
|
||||||
|
|
@ -1609,7 +1609,7 @@ static void kvm_riscv_handle_sbi_dbcn(CPUState *cs, struct kvm_run *run)
|
||||||
} else {
|
} else {
|
||||||
address_space_read(cs->as, addr, attrs, buf, num_bytes);
|
address_space_read(cs->as, addr, attrs, buf, num_bytes);
|
||||||
|
|
||||||
ret = qemu_chr_fe_write_all(serial_hd(0)->be, buf, num_bytes);
|
ret = qemu_chr_fe_write_all(serial_hd(0)->fe, buf, num_bytes);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
error_report("SBI_EXT_DBCN_CONSOLE_WRITE: error when "
|
error_report("SBI_EXT_DBCN_CONSOLE_WRITE: error when "
|
||||||
"writing chardev");
|
"writing chardev");
|
||||||
|
|
@ -1622,7 +1622,7 @@ static void kvm_riscv_handle_sbi_dbcn(CPUState *cs, struct kvm_run *run)
|
||||||
break;
|
break;
|
||||||
case SBI_EXT_DBCN_CONSOLE_WRITE_BYTE:
|
case SBI_EXT_DBCN_CONSOLE_WRITE_BYTE:
|
||||||
ch = run->riscv_sbi.args[0];
|
ch = run->riscv_sbi.args[0];
|
||||||
ret = qemu_chr_fe_write_all(serial_hd(0)->be, &ch, sizeof(ch));
|
ret = qemu_chr_fe_write_all(serial_hd(0)->fe, &ch, sizeof(ch));
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
error_report("SBI_EXT_DBCN_CONSOLE_WRITE_BYTE: error when "
|
error_report("SBI_EXT_DBCN_CONSOLE_WRITE_BYTE: error when "
|
||||||
|
|
@ -1645,10 +1645,10 @@ static int kvm_riscv_handle_sbi(CPUState *cs, struct kvm_run *run)
|
||||||
switch (run->riscv_sbi.extension_id) {
|
switch (run->riscv_sbi.extension_id) {
|
||||||
case SBI_EXT_0_1_CONSOLE_PUTCHAR:
|
case SBI_EXT_0_1_CONSOLE_PUTCHAR:
|
||||||
ch = run->riscv_sbi.args[0];
|
ch = run->riscv_sbi.args[0];
|
||||||
qemu_chr_fe_write(serial_hd(0)->be, &ch, sizeof(ch));
|
qemu_chr_fe_write(serial_hd(0)->fe, &ch, sizeof(ch));
|
||||||
break;
|
break;
|
||||||
case SBI_EXT_0_1_CONSOLE_GETCHAR:
|
case SBI_EXT_0_1_CONSOLE_GETCHAR:
|
||||||
ret = qemu_chr_fe_read_all(serial_hd(0)->be, &ch, sizeof(ch));
|
ret = qemu_chr_fe_read_all(serial_hd(0)->fe, &ch, sizeof(ch));
|
||||||
if (ret == sizeof(ch)) {
|
if (ret == sizeof(ch)) {
|
||||||
run->riscv_sbi.ret[0] = ch;
|
run->riscv_sbi.ret[0] = ch;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ static uint32_t errno_h2g(int host_errno)
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct XtensaSimConsole {
|
typedef struct XtensaSimConsole {
|
||||||
CharBackend be;
|
CharFrontend fe;
|
||||||
struct {
|
struct {
|
||||||
char buffer[16];
|
char buffer[16];
|
||||||
size_t offset;
|
size_t offset;
|
||||||
|
|
@ -182,8 +182,8 @@ void xtensa_sim_open_console(Chardev *chr)
|
||||||
{
|
{
|
||||||
static XtensaSimConsole console;
|
static XtensaSimConsole console;
|
||||||
|
|
||||||
qemu_chr_fe_init(&console.be, chr, &error_abort);
|
qemu_chr_fe_init(&console.fe, chr, &error_abort);
|
||||||
qemu_chr_fe_set_handlers(&console.be,
|
qemu_chr_fe_set_handlers(&console.fe,
|
||||||
sim_console_can_read,
|
sim_console_can_read,
|
||||||
sim_console_read,
|
sim_console_read,
|
||||||
NULL, NULL, &console,
|
NULL, NULL, &console,
|
||||||
|
|
@ -227,7 +227,7 @@ void HELPER(simcall)(CPUXtensaState *env)
|
||||||
len -= io_sz;
|
len -= io_sz;
|
||||||
if (fd < 3 && sim_console) {
|
if (fd < 3 && sim_console) {
|
||||||
if (is_write && (fd == 1 || fd == 2)) {
|
if (is_write && (fd == 1 || fd == 2)) {
|
||||||
io_done = qemu_chr_fe_write_all(&sim_console->be,
|
io_done = qemu_chr_fe_write_all(&sim_console->fe,
|
||||||
buf, io_sz);
|
buf, io_sz);
|
||||||
regs[3] = errno_h2g(errno);
|
regs[3] = errno_h2g(errno);
|
||||||
} else if (!is_write && fd == 0) {
|
} else if (!is_write && fd == 0) {
|
||||||
|
|
@ -241,7 +241,7 @@ void HELPER(simcall)(CPUXtensaState *env)
|
||||||
sim_console->input.buffer + io_done,
|
sim_console->input.buffer + io_done,
|
||||||
sim_console->input.offset - io_done);
|
sim_console->input.offset - io_done);
|
||||||
sim_console->input.offset -= io_done;
|
sim_console->input.offset -= io_done;
|
||||||
qemu_chr_fe_accept_input(&sim_console->be);
|
qemu_chr_fe_accept_input(&sim_console->fe);
|
||||||
} else {
|
} else {
|
||||||
io_done = -1;
|
io_done = -1;
|
||||||
regs[3] = TARGET_EAGAIN;
|
regs[3] = TARGET_EAGAIN;
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,7 @@ typedef struct TestServer {
|
||||||
gchar *mig_path;
|
gchar *mig_path;
|
||||||
gchar *chr_name;
|
gchar *chr_name;
|
||||||
gchar *tmpfs;
|
gchar *tmpfs;
|
||||||
CharBackend chr;
|
CharFrontend chr;
|
||||||
int fds_num;
|
int fds_num;
|
||||||
int fds[VHOST_MEMORY_MAX_NREGIONS];
|
int fds[VHOST_MEMORY_MAX_NREGIONS];
|
||||||
VhostUserMemory memory;
|
VhostUserMemory memory;
|
||||||
|
|
@ -180,10 +180,10 @@ struct vhost_user_ops {
|
||||||
|
|
||||||
/* VHOST-USER commands. */
|
/* VHOST-USER commands. */
|
||||||
uint64_t (*get_features)(TestServer *s);
|
uint64_t (*get_features)(TestServer *s);
|
||||||
void (*set_features)(TestServer *s, CharBackend *chr,
|
void (*set_features)(TestServer *s, CharFrontend *chr,
|
||||||
VhostUserMsg *msg);
|
VhostUserMsg *msg);
|
||||||
void (*get_protocol_features)(TestServer *s,
|
void (*get_protocol_features)(TestServer *s,
|
||||||
CharBackend *chr, VhostUserMsg *msg);
|
CharFrontend *chr, VhostUserMsg *msg);
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *init_hugepagefs(void);
|
static const char *init_hugepagefs(void);
|
||||||
|
|
@ -331,7 +331,7 @@ static int chr_can_read(void *opaque)
|
||||||
static void chr_read(void *opaque, const uint8_t *buf, int size)
|
static void chr_read(void *opaque, const uint8_t *buf, int size)
|
||||||
{
|
{
|
||||||
TestServer *s = opaque;
|
TestServer *s = opaque;
|
||||||
CharBackend *chr = &s->chr;
|
CharFrontend *chr = &s->chr;
|
||||||
VhostUserMsg msg;
|
VhostUserMsg msg;
|
||||||
uint8_t *p = (uint8_t *) &msg;
|
uint8_t *p = (uint8_t *) &msg;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
|
@ -1051,7 +1051,7 @@ static uint64_t vu_net_get_features(TestServer *s)
|
||||||
return features;
|
return features;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vu_net_set_features(TestServer *s, CharBackend *chr,
|
static void vu_net_set_features(TestServer *s, CharFrontend *chr,
|
||||||
VhostUserMsg *msg)
|
VhostUserMsg *msg)
|
||||||
{
|
{
|
||||||
g_assert(msg->payload.u64 & (0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES));
|
g_assert(msg->payload.u64 & (0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES));
|
||||||
|
|
@ -1061,7 +1061,7 @@ static void vu_net_set_features(TestServer *s, CharBackend *chr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vu_net_get_protocol_features(TestServer *s, CharBackend *chr,
|
static void vu_net_get_protocol_features(TestServer *s, CharFrontend *chr,
|
||||||
VhostUserMsg *msg)
|
VhostUserMsg *msg)
|
||||||
{
|
{
|
||||||
/* send back features to qemu */
|
/* send back features to qemu */
|
||||||
|
|
@ -1148,7 +1148,7 @@ static uint64_t vu_gpio_get_features(TestServer *s)
|
||||||
* that we support VHOST_USER_PROTOCOL_F_CONFIG as gpio would use it
|
* that we support VHOST_USER_PROTOCOL_F_CONFIG as gpio would use it
|
||||||
* talking to a read vhost-user daemon.
|
* talking to a read vhost-user daemon.
|
||||||
*/
|
*/
|
||||||
static void vu_gpio_get_protocol_features(TestServer *s, CharBackend *chr,
|
static void vu_gpio_get_protocol_features(TestServer *s, CharFrontend *chr,
|
||||||
VhostUserMsg *msg)
|
VhostUserMsg *msg)
|
||||||
{
|
{
|
||||||
/* send back features to qemu */
|
/* send back features to qemu */
|
||||||
|
|
@ -1191,7 +1191,7 @@ static uint64_t vu_scmi_get_features(TestServer *s)
|
||||||
0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES;
|
0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vu_scmi_get_protocol_features(TestServer *s, CharBackend *chr,
|
static void vu_scmi_get_protocol_features(TestServer *s, CharFrontend *chr,
|
||||||
VhostUserMsg *msg)
|
VhostUserMsg *msg)
|
||||||
{
|
{
|
||||||
msg->flags |= VHOST_USER_REPLY_MASK;
|
msg->flags |= VHOST_USER_REPLY_MASK;
|
||||||
|
|
|
||||||
|
|
@ -107,18 +107,18 @@ static void char_console_test(void)
|
||||||
static void char_stdio_test_subprocess(void)
|
static void char_stdio_test_subprocess(void)
|
||||||
{
|
{
|
||||||
Chardev *chr;
|
Chardev *chr;
|
||||||
CharBackend be;
|
CharFrontend c;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
chr = qemu_chr_new("label", "stdio", NULL);
|
chr = qemu_chr_new("label", "stdio", NULL);
|
||||||
g_assert_nonnull(chr);
|
g_assert_nonnull(chr);
|
||||||
|
|
||||||
qemu_chr_fe_init(&be, chr, &error_abort);
|
qemu_chr_fe_init(&c, chr, &error_abort);
|
||||||
qemu_chr_fe_set_open(&be, true);
|
qemu_chr_fe_set_open(&c, true);
|
||||||
ret = qemu_chr_fe_write(&be, (void *)"buf", 4);
|
ret = qemu_chr_fe_write(&c, (void *)"buf", 4);
|
||||||
g_assert_cmpint(ret, ==, 4);
|
g_assert_cmpint(ret, ==, 4);
|
||||||
|
|
||||||
qemu_chr_fe_deinit(&be, true);
|
qemu_chr_fe_deinit(&c, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void char_stdio_test(void)
|
static void char_stdio_test(void)
|
||||||
|
|
@ -132,7 +132,7 @@ static void char_ringbuf_test(void)
|
||||||
{
|
{
|
||||||
QemuOpts *opts;
|
QemuOpts *opts;
|
||||||
Chardev *chr;
|
Chardev *chr;
|
||||||
CharBackend be;
|
CharFrontend c;
|
||||||
char *data;
|
char *data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
|
@ -153,8 +153,8 @@ static void char_ringbuf_test(void)
|
||||||
g_assert_nonnull(chr);
|
g_assert_nonnull(chr);
|
||||||
qemu_opts_del(opts);
|
qemu_opts_del(opts);
|
||||||
|
|
||||||
qemu_chr_fe_init(&be, chr, &error_abort);
|
qemu_chr_fe_init(&c, chr, &error_abort);
|
||||||
ret = qemu_chr_fe_write(&be, (void *)"buff", 4);
|
ret = qemu_chr_fe_write(&c, (void *)"buff", 4);
|
||||||
g_assert_cmpint(ret, ==, 4);
|
g_assert_cmpint(ret, ==, 4);
|
||||||
|
|
||||||
data = qmp_ringbuf_read("ringbuf-label", 4, false, 0, &error_abort);
|
data = qmp_ringbuf_read("ringbuf-label", 4, false, 0, &error_abort);
|
||||||
|
|
@ -165,7 +165,7 @@ static void char_ringbuf_test(void)
|
||||||
g_assert_cmpstr(data, ==, "");
|
g_assert_cmpstr(data, ==, "");
|
||||||
g_free(data);
|
g_free(data);
|
||||||
|
|
||||||
qemu_chr_fe_deinit(&be, true);
|
qemu_chr_fe_deinit(&c, true);
|
||||||
|
|
||||||
/* check alias */
|
/* check alias */
|
||||||
opts = qemu_opts_create(qemu_find_opts("chardev"), "memory-label",
|
opts = qemu_opts_create(qemu_find_opts("chardev"), "memory-label",
|
||||||
|
|
@ -184,7 +184,7 @@ static void char_mux_test(void)
|
||||||
Chardev *chr, *base;
|
Chardev *chr, *base;
|
||||||
char *data;
|
char *data;
|
||||||
FeHandler h1 = { 0, false, 0, false, }, h2 = { 0, false, 0, false, };
|
FeHandler h1 = { 0, false, 0, false, }, h2 = { 0, false, 0, false, };
|
||||||
CharBackend chr_be1, chr_be2;
|
CharFrontend chr_fe1, chr_fe2;
|
||||||
Error *error = NULL;
|
Error *error = NULL;
|
||||||
|
|
||||||
/* Create mux and chardev to be immediately removed */
|
/* Create mux and chardev to be immediately removed */
|
||||||
|
|
@ -210,8 +210,8 @@ static void char_mux_test(void)
|
||||||
g_assert_nonnull(chr);
|
g_assert_nonnull(chr);
|
||||||
qemu_opts_del(opts);
|
qemu_opts_del(opts);
|
||||||
|
|
||||||
qemu_chr_fe_init(&chr_be1, chr, &error_abort);
|
qemu_chr_fe_init(&chr_fe1, chr, &error_abort);
|
||||||
qemu_chr_fe_set_handlers(&chr_be1,
|
qemu_chr_fe_set_handlers(&chr_fe1,
|
||||||
fe_can_read,
|
fe_can_read,
|
||||||
fe_read,
|
fe_read,
|
||||||
fe_event,
|
fe_event,
|
||||||
|
|
@ -219,15 +219,15 @@ static void char_mux_test(void)
|
||||||
&h1,
|
&h1,
|
||||||
NULL, true);
|
NULL, true);
|
||||||
|
|
||||||
qemu_chr_fe_init(&chr_be2, chr, &error_abort);
|
qemu_chr_fe_init(&chr_fe2, chr, &error_abort);
|
||||||
qemu_chr_fe_set_handlers(&chr_be2,
|
qemu_chr_fe_set_handlers(&chr_fe2,
|
||||||
fe_can_read,
|
fe_can_read,
|
||||||
fe_read,
|
fe_read,
|
||||||
fe_event,
|
fe_event,
|
||||||
NULL,
|
NULL,
|
||||||
&h2,
|
&h2,
|
||||||
NULL, true);
|
NULL, true);
|
||||||
qemu_chr_fe_take_focus(&chr_be2);
|
qemu_chr_fe_take_focus(&chr_fe2);
|
||||||
|
|
||||||
base = qemu_chr_find("mux-label-base");
|
base = qemu_chr_find("mux-label-base");
|
||||||
g_assert_cmpint(qemu_chr_be_can_write(base), !=, 0);
|
g_assert_cmpint(qemu_chr_be_can_write(base), !=, 0);
|
||||||
|
|
@ -271,8 +271,8 @@ static void char_mux_test(void)
|
||||||
g_assert_cmpint(h2.last_event, ==, CHR_EVENT_MUX_OUT);
|
g_assert_cmpint(h2.last_event, ==, CHR_EVENT_MUX_OUT);
|
||||||
|
|
||||||
/* open/close state and corresponding events */
|
/* open/close state and corresponding events */
|
||||||
g_assert_true(qemu_chr_fe_backend_open(&chr_be1));
|
g_assert_true(qemu_chr_fe_backend_open(&chr_fe1));
|
||||||
g_assert_true(qemu_chr_fe_backend_open(&chr_be2));
|
g_assert_true(qemu_chr_fe_backend_open(&chr_fe2));
|
||||||
g_assert_true(h1.is_open);
|
g_assert_true(h1.is_open);
|
||||||
g_assert_false(h1.openclose_mismatch);
|
g_assert_false(h1.openclose_mismatch);
|
||||||
g_assert_true(h2.is_open);
|
g_assert_true(h2.is_open);
|
||||||
|
|
@ -280,22 +280,22 @@ static void char_mux_test(void)
|
||||||
|
|
||||||
h1.openclose_count = h2.openclose_count = 0;
|
h1.openclose_count = h2.openclose_count = 0;
|
||||||
|
|
||||||
qemu_chr_fe_set_handlers(&chr_be1, NULL, NULL, NULL, NULL,
|
qemu_chr_fe_set_handlers(&chr_fe1, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, false);
|
NULL, NULL, false);
|
||||||
qemu_chr_fe_set_handlers(&chr_be2, NULL, NULL, NULL, NULL,
|
qemu_chr_fe_set_handlers(&chr_fe2, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, false);
|
NULL, NULL, false);
|
||||||
g_assert_cmpint(h1.openclose_count, ==, 0);
|
g_assert_cmpint(h1.openclose_count, ==, 0);
|
||||||
g_assert_cmpint(h2.openclose_count, ==, 0);
|
g_assert_cmpint(h2.openclose_count, ==, 0);
|
||||||
|
|
||||||
h1.is_open = h2.is_open = false;
|
h1.is_open = h2.is_open = false;
|
||||||
qemu_chr_fe_set_handlers(&chr_be1,
|
qemu_chr_fe_set_handlers(&chr_fe1,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
fe_event,
|
fe_event,
|
||||||
NULL,
|
NULL,
|
||||||
&h1,
|
&h1,
|
||||||
NULL, false);
|
NULL, false);
|
||||||
qemu_chr_fe_set_handlers(&chr_be2,
|
qemu_chr_fe_set_handlers(&chr_fe2,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
fe_event,
|
fe_event,
|
||||||
|
|
@ -314,14 +314,14 @@ static void char_mux_test(void)
|
||||||
g_assert_cmpint(h2.openclose_count, ==, 3);
|
g_assert_cmpint(h2.openclose_count, ==, 3);
|
||||||
g_assert_false(h2.openclose_mismatch);
|
g_assert_false(h2.openclose_mismatch);
|
||||||
|
|
||||||
qemu_chr_fe_set_handlers(&chr_be2,
|
qemu_chr_fe_set_handlers(&chr_fe2,
|
||||||
fe_can_read,
|
fe_can_read,
|
||||||
fe_read,
|
fe_read,
|
||||||
fe_event,
|
fe_event,
|
||||||
NULL,
|
NULL,
|
||||||
&h2,
|
&h2,
|
||||||
NULL, false);
|
NULL, false);
|
||||||
qemu_chr_fe_set_handlers(&chr_be1,
|
qemu_chr_fe_set_handlers(&chr_fe1,
|
||||||
fe_can_read,
|
fe_can_read,
|
||||||
fe_read,
|
fe_read,
|
||||||
fe_event,
|
fe_event,
|
||||||
|
|
@ -330,7 +330,7 @@ static void char_mux_test(void)
|
||||||
NULL, false);
|
NULL, false);
|
||||||
|
|
||||||
/* remove first handler */
|
/* remove first handler */
|
||||||
qemu_chr_fe_set_handlers(&chr_be1, NULL, NULL, NULL, NULL,
|
qemu_chr_fe_set_handlers(&chr_fe1, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, true);
|
NULL, NULL, true);
|
||||||
qemu_chr_be_write(base, (void *)"hello", 6);
|
qemu_chr_be_write(base, (void *)"hello", 6);
|
||||||
g_assert_cmpint(h1.read_count, ==, 0);
|
g_assert_cmpint(h1.read_count, ==, 0);
|
||||||
|
|
@ -349,13 +349,13 @@ static void char_mux_test(void)
|
||||||
g_assert_cmpint(strlen(data), !=, 0);
|
g_assert_cmpint(strlen(data), !=, 0);
|
||||||
g_free(data);
|
g_free(data);
|
||||||
|
|
||||||
qemu_chr_fe_deinit(&chr_be1, false);
|
qemu_chr_fe_deinit(&chr_fe1, false);
|
||||||
|
|
||||||
qmp_chardev_remove("mux-label", &error);
|
qmp_chardev_remove("mux-label", &error);
|
||||||
g_assert_cmpstr(error_get_pretty(error), ==, "Chardev 'mux-label' is busy");
|
g_assert_cmpstr(error_get_pretty(error), ==, "Chardev 'mux-label' is busy");
|
||||||
error_free(error);
|
error_free(error);
|
||||||
|
|
||||||
qemu_chr_fe_deinit(&chr_be2, false);
|
qemu_chr_fe_deinit(&chr_fe2, false);
|
||||||
qmp_chardev_remove("mux-label", &error_abort);
|
qmp_chardev_remove("mux-label", &error_abort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -366,7 +366,7 @@ static void char_hub_test(void)
|
||||||
char *data;
|
char *data;
|
||||||
FeHandler h = { 0, false, 0, false, };
|
FeHandler h = { 0, false, 0, false, };
|
||||||
Error *error = NULL;
|
Error *error = NULL;
|
||||||
CharBackend chr_be;
|
CharFrontend chr_fe;
|
||||||
int ret, i;
|
int ret, i;
|
||||||
|
|
||||||
#define RB_SIZE 128
|
#define RB_SIZE 128
|
||||||
|
|
@ -497,8 +497,8 @@ static void char_hub_test(void)
|
||||||
qemu_opts_del(opts);
|
qemu_opts_del(opts);
|
||||||
|
|
||||||
/* Attach hub to a frontend */
|
/* Attach hub to a frontend */
|
||||||
qemu_chr_fe_init(&chr_be, hub, &error_abort);
|
qemu_chr_fe_init(&chr_fe, hub, &error_abort);
|
||||||
qemu_chr_fe_set_handlers(&chr_be,
|
qemu_chr_fe_set_handlers(&chr_fe,
|
||||||
fe_can_read,
|
fe_can_read,
|
||||||
fe_read,
|
fe_read,
|
||||||
fe_event,
|
fe_event,
|
||||||
|
|
@ -507,7 +507,7 @@ static void char_hub_test(void)
|
||||||
NULL, true);
|
NULL, true);
|
||||||
|
|
||||||
/* Fails second time */
|
/* Fails second time */
|
||||||
qemu_chr_fe_init(&chr_be, hub, &error);
|
qemu_chr_fe_init(&chr_fe, hub, &error);
|
||||||
g_assert_cmpstr(error_get_pretty(error), ==, "chardev 'hub0' is already in use");
|
g_assert_cmpstr(error_get_pretty(error), ==, "chardev 'hub0' is already in use");
|
||||||
error_free(error);
|
error_free(error);
|
||||||
error = NULL;
|
error = NULL;
|
||||||
|
|
@ -531,7 +531,7 @@ static void char_hub_test(void)
|
||||||
h.read_count = 0;
|
h.read_count = 0;
|
||||||
|
|
||||||
/* Write to frontend, chr_be */
|
/* Write to frontend, chr_be */
|
||||||
ret = qemu_chr_fe_write(&chr_be, (void *)"heyhey", 6);
|
ret = qemu_chr_fe_write(&chr_fe, (void *)"heyhey", 6);
|
||||||
g_assert_cmpint(ret, ==, 6);
|
g_assert_cmpint(ret, ==, 6);
|
||||||
|
|
||||||
data = qmp_ringbuf_read("chr1", RB_SIZE, false, 0, &error_abort);
|
data = qmp_ringbuf_read("chr1", RB_SIZE, false, 0, &error_abort);
|
||||||
|
|
@ -557,7 +557,7 @@ static void char_hub_test(void)
|
||||||
error = NULL;
|
error = NULL;
|
||||||
|
|
||||||
/* Finalize frontend */
|
/* Finalize frontend */
|
||||||
qemu_chr_fe_deinit(&chr_be, false);
|
qemu_chr_fe_deinit(&chr_fe, false);
|
||||||
|
|
||||||
/* Finalize hub0 */
|
/* Finalize hub0 */
|
||||||
qmp_chardev_remove("hub0", &error_abort);
|
qmp_chardev_remove("hub0", &error_abort);
|
||||||
|
|
@ -632,8 +632,8 @@ static void char_hub_test(void)
|
||||||
qemu_opts_del(opts);
|
qemu_opts_del(opts);
|
||||||
|
|
||||||
/* Attach hub to a frontend */
|
/* Attach hub to a frontend */
|
||||||
qemu_chr_fe_init(&chr_be, hub, &error_abort);
|
qemu_chr_fe_init(&chr_fe, hub, &error_abort);
|
||||||
qemu_chr_fe_set_handlers(&chr_be,
|
qemu_chr_fe_set_handlers(&chr_fe,
|
||||||
fe_can_read,
|
fe_can_read,
|
||||||
fe_read,
|
fe_read,
|
||||||
fe_event,
|
fe_event,
|
||||||
|
|
@ -642,7 +642,7 @@ static void char_hub_test(void)
|
||||||
NULL, true);
|
NULL, true);
|
||||||
|
|
||||||
/* Write to frontend, chr_be */
|
/* Write to frontend, chr_be */
|
||||||
ret = qemu_chr_fe_write(&chr_be, (void *)"thisis", 6);
|
ret = qemu_chr_fe_write(&chr_fe, (void *)"thisis", 6);
|
||||||
g_assert_cmpint(ret, ==, 6);
|
g_assert_cmpint(ret, ==, 6);
|
||||||
|
|
||||||
data = qmp_ringbuf_read("chr1", RB_SIZE, false, 0, &error_abort);
|
data = qmp_ringbuf_read("chr1", RB_SIZE, false, 0, &error_abort);
|
||||||
|
|
@ -663,7 +663,7 @@ static void char_hub_test(void)
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
/* Add watch. 0 indicates no watches if nothing to wait for */
|
/* Add watch. 0 indicates no watches if nothing to wait for */
|
||||||
ret = qemu_chr_fe_add_watch(&chr_be, G_IO_OUT | G_IO_HUP,
|
ret = qemu_chr_fe_add_watch(&chr_fe, G_IO_OUT | G_IO_HUP,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
g_assert_cmpint(ret, ==, 0);
|
g_assert_cmpint(ret, ==, 0);
|
||||||
|
|
||||||
|
|
@ -672,14 +672,14 @@ static void char_hub_test(void)
|
||||||
* power of two to fit nicely the whole pipe buffer.
|
* power of two to fit nicely the whole pipe buffer.
|
||||||
*/
|
*/
|
||||||
len = 0;
|
len = 0;
|
||||||
while ((ret = qemu_chr_fe_write(&chr_be, (void *)"thisisit", 8))
|
while ((ret = qemu_chr_fe_write(&chr_fe, (void *)"thisisit", 8))
|
||||||
!= -1) {
|
!= -1) {
|
||||||
len += ret;
|
len += ret;
|
||||||
}
|
}
|
||||||
g_assert_cmpint(errno, ==, EAGAIN);
|
g_assert_cmpint(errno, ==, EAGAIN);
|
||||||
|
|
||||||
/* Further all writes should cause EAGAIN */
|
/* Further all writes should cause EAGAIN */
|
||||||
ret = qemu_chr_fe_write(&chr_be, (void *)"b", 1);
|
ret = qemu_chr_fe_write(&chr_fe, (void *)"b", 1);
|
||||||
g_assert_cmpint(ret, ==, -1);
|
g_assert_cmpint(ret, ==, -1);
|
||||||
g_assert_cmpint(errno, ==, EAGAIN);
|
g_assert_cmpint(errno, ==, EAGAIN);
|
||||||
|
|
||||||
|
|
@ -687,7 +687,7 @@ static void char_hub_test(void)
|
||||||
* Add watch. Non 0 indicates we have a blocked chardev, which
|
* Add watch. Non 0 indicates we have a blocked chardev, which
|
||||||
* can wakes us up when write is possible.
|
* can wakes us up when write is possible.
|
||||||
*/
|
*/
|
||||||
ret = qemu_chr_fe_add_watch(&chr_be, G_IO_OUT | G_IO_HUP,
|
ret = qemu_chr_fe_add_watch(&chr_fe, G_IO_OUT | G_IO_HUP,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
g_assert_cmpint(ret, !=, 0);
|
g_assert_cmpint(ret, !=, 0);
|
||||||
g_source_remove(ret);
|
g_source_remove(ret);
|
||||||
|
|
@ -712,10 +712,10 @@ static void char_hub_test(void)
|
||||||
* was already consumed and drained by the ring buffers, but
|
* was already consumed and drained by the ring buffers, but
|
||||||
* pipe have not recieved that yet.
|
* pipe have not recieved that yet.
|
||||||
*/
|
*/
|
||||||
ret = qemu_chr_fe_write(&chr_be, (void *)"thisisit", 8);
|
ret = qemu_chr_fe_write(&chr_fe, (void *)"thisisit", 8);
|
||||||
g_assert_cmpint(ret, ==, 8);
|
g_assert_cmpint(ret, ==, 8);
|
||||||
|
|
||||||
ret = qemu_chr_fe_write(&chr_be, (void *)"streamisrestored", 16);
|
ret = qemu_chr_fe_write(&chr_fe, (void *)"streamisrestored", 16);
|
||||||
g_assert_cmpint(ret, ==, 16);
|
g_assert_cmpint(ret, ==, 16);
|
||||||
|
|
||||||
data = qmp_ringbuf_read("chr1", RB_SIZE, false, 0, &error_abort);
|
data = qmp_ringbuf_read("chr1", RB_SIZE, false, 0, &error_abort);
|
||||||
|
|
@ -744,7 +744,7 @@ static void char_hub_test(void)
|
||||||
g_free(pipe);
|
g_free(pipe);
|
||||||
|
|
||||||
/* Finalize frontend */
|
/* Finalize frontend */
|
||||||
qemu_chr_fe_deinit(&chr_be, false);
|
qemu_chr_fe_deinit(&chr_fe, false);
|
||||||
|
|
||||||
/* Finalize hub0 */
|
/* Finalize hub0 */
|
||||||
qmp_chardev_remove("hub0", &error_abort);
|
qmp_chardev_remove("hub0", &error_abort);
|
||||||
|
|
@ -803,10 +803,10 @@ static void websock_client_read(void *opaque, const uint8_t *buf, int size)
|
||||||
Chardev *chr_client = opaque;
|
Chardev *chr_client = opaque;
|
||||||
|
|
||||||
if (websock_check_http_headers((char *) buf, size)) {
|
if (websock_check_http_headers((char *) buf, size)) {
|
||||||
qemu_chr_fe_write(chr_client->be, ping, sizeof(ping));
|
qemu_chr_fe_write(chr_client->fe, ping, sizeof(ping));
|
||||||
} else if (buf[0] == 0x8a && buf[1] == 0x05) {
|
} else if (buf[0] == 0x8a && buf[1] == 0x05) {
|
||||||
g_assert(strncmp((char *) buf + 2, "hello", 5) == 0);
|
g_assert(strncmp((char *) buf + 2, "hello", 5) == 0);
|
||||||
qemu_chr_fe_write(chr_client->be, binary, sizeof(binary));
|
qemu_chr_fe_write(chr_client->fe, binary, sizeof(binary));
|
||||||
} else {
|
} else {
|
||||||
g_assert(buf[0] == 0x88 && buf[1] == 0x16);
|
g_assert(buf[0] == 0x88 && buf[1] == 0x16);
|
||||||
g_assert(strncmp((char *) buf + 4, "peer requested close", 10) == 0);
|
g_assert(strncmp((char *) buf + 4, "peer requested close", 10) == 0);
|
||||||
|
|
@ -828,8 +828,8 @@ static void char_websock_test(void)
|
||||||
const char *port;
|
const char *port;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
char *handshake_port;
|
char *handshake_port;
|
||||||
CharBackend be;
|
CharFrontend fe;
|
||||||
CharBackend client_be;
|
CharFrontend client_fe;
|
||||||
Chardev *chr_client;
|
Chardev *chr_client;
|
||||||
Chardev *chr = qemu_chr_new("server",
|
Chardev *chr = qemu_chr_new("server",
|
||||||
"websocket:127.0.0.1:0,server=on,wait=off", NULL);
|
"websocket:127.0.0.1:0,server=on,wait=off", NULL);
|
||||||
|
|
@ -852,13 +852,13 @@ static void char_websock_test(void)
|
||||||
handshake_port = g_strdup_printf(handshake, port, port);
|
handshake_port = g_strdup_printf(handshake, port, port);
|
||||||
qobject_unref(qdict);
|
qobject_unref(qdict);
|
||||||
|
|
||||||
qemu_chr_fe_init(&be, chr, &error_abort);
|
qemu_chr_fe_init(&fe, chr, &error_abort);
|
||||||
qemu_chr_fe_set_handlers(&be, websock_server_can_read, websock_server_read,
|
qemu_chr_fe_set_handlers(&fe, websock_server_can_read, websock_server_read,
|
||||||
NULL, NULL, chr, NULL, true);
|
NULL, NULL, chr, NULL, true);
|
||||||
|
|
||||||
chr_client = qemu_chr_new("client", tmp, NULL);
|
chr_client = qemu_chr_new("client", tmp, NULL);
|
||||||
qemu_chr_fe_init(&client_be, chr_client, &error_abort);
|
qemu_chr_fe_init(&client_fe, chr_client, &error_abort);
|
||||||
qemu_chr_fe_set_handlers(&client_be, websock_client_can_read,
|
qemu_chr_fe_set_handlers(&client_fe, websock_client_can_read,
|
||||||
websock_client_read,
|
websock_client_read,
|
||||||
NULL, NULL, chr_client, NULL, true);
|
NULL, NULL, chr_client, NULL, true);
|
||||||
g_free(tmp);
|
g_free(tmp);
|
||||||
|
|
@ -887,7 +887,7 @@ static void char_pipe_test(void)
|
||||||
gchar *tmp_path = g_dir_make_tmp("qemu-test-char.XXXXXX", NULL);
|
gchar *tmp_path = g_dir_make_tmp("qemu-test-char.XXXXXX", NULL);
|
||||||
gchar *tmp, *in, *out, *pipe = g_build_filename(tmp_path, "pipe", NULL);
|
gchar *tmp, *in, *out, *pipe = g_build_filename(tmp_path, "pipe", NULL);
|
||||||
Chardev *chr;
|
Chardev *chr;
|
||||||
CharBackend be;
|
CharFrontend c;
|
||||||
int ret, fd;
|
int ret, fd;
|
||||||
char buf[10];
|
char buf[10];
|
||||||
FeHandler fe = { 0, };
|
FeHandler fe = { 0, };
|
||||||
|
|
@ -906,9 +906,9 @@ static void char_pipe_test(void)
|
||||||
g_assert_nonnull(chr);
|
g_assert_nonnull(chr);
|
||||||
g_free(tmp);
|
g_free(tmp);
|
||||||
|
|
||||||
qemu_chr_fe_init(&be, chr, &error_abort);
|
qemu_chr_fe_init(&c, chr, &error_abort);
|
||||||
|
|
||||||
ret = qemu_chr_fe_write(&be, (void *)"pipe-out", 9);
|
ret = qemu_chr_fe_write(&c, (void *)"pipe-out", 9);
|
||||||
g_assert_cmpint(ret, ==, 9);
|
g_assert_cmpint(ret, ==, 9);
|
||||||
|
|
||||||
fd = open(out, O_RDWR);
|
fd = open(out, O_RDWR);
|
||||||
|
|
@ -922,7 +922,7 @@ static void char_pipe_test(void)
|
||||||
g_assert_cmpint(ret, ==, 8);
|
g_assert_cmpint(ret, ==, 8);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
qemu_chr_fe_set_handlers(&be,
|
qemu_chr_fe_set_handlers(&c,
|
||||||
fe_can_read,
|
fe_can_read,
|
||||||
fe_read,
|
fe_read,
|
||||||
fe_event,
|
fe_event,
|
||||||
|
|
@ -935,7 +935,7 @@ static void char_pipe_test(void)
|
||||||
g_assert_cmpint(fe.read_count, ==, 8);
|
g_assert_cmpint(fe.read_count, ==, 8);
|
||||||
g_assert_cmpstr(fe.read_buf, ==, "pipe-in");
|
g_assert_cmpstr(fe.read_buf, ==, "pipe-in");
|
||||||
|
|
||||||
qemu_chr_fe_deinit(&be, true);
|
qemu_chr_fe_deinit(&c, true);
|
||||||
|
|
||||||
g_assert(g_unlink(in) == 0);
|
g_assert(g_unlink(in) == 0);
|
||||||
g_assert(g_unlink(out) == 0);
|
g_assert(g_unlink(out) == 0);
|
||||||
|
|
@ -951,8 +951,8 @@ typedef struct SocketIdleData {
|
||||||
GMainLoop *loop;
|
GMainLoop *loop;
|
||||||
Chardev *chr;
|
Chardev *chr;
|
||||||
bool conn_expected;
|
bool conn_expected;
|
||||||
CharBackend *be;
|
CharFrontend *fe;
|
||||||
CharBackend *client_be;
|
CharFrontend *client_fe;
|
||||||
} SocketIdleData;
|
} SocketIdleData;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -993,7 +993,7 @@ static void char_udp_test_internal(Chardev *reuse_chr, int sock)
|
||||||
struct sockaddr_in other;
|
struct sockaddr_in other;
|
||||||
SocketIdleData d = { 0, };
|
SocketIdleData d = { 0, };
|
||||||
Chardev *chr;
|
Chardev *chr;
|
||||||
CharBackend stack_be, *be = &stack_be;
|
CharFrontend stack_fe, *fe = &stack_fe;
|
||||||
socklen_t alen = sizeof(other);
|
socklen_t alen = sizeof(other);
|
||||||
int ret;
|
int ret;
|
||||||
char buf[10];
|
char buf[10];
|
||||||
|
|
@ -1001,7 +1001,7 @@ static void char_udp_test_internal(Chardev *reuse_chr, int sock)
|
||||||
|
|
||||||
if (reuse_chr) {
|
if (reuse_chr) {
|
||||||
chr = reuse_chr;
|
chr = reuse_chr;
|
||||||
be = chr->be;
|
fe = chr->fe;
|
||||||
} else {
|
} else {
|
||||||
int port;
|
int port;
|
||||||
sock = make_udp_socket(&port);
|
sock = make_udp_socket(&port);
|
||||||
|
|
@ -1009,11 +1009,11 @@ static void char_udp_test_internal(Chardev *reuse_chr, int sock)
|
||||||
chr = qemu_chr_new("client", tmp, NULL);
|
chr = qemu_chr_new("client", tmp, NULL);
|
||||||
g_assert_nonnull(chr);
|
g_assert_nonnull(chr);
|
||||||
|
|
||||||
qemu_chr_fe_init(be, chr, &error_abort);
|
qemu_chr_fe_init(fe, chr, &error_abort);
|
||||||
}
|
}
|
||||||
|
|
||||||
d.chr = chr;
|
d.chr = chr;
|
||||||
qemu_chr_fe_set_handlers(be, socket_can_read_hello, socket_read_hello,
|
qemu_chr_fe_set_handlers(fe, socket_can_read_hello, socket_read_hello,
|
||||||
NULL, NULL, &d, NULL, true);
|
NULL, NULL, &d, NULL, true);
|
||||||
ret = qemu_chr_write_all(chr, (uint8_t *)"hello", 5);
|
ret = qemu_chr_write_all(chr, (uint8_t *)"hello", 5);
|
||||||
g_assert_cmpint(ret, ==, 5);
|
g_assert_cmpint(ret, ==, 5);
|
||||||
|
|
@ -1028,7 +1028,7 @@ static void char_udp_test_internal(Chardev *reuse_chr, int sock)
|
||||||
|
|
||||||
if (!reuse_chr) {
|
if (!reuse_chr) {
|
||||||
close(sock);
|
close(sock);
|
||||||
qemu_chr_fe_deinit(be, true);
|
qemu_chr_fe_deinit(fe, true);
|
||||||
}
|
}
|
||||||
g_free(tmp);
|
g_free(tmp);
|
||||||
}
|
}
|
||||||
|
|
@ -1042,7 +1042,7 @@ static void char_udp_test(void)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int event;
|
int event;
|
||||||
bool got_pong;
|
bool got_pong;
|
||||||
CharBackend *be;
|
CharFrontend *fe;
|
||||||
} CharSocketTestData;
|
} CharSocketTestData;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1063,13 +1063,13 @@ char_socket_event_with_error(void *opaque, QEMUChrEvent event)
|
||||||
{
|
{
|
||||||
static bool first_error;
|
static bool first_error;
|
||||||
CharSocketTestData *data = opaque;
|
CharSocketTestData *data = opaque;
|
||||||
CharBackend *be = data->be;
|
CharFrontend *fe = data->fe;
|
||||||
data->event = event;
|
data->event = event;
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case CHR_EVENT_OPENED:
|
case CHR_EVENT_OPENED:
|
||||||
if (!first_error) {
|
if (!first_error) {
|
||||||
first_error = true;
|
first_error = true;
|
||||||
qemu_chr_fe_disconnect(be);
|
qemu_chr_fe_disconnect(fe);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case CHR_EVENT_CLOSED:
|
case CHR_EVENT_CLOSED:
|
||||||
|
|
@ -1185,7 +1185,7 @@ static void char_socket_server_test(gconstpointer opaque)
|
||||||
{
|
{
|
||||||
const CharSocketServerTestConfig *config = opaque;
|
const CharSocketServerTestConfig *config = opaque;
|
||||||
Chardev *chr;
|
Chardev *chr;
|
||||||
CharBackend be = {0};
|
CharFrontend c = {0};
|
||||||
CharSocketTestData data = {0};
|
CharSocketTestData data = {0};
|
||||||
QObject *qaddr;
|
QObject *qaddr;
|
||||||
SocketAddress *addr;
|
SocketAddress *addr;
|
||||||
|
|
@ -1224,12 +1224,12 @@ static void char_socket_server_test(gconstpointer opaque)
|
||||||
visit_free(v);
|
visit_free(v);
|
||||||
qobject_unref(qaddr);
|
qobject_unref(qaddr);
|
||||||
|
|
||||||
qemu_chr_fe_init(&be, chr, &error_abort);
|
qemu_chr_fe_init(&c, chr, &error_abort);
|
||||||
|
|
||||||
reconnect:
|
reconnect:
|
||||||
data.event = -1;
|
data.event = -1;
|
||||||
data.be = &be;
|
data.fe = &c;
|
||||||
qemu_chr_fe_set_handlers(&be, NULL, NULL,
|
qemu_chr_fe_set_handlers(&c, NULL, NULL,
|
||||||
char_socket_event, NULL,
|
char_socket_event, NULL,
|
||||||
&data, NULL, true);
|
&data, NULL, true);
|
||||||
g_assert(data.event == -1);
|
g_assert(data.event == -1);
|
||||||
|
|
@ -1260,13 +1260,13 @@ static void char_socket_server_test(gconstpointer opaque)
|
||||||
data.event = -1;
|
data.event = -1;
|
||||||
|
|
||||||
/* Send a greeting to the client */
|
/* Send a greeting to the client */
|
||||||
ret = qemu_chr_fe_write_all(&be, (const uint8_t *)SOCKET_PING,
|
ret = qemu_chr_fe_write_all(&c, (const uint8_t *)SOCKET_PING,
|
||||||
sizeof(SOCKET_PING));
|
sizeof(SOCKET_PING));
|
||||||
g_assert_cmpint(ret, ==, sizeof(SOCKET_PING));
|
g_assert_cmpint(ret, ==, sizeof(SOCKET_PING));
|
||||||
g_assert(data.event == -1);
|
g_assert(data.event == -1);
|
||||||
|
|
||||||
/* Setup a callback to receive the reply to our greeting */
|
/* Setup a callback to receive the reply to our greeting */
|
||||||
qemu_chr_fe_set_handlers(&be, char_socket_can_read,
|
qemu_chr_fe_set_handlers(&c, char_socket_can_read,
|
||||||
char_socket_read,
|
char_socket_read,
|
||||||
char_socket_event, NULL,
|
char_socket_event, NULL,
|
||||||
&data, NULL, true);
|
&data, NULL, true);
|
||||||
|
|
@ -1375,7 +1375,7 @@ static void char_socket_client_test(gconstpointer opaque)
|
||||||
QIOChannelSocket *ioc;
|
QIOChannelSocket *ioc;
|
||||||
char *optstr;
|
char *optstr;
|
||||||
Chardev *chr;
|
Chardev *chr;
|
||||||
CharBackend be = {0};
|
CharFrontend c = {0};
|
||||||
CharSocketTestData data = {0};
|
CharSocketTestData data = {0};
|
||||||
SocketAddress *addr;
|
SocketAddress *addr;
|
||||||
QemuThread thread;
|
QemuThread thread;
|
||||||
|
|
@ -1431,12 +1431,12 @@ static void char_socket_client_test(gconstpointer opaque)
|
||||||
&error_abort));
|
&error_abort));
|
||||||
}
|
}
|
||||||
|
|
||||||
qemu_chr_fe_init(&be, chr, &error_abort);
|
qemu_chr_fe_init(&c, chr, &error_abort);
|
||||||
|
|
||||||
reconnect:
|
reconnect:
|
||||||
data.event = -1;
|
data.event = -1;
|
||||||
data.be = &be;
|
data.fe = &c;
|
||||||
qemu_chr_fe_set_handlers(&be, NULL, NULL,
|
qemu_chr_fe_set_handlers(&c, NULL, NULL,
|
||||||
event_cb, NULL,
|
event_cb, NULL,
|
||||||
&data, NULL, true);
|
&data, NULL, true);
|
||||||
if (config->reconnect) {
|
if (config->reconnect) {
|
||||||
|
|
@ -1467,13 +1467,13 @@ static void char_socket_client_test(gconstpointer opaque)
|
||||||
g_assert(object_property_get_bool(OBJECT(chr), "connected", &error_abort));
|
g_assert(object_property_get_bool(OBJECT(chr), "connected", &error_abort));
|
||||||
|
|
||||||
/* Send a greeting to the server */
|
/* Send a greeting to the server */
|
||||||
ret = qemu_chr_fe_write_all(&be, (const uint8_t *)SOCKET_PING,
|
ret = qemu_chr_fe_write_all(&c, (const uint8_t *)SOCKET_PING,
|
||||||
sizeof(SOCKET_PING));
|
sizeof(SOCKET_PING));
|
||||||
g_assert_cmpint(ret, ==, sizeof(SOCKET_PING));
|
g_assert_cmpint(ret, ==, sizeof(SOCKET_PING));
|
||||||
g_assert(data.event == -1);
|
g_assert(data.event == -1);
|
||||||
|
|
||||||
/* Setup a callback to receive the reply to our greeting */
|
/* Setup a callback to receive the reply to our greeting */
|
||||||
qemu_chr_fe_set_handlers(&be, char_socket_can_read,
|
qemu_chr_fe_set_handlers(&c, char_socket_can_read,
|
||||||
char_socket_read,
|
char_socket_read,
|
||||||
event_cb, NULL,
|
event_cb, NULL,
|
||||||
&data, NULL, true);
|
&data, NULL, true);
|
||||||
|
|
@ -1521,7 +1521,7 @@ static void char_socket_server_two_clients_test(gconstpointer opaque)
|
||||||
{
|
{
|
||||||
SocketAddress *incoming_addr = (gpointer) opaque;
|
SocketAddress *incoming_addr = (gpointer) opaque;
|
||||||
Chardev *chr;
|
Chardev *chr;
|
||||||
CharBackend be = {0};
|
CharFrontend c = {0};
|
||||||
QObject *qaddr;
|
QObject *qaddr;
|
||||||
SocketAddress *addr;
|
SocketAddress *addr;
|
||||||
Visitor *v;
|
Visitor *v;
|
||||||
|
|
@ -1558,9 +1558,9 @@ static void char_socket_server_two_clients_test(gconstpointer opaque)
|
||||||
visit_free(v);
|
visit_free(v);
|
||||||
qobject_unref(qaddr);
|
qobject_unref(qaddr);
|
||||||
|
|
||||||
qemu_chr_fe_init(&be, chr, &error_abort);
|
qemu_chr_fe_init(&c, chr, &error_abort);
|
||||||
|
|
||||||
qemu_chr_fe_set_handlers(&be, char_socket_can_read, char_socket_discard_read,
|
qemu_chr_fe_set_handlers(&c, char_socket_can_read, char_socket_discard_read,
|
||||||
count_closed_event, NULL,
|
count_closed_event, NULL,
|
||||||
&closed, NULL, true);
|
&closed, NULL, true);
|
||||||
|
|
||||||
|
|
@ -1570,7 +1570,7 @@ static void char_socket_server_two_clients_test(gconstpointer opaque)
|
||||||
|
|
||||||
/* switch the chardev to another context */
|
/* switch the chardev to another context */
|
||||||
GMainContext *ctx = g_main_context_new();
|
GMainContext *ctx = g_main_context_new();
|
||||||
qemu_chr_fe_set_handlers(&be, char_socket_can_read, char_socket_discard_read,
|
qemu_chr_fe_set_handlers(&c, char_socket_can_read, char_socket_discard_read,
|
||||||
count_closed_event, NULL,
|
count_closed_event, NULL,
|
||||||
&closed, ctx, true);
|
&closed, ctx, true);
|
||||||
|
|
||||||
|
|
@ -1649,7 +1649,7 @@ static void char_parallel_test(void)
|
||||||
static void char_file_fifo_test(void)
|
static void char_file_fifo_test(void)
|
||||||
{
|
{
|
||||||
Chardev *chr;
|
Chardev *chr;
|
||||||
CharBackend be;
|
CharFrontend c;
|
||||||
char *tmp_path = g_dir_make_tmp("qemu-test-char.XXXXXX", NULL);
|
char *tmp_path = g_dir_make_tmp("qemu-test-char.XXXXXX", NULL);
|
||||||
char *fifo = g_build_filename(tmp_path, "fifo", NULL);
|
char *fifo = g_build_filename(tmp_path, "fifo", NULL);
|
||||||
char *out = g_build_filename(tmp_path, "out", NULL);
|
char *out = g_build_filename(tmp_path, "out", NULL);
|
||||||
|
|
@ -1671,8 +1671,8 @@ static void char_file_fifo_test(void)
|
||||||
chr = qemu_chardev_new("label-file", TYPE_CHARDEV_FILE, &backend,
|
chr = qemu_chardev_new("label-file", TYPE_CHARDEV_FILE, &backend,
|
||||||
NULL, &error_abort);
|
NULL, &error_abort);
|
||||||
|
|
||||||
qemu_chr_fe_init(&be, chr, &error_abort);
|
qemu_chr_fe_init(&c, chr, &error_abort);
|
||||||
qemu_chr_fe_set_handlers(&be,
|
qemu_chr_fe_set_handlers(&c,
|
||||||
fe_can_read,
|
fe_can_read,
|
||||||
fe_read,
|
fe_read,
|
||||||
fe_event,
|
fe_event,
|
||||||
|
|
@ -1692,7 +1692,7 @@ static void char_file_fifo_test(void)
|
||||||
g_assert_cmpint(fe.read_count, ==, 8);
|
g_assert_cmpint(fe.read_count, ==, 8);
|
||||||
g_assert_cmpstr(fe.read_buf, ==, "fifo-in");
|
g_assert_cmpstr(fe.read_buf, ==, "fifo-in");
|
||||||
|
|
||||||
qemu_chr_fe_deinit(&be, true);
|
qemu_chr_fe_deinit(&c, true);
|
||||||
|
|
||||||
g_unlink(fifo);
|
g_unlink(fifo);
|
||||||
g_free(fifo);
|
g_free(fifo);
|
||||||
|
|
@ -1752,7 +1752,7 @@ static void char_null_test(void)
|
||||||
{
|
{
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
Chardev *chr;
|
Chardev *chr;
|
||||||
CharBackend be;
|
CharFrontend c;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
chr = qemu_chr_find("label-null");
|
chr = qemu_chr_find("label-null");
|
||||||
|
|
@ -1768,27 +1768,27 @@ static void char_null_test(void)
|
||||||
QEMU_CHAR_FEATURE_RECONNECTABLE) == false);
|
QEMU_CHAR_FEATURE_RECONNECTABLE) == false);
|
||||||
|
|
||||||
/* check max avail */
|
/* check max avail */
|
||||||
qemu_chr_fe_init(&be, chr, &error_abort);
|
qemu_chr_fe_init(&c, chr, &error_abort);
|
||||||
qemu_chr_fe_init(&be, chr, &err);
|
qemu_chr_fe_init(&c, chr, &err);
|
||||||
error_free_or_abort(&err);
|
error_free_or_abort(&err);
|
||||||
|
|
||||||
/* deinit & reinit */
|
/* deinit & reinit */
|
||||||
qemu_chr_fe_deinit(&be, false);
|
qemu_chr_fe_deinit(&c, false);
|
||||||
qemu_chr_fe_init(&be, chr, &error_abort);
|
qemu_chr_fe_init(&c, chr, &error_abort);
|
||||||
|
|
||||||
qemu_chr_fe_set_open(&be, true);
|
qemu_chr_fe_set_open(&c, true);
|
||||||
|
|
||||||
qemu_chr_fe_set_handlers(&be,
|
qemu_chr_fe_set_handlers(&c,
|
||||||
fe_can_read,
|
fe_can_read,
|
||||||
fe_read,
|
fe_read,
|
||||||
fe_event,
|
fe_event,
|
||||||
NULL,
|
NULL,
|
||||||
NULL, NULL, true);
|
NULL, NULL, true);
|
||||||
|
|
||||||
ret = qemu_chr_fe_write(&be, (void *)"buf", 4);
|
ret = qemu_chr_fe_write(&c, (void *)"buf", 4);
|
||||||
g_assert_cmpint(ret, ==, 4);
|
g_assert_cmpint(ret, ==, 4);
|
||||||
|
|
||||||
qemu_chr_fe_deinit(&be, true);
|
qemu_chr_fe_deinit(&c, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void char_invalid_test(void)
|
static void char_invalid_test(void)
|
||||||
|
|
@ -1814,7 +1814,7 @@ static void char_hotswap_test(void)
|
||||||
{
|
{
|
||||||
char *chr_args;
|
char *chr_args;
|
||||||
Chardev *chr;
|
Chardev *chr;
|
||||||
CharBackend be;
|
CharFrontend c;
|
||||||
|
|
||||||
gchar *tmp_path = g_dir_make_tmp("qemu-test-char.XXXXXX", NULL);
|
gchar *tmp_path = g_dir_make_tmp("qemu-test-char.XXXXXX", NULL);
|
||||||
char *filename = g_build_filename(tmp_path, "file", NULL);
|
char *filename = g_build_filename(tmp_path, "file", NULL);
|
||||||
|
|
@ -1830,32 +1830,32 @@ static void char_hotswap_test(void)
|
||||||
chr_args = g_strdup_printf("udp:127.0.0.1:%d", port);
|
chr_args = g_strdup_printf("udp:127.0.0.1:%d", port);
|
||||||
|
|
||||||
chr = qemu_chr_new("chardev", chr_args, NULL);
|
chr = qemu_chr_new("chardev", chr_args, NULL);
|
||||||
qemu_chr_fe_init(&be, chr, &error_abort);
|
qemu_chr_fe_init(&c, chr, &error_abort);
|
||||||
|
|
||||||
/* check that chardev operates correctly */
|
/* check that chardev operates correctly */
|
||||||
char_udp_test_internal(chr, sock);
|
char_udp_test_internal(chr, sock);
|
||||||
|
|
||||||
/* set the handler that denies the hotswap */
|
/* set the handler that denies the hotswap */
|
||||||
qemu_chr_fe_set_handlers(&be, NULL, NULL,
|
qemu_chr_fe_set_handlers(&c, NULL, NULL,
|
||||||
NULL, chardev_change_denied, NULL, NULL, true);
|
NULL, chardev_change_denied, NULL, NULL, true);
|
||||||
|
|
||||||
/* now, change is denied and has to keep the old backend operating */
|
/* now, change is denied and has to keep the old backend operating */
|
||||||
ret = qmp_chardev_change("chardev", &backend, NULL);
|
ret = qmp_chardev_change("chardev", &backend, NULL);
|
||||||
g_assert(!ret);
|
g_assert(!ret);
|
||||||
g_assert(be.chr == chr);
|
g_assert(c.chr == chr);
|
||||||
|
|
||||||
char_udp_test_internal(chr, sock);
|
char_udp_test_internal(chr, sock);
|
||||||
|
|
||||||
/* now allow the change */
|
/* now allow the change */
|
||||||
qemu_chr_fe_set_handlers(&be, NULL, NULL,
|
qemu_chr_fe_set_handlers(&c, NULL, NULL,
|
||||||
NULL, chardev_change, NULL, NULL, true);
|
NULL, chardev_change, NULL, NULL, true);
|
||||||
|
|
||||||
/* has to succeed now */
|
/* has to succeed now */
|
||||||
ret = qmp_chardev_change("chardev", &backend, &error_abort);
|
ret = qmp_chardev_change("chardev", &backend, &error_abort);
|
||||||
g_assert(be.chr != chr);
|
g_assert(c.chr != chr);
|
||||||
|
|
||||||
close(sock);
|
close(sock);
|
||||||
chr = be.chr;
|
chr = c.chr;
|
||||||
|
|
||||||
/* run the file chardev test */
|
/* run the file chardev test */
|
||||||
char_file_test_internal(chr, filename);
|
char_file_test_internal(chr, filename);
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ static void char_change_test(gconstpointer opaque)
|
||||||
CharChangeTestConfig *conf = (gpointer) opaque;
|
CharChangeTestConfig *conf = (gpointer) opaque;
|
||||||
SocketAddress *addr;
|
SocketAddress *addr;
|
||||||
Chardev *chr;
|
Chardev *chr;
|
||||||
CharBackend be;
|
CharFrontend fe;
|
||||||
ChardevReturn *ret;
|
ChardevReturn *ret;
|
||||||
QIOChannelSocket *ioc;
|
QIOChannelSocket *ioc;
|
||||||
QemuThread thread;
|
QemuThread thread;
|
||||||
|
|
@ -144,9 +144,9 @@ static void char_change_test(gconstpointer opaque)
|
||||||
qemu_thread_join(&thread);
|
qemu_thread_join(&thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
qemu_chr_fe_init(&be, chr, &error_abort);
|
qemu_chr_fe_init(&fe, chr, &error_abort);
|
||||||
/* allow chardev-change */
|
/* allow chardev-change */
|
||||||
qemu_chr_fe_set_handlers(&be, NULL, NULL,
|
qemu_chr_fe_set_handlers(&fe, NULL, NULL,
|
||||||
NULL, chardev_change, NULL, NULL, true);
|
NULL, chardev_change, NULL, NULL, true);
|
||||||
|
|
||||||
if (conf->fail) {
|
if (conf->fail) {
|
||||||
|
|
@ -154,7 +154,7 @@ static void char_change_test(gconstpointer opaque)
|
||||||
ret = qmp_chardev_change("chardev", &fail_backend[conf->new_yank],
|
ret = qmp_chardev_change("chardev", &fail_backend[conf->new_yank],
|
||||||
NULL);
|
NULL);
|
||||||
g_assert_null(ret);
|
g_assert_null(ret);
|
||||||
g_assert(be.chr == chr);
|
g_assert(fe.chr == chr);
|
||||||
g_assert(is_yank_instance_registered() == conf->old_yank);
|
g_assert(is_yank_instance_registered() == conf->old_yank);
|
||||||
g_unsetenv("QTEST_SILENT_ERRORS");
|
g_unsetenv("QTEST_SILENT_ERRORS");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -168,11 +168,11 @@ static void char_change_test(gconstpointer opaque)
|
||||||
qemu_thread_join(&thread);
|
qemu_thread_join(&thread);
|
||||||
}
|
}
|
||||||
g_assert_nonnull(ret);
|
g_assert_nonnull(ret);
|
||||||
g_assert(be.chr != chr);
|
g_assert(fe.chr != chr);
|
||||||
g_assert(is_yank_instance_registered() == conf->new_yank);
|
g_assert(is_yank_instance_registered() == conf->new_yank);
|
||||||
}
|
}
|
||||||
|
|
||||||
object_unparent(OBJECT(be.chr));
|
object_unparent(OBJECT(fe.chr));
|
||||||
object_unref(OBJECT(ioc));
|
object_unref(OBJECT(ioc));
|
||||||
qapi_free_ChardevReturn(ret);
|
qapi_free_ChardevReturn(ret);
|
||||||
qapi_free_SocketAddress(addr);
|
qapi_free_SocketAddress(addr);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue