summaryrefslogtreecommitdiff
path: root/qemu-char.c
AgeCommit message (Collapse)AuthorFilesLines
2013-03-08qemu-char: add watch supportAnthony Liguori1-1/+31
This allows a front-end to request for a callback when the backend is writable again. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Amit Shah <amit.shah@redhat.com> Message-id: 96f93c0f741064604bbb6389ce962191120af8b7.1362505276.git.amit.shah@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-03-08qemu-char: tcp: make use GIOChannelAnthony Liguori1-18/+42
I didn't bother switching to g_io_channel_read/write because we need to use sendmsg on Unix. No problem though since we're using an unbuffered channel. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Amit Shah <amit.shah@redhat.com> Message-id: 002f726576dfb51bca4854aa257b74d77c1cd4e8.1362505276.git.amit.shah@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-03-08qemu-char: convert UDP to GIOChannelAnthony Liguori1-11/+57
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Amit Shah <amit.shah@redhat.com> Message-id: 775a2bd666a3d1fa008656bf97191b7573c6ffb5.1362505276.git.amit.shah@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-03-08qemu-char: convert pty to GIOChannelAnthony Liguori1-17/+27
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Amit Shah <amit.shah@redhat.com> Message-id: 339eebf3c59a450b0354056e9ac4b41f67230831.1362505276.git.amit.shah@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-03-08qemu-char: convert fd_chr to use a GIOChannelAnthony Liguori1-41/+62
This uses the newly introduced IOWatchPoll source. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Amit Shah <amit.shah@redhat.com> Message-id: 0cb5d14510ee835a0ebc23676d10a2cce9280da5.1362505276.git.amit.shah@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-03-08char: add IOWatchPoll supportAnthony Liguori1-0/+140
This is a special GSource that supports CharDriverState style poll callbacks. For reviewability and bisectability, this code is #if 0'd out in this patch to avoid unused warnings since all of the functions are static. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Amit Shah <amit.shah@redhat.com> Message-id: 9b59ac17b9d0bb3972a73fed04d415f07b391936.1362505276.git.amit.shah@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-03-08qemu-char: remove dead/confusing logic with nb_stdio_clientsAnthony Liguori1-106/+30
This code is very old dating back to 2007. What is puzzling is that STDIO_MAX_CLIENTS was always #define to 1 meaning that all of the code to deal with more than one client was unreachable. Just remove the whole mess of it. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Amit Shah <amit.shah@redhat.com> Message-id: d276bccdbf4e7463020c5f539f61ae3bfbc88d1d.1362505276.git.amit.shah@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-03-04move socket_set_nodelay to osdep.cMORITA Kazutaka1-6/+0
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-02-21console: allow VCs to be overridden by UIAnthony Liguori1-1/+1
We want to expose VCs using a VteTerminal widget. We need access to provide our own CharDriverState in order to do this. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Message-id: 1361367806-4599-3-git-send-email-aliguori@us.ibm.com
2013-02-13qapi: Flatten away ChardevPortMarkus Armbruster1-35/+41
Simplifies the schema and the code. QMP command { "execute" : "chardev-add", "arguments" : { "id" : "ser0", "backend" : { "type" : "port", "data" : { "type": "serial", "device":"/dev/ttyS0"} } } } becomes { "execute" : "chardev-add", "arguments" : { "id" : "ser0", "backend" : { "type" : "serial", "data" : { "device":"/dev/ttyS0"} } } } Bonus: nicer error messages. "unknown chardev port (1)" becomes "character device backend type 'parallel' not supported". Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Message-id: 1360767256-610-3-git-send-email-armbru@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-11error: Strip trailing '\n' from error string arguments (again)Markus Armbruster1-4/+4
Commit 6daf194d and be62a2eb got rid of a bunch, but they keep coming back. Tracked down with this Coccinelle semantic patch: @r@ expression err, eno, cls, fmt; position p; @@ ( error_report(fmt, ...)@p | error_set(err, cls, fmt, ...)@p | error_set_errno(err, eno, cls, fmt, ...)@p | error_setg(err, fmt, ...)@p | error_setg_errno(err, eno, fmt, ...)@p ) @script:python@ fmt << r.fmt; p << r.p; @@ if "\\n" in str(fmt): print "%s:%s:%s:%s" % (p[0].file, p[0].line, p[0].column, fmt) Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-id: 1360354939-10994-4-git-send-email-armbru@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-06qemu-char: Support suffixed ringbuf size arguments like "size=64K"Markus Armbruster1-4/+3
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-06qemu-char: Saner naming of memchar stuff & doc fixesMarkus Armbruster1-29/+36
New device, has never been released, so we can still improve things without worrying about compatibility. Naming is a mess. The code calls the device driver CirMemCharDriver, the public API calls it "memory", "memchardev", or "memchar", and the special commands are named like "memchar-FOO". "memory" is a particularly unfortunate choice, because there's another character device driver called MemoryDriver. Moreover, the device's distinctive property is that it's a ring buffer, not that's in memory. Therefore: * Rename CirMemCharDriver to RingBufCharDriver, and call the thing a "ringbuf" in the API. * Rename QMP and HMP commands from memchar-FOO to ringbuf-FOO. * Rename device parameter from maxcapacity to size (simple words are good for you). * Clearly mark the parameter as optional in documentation. * Fix error reporting so that chardev-add reports to current monitor, not stderr. * Replace cirmem in C identifiers by ringbuf. * Rework documentation. Document the impact of our crappy UTF-8 handling on reading. * QMP examples that even work. I could split this up into multiple commits, but they'd change the same documentation lines multiple times. Not worth it. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-06qemu-char: General chardev "memory" code cleanupMarkus Armbruster1-19/+12
Inline trivial cirmem_chr_is_empty() into its only caller. Rename qemu_chr_cirmem_count() to cirmem_count(). Fast ring buffer index wraparound. Without this, there's no point in restricting size to a power two. qemu_is_chr(chr, "memory") returns *zero* when chr is a memory character device, which isn't what I'd expect. Replace it by the saner and more obviously correct chr_is_cirmem(). Also avoids encouraging testing for specific character devices elsewhere. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-06qemu-char: Drop undocumented chardev "memory" compatibility syntaxMarkus Armbruster1-5/+0
This is a new device, so there's no compatibility to maintain, and its use case isn't common enough to justify shorthand syntax. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-06qemu-char: Fix chardev "memory" not to drop IAC charactersMarkus Armbruster1-5/+0
Undocumented misfeature, get rid of it while we can. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-06qmp: Drop wasteful zero-initialization in qmp_memchar_read()Markus Armbruster1-1/+2
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-06qmp: Drop superfluous special case "empty" in qmp_memchar_read()Markus Armbruster1-4/+0
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-06qmp: Plug memory leaks in memchar-write, memchar-readMarkus Armbruster1-0/+5
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-06qmp: Clean up type usage in qmp_memchar_write(), qmp_memchar_read()Markus Armbruster1-3/+3
Const-correctness, consistently use standard C types instead of mixing them with GLib types. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-06qmp: Use generic errors in memchar-read, memchar-writeMarkus Armbruster1-2/+2
New errors should be generic unless there's a real use case for rich errors. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-06qmp: Clean up design of memchar-readMarkus Armbruster1-12/+9
The data returned has a well-defined size, which makes the size returned along with it redundant at best. Drop it. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-06qmp: Fix design bug and read beyond buffer in memchar-writeMarkus Armbruster1-5/+3
Command memchar-write takes data and size parameter. Begs the question what happens when data doesn't match size. With format base64, qmp_memchar_write() copies the full data argument, regardless of size argument. With format utf8, qmp_memchar_write() copies size bytes from data, happily reading beyond data. Copies crap from the heap or even crashes. Drop the size parameter, and always copy the full data argument. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-01-28Merge remote-tracking branch 'luiz/queue/qmp' into stagingAnthony Liguori1-0/+203
# By Lei Li (3) and others # Via Luiz Capitulino * luiz/queue/qmp: QAPI: Introduce memchar-read QMP command QAPI: Introduce memchar-write QMP command qemu-char: Add new char backend CirMemCharDriver docs: document virtio-balloon stats balloon: re-enable balloon stats balloon: drop old stats code & API block: Monitor command commit neglects to report some errors
2013-01-26qemu-char: Avoid unused variable warning in some configsPeter Maydell1-2/+6
Avoid unused variable warnings: qemu-char.c: In function 'qmp_chardev_open_port': qemu-char.c:3132: warning: unused variable 'fd' qemu-char.c:3132: warning: unused variable 'flags' in configurations with neither HAVE_CHARDEV_TTY nor HAVE_CHARDEV_PARPORT set. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-01-25QAPI: Introduce memchar-read QMP commandLei Li1-0/+47
Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2013-01-25QAPI: Introduce memchar-write QMP commandLei Li1-0/+42
Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2013-01-25qemu-char: Add new char backend CirMemCharDriverLei Li1-0/+114
Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2013-01-16chardev: add pty chardev support to chardev-add (qmp)Gerd Hoffmann1-0/+13
The ptsname is returned directly, so there is no need to use query-chardev to figure the pty device path. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-16chardev: add socket chardev support to chardev-add (qmp)Gerd Hoffmann1-53/+113
qemu_chr_open_socket is split into two functions. All initialization after creating the socket file handler is split away into the new qemu_chr_open_socket_fd function. chr->filename doesn't get filled from QemuOpts any more. Qemu gathers the information using getsockname and getnameinfo instead. This way it will also work correctly for file handles passed via file descriptor passing. Finally qmp_chardev_open_socket() is the actual qmp hotplug implementation which basically just calls socket_listen or socket_connect and the new qemu_chr_open_socket_fd function. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-16chardev: add parallel chardev support to chardev-add (qmp)Gerd Hoffmann1-16/+28
Also alias the old parport name to parallel for -chardev. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-16chardev: add serial chardev support to chardev-add (qmp)Gerd Hoffmann1-8/+54
Similar to file, except that no separate in/out files are supported because it's pointless for direct device access. Also the special tty ioctl hooks (pass through linespeed settings etc) are activated on Unix. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-16chardev: add file chardev support to chardev-add (qmp)Gerd Hoffmann1-0/+61
Add support for file chardevs. Output file is mandatory, input file is optional. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-16chardev: add qmp hotplug commands, with null chardev supportGerd Hoffmann1-0/+53
Add chardev-add and chardev-remove qmp commands. Hotplugging a null chardev is supported for now, more will be added later. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-16chardev: reduce chardev ifdef mess a bitGerd Hoffmann1-11/+11
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-16chardev: fix QemuOpts lifecycleGerd Hoffmann1-6/+14
qemu_chr_new_from_opts handles QemuOpts release now, so callers don't have to worry. It will either be saved in CharDriverState, then released in qemu_chr_delete, or in the error case released instantly. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-16chardev: add error reporting for qemu_chr_new_from_optsGerd Hoffmann1-9/+15
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-12qemu-option: move standard option definitions out of qemu-config.cPaolo Bonzini1-0/+72
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-01-03pty: unbreak libvirtGerd Hoffmann1-4/+5
Commit 586502189edf9fd0f89a83de96717a2ea826fdb0 breaks libvirt pty support because it tried to figure the pts name from stderr output. Fix this by moving the label to the end of the line, this way the libvirt parser does still recognise the message. libvirt looks for "char device redirected to ${ptsname}<whitespace>". Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-01-02disallow -daemonize usage of stdio (curses display, -nographic, -serial ↵Michael Tokarev1-0/+4
stdio etc) Curses display requires stdin/out to stay on the terminal, so -daemonize makes no sense in this case. Instead of leaving display uninitialized like is done since 995ee2bf469de6bb, explicitly detect this case earlier and error out. -nographic can actually be used with -daemonize, by redirecting everything to a null device, but the problem is that according to documentation and historical behavour, -nographic redirects guest ports to stdin/out, which, again, makes no sense in case of -daemonize. Since -nographic is a legacy option, don't bother fixing this case (to allow -nographic and -daemonize by redirecting guest ports to null instead of stdin/out in this case), but disallow it completely instead, to stop garbling host terminal. If no display display needed and user wants to use -nographic, the right way to go is to use -serial null -parallel null -monitor none -display none -vga none instead of -nographic. Also prevent the same issue -- it was possible to get garbled host tty after -nographic -daemonize and it is still possible to have it by using -serial stdio -daemonize Fix this by disallowing opening stdio chardev when -daemonize is specified. Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-12-23qemu-char: Inherit ptys and improve output from -serial ptyLei Li1-1/+7
Changes since V1: - Avoid crashing since qemu_opts_id() may return null on some systems according to Markus's suggestion. When controlling a qemu instance from another program, it's hard to know which serial port or monitor device is redirected to which pty. With more than one device using "pty" a lot of guesswork is involved. $ ./x86_64-softmmu/qemu-system-x86_64 -serial pty -serial pty -monitor pty char device redirected to /dev/pts/5 char device redirected to /dev/pts/6 char device redirected to /dev/pts/7 Although we can find out what everything else is connected to by the "info chardev" with "-monitor stdio" in the command line, It'd be very useful to be able to have qemu inherit pseudo-tty file descriptors so they could just be specified on the command line like: $ ./x86_64-softmmu/qemu-system-x86_64 -serial pty -serial pty -monitor pty char device compat_monitor0 redirected to /dev/pts/5 char device serial0 redirected to /dev/pts/6 char device serial1 redirected to /dev/pts/7 Referred link: https://bugs.launchpad.net/qemu/+bug/938552 Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-12-19Merge remote-tracking branch 'bonzini/header-dirs' into stagingAnthony Liguori1-7/+6
* bonzini/header-dirs: (45 commits) janitor: move remaining public headers to include/ hw: move executable format header files to hw/ fpu: move public header file to include/fpu softmmu: move remaining include files to include/ subdirectories softmmu: move include files to include/sysemu/ misc: move include files to include/qemu/ qom: move include files to include/qom/ migration: move include files to include/migration/ monitor: move include files to include/monitor/ exec: move include files to include/exec/ block: move include files to include/block/ qapi: move include files to include/qobject/ janitor: add guards to headers qapi: make struct Visitor opaque qapi: remove qapi/qapi-types-core.h qapi: move inclusions of qemu-common.h from headers to .c files ui: move files to ui/ and include/ui/ qemu-ga: move qemu-ga files to qga/ net: reorganize headers net: move net.c to net/ ... Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-12-19softmmu: move remaining include files to include/ subdirectoriesPaolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19softmmu: move include files to include/sysemu/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19misc: move include files to include/qemu/Paolo Bonzini1-2/+2
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19monitor: move include files to include/monitor/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19ui: move files to ui/ and include/ui/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19net: do not include net.h everywherePaolo Bonzini1-1/+0
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-17spice-qemu-char: add spiceport chardevMarc-André Lureau1-0/+3
Add a new spice chardev to allow arbitrary communication between the host and the Spice client via the spice server. Examples: This allows the Spice client to have a special port for the qemu monitor: ... -chardev spiceport,name=org.qemu.monitor,id=monitorport -mon chardev=monitorport v2: - remove support for chardev to chardev linking - conditionnaly compile with SPICE_SERVER_VERSION Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-24chardev: Use real-time clock for open timerJan Kiszka1-2/+2
The vm clock may be stopped, and then we won't get open events anymore. Seen with QMP sessions. Reported-by: Dietmar Maurer <dietmar@proxmox.com> Tested-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>