Re: [Qemu-devel] [PATCH] qemu-iotests: filter QEMU monitor \r\n

2013-12-05 Thread Stefan Hajnoczi
On Thu, Nov 14, 2013 at 03:34:06PM +0100, Stefan Hajnoczi wrote:
> SMTP does not preserve newlines.  This is normally not a problem if the
> email body uses DOS or UNIX newlines consistently.  In 051.out we mix
> UNIX newlines with DOS newlines (since QEMU monitor output uses \r\n).
> 
> This patch filters the QEMU monitor output so the golden master file
> uses UNIX newlines exclusively.
> 
> The result is that patches touching 051.out will apply cleanly without
> mangling newlines after this commit.
> 
> Signed-off-by: Stefan Hajnoczi 
> ---
> If you have trouble applying this patch, you can use by git repo:
>   git://github.com/stefanha/qemu.git fix-qemu-io-cr
> 
> Luiz: CCed you just because I was surprised monitor.c uses \r\n.  Perhaps this
> is because terminal or telnet emulation is somehow mixed into the core
> monitor.c code?
> 
>  tests/qemu-iotests/051.out   | 112 
> +++
>  tests/qemu-iotests/common.filter |   3 +-
>  2 files changed, 58 insertions(+), 57 deletions(-)

Applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan



Re: [Qemu-devel] [PATCH] qemu-iotests: filter QEMU monitor \r\n

2013-11-15 Thread Stefan Hajnoczi
On Thu, Nov 14, 2013 at 07:58:00AM -0700, Eric Blake wrote:
> On 11/14/2013 07:34 AM, Stefan Hajnoczi wrote:
> > SMTP does not preserve newlines.  This is normally not a problem if the
> > email body uses DOS or UNIX newlines consistently.  In 051.out we mix
> > UNIX newlines with DOS newlines (since QEMU monitor output uses \r\n).
> > 
> > This patch filters the QEMU monitor output so the golden master file
> > uses UNIX newlines exclusively.
> > 
> > The result is that patches touching 051.out will apply cleanly without
> > mangling newlines after this commit.
> 
> The idea makes sense.  However...
> 
> > 
> > Signed-off-by: Stefan Hajnoczi 
> > ---
> > If you have trouble applying this patch, you can use by git repo:
> >   git://github.com/stefanha/qemu.git fix-qemu-io-cr
> > 
> 
> > +++ b/tests/qemu-iotests/common.filter
> > @@ -156,7 +156,8 @@ _filter_qemu_io()
> >  _filter_qemu()
> >  {
> >  sed -e "s#\\(^\\|(qemu) \\)$(basename $QEMU_PROG):#\1QEMU_PROG:#" \
> > --e 's#^QEMU [0-9]\+\.[0-9]\+\.[0-9]\+ monitor#QEMU X.Y.Z monitor#'
> > +-e 's#^QEMU [0-9]\+\.[0-9]\+\.[0-9]\+ monitor#QEMU X.Y.Z monitor#' 
> > \
> > +-e 's#\r##' # QEMU monitor uses \r\n line endings
> 
> \r is not portable sed (some implementations match a literal \ followed
> by a literal r; some treat it as a syntax error; while you want it to be
> treated as an escape sequence for CR).  Then again, \+ is not portable
> sed either, so we already fail to run on non-GNU sed.
> 
> Both problems could be avoided: write '[0-9][0-9]*' instead of
> '[0-9]\+'; and exploit the fact that common.filter already requires bash
> by writing "-e $'s#\r##'" (using $'' to do the \r interpolation prior to
> handing the argument to sed).

Thanks Eric.  I'd rather not fix up existing code in the same commit but
we can switch to the portable bash version.  In general, qemu-iotests
only supports Linux today.

Kevin (or note to self): use "-e $'s#\r##'" when merging.

Stefan



Re: [Qemu-devel] [PATCH] qemu-iotests: filter QEMU monitor \r\n

2013-11-14 Thread Luiz Capitulino
On Thu, 14 Nov 2013 15:34:06 +0100
Stefan Hajnoczi  wrote:

> SMTP does not preserve newlines.  This is normally not a problem if the
> email body uses DOS or UNIX newlines consistently.  In 051.out we mix
> UNIX newlines with DOS newlines (since QEMU monitor output uses \r\n).
> 
> This patch filters the QEMU monitor output so the golden master file
> uses UNIX newlines exclusively.
> 
> The result is that patches touching 051.out will apply cleanly without
> mangling newlines after this commit.
> 
> Signed-off-by: Stefan Hajnoczi 
> ---
> If you have trouble applying this patch, you can use by git repo:
>   git://github.com/stefanha/qemu.git fix-qemu-io-cr
> 
> Luiz: CCed you just because I was surprised monitor.c uses \r\n.  Perhaps this
> is because terminal or telnet emulation is somehow mixed into the core
> monitor.c code?

Yes, it's telnet support (we allow a telnet client to connect to the
monitor).



