Skip to contentSkip to conversation

Do not ignore error, if open file failed (-serial /dev/tty)

PATCH Applied Evgeniy Dushistov 2 participants 2 messages Jan 28, 2010 – Feb 10, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Do not ignore error, if open file failed (-serial /dev/tty)

In case, when qemu is executed with option like -serial /dev/ttyS0, report if there are problems with opening of devices. At now errors are silently ignoring.

---
 qemu-char.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
qemu-char.c +3 -0
index 800ee6c..75dbf66 100644
@@ -1180,6 +1180,9 @@ static CharDriverState *qemu_chr_open_tty(QemuOpts *opts)
     int fd;
 
     TFR(fd = open(filename, O_RDWR | O_NONBLOCK));
+    if (fd < 0) {
+        return NULL;
+    }
     tty_serial_init(fd, 115200, 'N', 8, 1);
     chr = qemu_chr_open_fd(fd, fd);
     if (!chr) {
Signature · 5 lines
1.6.5.6


-- 
/Evgeniy
#1 lore raw
Quoted 6 lines · Evgeniy Dushistov

In case, when qemu is executed with option like -serial /dev/ttyS0, report if there are problems with opening of devices. At now errors are silently ignoring.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 19 lines
---
  qemu-char.c |    3 +++
  1 files changed, 3 insertions(+), 0 deletions(-)
qemu-char.c +3 -0
index 800ee6c..75dbf66 100644
@@ -1180,6 +1180,9 @@ static CharDriverState *qemu_chr_open_tty(QemuOpts *opts)
      int fd;
 
      TFR(fd = open(filename, O_RDWR | O_NONBLOCK));
+    if (fd<  0) {
+        return NULL;
+    }
      tty_serial_init(fd, 115200, 'N', 8, 1);
      chr = qemu_chr_open_fd(fd, fd);
      if (!chr) {