aboutsummaryrefslogtreecommitdiff
path: root/hw/char/xen_console.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/char/xen_console.c')
-rw-r--r--hw/char/xen_console.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/hw/char/xen_console.c b/hw/char/xen_console.c
index 11bf6a44cf..c1d36dc2d0 100644
--- a/hw/char/xen_console.c
+++ b/hw/char/xen_console.c
@@ -26,6 +26,7 @@
#include "hw/hw.h"
#include "sysemu/char.h"
#include "hw/xen/xen_backend.h"
+#include "qapi/error.h"
#include <xen/io/console.h>
@@ -43,7 +44,7 @@ struct XenConsole {
char console[XEN_BUFSIZE];
int ring_ref;
void *sring;
- CharDriverState *chr;
+ CharBackend chr;
int backlog;
};
@@ -148,11 +149,13 @@ static void xencons_send(struct XenConsole *con)
ssize_t len, size;
size = con->buffer.size - con->buffer.consumed;
- if (con->chr)
- len = qemu_chr_fe_write(con->chr, con->buffer.data + con->buffer.consumed,
- size);
- else
+ if (con->chr.chr) {
+ len = qemu_chr_fe_write(con->chr.chr,
+ con->buffer.data + con->buffer.consumed,
+ size);
+ } else {
len = size;
+ }
if (len < 1) {
if (!con->backlog) {
con->backlog = 1;
@@ -196,13 +199,17 @@ static int con_init(struct XenDevice *xendev)
/* no Xen override, use qemu output device */
if (output == NULL) {
- con->chr = serial_hds[con->xendev.dev];
+ if (con->xendev.dev) {
+ qemu_chr_fe_init(&con->chr, serial_hds[con->xendev.dev],
+ &error_abort);
+ }
} else {
snprintf(label, sizeof(label), "xencons%d", con->xendev.dev);
- con->chr = qemu_chr_new(label, output);
+ qemu_chr_fe_init(&con->chr,
+ qemu_chr_new(label, output), &error_abort);
}
- xenstore_store_pv_console_info(con->xendev.dev, con->chr);
+ xenstore_store_pv_console_info(con->xendev.dev, con->chr.chr);
out:
g_free(type);
@@ -235,15 +242,15 @@ static int con_initialise(struct XenDevice *xendev)
return -1;
xen_be_bind_evtchn(&con->xendev);
- if (con->chr) {
- if (qemu_chr_fe_claim(con->chr) == 0) {
- qemu_chr_add_handlers(con->chr, xencons_can_receive,
+ if (con->chr.chr) {
+ if (qemu_chr_fe_claim(con->chr.chr) == 0) {
+ qemu_chr_add_handlers(con->chr.chr, xencons_can_receive,
xencons_receive, NULL, con);
} else {
xen_be_printf(xendev, 0,
"xen_console_init error chardev %s already used\n",
- con->chr->label);
- con->chr = NULL;
+ con->chr.chr->label);
+ con->chr.chr = NULL;
}
}
@@ -259,9 +266,9 @@ static void con_disconnect(struct XenDevice *xendev)
{
struct XenConsole *con = container_of(xendev, struct XenConsole, xendev);
- if (con->chr) {
- qemu_chr_add_handlers(con->chr, NULL, NULL, NULL, NULL);
- qemu_chr_fe_release(con->chr);
+ if (con->chr.chr) {
+ qemu_chr_add_handlers(con->chr.chr, NULL, NULL, NULL, NULL);
+ qemu_chr_fe_release(con->chr.chr);
}
xen_be_unbind_evtchn(&con->xendev);