From b47543c4f065e6cab06676a988a49c5d09229abe Mon Sep 17 00:00:00 2001 From: aurel32 Date: Sun, 18 Jan 2009 14:28:10 +0000 Subject: [PATCH] serial: open a null device if the CharDriverState argument is null Signed-off-by: Aurelien Jarno git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6366 c046a42c-6fe2-441c-8c8c-71466251a162 --- hw/serial.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/hw/serial.c b/hw/serial.c index 513ad27c90..02731770df 100644 --- a/hw/serial.c +++ b/hw/serial.c @@ -711,7 +711,7 @@ static void serial_init_core(SerialState *s, qemu_irq irq, int baudbase, { s->irq = irq; s->baudbase = baudbase; - s->chr = chr; + s->chr = chr ?: qemu_chr_open("null", "null", NULL); s->modem_status_poll = qemu_new_timer(vm_clock, (QEMUTimerCB *) serial_update_msl, s); @@ -721,6 +721,8 @@ static void serial_init_core(SerialState *s, qemu_irq irq, int baudbase, qemu_register_reset(serial_reset, s); serial_reset(s); + qemu_chr_add_handlers(s->chr, serial_can_receive1, serial_receive1, + serial_event, s); } /* If fd is zero, it means that the serial device uses the console */ @@ -739,8 +741,6 @@ SerialState *serial_init(int base, qemu_irq irq, int baudbase, register_ioport_write(base, 8, 1, serial_ioport_write, s); register_ioport_read(base, 8, 1, serial_ioport_read, s); - qemu_chr_add_handlers(chr, serial_can_receive1, serial_receive1, - serial_event, s); return s; } @@ -837,8 +837,6 @@ SerialState *serial_mm_init (target_phys_addr_t base, int it_shift, serial_mm_write, s); cpu_register_physical_memory(base, 8 << it_shift, s_io_memory); } - qemu_chr_add_handlers(chr, serial_can_receive1, serial_receive1, - serial_event, s); serial_update_msl(s); return s; } -- 2.11.4.GIT