Commit b47543c4f065e6cab06676a988a49c5d09229abe

Authored by aurel32
1 parent ceecf1d1

serial: open a null device if the CharDriverState argument is null

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6366 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 3 additions and 5 deletions
hw/serial.c
@@ -711,7 +711,7 @@ static void serial_init_core(SerialState *s, qemu_irq irq, int baudbase, @@ -711,7 +711,7 @@ static void serial_init_core(SerialState *s, qemu_irq irq, int baudbase,
711 { 711 {
712 s->irq = irq; 712 s->irq = irq;
713 s->baudbase = baudbase; 713 s->baudbase = baudbase;
714 - s->chr = chr; 714 + s->chr = chr ?: qemu_chr_open("null", "null", NULL);
715 715
716 s->modem_status_poll = qemu_new_timer(vm_clock, (QEMUTimerCB *) serial_update_msl, s); 716 s->modem_status_poll = qemu_new_timer(vm_clock, (QEMUTimerCB *) serial_update_msl, s);
717 717
@@ -721,6 +721,8 @@ static void serial_init_core(SerialState *s, qemu_irq irq, int baudbase, @@ -721,6 +721,8 @@ static void serial_init_core(SerialState *s, qemu_irq irq, int baudbase,
721 qemu_register_reset(serial_reset, s); 721 qemu_register_reset(serial_reset, s);
722 serial_reset(s); 722 serial_reset(s);
723 723
  724 + qemu_chr_add_handlers(s->chr, serial_can_receive1, serial_receive1,
  725 + serial_event, s);
724 } 726 }
725 727
726 /* If fd is zero, it means that the serial device uses the console */ 728 /* 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, @@ -739,8 +741,6 @@ SerialState *serial_init(int base, qemu_irq irq, int baudbase,
739 741
740 register_ioport_write(base, 8, 1, serial_ioport_write, s); 742 register_ioport_write(base, 8, 1, serial_ioport_write, s);
741 register_ioport_read(base, 8, 1, serial_ioport_read, s); 743 register_ioport_read(base, 8, 1, serial_ioport_read, s);
742 - qemu_chr_add_handlers(chr, serial_can_receive1, serial_receive1,  
743 - serial_event, s);  
744 return s; 744 return s;
745 } 745 }
746 746
@@ -837,8 +837,6 @@ SerialState *serial_mm_init (target_phys_addr_t base, int it_shift, @@ -837,8 +837,6 @@ SerialState *serial_mm_init (target_phys_addr_t base, int it_shift,
837 serial_mm_write, s); 837 serial_mm_write, s);
838 cpu_register_physical_memory(base, 8 << it_shift, s_io_memory); 838 cpu_register_physical_memory(base, 8 << it_shift, s_io_memory);
839 } 839 }
840 - qemu_chr_add_handlers(chr, serial_can_receive1, serial_receive1,  
841 - serial_event, s);  
842 serial_update_msl(s); 840 serial_update_msl(s);
843 return s; 841 return s;
844 } 842 }