aboutsummaryrefslogtreecommitdiff
path: root/qemu-char.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2016-10-21 22:38:41 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2017-01-27 18:07:59 +0100
commitad5c679c7f4c10cc1bf4899ee2dfba08cc383f13 (patch)
tree7ff650b5ae1842470469f45e6da7b3902336aca7 /qemu-char.c
parentacbfbe4a060442122ca099122e60a191d0715d41 (diff)
char: introduce generic qemu_chr_get_kind()
This allows to remove the "is_mux" field from CharDriverState. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'qemu-char.c')
-rw-r--r--qemu-char.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/qemu-char.c b/qemu-char.c
index 4719ad6959..a7afb5978d 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -781,7 +781,7 @@ static void muxes_realize_done(Notifier *notifier, void *unused)
CharDriverState *chr;
QTAILQ_FOREACH(chr, &chardevs, next) {
- if (chr->is_mux) {
+ if (qemu_chr_get_kind(chr) == CHARDEV_BACKEND_KIND_MUX) {
MuxDriver *d = chr->opaque;
int i;
@@ -888,7 +888,6 @@ static CharDriverState *qemu_chr_open_mux(const CharDriver *driver,
* set of muxes
*/
*be_opened = muxes_realized;
- chr->is_mux = 1;
if (!qemu_chr_fe_init(&d->chr, drv, errp)) {
qemu_chr_free(chr);
return NULL;
@@ -906,7 +905,7 @@ bool qemu_chr_fe_init(CharBackend *b, CharDriverState *s, Error **errp)
{
int tag = 0;
- if (s->is_mux) {
+ if (qemu_chr_get_kind(s) == CHARDEV_BACKEND_KIND_MUX) {
MuxDriver *d = s->opaque;
if (d->mux_cnt >= MAX_MUX) {
@@ -933,7 +932,7 @@ unavailable:
static bool qemu_chr_is_busy(CharDriverState *s)
{
- if (s->is_mux) {
+ if (qemu_chr_get_kind(s) == CHARDEV_BACKEND_KIND_MUX) {
MuxDriver *d = s->opaque;
return d->mux_cnt >= 0;
} else {
@@ -950,7 +949,7 @@ void qemu_chr_fe_deinit(CharBackend *b)
if (b->chr->be == b) {
b->chr->be = NULL;
}
- if (b->chr->is_mux) {
+ if (qemu_chr_get_kind(b->chr) == CHARDEV_BACKEND_KIND_MUX) {
MuxDriver *d = b->chr->opaque;
d->backends[b->tag] = NULL;
}
@@ -1001,7 +1000,7 @@ void qemu_chr_fe_set_handlers(CharBackend *b,
}
}
- if (s->is_mux) {
+ if (qemu_chr_get_kind(s) == CHARDEV_BACKEND_KIND_MUX) {
mux_chr_set_handlers(s, context);
}
}
@@ -1012,7 +1011,7 @@ void qemu_chr_fe_take_focus(CharBackend *b)
return;
}
- if (b->chr->is_mux) {
+ if (qemu_chr_get_kind(b->chr) == CHARDEV_BACKEND_KIND_MUX) {
mux_set_focus(b->chr, b->tag);
}
}
@@ -3559,9 +3558,9 @@ fail:
return NULL;
}
-bool chr_is_ringbuf(const CharDriverState *chr)
+ChardevBackendKind qemu_chr_get_kind(const CharDriverState *chr)
{
- return chr->driver->chr_write == ringbuf_chr_write;
+ return chr->driver->kind;
}
void qmp_ringbuf_write(const char *device, const char *data,
@@ -3579,7 +3578,7 @@ void qmp_ringbuf_write(const char *device, const char *data,
return;
}
- if (!chr_is_ringbuf(chr)) {
+ if (!qemu_chr_is_ringbuf(chr)) {
error_setg(errp,"%s is not a ringbuf device", device);
return;
}
@@ -3623,7 +3622,7 @@ char *qmp_ringbuf_read(const char *device, int64_t size,
return NULL;
}
- if (!chr_is_ringbuf(chr)) {
+ if (!qemu_chr_is_ringbuf(chr)) {
error_setg(errp,"%s is not a ringbuf device", device);
return NULL;
}