serial: Open non-block
PATCH 1/1 serial: Open non-block
From: "Dr. David Alan Gilbert" <[email protected]>
On a real serial device, the open can block if the handshake lines are in a particular state. If a QEMU is passing the serial device to the guest, the QEMU startup is blocked opening the device (with a symptom seen as a timeout from libvirt).
Open the serial port with O_NONBLOCK.
--- chardev/char-serial.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
chardev/char-serial.c +2 -1
@@ -265,7 +265,8 @@ static void qmp_chardev_open_serial(Chardev *chr,ChardevHostdev *serial = backend->u.serial.data;int fd; - fd =qmp_chardev_open_file_source (serial->device,O_RDWR , errp); + fd =qmp_chardev_open_file_source (serial->device,O_RDWR |O_NONBLOCK , + errp);if (fd <0 ) {return ; }
Signature · 1 line
2.14.3
Quoted 10 lines · Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" <[email protected]>
On a real serial device, the open can block if the handshake lines are in a particular state. If a QEMU is passing the serial device to the guest, the QEMU startup is blocked opening the device (with a symptom seen as a timeout from libvirt).
Open the serial port with
O_NONBLOCK.Signed-off-by Dr. David Alan Gilbert <[email protected]>
Socket chardevs have "nowait" for that. Should serial have something similar?
Thanks,
Paolo
Quoted 19 lines
--- chardev/char-serial.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)chardev/char-serial.c +2
-1@@ -265,7 +265,8 @@ static void qmp_chardev_open_serial(Chardev *chr,ChardevHostdev *serial = backend->u.serial.data;int fd; - fd =qmp_chardev_open_file_source (serial->device,O_RDWR , errp); + fd =qmp_chardev_open_file_source (serial->device,O_RDWR |O_NONBLOCK , + errp);if (fd <0 ) {return ; }
Quoted 8 lines · * Paolo Bonzini ([email protected]) wrote:
Quoted 7 lines · Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" <[email protected]>
On a real serial device, the open can block if the handshake lines are in a particular state. If a QEMU is passing the serial device to the guest, the QEMU startup is blocked opening the device (with a symptom seen as a timeout from libvirt).
Quoted 6 lines
Quoted 3 lines
Open the serial port with
O_NONBLOCK.Signed-off-by Dr. David Alan Gilbert <[email protected]>Socket chardevs have "nowait" for that. Should serial have something similar?
Hmm, maybe, although I think for real serial the nonblocking open should be the default.
I've not got any more complex tests though for it.
stty -F uses the same trick of opening non-blocking.
Dave
Quoted 16 lines
Thanks,
Paolo
Quoted 12 lines
--- chardev/char-serial.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)chardev/char-serial.c +0
-0@@ -265,7 +265,8 @@ static void qmp_chardev_open_serial(Chardev *chr,ChardevHostdev *serial = backend->u.serial.data;int fd;
Quoted 8 lines
chardev/char-serial.c static void qmp_chardev_open_serial(Chardev *chr, · line 272
Quoted 7 lines
chardev/char-serial.c +2
-1- fd =qmp_chardev_open_file_source (serial->device,O_RDWR , errp); + fd =qmp_chardev_open_file_source (serial->device,O_RDWR |O_NONBLOCK , + errp);if (fd <0 ) {return ; }
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Paolo Bonzini
AppliedQuoted 20 lines · Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" <[email protected]>
On a real serial device, the open can block if the handshake lines are in a particular state. If a QEMU is passing the serial device to the guest, the QEMU startup is blocked opening the device (with a symptom seen as a timeout from libvirt).
Open the serial port with
O_NONBLOCK.Signed-off-by Dr. David Alan Gilbert <[email protected]>--- chardev/char-serial.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)chardev/char-serial.c +0
-0
chardev/char-serial.c static void qmp_chardev_open_serial(Chardev *chr, · line 272
Quoted 9 lines
chardev/char-serial.c +2
-1@@ -265,7 +265,8 @@ static void qmp_chardev_open_serial(Chardev *chr,ChardevHostdev *serial = backend->u.serial.data;int fd; - fd =qmp_chardev_open_file_source (serial->device,O_RDWR , errp); + fd =qmp_chardev_open_file_source (serial->device,O_RDWR |O_NONBLOCK , + errp);if (fd <0 ) {return ; }
Queued, thanks.
Paolo