summaryrefslogtreecommitdiff
path: root/qemu-char.c
AgeCommit message (Collapse)AuthorFilesLines
2011-08-22char: remove qemu_chr_send_event()Anthony Liguori1-6/+0
It's dead code. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22char: rename qemu_chr_get_msgfd() -> qemu_chr_fe_get_msgfd()Anthony Liguori1-1/+1
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22char: rename qemu_chr_close() -> qemu_chr_delete()Anthony Liguori1-2/+2
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22char: qemu_chr_open_opts() -> qemu_chr_new_from_opts()Anthony Liguori1-2/+2
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22char: rename qemu_chr_open() -> qemu_chr_new()Anthony Liguori1-1/+1
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22char: rename qemu_chr_set_echo() -> qemu_chr_fe_set_echo()Anthony Liguori1-2/+2
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22char: qemu_chr_ioctl() -> qemu_chr_fe_ioctl()Anthony Liguori1-1/+1
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22char: rename qemu_chr_guest_close() -> qemu_chr_fe_close()Anthony Liguori1-1/+1
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22char: rename qemu_chr_guest_open() -> qemu_chr_fe_open()Anthony Liguori1-1/+1
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22char: rename qemu_chr_can_read() -> qemu_chr_be_can_read()Anthony Liguori1-10/+10
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22char: rename qemu_chr_read() -> qemu_chr_be_write()Anthony Liguori1-9/+9
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22char: rename qemu_chr_printf() -> qemu_chr_fe_printf()Anthony Liguori1-1/+1
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22char: rename qemu_chr_write() -> qemu_chr_fe_write()Anthony Liguori1-2/+2
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-20Use glib memory allocation and free functionsAnthony Liguori1-42/+42
qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-07-25Wrap recv to avoid warningsBlue Swirl1-2/+2
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 Swirl1-3/+4
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. Berrange1-6/+24
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 Wolf1-68/+97
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 Raymond1-1/+0
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 Shah1-1/+1
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 Kouichi1-1/+4
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 Goede1-0/+17
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 Liguori1-0/+4
2011-03-21char: Prevent multiple devices opening same chardevAmit Shah1-0/+4
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 Bonzini1-4/+4
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 Weil1-2/+2
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 Hajnoczi1-0/+5
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 Bonzini1-0/+1
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 Bonzini1-10/+16
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 Bonzini1-10/+8
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 Bonzini1-0/+7
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-02-01remove broken code for ttyPaolo Bonzini1-10/+0
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 Levy1-0/+4
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 Capitulino1-0/+64
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 Sorensen1-6/+2
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 Hoffmann1-1/+1
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 Swirl1-3/+4
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 Macdonell1-0/+6
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 Armbruster1-6/+1
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 Armbruster1-1/+0
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 Capitulino1-16/+0
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 Bonzini1-6/+3
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 Graf1-0/+20
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 Voipio1-1/+1
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 Havivi1-1/+3
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 Lock1-2/+2
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 Liguori1-9/+2
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 Liguori1-2/+9
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 Quintela1-2/+2
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 Kiszka1-1/+1
The missing '@' broke 'udp::<port>@:<port>' parsing. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>