All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patryk Olszewski <patryk@fala.ehost.pl>
To: Greg Kurz <groug@kaod.org>, Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, Thomas Huth <thuth@redhat.com>,
	Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PULL 52/53] char: Remove unwanted crlf conversion
Date: Fri, 8 Jun 2018 20:08:46 +0200	[thread overview]
Message-ID: <372f6a74-61c9-c234-2751-e16012312dc5@fala.ehost.pl> (raw)
In-Reply-To: <20180608193905.0841f4d5@bahia.lan>

W dniu 08.06.2018 o 19:39, Greg Kurz pisze:
> On Thu, 31 May 2018 19:16:05 +0200
> Paolo Bonzini <pbonzini@redhat.com> wrote:
>
>> From: Patryk Olszewski <patryk@fala.ehost.pl>
>>
>> This patch fixes a bug in serial that made it almost impossible for guest
>> to communicate with devices through host's serial.
>>
>> OPOST flag in c_oflag enables output processing letting other flags in
>> c_oflag take effect. Usually in c_oflag ONLCR flag is also set, which
>> causes crlf to be sent in place of lf. This breaks binary transmissions.
>> Unsetting OPOST flag turns off any output processing which fixes the bug.
>>
> But it damages error reporting...
>
> Without this patch:
>
> $ qemu-system-ppc64 -serial stdio -kernel foo
> foo: No such file or directory
> qemu-system-ppc64: error loading foo: Failed to load ELF
> $
>
> With this patch:
>
> $ .mbuild-ppc-for-3.0/obj/ppc64-softmmu/qemu-system-ppc64 -serial stdio -kernel foo
> foo: No such file or directory
>                               qemu-system-ppc64: error loading foo: Failed to load ELF
>                                                                                       $
>
> It is possible to patch vreport() to append an explicit CR:
>
>      error_vprintf(fmt, ap);
> -    error_printf("\n");
> +    error_printf("\n\r");
>  }
>
> but it only fixes the trailing newline of error_report(). Any other newline,
> eg when using error_append_hint(), will lack the CR... Not sure how to fix
> this :-\
>
>> Bug reports related:
>> https://bugs.launchpad.net/qemu/+bug/1772086
>> https://bugs.launchpad.net/qemu/+bug/1407813
>> https://bugs.launchpad.net/qemu/+bug/1715296
>> also
>> https://lists.nongnu.org/archive/html/qemu-devel/2006-06/msg00196.html
>>
>> Signed-off-by: Patryk Olszewski <patryk@fala.ehost.pl>
>> Message-Id: <1527105041-21013-1-git-send-email-patryk@fala.ehost.pl>
>> Reviewed-by: Markus Armbruster <armbru@redhat.com>
>> Reviewed-by: Thomas Huth <thuth@redhat.com>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>  chardev/char-serial.c | 2 +-
>>  chardev/char-stdio.c  | 2 +-
>>  2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/chardev/char-serial.c b/chardev/char-serial.c
>> index feb52e559d..ae548d28da 100644
>> --- a/chardev/char-serial.c
>> +++ b/chardev/char-serial.c
>> @@ -139,7 +139,7 @@ static void tty_serial_init(int fd, int speed,
>>  
>>      tty.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP
>>                       | INLCR | IGNCR | ICRNL | IXON);
>> -    tty.c_oflag |= OPOST;
>> +    tty.c_oflag &= ~OPOST;
>>      tty.c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN | ISIG);
>>      tty.c_cflag &= ~(CSIZE | PARENB | PARODD | CRTSCTS | CSTOPB);
>>      switch (data_bits) {
>> diff --git a/chardev/char-stdio.c b/chardev/char-stdio.c
>> index 96375f2ab8..d83e60e787 100644
>> --- a/chardev/char-stdio.c
>> +++ b/chardev/char-stdio.c
>> @@ -59,7 +59,7 @@ static void qemu_chr_set_echo_stdio(Chardev *chr, bool echo)
>>      if (!echo) {
>>          tty.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP
>>                           | INLCR | IGNCR | ICRNL | IXON);
>> -        tty.c_oflag |= OPOST;
>> +        tty.c_oflag &= ~OPOST;
>>          tty.c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN);
>>          tty.c_cflag &= ~(CSIZE | PARENB);
>>          tty.c_cflag |= CS8;

The change to char-stdio.c wasn't actually introduced by me.
(https://lists.nongnu.org/archive/html/qemu-devel/2018-05/msg05416.html).
Anyway, I haven't yet investigated it thoroughly but right now I think the problem is with that error reporting system. After all serial device shouldn't alter data coming from the guest. You never know when somebody will come up with crazy idea of pushing binary data through stdout.

  parent reply	other threads:[~2018-06-08 18:08 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-31 17:12 [Qemu-devel] [PULL 00/53] Misc patches for 2018-05-31 Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 01/53] sandbox: disable -sandbox if CONFIG_SECCOMP undefined Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 02/53] vfio: Include "exec/address-spaces.h" directly in the source file Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 03/53] accel: Do not include "exec/address-spaces.h" if it is not necessary Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 04/53] target: " Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 05/53] memory: Do not include "exec/ioport.h" " Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 06/53] target/i386: " Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 07/53] target/xtensa: Include "qemu/timer.h" to use NANOSECONDS_PER_SECOND Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 08/53] target/ppc: Include "exec/exec-all.h" which provides tlb_flush() Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 09/53] target/hppa: Include "qemu/log.h" to use qemu_log() Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 10/53] target: Do not include "exec/exec-all.h" if it is not necessary Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 11/53] nios2: do not include exec-all.h from cpu.h Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 12/53] hw: Do not include "exec/ioport.h" if it is not necessary Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 13/53] hw: Do not include "exec/address-spaces.h" " Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 14/53] hw: Do not include "sysemu/block-backend.h" " Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 15/53] hw: Do not include "sysemu/blockdev.h" " Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 16/53] " Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 17/53] hw/block/nvme: Include "qemu/cutils.h" directly in the source file Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 18/53] hw/misc/mips_itu: Cleanup includes Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 19/53] hw/misc/sga: Use the correct ISA include Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 20/53] hw/hppa: Remove unused include Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 21/53] hw/i386/pc: " Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 22/53] hw/ide: " Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 23/53] hw: Clean "hw/devices.h" includes Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 24/53] qom: Document qom/device-list-properties implementation specific Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 25/53] qom: support orphan objects in object_get_canonical_path Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 26/53] virtio: free MemoryRegionCache when initialization fails Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 27/53] memory.h: Fix typo in documentation comment Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 28/53] memory: get rid of memory_region_init_reservation Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 29/53] memory: delete struct AddressSpaceOps Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 30/53] hw/isa/superio: Fix inconsistent use of Chardev->be Paolo Bonzini
2018-05-31 18:08   ` Philippe Mathieu-Daudé
2018-05-31 17:12 ` [Qemu-devel] [PULL 31/53] mux: fix ctrl-a b again Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 32/53] memfd: Avoid Coverity warning about integer overflow Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 33/53] exec.c: Initialize sa_flags passed to sigaction() Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 34/53] WHPX: dynamically load WHP libraries Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 35/53] WHPX: fix some compiler warnings Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 36/53] qemu-options: Mark the non-functional -clock option as deprecated Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 37/53] tcg: remove softfloat from --disable-tcg builds Paolo Bonzini
2018-05-31 17:15 ` [Qemu-devel] [PULL 39/53] ipmi: Use proper struct reference for KCS vmstate Paolo Bonzini
2018-05-31 17:15   ` [Qemu-devel] [PULL 40/53] docs/interop: add "firmware.json" Paolo Bonzini
2018-05-31 19:07     ` Eric Blake
2018-05-31 17:15   ` [Qemu-devel] [PULL 41/53] gdbstub: Prevent fd leakage Paolo Bonzini
2018-05-31 17:15   ` [Qemu-devel] [PULL 42/53] virtio-gpu-3d: Define VIRTIO_GPU_CAPSET_VIRGL2 elsewhere Paolo Bonzini
2018-05-31 17:15   ` [Qemu-devel] [PULL 43/53] scripts/update-linux-headers: Handle __aligned_u64 Paolo Bonzini
2018-05-31 17:15   ` [Qemu-devel] [PULL 44/53] scripts/update-linux-headers: Handle kernel license no longer being one file Paolo Bonzini
2018-05-31 17:15   ` [Qemu-devel] [PULL 45/53] target/i386/kvm.c: Handle renaming of KVM_HINTS_DEDICATED Paolo Bonzini
2018-05-31 17:15   ` [Qemu-devel] [PULL 46/53] Update Linux headers to 4.17-rc6 Paolo Bonzini
2018-05-31 17:16   ` [Qemu-devel] [PULL 47/53] target/i386/kvm.c: Remove compatibility shim for KVM_HINTS_REALTIME Paolo Bonzini
2018-05-31 17:16   ` [Qemu-devel] [PULL 48/53] hw/i2c/smbus: Use DeviceClass::realize instead of SMBusDeviceClass::init Paolo Bonzini
2018-05-31 17:16   ` [Qemu-devel] [PULL 49/53] hw/i2c: Use DeviceClass::realize instead of I2CSlaveClass::init Paolo Bonzini
2018-05-31 17:16   ` [Qemu-devel] [PULL 50/53] qdev: Simplify the SysBusDeviceClass::init path Paolo Bonzini
2018-05-31 17:16   ` [Qemu-devel] [PULL 51/53] qdev: Remove DeviceClass::init() and ::exit() Paolo Bonzini
2018-05-31 17:16   ` [Qemu-devel] [PULL 52/53] char: Remove unwanted crlf conversion Paolo Bonzini
2018-06-08 17:39     ` Greg Kurz
2018-06-08 17:56       ` Philippe Mathieu-Daudé
2018-06-09  7:31         ` Greg Kurz
2018-06-08 18:08       ` Patryk Olszewski [this message]
2018-05-31 17:16   ` [Qemu-devel] [PULL 53/53] memory: Make operations using MemoryRegionIoeventfd struct pass by pointer Paolo Bonzini
2018-05-31 17:16 ` [Qemu-devel] [PULL 37/53] tcg: remove softfloat from --disable-tcg builds Paolo Bonzini
2018-05-31 17:16   ` [Qemu-devel] [PULL 38/53] vmstate: Add a VSTRUCT type Paolo Bonzini
2018-05-31 17:52 ` [Qemu-devel] [PULL 00/53] Misc patches for 2018-05-31 Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=372f6a74-61c9-c234-2751-e16012312dc5@fala.ehost.pl \
    --to=patryk@fala.ehost.pl \
    --cc=armbru@redhat.com \
    --cc=groug@kaod.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.