Re: [Qemu-devel] [PATCH] qemu-iotests: filter QEMU monitor \r\n

2013-11-14 Thread Eric Blake
On 11/14/2013 07:34 AM, Stefan Hajnoczi wrote:
> SMTP does not preserve newlines.  This is normally not a problem if the
> email body uses DOS or UNIX newlines consistently.  In 051.out we mix
> UNIX newlines with DOS newlines (since QEMU monitor output uses \r\n).
> 
> This patch filters the QEMU monitor output so the golden master file
> uses UNIX newlines exclusively.
> 
> The result is that patches touching 051.out will apply cleanly without
> mangling newlines after this commit.

The idea makes sense.  However...

> 
> Signed-off-by: Stefan Hajnoczi 
> ---
> If you have trouble applying this patch, you can use by git repo:
>   git://github.com/stefanha/qemu.git fix-qemu-io-cr
> 

> +++ b/tests/qemu-iotests/common.filter
> @@ -156,7 +156,8 @@ _filter_qemu_io()
>  _filter_qemu()
>  {
>  sed -e "s#\\(^\\|(qemu) \\)$(basename $QEMU_PROG):#\1QEMU_PROG:#" \
> --e 's#^QEMU [0-9]\+\.[0-9]\+\.[0-9]\+ monitor#QEMU X.Y.Z monitor#'
> +-e 's#^QEMU [0-9]\+\.[0-9]\+\.[0-9]\+ monitor#QEMU X.Y.Z monitor#' \
> +-e 's#\r##' # QEMU monitor uses \r\n line endings

\r is not portable sed (some implementations match a literal \ followed
by a literal r; some treat it as a syntax error; while you want it to be
treated as an escape sequence for CR).  Then again, \+ is not portable
sed either, so we already fail to run on non-GNU sed.

Both problems could be avoided: write '[0-9][0-9]*' instead of
'[0-9]\+'; and exploit the fact that common.filter already requires bash
by writing "-e $'s#\r##'" (using $'' to do the \r interpolation prior to
handing the argument to sed).

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [PATCH] qemu-iotests: filter QEMU monitor \r\n

2013-11-14 Thread Stefan Hajnoczi
SMTP does not preserve newlines.  This is normally not a problem if the
email body uses DOS or UNIX newlines consistently.  In 051.out we mix
UNIX newlines with DOS newlines (since QEMU monitor output uses \r\n).

This patch filters the QEMU monitor output so the golden master file
uses UNIX newlines exclusively.

The result is that patches touching 051.out will apply cleanly without
mangling newlines after this commit.

Signed-off-by: Stefan Hajnoczi 
---
If you have trouble applying this patch, you can use by git repo:
  git://github.com/stefanha/qemu.git fix-qemu-io-cr

Luiz: CCed you just because I was surprised monitor.c uses \r\n.  Perhaps this
is because terminal or telnet emulation is somehow mixed into the core
monitor.c code?

 tests/qemu-iotests/051.out   | 112 +++
 tests/qemu-iotests/common.filter |   3 +-
 2 files changed, 58 insertions(+), 57 deletions(-)

diff --git a/tests/qemu-iotests/051.out b/tests/qemu-iotests/051.out
index 15deef6..186a5f3 100644
--- a/tests/qemu-iotests/051.out
+++ b/tests/qemu-iotests/051.out
@@ -30,12 +30,12 @@ ide0-hd0: TEST_DIR/t.qcow2 (qcow2)
 === Enable and disable lazy refcounting on the command line, plus some invalid 
values ===
 
 Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,lazy-refcounts=on
-QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) qququiquit
+QEMU X.Y.Z monitor - type 'help' for more information
+(qemu) qququiquit
 
 Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,lazy-refcounts=off
-QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) qququiquit
+QEMU X.Y.Z monitor - type 'help' for more information
+(qemu) qququiquit
 
 Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,lazy-refcounts=
 QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,lazy-refcounts=: could 
not open disk image TEST_DIR/t.qcow2: Parameter 'lazy-refcounts' expects 'on' 
or 'off'
@@ -54,71 +54,71 @@ Testing: -drive 
file=TEST_DIR/t.qcow2,format=qcow2,lazy-refcounts=on
 QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,lazy-refcounts=on: could 
not open disk image TEST_DIR/t.qcow2: Lazy refcounts require a qcow2 image with 
at least qemu 1.1 compatibility level
 
 Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,lazy-refcounts=off
-QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) qququiquit
+QEMU X.Y.Z monitor - type 'help' for more information
+(qemu) qququiquit
 
 
 === No medium ===
 
 Testing: -drive if=floppy
-QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) qququiquit
+QEMU X.Y.Z monitor - type 'help' for more information
+(qemu) qququiquit
 
 Testing: -drive if=ide,media=cdrom
-QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) qququiquit
+QEMU X.Y.Z monitor - type 'help' for more information
+(qemu) qququiquit
 
 Testing: -drive if=scsi,media=cdrom
-QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) qququiquit
+QEMU X.Y.Z monitor - type 'help' for more information
+(qemu) qququiquit
 
 Testing: -drive if=ide
-QEMU X.Y.Z monitor - type 'help' for more information
+QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) QEMU_PROG: Device needs media, but drive is empty
 QEMU_PROG: Device initialization failed.
 QEMU_PROG: Initialization of device ide-hd failed
 
 Testing: -drive if=virtio
-QEMU X.Y.Z monitor - type 'help' for more information
+QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) QEMU_PROG: -drive if=virtio: Device needs media, but drive is empty
 QEMU_PROG: -drive if=virtio: Device initialization failed.
 QEMU_PROG: -drive if=virtio: Device initialization failed.
 QEMU_PROG: -drive if=virtio: Device 'virtio-blk-pci' could not be initialized
 
 Testing: -drive if=scsi
-QEMU X.Y.Z monitor - type 'help' for more information
+QEMU X.Y.Z monitor - type 'help' for more information
 (qemu) QEMU_PROG: -drive if=scsi: Device needs media, but drive is empty
 QEMU_PROG: Device initialization failed.
 QEMU_PROG: Initialization of device lsi53c895a failed
 
 Testing: -drive if=none,id=disk -device ide-cd,drive=disk
-QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) qququiquit
+QEMU X.Y.Z monitor - type 'help' for more information
+(qemu) qququiquit
 
 Testing: -drive if=none,id=disk -device lsi53c895a -device scsi-cd,drive=disk
-QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) qququiquit
+QEMU X.Y.Z monitor - type 'help' for more information
+(qemu) qququiquit
 
 Testing: -drive if=none,id=disk -device ide-drive,drive=disk
-QEMU X.Y.Z m