diff options
-rw-r--r-- | qapi-schema.json | 18 | ||||
-rw-r--r-- | qemu-char.c | 14 | ||||
-rw-r--r-- | qemu-options.hx | 14 |
3 files changed, 33 insertions, 13 deletions
diff --git a/qapi-schema.json b/qapi-schema.json index 5ad6894738..f76bc0c2fb 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3186,7 +3186,7 @@ # Configuration info for device and pipe chardevs. # # @device: The name of the special file for the device, -# i.e. /dev/ttyS0 on Unix or COM1: on Windows +# i.e. /dev/parport0 on Unix. # @type: What kind of device this is. # # Since: 1.4 @@ -3194,6 +3194,20 @@ { 'type': 'ChardevHostdev', 'data': { 'device' : 'str' } } ## +# @ChardevSerial +# +# Configuration info for serial chardevs. +# +# @device: The name of the special file for the device, +# i.e. /dev/ttyS0 on Unix or COM1: on Windows +# @baud: #optional baud rate to set for host device. (default 115200) +# +# Since: 1.5 +## +{ 'type': 'ChardevSerial', 'data': { 'device' : 'str', + '*baud': 'int' } } + +## # @ChardevSocket: # # Configuration info for (stream) socket chardevs. @@ -3311,7 +3325,7 @@ { 'type': 'ChardevDummy', 'data': { } } { 'union': 'ChardevBackend', 'data': { 'file' : 'ChardevFile', - 'serial' : 'ChardevHostdev', + 'serial' : 'ChardevSerial', 'parallel': 'ChardevHostdev', 'pipe' : 'ChardevHostdev', 'socket' : 'ChardevSocket', 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; diff --git a/qemu-options.hx b/qemu-options.hx index bf94862b58..5f20edd923 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1794,8 +1794,8 @@ DEF("chardev", HAS_ARG, QEMU_OPTION_chardev, #endif #if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) - "-chardev serial,id=id,path=path[,mux=on|off]\n" - "-chardev tty,id=id,path=path[,mux=on|off]\n" + "-chardev serial,id=id,path=path[,mux=on|off][,baud=baud]\n" + "-chardev tty,id=id,path=path[,mux=on|off][,baud=baud]\n" #endif #if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) "-chardev parallel,id=id,path=path[,mux=on|off]\n" @@ -1963,7 +1963,7 @@ take any options. @option{console} is only available on Windows hosts. -@item -chardev serial ,id=@var{id} ,path=@option{path} +@item -chardev serial ,id=@var{id} ,path=@option{path} [,baud=@option{baud}] Send traffic from the guest to a serial device on the host. @@ -1972,6 +1972,9 @@ not only serial lines. @option{path} specifies the name of the serial device to open. +On Unix hosts, the @option{baud} specifies the baud rate for the host serial +device. It is optional and defaults to 115200. + @item -chardev pty ,id=@var{id} Create a new pseudo-terminal on the host and connect to it. @option{pty} does @@ -2404,9 +2407,10 @@ vc:80Cx24C No device is allocated. @item null void device -@item /dev/XXX +@item /dev/XXX[,baud=@var{baud}] [Linux only] Use host tty, e.g. @file{/dev/ttyS0}. The host serial port -parameters are set according to the emulated ones. +parameters are set according to the emulated ones. The optional @var{baud} +option allows for overriding the default host baud rate of 115200. @item /dev/parport@var{N} [Linux only, parallel port only] Use host parallel port @var{N}. Currently SPP and EPP parallel port features can be used. |