* [PATCH] kvm tools: Sanitize output characters in serial console
@ 2011-08-09 23:56 Asias He
2011-08-10 5:30 ` Pekka Enberg
2011-08-11 8:36 ` Avi Kivity
0 siblings, 2 replies; 11+ messages in thread
From: Asias He @ 2011-08-09 23:56 UTC (permalink / raw)
To: Pekka Enberg
Cc: Cyrill Gorcunov, Ingo Molnar, Sasha Levin, Prasad Joshi, kvm,
Asias He
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@gmail.com>
---
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))
+ fprintf(stdout, "%c", *addr++);
+ }
fflush(stdout);
return cnt;
--
1.7.5.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] kvm tools: Sanitize output characters in serial console
2011-08-09 23:56 [PATCH] kvm tools: Sanitize output characters in serial console Asias He
@ 2011-08-10 5:30 ` Pekka Enberg
2011-08-10 5:43 ` Asias He
2011-08-11 8:36 ` Avi Kivity
1 sibling, 1 reply; 11+ messages in thread
From: Pekka Enberg @ 2011-08-10 5:30 UTC (permalink / raw)
To: Asias He; +Cc: Cyrill Gorcunov, Ingo Molnar, Sasha Levin, Prasad Joshi, kvm
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@gmail.com>
> ---
> 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;
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] kvm tools: Sanitize output characters in serial console
2011-08-10 5:30 ` Pekka Enberg
@ 2011-08-10 5:43 ` Asias He
2011-08-10 5:55 ` Pekka Enberg
0 siblings, 1 reply; 11+ messages in thread
From: Asias He @ 2011-08-10 5:43 UTC (permalink / raw)
To: Pekka Enberg; +Cc: Cyrill Gorcunov, Ingo Molnar, Sasha Levin, Prasad Joshi, kvm
On 08/10/2011 01:30 PM, Pekka Enberg wrote:
> 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@gmail.com>
>> ---
>> 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?
Sure. Have a try ;-)
http://en.wikipedia.org/wiki/ASCII
>
>> + fprintf(stdout, "%c", *addr++);
>> + }
>>
>> fflush(stdout);
>> return cnt;
>
>
--
Best Regards,
Asias He
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] kvm tools: Sanitize output characters in serial console
2011-08-10 5:43 ` Asias He
@ 2011-08-10 5:55 ` Pekka Enberg
2011-08-10 6:15 ` Asias He
0 siblings, 1 reply; 11+ messages in thread
From: Pekka Enberg @ 2011-08-10 5:55 UTC (permalink / raw)
To: Asias He; +Cc: Cyrill Gorcunov, Ingo Molnar, Sasha Levin, Prasad Joshi, kvm
On Wed, Aug 10, 2011 at 8:43 AM, Asias He <asias.hejun@gmail.com> wrote:
> On 08/10/2011 01:30 PM, Pekka Enberg wrote:
>> 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@gmail.com>
>>> ---
>>> 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?
>
> Sure. Have a try ;-)
>
> http://en.wikipedia.org/wiki/ASCII
OK, cool. Do we know what the extra characters are and why the guest
is sending them?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] kvm tools: Sanitize output characters in serial console
2011-08-10 5:55 ` Pekka Enberg
@ 2011-08-10 6:15 ` Asias He
2011-08-10 6:53 ` walimis
2011-08-10 7:01 ` Sasha Levin
0 siblings, 2 replies; 11+ messages in thread
From: Asias He @ 2011-08-10 6:15 UTC (permalink / raw)
To: Pekka Enberg; +Cc: Cyrill Gorcunov, Ingo Molnar, Sasha Levin, Prasad Joshi, kvm
On 08/10/2011 01:55 PM, Pekka Enberg wrote:
> On Wed, Aug 10, 2011 at 8:43 AM, Asias He <asias.hejun@gmail.com> wrote:
>> On 08/10/2011 01:30 PM, Pekka Enberg wrote:
>>> 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@gmail.com>
>>>> ---
>>>> 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?
>>
>> Sure. Have a try ;-)
>>
>> http://en.wikipedia.org/wiki/ASCII
>
> OK, cool. Do we know what the extra characters are and why the guest
> is sending them?
>
This tells us
while (cnt--) {
if (isascii(*addr))
fprintf(stdout, "%c", *addr++);
else
fprintf(stdout, "\n---%x---\n", *addr++);
}
the extra chars is 0xff.
The reason is not understood.
--
Best Regards,
Asias He
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] kvm tools: Sanitize output characters in serial console
2011-08-10 6:15 ` Asias He
@ 2011-08-10 6:53 ` walimis
2011-08-10 7:22 ` Amos Kong
2011-08-10 8:31 ` Asias He
2011-08-10 7:01 ` Sasha Levin
1 sibling, 2 replies; 11+ messages in thread
From: walimis @ 2011-08-10 6:53 UTC (permalink / raw)
To: Asias He
Cc: Pekka Enberg, Cyrill Gorcunov, Ingo Molnar, Sasha Levin,
Prasad Joshi, kvm
On Wed, Aug 10, 2011 at 02:15:45PM +0800, Asias He wrote:
>On 08/10/2011 01:55 PM, Pekka Enberg wrote:
>> On Wed, Aug 10, 2011 at 8:43 AM, Asias He <asias.hejun@gmail.com> wrote:
>>> On 08/10/2011 01:30 PM, Pekka Enberg wrote:
>>>> 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@gmail.com>
>>>>> ---
>>>>> 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?
>>>
>>> Sure. Have a try ;-)
>>>
>>> http://en.wikipedia.org/wiki/ASCII
>>
>> OK, cool. Do we know what the extra characters are and why the guest
>> is sending them?
I think the reason is not important here. I use qemu to test
and it also outputs that extra characters. They seem to be outputted by
driver or kernel of guest os.
It's not sane to change the output of guest os. Suppose if we just
want to see what "cat /dev/urandom" prints, then only
allow ascii characters to be outputted? I think that's not what we expect.
walimis
>>
>
>
>This tells us
>
> while (cnt--) {
> if (isascii(*addr))
> fprintf(stdout, "%c", *addr++);
> else
> fprintf(stdout, "\n---%x---\n", *addr++);
> }
>
>the extra chars is 0xff.
>
>The reason is not understood.
>
>--
>Best Regards,
>Asias He
>--
>To unsubscribe from this list: send the line "unsubscribe kvm" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] kvm tools: Sanitize output characters in serial console
2011-08-10 6:15 ` Asias He
2011-08-10 6:53 ` walimis
@ 2011-08-10 7:01 ` Sasha Levin
1 sibling, 0 replies; 11+ messages in thread
From: Sasha Levin @ 2011-08-10 7:01 UTC (permalink / raw)
To: Asias He; +Cc: Pekka Enberg, Cyrill Gorcunov, Ingo Molnar, Prasad Joshi, kvm
On Wed, 2011-08-10 at 14:15 +0800, Asias He wrote:
> On 08/10/2011 01:55 PM, Pekka Enberg wrote:
> > On Wed, Aug 10, 2011 at 8:43 AM, Asias He <asias.hejun@gmail.com> wrote:
> >> On 08/10/2011 01:30 PM, Pekka Enberg wrote:
> >>> 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@gmail.com>
> >>>> ---
> >>>> 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?
> >>
> >> Sure. Have a try ;-)
> >>
> >> http://en.wikipedia.org/wiki/ASCII
> >
> > OK, cool. Do we know what the extra characters are and why the guest
> > is sending them?
> >
>
>
> This tells us
>
> while (cnt--) {
> if (isascii(*addr))
> fprintf(stdout, "%c", *addr++);
> else
> fprintf(stdout, "\n---%x---\n", *addr++);
> }
>
> the extra chars is 0xff.
>
> The reason is not understood.
>
They are being printed when the serial device is probed. Can we
mistakenly interpret the probe as a print request?
--
Sasha.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] kvm tools: Sanitize output characters in serial console
2011-08-10 6:53 ` walimis
@ 2011-08-10 7:22 ` Amos Kong
2011-08-10 8:31 ` Asias He
1 sibling, 0 replies; 11+ messages in thread
From: Amos Kong @ 2011-08-10 7:22 UTC (permalink / raw)
To: walimis
Cc: Asias He, Pekka Enberg, Cyrill Gorcunov, Ingo Molnar, Sasha Levin,
Prasad Joshi, kvm
On Wed, Aug 10, 2011 at 2:53 PM, walimis <walimisdev@gmail.com> wrote:
> On Wed, Aug 10, 2011 at 02:15:45PM +0800, Asias He wrote:
>>On 08/10/2011 01:55 PM, Pekka Enberg wrote:
>>> On Wed, Aug 10, 2011 at 8:43 AM, Asias He <asias.hejun@gmail.com> wrote:
>>>> On 08/10/2011 01:30 PM, Pekka Enberg wrote:
>>>>> On 8/10/11 2:56 AM, Asias He wrote:
>>>>>> This patch fixes strange characters in serial console.
...
>>> OK, cool. Do we know what the extra characters are and why the guest
>>> is sending them?
> I think the reason is not important here. I use qemu to test
> and it also outputs that extra characters. They seem to be outputted by
> driver or kernel of guest os.
>
> It's not sane to change the output of guest os. Suppose if we just
> want to see what "cat /dev/urandom" prints, then only
> allow ascii characters to be outputted? I think that's not what we expect.
So we don't need this patch, otherwise, the possible error would be hidden.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] kvm tools: Sanitize output characters in serial console
2011-08-10 6:53 ` walimis
2011-08-10 7:22 ` Amos Kong
@ 2011-08-10 8:31 ` Asias He
2011-08-10 9:19 ` Pekka Enberg
1 sibling, 1 reply; 11+ messages in thread
From: Asias He @ 2011-08-10 8:31 UTC (permalink / raw)
To: walimis
Cc: Pekka Enberg, Cyrill Gorcunov, Ingo Molnar, Sasha Levin,
Prasad Joshi, kvm
On 08/10/2011 02:53 PM, walimis wrote:
> On Wed, Aug 10, 2011 at 02:15:45PM +0800, Asias He wrote:
>> On 08/10/2011 01:55 PM, Pekka Enberg wrote:
>>> On Wed, Aug 10, 2011 at 8:43 AM, Asias He <asias.hejun@gmail.com> wrote:
>>>> On 08/10/2011 01:30 PM, Pekka Enberg wrote:
>>>>> 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@gmail.com>
>>>>>> ---
>>>>>> 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?
>>>>
>>>> Sure. Have a try ;-)
>>>>
>>>> http://en.wikipedia.org/wiki/ASCII
>>>
>>> OK, cool. Do we know what the extra characters are and why the guest
>>> is sending them?
> I think the reason is not important here. I use qemu to test
> and it also outputs that extra characters. They seem to be outputted by
> driver or kernel of guest os.
>
> It's not sane to change the output of guest os. Suppose if we just
> want to see what "cat /dev/urandom" prints, then only
> allow ascii characters to be outputted? I think that's not what we expect.
This is a good reason why we should not only allow ascii to be printed.
Anyway, this is really annoying. Maybe it is a serial driver bug?
>
> walimis
>>>
>>
>>
>> This tells us
>>
>> while (cnt--) {
>> if (isascii(*addr))
>> fprintf(stdout, "%c", *addr++);
>> else
>> fprintf(stdout, "\n---%x---\n", *addr++);
>> }
>>
>> the extra chars is 0xff.
>>
>> The reason is not understood.
>>
>> --
>> Best Regards,
>> Asias He
>> --
>> To unsubscribe from this list: send the line "unsubscribe kvm" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
Best Regards,
Asias He
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] kvm tools: Sanitize output characters in serial console
2011-08-10 8:31 ` Asias He
@ 2011-08-10 9:19 ` Pekka Enberg
0 siblings, 0 replies; 11+ messages in thread
From: Pekka Enberg @ 2011-08-10 9:19 UTC (permalink / raw)
To: Asias He
Cc: walimis, Cyrill Gorcunov, Ingo Molnar, Sasha Levin, Prasad Joshi,
kvm
On Wed, Aug 10, 2011 at 11:31 AM, Asias He <asias.hejun@gmail.com> wrote:
>> I think the reason is not important here. I use qemu to test
>> and it also outputs that extra characters. They seem to be outputted by
>> driver or kernel of guest os.
>>
>> It's not sane to change the output of guest os. Suppose if we just
>> want to see what "cat /dev/urandom" prints, then only
>> allow ascii characters to be outputted? I think that's not what we expect.
>
> This is a good reason why we should not only allow ascii to be printed.
>
> Anyway, this is really annoying. Maybe it is a serial driver bug?
Could be. It's probably best to track down where the byte is being
sent in the driver.
Pekka
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] kvm tools: Sanitize output characters in serial console
2011-08-09 23:56 [PATCH] kvm tools: Sanitize output characters in serial console Asias He
2011-08-10 5:30 ` Pekka Enberg
@ 2011-08-11 8:36 ` Avi Kivity
1 sibling, 0 replies; 11+ messages in thread
From: Avi Kivity @ 2011-08-11 8:36 UTC (permalink / raw)
To: Asias He
Cc: Pekka Enberg, Cyrill Gorcunov, Ingo Molnar, Sasha Levin,
Prasad Joshi, kvm
On 08/10/2011 02: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@gmail.com>
> ---
> 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))
> + fprintf(stdout, "%c", *addr++);
> + }
>
> fflush(stdout);
> return cnt;
This will likely kill UTF-8.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2011-08-11 8:36 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-09 23:56 [PATCH] kvm tools: Sanitize output characters in serial console Asias He
2011-08-10 5:30 ` Pekka Enberg
2011-08-10 5:43 ` Asias He
2011-08-10 5:55 ` Pekka Enberg
2011-08-10 6:15 ` Asias He
2011-08-10 6:53 ` walimis
2011-08-10 7:22 ` Amos Kong
2011-08-10 8:31 ` Asias He
2011-08-10 9:19 ` Pekka Enberg
2011-08-10 7:01 ` Sasha Levin
2011-08-11 8:36 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).