Re: [PATCH] kvm tools: Sanitize output characters in serial console

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/10/11 2:56 AM, Asias He wrote:
This patch fixes strange characters in serial console.

Before:

[    0.448000] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
�[    0.695000] serial8250: ttyS0 at I/O 0x3f8 (irq = 0) is a 16550A
�[    0.942000] serial8250: ttyS1 at I/O 0x2f8 (irq = 0) is a 16550A
�[    1.189000] serial8250: ttyS2 at I/O 0x3e8 (irq = 0) is a 16550A
[    1.194000] Non-volatile memory driver v1.3

After:

[    0.541000] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[    0.788000] serial8250: ttyS0 at I/O 0x3f8 (irq = 0) is a 16550A
[    1.041000] serial8250: ttyS1 at I/O 0x2f8 (irq = 0) is a 16550A
[    1.294000] serial8250: ttyS2 at I/O 0x3e8 (irq = 0) is a 16550A
[    1.309000] Non-volatile memory driver v1.3

Signed-off-by: Asias He<asias.hejun@xxxxxxxxx>
---
  tools/kvm/term.c |    7 +++++--
  1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/kvm/term.c b/tools/kvm/term.c
index 2a3e1f0..85b41e7 100644
--- a/tools/kvm/term.c
+++ b/tools/kvm/term.c
@@ -5,6 +5,7 @@
  #include<unistd.h>
  #include<sys/uio.h>
  #include<signal.h>
+#include<ctype.h>

  #include "kvm/read-write.h"
  #include "kvm/term.h"
@@ -57,8 +58,10 @@ int term_putc(int who, char *addr, int cnt)
  	if (who != active_console)
  		return -1;

-	while (cnt--)
-		fprintf(stdout, "%c", *addr++);
+	while (cnt--) {
+		if (isascii(*addr))

Do things like backspace still work with this?

+			fprintf(stdout, "%c", *addr++);
+	}

  	fflush(stdout);
  	return cnt;

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux