Skip to contentSkip to conversation

-serial option for 0.6.0

PATCH New Rusty Russell 1 participant 1 message Aug 18, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 -serial option for 0.6.0

I had reason recently to use a tty as a serial console, so I added the "-serial" option. This also allows you to cleanly output the serial to a file while still having a console on stdin.

Ideally it would allow use of a real serial port in future.

Thanks,
Rusty.

hw/pc.c +2 -2
diff -ur qemu-0.6.0/hw/pc.c qemu-0.6.0-serial/hw/pc.c
@@ -321,7 +321,7 @@
 void pc_init(int ram_size, int vga_ram_size, int boot_device,
              DisplayState *ds, const char **fd_filename, int snapshot,
              const char *kernel_filename, const char *kernel_cmdline,
-             const char *initrd_filename)
+             const char *initrd_filename, const char *serial_filename)
 {
     char buf[1024];
     int ret, linux_boot, initrd_size, i, nb_nics1, fd;
@@ -471,7 +471,7 @@
     pic_init();
     pit = pit_init(0x40, 0);
 
-    fd = serial_open_device();
+    fd = serial_open_device(serial_filename);
     serial_init(0x3f8, 4, fd);
 
     if (pci_enabled) {

Only in qemu-0.6.0-serial/hw: pc.c.~1~

hw/ppc.c +3 -3
diff -ur qemu-0.6.0/hw/ppc.c qemu-0.6.0-serial/hw/ppc.c
@@ -446,16 +446,16 @@
 void ppc_init (int ram_size, int vga_ram_size, int boot_device,
 	       DisplayState *ds, const char **fd_filename, int snapshot,
 	       const char *kernel_filename, const char *kernel_cmdline,
-	       const char *initrd_filename)
+	       const char *initrd_filename, const char *serial_filename)
 {
     if (prep_enabled) {
         ppc_prep_init(ram_size, vga_ram_size, boot_device, ds, fd_filename,
                       snapshot, kernel_filename, kernel_cmdline,
-                      initrd_filename);
+                      initrd_filename, serial_filename);
     } else {
         ppc_chrp_init(ram_size, vga_ram_size, boot_device, ds, fd_filename,
                       snapshot, kernel_filename, kernel_cmdline,
-                      initrd_filename);
+                      initrd_filename, serial_filename);
     }
     /* Special port to get debug messages from Open-Firmware */
     register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL);
hw/ppc_chrp.c +2 -2
diff -ur qemu-0.6.0/hw/ppc_chrp.c qemu-0.6.0-serial/hw/ppc_chrp.c
@@ -120,7 +120,7 @@
 void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device,
 		   DisplayState *ds, const char **fd_filename, int snapshot,
 		   const char *kernel_filename, const char *kernel_cmdline,
-		   const char *initrd_filename)
+		   const char *initrd_filename, const char *serial_filename)
 {
     char buf[1024];
     openpic_t *openpic;
@@ -200,7 +200,7 @@
     pic_init();
 
     /* XXX: use Mac Serial port */
-    fd = serial_open_device();
+    fd = serial_open_device(serial_filename);
     serial_init(0x3f8, 4, fd);
 
     for(i = 0; i < nb_nics; i++) {

Only in qemu-0.6.0-serial/hw: ppc_chrp.c.~1~

hw/ppc_prep.c +2 -2
diff -ur qemu-0.6.0/hw/ppc_prep.c qemu-0.6.0-serial/hw/ppc_prep.c
@@ -410,7 +410,7 @@
 void ppc_prep_init(int ram_size, int vga_ram_size, int boot_device,
 		   DisplayState *ds, const char **fd_filename, int snapshot,
 		   const char *kernel_filename, const char *kernel_cmdline,
-		   const char *initrd_filename)
+		   const char *initrd_filename, const char *serial_filename)
 {
     char buf[1024];
     m48t59_t *nvram;
@@ -492,7 +492,7 @@
     pic_init();
     //    pit = pit_init(0x40, 0);
 
-    fd = serial_open_device();
+    fd = serial_open_device(serial_filename);
     serial_init(0x3f8, 4, fd);
     nb_nics1 = nb_nics;
     if (nb_nics1 > NE2000_NB_MAX)

Only in qemu-0.6.0-serial/hw: ppc_prep.c.~1~

hw/serial.c +3 -1
diff -ur qemu-0.6.0/hw/serial.c qemu-0.6.0-serial/hw/serial.c
@@ -125,9 +125,11 @@
 
             if (s->out_fd >= 0) {
                 ch = val;
+		/* Most likely nonblocking (we do that to stdin), so
+		 * we spin, unless it's really dead. */
                 do {
                     ret = write(s->out_fd, &ch, 1);
-                } while (ret != 1);
+                } while (ret == 0 || (ret < 0 && errno == EAGAIN));
             }
             s->thr_ipending = 1;
             s->lsr |= UART_LSR_THRE;
qemu-doc.texi +3 -0
diff -ur qemu-0.6.0/qemu-doc.texi qemu-0.6.0-serial/qemu-doc.texi
@@ -178,6 +178,9 @@
 @item -initrd file
 Use @var{file} as initial ram disk.
 
+@item -serial file
+Use @var{file} as serial device: create it for output if neccessary.
+
 @item -nographic
 
 Normally, QEMU uses SDL to display the VGA output. With this option,
vl.c +22 -22

100 lines not on this page · raw message

vl.h +5 -5
diff -ur qemu-0.6.0/vl.h qemu-0.6.0-serial/vl.h
@@ -216,7 +216,7 @@
 void pstrcpy(char *buf, int buf_size, const char *str);
 char *pstrcat(char *buf, int buf_size, const char *s);
 
-int serial_open_device(void);
+int serial_open_device(const char *serial_filename);
 
 extern int vm_running;
 
@@ -675,21 +675,21 @@
 void pc_init(int ram_size, int vga_ram_size, int boot_device,
              DisplayState *ds, const char **fd_filename, int snapshot,
              const char *kernel_filename, const char *kernel_cmdline,
-             const char *initrd_filename);
+             const char *initrd_filename, const char *serial_filename);
 
 /* ppc.c */
 void ppc_init (int ram_size, int vga_ram_size, int boot_device,
 	       DisplayState *ds, const char **fd_filename, int snapshot,
 	       const char *kernel_filename, const char *kernel_cmdline,
-	       const char *initrd_filename);
+	       const char *initrd_filename, const char *serial_filename);
 void ppc_prep_init (int ram_size, int vga_ram_size, int boot_device,
 		    DisplayState *ds, const char **fd_filename, int snapshot,
 		    const char *kernel_filename, const char *kernel_cmdline,
-		    const char *initrd_filename);
+		    const char *initrd_filename, const char *serial_filename);
 void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device,
 		   DisplayState *ds, const char **fd_filename, int snapshot,
 		   const char *kernel_filename, const char *kernel_cmdline,
-		   const char *initrd_filename);
+		   const char *initrd_filename, const char *serial_filename);
 #ifdef TARGET_PPC
 ppc_tb_t *cpu_ppc_tb_init (CPUState *env, uint32_t freq);
 #endif
Signature · 1 line
Anyone who quotes me in their signature is an idiot -- Rusty Russell