aboutsummaryrefslogtreecommitdiff
path: root/qemu-char.c
AgeCommit message (Collapse)Author
2011-07-25Wrap recv to avoid warningsBlue Swirl
Avoid warnings like these by wrapping recv(): CC slirp/ip_icmp.o /src/qemu/slirp/ip_icmp.c: In function 'icmp_receive': /src/qemu/slirp/ip_icmp.c:418:5: error: passing argument 2 of 'recv' from incompatible pointer type [-Werror] /usr/local/lib/gcc/i686-mingw32msvc/4.6.0/../../../../i686-mingw32msvc/include/winsock2.h:547:32: note: expected 'char *' but argument is of type 'struct icmp *' Remove also casts used to avoid warnings. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-07-24Fix chrdev return value conversionBlue Swirl
6e1db57b2ac9025c2443c665a0d9e78748637b26 didn't convert brlapi or win32 chrdevs, breaking build for those. Fix by converting the chrdevs. Acked-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-07-23Introduce a 'client_add' monitor command accepting an open FDDaniel P. Berrange
Allow client connections for VNC and socket based character devices to be passed in over the monitor using SCM_RIGHTS. One intended usage scenario is to start QEMU with VNC on a UNIX domain socket. An unprivileged user which cannot access the UNIX domain socket, can then connect to QEMU's VNC server by passing an open FD to libvirt, which passes it onto QEMU. { "execute": "get_fd", "arguments": { "fdname": "myclient" } } { "return": {} } { "execute": "add_client", "arguments": { "protocol": "vnc", "fdname": "myclient", "skipauth": true } } { "return": {} } In this case 'protocol' can be 'vnc' or 'spice', or the name of a character device (eg from -chardev id=XXXX) The 'skipauth' parameter can be used to skip any configured VNC authentication scheme, which is useful if the mgmt layer talking to the monitor has already authenticated the client in another way. * console.h: Define 'vnc_display_add_client' method * monitor.c: Implement 'client_add' command * qemu-char.c, qemu-char.h: Add 'qemu_char_add_client' method * qerror.c, qerror.h: Add QERR_ADD_CLIENT_FAILED * qmp-commands.hx: Declare 'client_add' command * ui/vnc.c: Implement 'vnc_display_add_client' method Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-07-23qemu-char: Print strerror message on failureKevin Wolf
The only way for chardev drivers to communicate an error was to return a NULL pointer, which resulted in an error message that said _that_ something went wrong, but not _why_. This patch changes the interface to return 0/-errno and updates qemu_chr_open_opts to use strerror to display a more helpful error message. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-06-08Fix compilation warning due to missing header for sigaction (followup)Alexandre Raymond
This patch removes all references to signal.h when qemu-common.h is included as they become redundant. Signed-off-by: Alexandre Raymond <cerbere@gmail.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-04-28char: Detect chardev release by NULL handlers as well as NULL opaqueAmit Shah
Juan says he prefers these extra checks to ensure a user of a chardev is releasing it. Requested-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Amit Shah <amit.shah@redhat.com>
2011-04-28char: Allow devices to use a single multiplexed chardev.Kusanagi Kouichi
This fixes regression caused by commit 2d6c1ef40f3678ab47a4d14fb5dadaa486bfcda6 ("char: Prevent multiple devices opening same chardev"): -nodefaults -nographic -chardev stdio,id=stdio,mux=on,signal=off \ -mon stdio -device virtio-serial-pci \ -device virtconsole,chardev=stdio -device isa-serial,chardev=stdio fails with: qemu-system-x86_64: -device isa-serial,chardev=stdio: Property 'isa-serial.chardev' can't take value 'stdio', it's in use Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp> Signed-off-by: Amit Shah <amit.shah@redhat.com>
2011-04-28chardev: Allow frontends to notify backends of guest open / closeHans de Goede
Some frontends know when the guest has opened the "channel" and is actively listening to it, for example virtio-serial. This patch adds 2 new qemu-chardev functions which can be used by frontends to signal guest open / close, and allows interested backends to listen to this. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Alon Levy <alevy@redhat.com> Signed-off-by: Amit Shah <amit.shah@redhat.com>
2011-03-24Merge remote branch 'amit/for-anthony' into stagingAnthony Liguori
2011-03-21char: Prevent multiple devices opening same chardevAmit Shah
Prevent: -chardev socket,path=/tmp/foo,server,nowait,id=c0 \ -device virtserialport,chardev=c0,id=vs0 \ -device virtserialport,chardev=c0,id=vs1 Reported-by: Mike Cao <bcao@redhat.com> Signed-off-by: Amit Shah <amit.shah@redhat.com>
2011-03-21change all rt_clock references to use millisecond resolution accessorsPaolo Bonzini
This was done with: sed -i '/get_clock\>.*rt_clock/s/get_clock\>/get_clock_ms/' \ $(git grep -l 'get_clock\>.*rt_clock' ) sed -i '/new_timer\>.*rt_clock/s/new_timer\>/new_timer_ms/' \ $(git grep -l 'new_timer\>.*rt_clock' ) after checking that get_clock and new_timer never occur twice on the same line. There were no missed occurrences; however, even if there had been, they would have been caught by the compiler. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2011-03-20Fix conversions from pointer to int and vice versaStefan Weil
Here the int values fds[0], sigfd, s, sock and fd are converted to void pointers which are later converted back to an int value. These conversions should always use intptr_t instead of unsigned long. They are needed for environments where sizeof(long) != sizeof(void *). Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-02-20qemu-char: Check for missing backend nameStefan Hajnoczi
Check if the backend option is missing before searching the backend table. This fixes a NULL pointer dereference when QEMU is invoked with the following invalid command-line: $ qemu -chardev id=foo,path=/tmp/socket Previously QEMU would segfault, now it produces this error message: chardev: "foo" missing backend Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-02-01fix QemuOpts leakPaolo Bonzini
Now that no backend's open function saves the passed QemuOpts, fix a leak in the qemu_chr_open backwards-compatible parser. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-02-01add set_echo implementation for qemu_chr_stdioPaolo Bonzini
This also requires moving QemuOpts out of term_init. Clearing ISIG is independent of whether echo is enabled or disabled. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-02-01move atexit(term_exit) and O_NONBLOCK to qemu_chr_open_stdioPaolo Bonzini
In the next patch, term_init will be changed to enable or disable echo at will. Move extraneous stuff out of it. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-02-01add qemu_chr_set_echoPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-02-01remove broken code for ttyPaolo Bonzini
This code is taking the settings for a serial port and moving it to fd 0 when qemu exits. This is likely just cut-and-paste, rip it. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-01-24spice: add chardev (v5)Alon Levy
Adding a chardev backend for spice, where spice determines what to do with it based on the name attribute given during chardev creation. For usage by spice vdagent in conjunction with a properly named virtio-serial device, and future smartcard channel usage. Example usage: qemu -device virtio-serial -chardev spicevmc,name=vdagent,id=vdagent \ -device virtserialport,chardev=vdagent,name=com.redhat.spice.0 v4->v5: * add tracing events * fix missing comma * fix help string to show debug is optional v3->v4: * updated commit message v1->v3 changes: (v2 had a wrong commit message) * removed spice-qemu-char.h, folded into ui/qemu-spice.h * removed dead IOCTL code * removed comment * removed ifdef CONFIG_SPICE from qemu-config.c and qemu-options.hx help. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2010-11-17qemu-char: Introduce Memory driverLuiz Capitulino
This driver handles in-memory chardev operations. That's, all writes to this driver are stored in an internal buffer and it doesn't talk to the external world in any way. Right now it's very simple: it supports only writes. But it can be easily extended to support more operations. This is going to be used by the monitor's "HMP passthrough via QMP" feature, which needs to run monitor handlers without a backing device. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-11-03Fold send_all() wrapper unix_write() into one functionJes Sorensen
The current send_all() wrapper for POSIX calls does nothing but call unix_write(). Merge them to simplify the code. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-08-22QemuOpts: make most qemu_*_opts staticGerd Hoffmann
Switch tree to lookup-by-name using qemu_find_opts(). Also hook up virtfs options so qemu_find_opts works for them too. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-08-15Fix mingw32 buildBlue Swirl
Don't define qemu_chr_open_eventfd() on Windows. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-08-10RESEND: Inter-VM shared memory PCI deviceCam Macdonell
resend for bug fix related to removal of irqfd Support an inter-vm shared memory device that maps a shared-memory object as a PCI device in the guest. This patch also supports interrupts between guest by communicating over a unix domain socket. This patch applies to the qemu-kvm repository. -device ivshmem,size=<size in format accepted by -m>[,shm=<shm name>] Interrupts are supported between multiple VMs by using a shared memory server by using a chardev socket. -device ivshmem,size=<size in format accepted by -m>[,shm=<shm name>] [,chardev=<id>][,msi=on][,ioeventfd=on][,vectors=n][,role=peer|master] -chardev socket,path=<path>,id=<id> The shared memory server, sample programs and init scripts are in a git repo here: www.gitorious.org/nahanni Signed-off-by: Cam Macdonell <cam@cs.ualberta.ca> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-06-15block: Decouple block device "commit all" from DriveInfoMarkus Armbruster
do_commit() and mux_proc_byte() iterate over the list of drives defined with drive_init(). This misses host block devices defined by other means. Such means don't exist now, but will be introduced later in this series. Change them to use new bdrv_commit_all(), which iterates over all host block devices. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-06-04blockdev: Collect block device code in new blockdev.cMarkus Armbruster
Anything that moves hundreds of lines out of vl.c can't be all bad. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-06-01Monitor: Drop QMP documentation from codeLuiz Capitulino
Previous commit added QMP documentation to the qemu-monitor.hx file, it's is a copy of this information. While it's good to keep it near code, maintaining two copies of the same information is too hard and has little benefit as we don't expect client writers to consult the code to find how to use a QMP command. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-04-26stash away SCM_RIGHTS fd until a getfd command arrivesPaolo Bonzini
If there is already a fd in s->msgfd before recvmsg it is closed by parts that this patch does not touch. So, only one descriptor can be "leaked" by attaching it to a command other than getfd. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-04-09Always notify consumers of char devices if they're openAlexander Graf
When using virtio-console on s390, the input doesn't work. The root of the problem is rather simple. What happens is the following: 1) create character device for stdio 2) char device is done creating, sends OPENED event 3) virtio-console adds handlers 4) no event comes because the char device is open already 5) virtio-console doesn't accept input because it didn't receive an OPENED event To make that sure virtio-console gets notified that the character device is open even when it's been open from the beginning, this patch introduces a variable that keeps track of the opened state. If the device is open when the event handlers get installed, we just notify the handler. This fixes input with virtio-console on s390. Signed-off-by: Alexander Graf <agraf@suse.de> Acked-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-04-08fix function signature of qemu_chr_open_pty on !linuxRiku Voipio
Signed-off-By: Riku Voipio <riku.voipio@nokia.com> Signed-off-By: Juha Riihimäki <juha.riihimaki@nokia.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-03-31Restore terminal monitor attributes - additionShahar Havivi
Patch 2d753894c7553d6a05e8fdbed5f4704398919a35 was missing this check, when running monitor as /dev/tty and other serial device, i.e: qemu -monitor /dev/tty -serial /dev/pts/1 Without this patch any serial device will override the monitor stored attributes. (monitor is called in main() before any serial device). Signed-off-by: Shahar Havivi <shaharh@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-03-30Fix some compilation warnings on FreeBSD hostsJuergen Lock
Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-03-21Revert "Convert atexit users to exit_notifier"Anthony Liguori
This reverts commit d7234f4d7e373a708e1df9ab565a71b71b189025. Conflicts: hw/xen_machine_pv.c This should have never been committed. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-03-19Convert atexit users to exit_notifierAnthony Liguori
All of these users have global state so we really don't see a benefit from exit_notifier. However, using exit_notifier means that there's one less justification for having global state in the first place. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-03-19rename IOCanRWHandler to IOCanReadHandlerJuan Quintela
It was always only used for reads Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-03-14Fix corner case in chardev udp: parameterJan Kiszka
The missing '@' broke 'udp::<port>@:<port>' parsing. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-03-09Restore terminal attributes for tty based monitorShahar Havivi
Patch http://permalink.gmane.org/gmane.comp.emulators.qemu/63472 handle close when using tty devices (like /dev/ttyS0), yet tty based monitor are not restoring terminal attributes (as done with stdio based monitor), when closing qemu after that command: $ qemu -monitor /dev/tty the terminal is not responding until you write reset (blindly), this patch fix it Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-28qemu-char.c: drop debug printfs from qemu_chr_parse_compatJan Kiszka
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-02-22add close callback for tty-based char deviceDavid Ahern
v1 -> v2 coding style changes Add a tty close callback. Right now if a guest device that is connected to a tty-based chardev in the host is removed, the tty is not closed. With this patch it is closed. Example use case is connecting an emulated USB serial cable in the guest to ttyS0 of the host using the monitor command: usb_add serial::/dev/ttyS0 and then removing the device with: usb_del serial::/dev/ttyS0 Signed-off-by: David Ahern <daahern@cisco.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-10Do not ignore error, if open file failed (-serial /dev/tty)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. Signed-off-by: Evgeniy Dushistov <dushistov@mail.ru> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-19char: Remove redundant qemu_chr_generic_open() call.Kusanagi Kouichi
qemu_chr_open_fd() calls qemu_chr_generic_open(), so qemu_chr_open_tty() doesn't need to call it. Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-12char: Convert qemu_chr_info() to QObjectLuiz Capitulino
Each device is represented by a QDict. The returned QObject is a QList of all devices. This commit should not change user output. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-12un-static qemu_chr_parse_compat()Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03Don't leak file descriptorsKevin Wolf
We're leaking file descriptors to child processes. Set FD_CLOEXEC on file descriptors that don't need to be passed to children to stop this misbehaviour. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-30Fix commit a167ba50851cdac2fa36633587e98c5956cd6b18Aurelien Jarno
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-11-29Add support for GNU/kFreeBSDAurelien Jarno
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-11-17char: rename qemu_chr_reset to qemu_chr_generic_openAmit Shah
This function sends out the OPENED event to backends that have drive the chardevs. The 'reset' is now a historical artifact and we can now just call the function for what it is. Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-17char: Remove special init_reset handlingAmit Shah
The initial_reset sent to chardevs doesn't do much other than setting a bool to true. Char devices are interested in the open event and that gets sent whenever the device is opened. Moreover, the reset logic breaks as and when qemu's bh scheduling changes. Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-17char: don't limit data sent to backends to 1k per bufferAmit Shah
chardevs have a 'can_read' function via which backends specify the amount of data they can receive. When can_read returns > 0, apps can start sending data. However, each chardev driver here allows a max. of 1k bytes inspite of the backend being able to receive more. The best we can do here is to allocate s->max_size bytes from the heap on each call (which is the number returned by the backend from the can_read call). This is an intermediate step to bump up the bytes written in each call to 4k. Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30serial: Support additional serial speed valuesStefan Weil
* Allow any speed value which is defined for Linux (and possibly other systems). * Compare int values instead of double values. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>