summaryrefslogtreecommitdiff
path: root/qemu-char.c
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2013-06-08 23:25:08 +0200
committerPeter Wu <lekensteyn@gmail.com>2013-06-08 23:34:14 +0200
commitb8f9d44cfd94c2ae4a810f3469d08da120424ffc (patch)
tree5e636b69812b5b28a4d4d9641b89cd5dc31389c9 /qemu-char.c
parent7387de16d0e4d2988df350926537cd12a8e34206 (diff)
downloadqemu-serial-baud.tar.gz
chardev: add baud parameter for serial host deviceserial-baud
When QEMU starts, it always changes the serial port parameters including baud rate. This confused my guest which thought it was outputting at 9600 baud while it was in fact changed to 115200. After this patch, I can use `-serial /dev/ttyS0,baud=9600` to override the default baud rate of 115200. Documentation is updated as well, so that users know about the new `baud` parameter for `-serial` and `-chardev serial` (and its alias `-chardev tty`). Note that the baud option is not implemented for Windows. QEMU does not change the default baud rate on Windows anyway. If somebody is going to implement it, do not forget to update the documentation on "COM" devices which is also of backend serial. Signed-off-by: Peter Wu <lekensteyn@gmail.com>
Diffstat (limited to 'qemu-char.c')
-rw-r--r--qemu-char.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/qemu-char.c b/qemu-char.c
index d04b429a03..421730a79c 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -1450,11 +1450,11 @@ static void qemu_chr_close_tty(CharDriverState *chr)
}
}
-static CharDriverState *qemu_chr_open_tty_fd(int fd)
+static CharDriverState *qemu_chr_open_tty_fd(int fd, int baud)
{
CharDriverState *chr;
- tty_serial_init(fd, 115200, 'N', 8, 1);
+ tty_serial_init(fd, baud, 'N', 8, 1);
chr = qemu_chr_open_fd(fd, fd);
chr->chr_ioctl = tty_serial_ioctl;
chr->chr_close = qemu_chr_close_tty;
@@ -3155,13 +3155,15 @@ static void qemu_chr_parse_serial(QemuOpts *opts, ChardevBackend *backend,
Error **errp)
{
const char *device = qemu_opt_get(opts, "path");
+ const int baud = qemu_opt_get_number(opts, "baud", 115200);
if (device == NULL) {
error_setg(errp, "chardev: serial/tty: no device path given");
return;
}
- backend->serial = g_new0(ChardevHostdev, 1);
+ backend->serial = g_new0(ChardevSerial, 1);
backend->serial->device = g_strdup(device);
+ backend->serial->baud = baud;
}
static void qemu_chr_parse_parallel(QemuOpts *opts, ChardevBackend *backend,
@@ -3590,7 +3592,7 @@ static CharDriverState *qmp_chardev_open_file(ChardevFile *file, Error **errp)
return qemu_chr_open_win_file(out);
}
-static CharDriverState *qmp_chardev_open_serial(ChardevHostdev *serial,
+static CharDriverState *qmp_chardev_open_serial(ChardevSerial *serial,
Error **errp)
{
return qemu_chr_open_win_path(serial->device);
@@ -3639,7 +3641,7 @@ static CharDriverState *qmp_chardev_open_file(ChardevFile *file, Error **errp)
return qemu_chr_open_fd(in, out);
}
-static CharDriverState *qmp_chardev_open_serial(ChardevHostdev *serial,
+static CharDriverState *qmp_chardev_open_serial(ChardevSerial *serial,
Error **errp)
{
#ifdef HAVE_CHARDEV_TTY
@@ -3650,7 +3652,7 @@ static CharDriverState *qmp_chardev_open_serial(ChardevHostdev *serial,
return NULL;
}
qemu_set_nonblock(fd);
- return qemu_chr_open_tty_fd(fd);
+ return qemu_chr_open_tty_fd(fd, serial->baud);
#else
error_setg(errp, "character device backend type 'serial' not supported");
return NULL;