summaryrefslogtreecommitdiffstats
path: root/qemu-char.c
Commit message (Collapse)AuthorAgeFilesLines
* char: Convert to new qapi union layoutEric Blake2015-11-021-82/+82
| | | | | | | | | | | | | | | | | | We have two issues with our qapi union layout: 1) Even though the QMP wire format spells the tag 'type', the C code spells it 'kind', requiring some hacks in the generator. 2) The C struct uses an anonymous union, which places all tag values in the same namespace as all non-variant members. This leads to spurious collisions if a tag value matches a non-variant member's name. Make the conversion to the new layout for character-related code. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1445898903-12082-19-git-send-email-eblake@redhat.com> [Commit message tweaked slightly] Signed-off-by: Markus Armbruster <armbru@redhat.com>
* char: add qemu_chr_free()Marc-André Lureau2015-10-241-2/+7
| | | | | | | | | | If a chardev is allowed to be created outside of QMP, then it must be also possible to free it. This is useful for ivshmem that creates chardev anonymously and must be able to free them. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
* sockets: move qapi_copy_SocketAddress into qemu-sockets.cDaniel P. Berrange2015-10-201-25/+0
| | | | | | | | | The qapi_copy_SocketAddress method is going to be useful in more places than just qemu-char.c, so move it into the qemu-sockets.c file to allow its reuse. Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* qemu-char: cleanup after completed conversion to cd->createPaolo Bonzini2015-10-191-76/+4
| | | | | | | | | | All backends now return errors through Error*, so the "Failed to create chardev" placeholder error can only be reached if the backend is not available (and only from the chardev-add QMP command; instead, the -chardev command line option fails earlier). Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: convert ringbuf backend to data-driven creationPaolo Bonzini2015-10-191-4/+7
| | | | | Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: convert vc backend to data-driven creationPaolo Bonzini2015-10-191-1/+1
| | | | | Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: convert spice backend to data-driven creationPaolo Bonzini2015-10-191-4/+2
| | | | | Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: convert console backend to data-driven creationPaolo Bonzini2015-10-191-5/+8
| | | | | Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: convert stdio backend to data-driven creationPaolo Bonzini2015-10-191-18/+39
| | | | | | | | | | | | | | | The backend now always returns errors via the Error* argument. This avoids a double error message. Before: qemu-system-x86_64: -chardev stdio,id=base: cannot use stdio with -daemonize qemu-system-x86_64: -chardev stdio,id=base: Failed to create chardev After: qemu-system-x86_64: -chardev stdio,id=base: cannot use stdio with -daemonize Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: convert testdev backend to data-driven creationPaolo Bonzini2015-10-191-1/+1
| | | | | Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: convert braille backend to data-driven creationPaolo Bonzini2015-10-191-3/+1
| | | | | Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: convert msmouse backend to data-driven creationPaolo Bonzini2015-10-191-1/+1
| | | | | Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: convert mux backend to data-driven creationPaolo Bonzini2015-10-191-11/+14
| | | | | Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: convert null backend to data-driven creationPaolo Bonzini2015-10-191-3/+6
| | | | | Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: convert pty backend to data-driven creationPaolo Bonzini2015-10-191-5/+8
| | | | | Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: convert UDP backend to data-driven creationPaolo Bonzini2015-10-191-3/+6
| | | | | Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: convert socket backend to data-driven creationPaolo Bonzini2015-10-191-3/+6
| | | | | Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: convert pipe backend to data-driven creationPaolo Bonzini2015-10-191-16/+21
| | | | | Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: convert parallel backend to data-driven creationPaolo Bonzini2015-10-191-16/+15
| | | | | | | | | | | | | Conversion to Error * brings better error messages; before: qemu-system-x86_64: -chardev id=serial,backend=parallel,path=vl.c: Failed to create chardev After: qemu-system-x86_64: -chardev id=serial,backend=parallel,path=vl.c: not a parallel port: Inappropriate ioctl for device Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: convert serial backend to data-driven creationPaolo Bonzini2015-10-141-19/+29
| | | | | Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: convert file backend to data-driven creationPaolo Bonzini2015-10-141-4/+12
| | | | | Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: add create to register_char_driverPaolo Bonzini2015-10-141-93/+120
| | | | | | | | | | | | | Having creation as a member of the CharDriver struct removes the need to export functions for qemu-char.c's usage. After the conversion, chardev backends implemented outside qemu-char.c will not need a stub creation function anymore. Ultimately all drivers will be converted. For now, support the case where cd->create == NULL. Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: cleanup HAVE_CHARDEV_*Paolo Bonzini2015-10-141-12/+12
| | | | | | | | | Move the #ifdef up into qmp_chardev_add, and avoid duplicating the code that reports unavailable backends. Split HAVE_CHARDEV_TTY into HAVE_CHARDEV_SERIAL and HAVE_CHARDEV_PTY. Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: cleanup qmp_chardev_addPaolo Bonzini2015-10-141-25/+31
| | | | | | | Use the usual idioms for error propagation. Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: Use g_new() & friends where that makes obvious senseMarkus Armbruster2015-09-161-11/+11
| | | | | | | | | | | | | | g_new(T, n) is neater than g_malloc(sizeof(T) * n). It's also safer, for two reasons. One, it catches multiplication overflowing size_t. Two, it returns T * rather than void *, which lets the compiler catch more type errors. This commit only touches allocations with size arguments of the form sizeof(T). Same Coccinelle semantic patch as in commit b45c03f. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1442231643-23630-1-git-send-email-armbru@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* maint: avoid useless "if (foo) free(foo)" patternDaniel P. Berrange2015-09-111-3/+1
| | | | | | | | | | | | The free() and g_free() functions both happily accept NULL on any platform QEMU builds on. As such putting a conditional 'if (foo)' check before calls to 'free(foo)' merely serves to bloat the lines of code. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* maint: remove unused include for dirent.hDaniel P. Berrange2015-09-111-1/+0
| | | | | | | | | A number of files were including dirent.h but not using any of the functions it provides Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* qemu-char: Fix missed data on unix socketNils Carlson2015-07-231-8/+5
| | | | | | | | | | | | | | | | | | | Commit 812c1057 introduced HUP detection on unix and tcp sockets prior to a read in tcp_chr_read. This unfortunately broke CloudStack 4.2 which relied on the old behaviour where data on a socket was readable even if a HUP was present. A working solution is to properly check the return values from recv, handling a closed socket once there is no more data to read. Also enable polling for G_IO_NVAL to ensure the callback is called for all possible events as these should now be possible to handle with the improved error detection. Signed-off-by: Nils Carlson <pyssling@ludd.ltu.se> Message-Id: <1437338396-22336-1-git-send-email-pyssling@ludd.ltu.se> [Do not handle EINTR; use socket_error(). - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: handle EINTR for TCP character devicesPaolo Bonzini2015-07-231-2/+11
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qerror: Move #include out of qerror.hMarkus Armbruster2015-06-221-0/+1
| | | | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
* qemu-char: remove unused list node from FDCharDriverEmilio G. Cota2015-04-301-1/+0
| | | | | Signed-off-by: Emilio G. Cota <cota@braap.org> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* qemu-img: Suppress unhelpful extra errors in convert, amendMarkus Armbruster2015-02-261-2/+8
| | | | | | | | | | | | | | | | | | | | img_convert() and img_amend() use qemu_opts_do_parse(), which reports errors with qerror_report_err(). Its error messages aren't helpful here, the caller reports one that actually makes sense. Reproducer: $ qemu-img convert -o backing_format=raw in.img out.img qemu-img: Invalid parameter 'backing_format' qemu-img: Invalid options for file format 'raw' To fix, propagate errors through qemu_opts_do_parse(). This lifts the error reporting into callers. Drop it from img_convert() and img_amend(), keep it in qemu_chr_parse_compat(), bdrv_img_create(). Since I'm touching qemu_opts_do_parse() anyway, write a function comment for it. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* QemuOpts: Drop qemu_opt_set(), rename qemu_opt_set_err(), fix useMarkus Armbruster2015-02-261-29/+29
| | | | | | | | | | | | | | | | qemu_opt_set() is a wrapper around qemu_opt_set() that reports the error with qerror_report_err(). Most of its users assume the function can't fail. Make them use qemu_opt_set_err() with &error_abort, so that should the assumption ever break, it'll break noisily. Just two users remain, in util/qemu-config.c. Switch them to qemu_opt_set_err() as well, then rename qemu_opt_set_err() to qemu_opt_set(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* qemu-char: Avoid qerror_report_err() outside QMP command handlersMarkus Armbruster2015-02-181-2/+1
| | | | | | | | | | | qerror_report_err() is a transitional interface to help with converting existing monitor commands to QMP. It should not be used elsewhere. Replace by error_report_err() in legacy chardev parser qemu_chr_parse_compat(). Legacy chardev syntax is not to be used in QMP. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* error: Use error_report_err() where appropriateMarkus Armbruster2015-02-181-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Coccinelle semantic patch: @@ expression E; @@ - error_report("%s", error_get_pretty(E)); - error_free(E); + error_report_err(E); @@ expression E, S; @@ - error_report("%s", error_get_pretty(E)); + error_report_err(E); ( exit(S); | abort(); ) Trivial manual touch-ups in block/sheepdog.c. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* Do not hang on full PTYDon Slutz2015-01-151-0/+1
| | | | | | Signed-off-by: Don Slutz <dslutz@verizon.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* char: restore stdio echo on resume from suspend.Gal Hammer2015-01-091-0/+15
| | | | | | | | The monitor's auto-completion feature stopped working when stdio is used as an input and qemu was resumed after it was suspended (using ctrl-z). Signed-off-by: Gal Hammer <ghammer@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* Drop superfluous conditionals around qemu_opts_del()Markus Armbruster2014-12-101-3/+1
| | | | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* qemu-char: fix tcp_get_fdsMichael S. Tsirkin2014-11-231-1/+4
| | | | | | | | | | | | | | | tcp_get_fds API discards fds if there's more than 1 of these. It's tricky to fix this without API changes in the generic case. However, this API is only used by tests ATM, and tests know how many fds they expect. So let's not waste cycles trying to fix this properly: simply assume at most 16 fds (tests use at most 8 now). assert if some test tries to get more. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* qemu-char: fix MISSING_COMMAGonglei2014-11-171-1/+1
| | | | | Signed-off-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: Fix reconnect socket error reportingCorey Minyard2014-10-091-18/+34
| | | | | | | | | | | | | | If reconnect was set, errors wouldn't always be reported. Fix that and also only report a connect error once until a connection has been made. The primary purpose of this is to tell the user that a connection failed so they can know they need to figure out what went wrong. So we don't want to spew too much out here, just enough so they know. Signed-off-by: Corey Minyard <cminyard@mvista.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-sockets: Add error to non-blocking connect handlerCorey Minyard2014-10-091-2/+5
| | | | | | | | | An error value here would be quite handy and more consistent with the rest of the code. Signed-off-by: Corey Minyard <cminyard@mvista.com> [Make sure SO_ERROR value is passed to error_setg_errno. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: Print the remote and local addresses for a socketCorey Minyard2014-10-041-9/+18
| | | | | | | | | | It seems that it might be a good idea to know what is at the remote end of a socket for tracking down issues. So add that to the socket filename. Signed-off-by: Corey Minyard <cminyard@mvista.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: Add reconnecting to client socketsCorey Minyard2014-10-041-5/+73
| | | | | | | | | | Adds a "reconnect" option to socket backends that gives a reconnect timeout. This only applies to client sockets. If the other end of a socket closes the connection, qemu will attempt to reconnect after the given number of seconds. Signed-off-by: Corey Minyard <cminyard@mvista.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: set socket filename to disconnected when not connectedCorey Minyard2014-10-041-38/+72
| | | | | | | | | | This way we can tell if the socket is connected or not. It also splits the string conversions out into separate functions to make this more convenient. Signed-off-by: Corey Minyard <cminyard@mvista.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: Move some items into TCPCharDriverCorey Minyard2014-10-041-14/+51
| | | | | | | | | This keeps them from having to be passed around and makes them available for later functions, like printing and reconnecting. Signed-off-by: Corey Minyard <cminyard@mvista.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: Rework qemu_chr_open_socket() for reconnectCorey Minyard2014-10-041-50/+68
| | | | | | | | | | | Move all socket configuration to qmp_chardev_open_socket(). qemu_chr_open_socket_fd() just opens the socket. This is getting ready for the reconnect code, which will call open_sock_fd() on a reconnect attempt. Signed-off-by: Corey Minyard <cminyard@mvista.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: Make the filename size for a chardev a #defineCorey Minyard2014-10-041-7/+9
| | | | | | Signed-off-by: Corey Minyard <cminyard@mvista.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-char: Permit only a single "stdio" character deviceLi Liu2014-09-201-1/+9
| | | | | | | | | | | | | When more than one is used, the terminal settings aren't restored correctly on exit. Fixable. However, such usage makes no sense, because the users race for input, so outlaw it instead. If you want to connect multiple things to stdio, use the mux chardev. Signed-off-by: Li Liu <john.liuli@huawei.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* qemu-char: Rename register_char_driver_qapi() to register_char_driver()Peter Maydell2014-09-161-28/+26
| | | | | | | | | Now we have removed the legacy register_char_driver() we can rename register_char_driver_qapi() to the more obvious and shorter name. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 1409653457-27863-6-git-send-email-peter.maydell@linaro.org
OpenPOWER on IntegriCloud