History | View | Annotate | Download (74.3 kB)
qemu-char: Plug memory leak on qemu_chr_open_pty() error path
Spotted by Coverity.
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Add stdio char device on windows
Simple implementation of an stdio char device on Windows.
Signed-off-by: Fabien Chouteau <chouteau@adacore.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
qemu-char: Fix use of free() instead of g_free()
cppcheck reported these errors:
qemu-char.c:1667: error: Mismatching allocation and deallocation: sqemu-char.c:1668: error: Mismatching allocation and deallocation: chrqemu-char.c:1769: error: Mismatching allocation and deallocation: s...
qapi: Convert query-chardev
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>Tested-by: Michael Roth <mdroth@linux.vnet.ibm.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
qemu-char: use qemu_set_fd_handler/2 consistently
Now that qemu_set_fd_handler and qemu_set_fd_handler2 have differentimplementations, one using qemu iohandlers and the other glib, it is notsafe to mix the two when inserting/deleting handlers.
Fixes kvm-autotest....
char: rename qemu_chr_get_msgfd() -> qemu_chr_fe_get_msgfd()
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
char: remove qemu_chr_send_event()
It's dead code.
char: rename qemu_chr_open() -> qemu_chr_new()
char: qemu_chr_open_opts() -> qemu_chr_new_from_opts()
char: rename qemu_chr_close() -> qemu_chr_delete()
char: qemu_chr_ioctl() -> qemu_chr_fe_ioctl()
char: rename qemu_chr_set_echo() -> qemu_chr_fe_set_echo()
char: rename qemu_chr_read() -> qemu_chr_be_write()
char: rename qemu_chr_can_read() -> qemu_chr_be_can_read()
char: rename qemu_chr_guest_open() -> qemu_chr_fe_open()
char: rename qemu_chr_guest_close() -> qemu_chr_fe_close()
char: rename qemu_chr_write() -> qemu_chr_fe_write()
char: rename qemu_chr_printf() -> qemu_chr_fe_printf()
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.
Wrap recv to avoid warnings
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]...
Fix chrdev return value conversion
6e1db57b2ac9025c2443c665a0d9e78748637b26 didn'tconvert 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>
Introduce a 'client_add' monitor command accepting an open FD
Allow client connections for VNC and socket based characterdevices to be passed in over the monitor using SCM_RIGHTS.
One intended usage scenario is to start QEMU with VNC on aUNIX domain socket. An unprivileged user which cannot access...
qemu-char: Print strerror message on failure
The only way for chardev drivers to communicate an error was to return a NULLpointer, which resulted in an error message that said that something wentwrong, but not why.
This patch changes the interface to return 0/-errno and updates...
Fix compilation warning due to missing header for sigaction (followup)
This patch removes all references to signal.h when qemu-common.h is includedas they become redundant.
Signed-off-by: Alexandre Raymond <cerbere@gmail.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
char: Detect chardev release by NULL handlers as well as NULL opaque
Juan says he prefers these extra checks to ensure a user of a chardev isreleasing it.
Requested-by: Juan Quintela <quintela@redhat.com>Signed-off-by: Amit Shah <amit.shah@redhat.com>
char: Allow devices to use a single multiplexed chardev.
This fixes regression caused by commit2d6c1ef40f3678ab47a4d14fb5dadaa486bfcda6("char: Prevent multiple devices opening same chardev"):
-nodefaults -nographic -chardev stdio,id=stdio,mux=on,signal=off \...
chardev: Allow frontends to notify backends of guest open / close
Some frontends know when the guest has opened the "channel" and is activelylistening to it, for example virtio-serial. This patch adds 2 new qemu-chardevfunctions which can be used by frontends to signal guest open / close, and...
Merge remote branch 'amit/for-anthony' into staging
char: Prevent multiple devices opening same chardev
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>
change all rt_clock references to use millisecond resolution accessors
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/' \...
Fix conversions from pointer to int and vice versa
Here the int values fds0, sigfd, s, sock and fd are convertedto 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 *)....
qemu-char: Check for missing backend name
Check if the backend option is missing before searching the backendtable. This fixes a NULL pointer dereference when QEMU is invoked withthe following invalid command-line:
$ qemu -chardev id=foo,path=/tmp/socket...
fix QemuOpts leak
Now that no backend's open function saves the passed QemuOpts, fix a leakin the qemu_chr_open backwards-compatible parser.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
remove broken code for tty
This code is taking the settings for a serial port and moving it tofd 0 when qemu exits. This is likely just cut-and-paste, rip it.
add qemu_chr_set_echo
move atexit(term_exit) and O_NONBLOCK to qemu_chr_open_stdio
In the next patch, term_init will be changed to enable or disableecho at will. Move extraneous stuff out of it.
add set_echo implementation for qemu_chr_stdio
This also requires moving QemuOpts out of term_init.
Clearing ISIG is independent of whether echo is enabled or disabled.
spice: add chardev (v5)
Adding a chardev backend for spice, where spice determines whatto do with it based on the name attribute given during chardev creation.For usage by spice vdagent in conjunction with a properly namedvirtio-serial device, and future smartcard channel usage....
qemu-char: Introduce Memory driver
This driver handles in-memory chardev operations. That's, all writesto this driver are stored in an internal buffer and it doesn't talkto the external world in any way.
Right now it's very simple: it supports only writes. But it can be...
Fold send_all() wrapper unix_write() into one function
The current send_all() wrapper for POSIX calls does nothing but callunix_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>
QemuOpts: make most qemu_*_opts static
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>
Fix mingw32 build
Don't define qemu_chr_open_eventfd() on Windows.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
RESEND: Inter-VM shared memory PCI device
resend for bug fix related to removal of irqfd
Support an inter-vm shared memory device that maps a shared-memory object as aPCI device in the guest. This patch also supports interrupts between guest bycommunicating over a unix domain socket. This patch applies to the qemu-kvm...
block: Decouple block device "commit all" from DriveInfo
do_commit() and mux_proc_byte() iterate over the list of drivesdefined with drive_init(). This misses host block devices defined byother means. Such means don't exist now, but will be introduced later...
blockdev: Collect block device code in new blockdev.c
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>
Monitor: Drop QMP documentation from code
Previous commit added QMP documentation to the qemu-monitor.hxfile, it's is a copy of this information.
While it's good to keep it near code, maintaining two copies ofthe same information is too hard and has little benefit as we...
stash away SCM_RIGHTS fd until a getfd command arrives
If there is already a fd in s->msgfd before recvmsg it isclosed by parts that this patch does not touch. So, onlyone descriptor can be "leaked" by attaching it to a commandother than getfd.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
Always notify consumers of char devices if they're open
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...
fix function signature of qemu_chr_open_pty on !linux
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>
Restore terminal monitor attributes - addition
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...
Fix some compilation warnings on FreeBSD hosts
Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Revert "Convert atexit users to exit_notifier"
This reverts commit d7234f4d7e373a708e1df9ab565a71b71b189025.
Conflicts:
hw/xen_machine_pv.c
This should have never been committed.
Convert atexit users to exit_notifier
All of these users have global state so we really don't see a benefit fromexit_notifier. However, using exit_notifier means that there's one lessjustification for having global state in the first place.
rename IOCanRWHandler to IOCanReadHandler
It was always only used for reads
Signed-off-by: Juan Quintela <quintela@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Fix corner case in chardev udp: parameter
The missing '' broke 'udp::<port>:<port>' parsing.
' broke 'udp::<port>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Restore terminal attributes for tty based monitor
Patch http://permalink.gmane.org/gmane.comp.emulators.qemu/63472 handleclose when using tty devices (like /dev/ttyS0),yet tty based monitor are not restoring terminal attributes (as donewith stdio based monitor), when closing qemu after that command:...
qemu-char.c: drop debug printfs from qemu_chr_parse_compat
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Acked-by: Gerd Hoffmann <kraxel@redhat.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
add close callback for tty-based char device
v1 -> v2 coding style changes
Add a tty close callback. Right now if a guest device that is connectedto 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...
Do not ignore error, if open file failed (-serial /dev/tty)
In case, when qemu is executed with option like-serial /dev/ttyS0, report if there are problems withopening of devices. At now errors are silently ignoring.
Signed-off-by: Evgeniy Dushistov <dushistov@mail.ru>...
char: Remove redundant qemu_chr_generic_open() call.
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>
char: Convert qemu_chr_info() to QObject
Each device is represented by a QDict. The returned QObject is a QListof 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>
un-static qemu_chr_parse_compat()
Don't leak file descriptors
We're leaking file descriptors to child processes. Set FD_CLOEXEC on filedescriptors 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>
Fix commit a167ba50851cdac2fa36633587e98c5956cd6b18
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Add support for GNU/kFreeBSD
char: rename qemu_chr_reset to qemu_chr_generic_open
This function sends out the OPENED event to backends thathave drive the chardevs. The 'reset' is now a historicalartifact and we can now just call the function for what itis.
Signed-off-by: Amit Shah <amit.shah@redhat.com>...
char: don't limit data sent to backends to 1k per buffer
chardevs have a 'can_read' function via which backends specifythe amount of data they can receive. When can_read returns > 0,apps can start sending data. However, each chardev driver hereallows a max. of 1k bytes inspite of the backend being able to...
char: Remove special init_reset handling
The initial_reset sent to chardevs doesn't do much other than settinga bool to true. Char devices are interested in the open event andthat gets sent whenever the device is opened.
Moreover, the reset logic breaks as and when qemu's bh scheduling...
serial: Support additional serial speed values
Signed-off-by: Stefan Weil <weil@mail.berlios.de>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Revert "char: emit the OPENED event only when a new char connection is opened"
This reverts commit 6cfa64de908d67fb6f6b6e3ae4888dd863f69e44.
This breaks the monitor prompt. Proper fix will come from Amit.
net: remove unused includes of if_tun.h and if_tap.h
Looks like these are just artifacts of vl.c being split up.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Add chardev option to disable signal.
If I am using vga and serial which is stdio and hit C-c onserial console, qemu terminates. That is annoying for me.So make it configurable whether signal is generated when C-c is hit.
Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>...
char: check for initial_reset_issued unnecessary
At init, qemu_chr_reset is always called with initial_reset_issued set to 1.So checking for it to be set is not necessary.
Patchworks-ID: 35286Signed-off-by: Amit Shah <amit.shah@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
char: rename CHR_EVENT_RESET to CHR_EVENT_OPENED
The char event RESET is emitted when a char device is opened.Give it a better name.
Patchworks-ID: 35287Signed-off-by: Amit Shah <amit.shah@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
char: emit the OPENED event only when a new char connection is opened
The OPENED event gets sent also when qemu resets its state initially.The consumers of the event aren't interested in receiving this eventon reset.
Patchworks-ID: 35288Signed-off-by: Amit Shah <amit.shah@redhat.com>...
Fix sys-queue.h conflict for good
Problem: Our file sys-queue.h is a copy of the BSD file, but there aresome additions and it's not entirely compatible. Because of that, there havebeen conflicts with system headers on BSD systems. Some hacks have beenintroduced in the commits 15cc9235840a22c289edbe064a9b3c19c5f49896,...
convert windows console chardev to QemuOpts.
convert tty + parport chardevs to QemuOpts.
new cmd line syntax: -chardev tty,id=name,path=/dev/tty* -chardev parport,id=name,path=/dev/parport*
convert vc chardev to QemuOpts.
new cmd line syntax: -chardev vc,id=name -chardev vc,id=name,width=pixels,height=pixels -chardev vc,id=name,cols=chars,rows=chars
convert mux chardev to QemuOpts.
new cmd line syntax: you can add mux=1 to any chardev to enable muxing,then attach it multiple times, like this:
-chardev pty,name=mux,mux=on
convert udp chardev to QemuOpts.
While being at it: create a new inet_dgram_opts() function for udp setup,so udp can handle IPv6 now.
new cmd line syntax: -chardev udp,id=name,host=remotehost,port=remoteport,\ localaddr=bindaddr,localport=bindport...
Allow -serial chardev:<name>
Lets put -chardev into use now. With this patch applied chardev:name isaccepted as chardev specification everywhere, i.e. now you can:
-chardev stdio,id=ttyS0 -serial chardev:ttyS0
which does the same as '-serial stdio"....
monitor: fix muxing
make the mux driver send mux_in and mux_out events when switchingfocus while hooking up more handlers.
stop using CharDriverState->focus in monitor.c, track state usingthe mux events instead. This also removes the implicit assumtion...
move mux focus field from CharDriverState to MuxDriver
Now that monitor stopped using focus we can make it internalto the mux driver.
convert unix+tcp chardevs to QemuOpts.
new cmd line syntax: unix socket: -chardev socket,id=name,path=/path/to/socket tcp socket: -chardev socket,id=name,host=hostaddr|ipaddr,port=portnr
server and nowait options work as usual. Alternatively you can use...
convert pty chardev to QemuOpts.
convert stdio chardev to QemuOpts.
convert msmouse chardev to QemuOpts.
convert braille chardev to QemuOpts.
switch chardev to QemuOpts: infrastructure, null device
start switching chardevs to QemuOpts. This patch adds theinfrastructure and converts the null device.
The patch brings two new functions:
qemu_chr_open_opts() same as qemu_chr_open(), but uses QemuOpts instead of a...
convert file+pipe chardevs to QemuOpts.
new cmd line syntax: -chardev file,id=name,path=/path/to/file -chardev pipe,id=name,path=/path/to/pipe
char: Emit 'CLOSED' events on char device close
Notify users of the char interface whenever the file / connection isclosed.
Signed-off-by: Amit Shah <amit.shah@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
More NULL pointer fixes
Fix typo WIN32 -> _WIN32
This was spotted by Juan Quintela
rename HOST_BSD to CONFIG_BSD
kill drives_table
First step cleaning up the drives handling. This one does nothing butremoving drives_table[], still it became seriously big.
drive_get_index() is gone and is replaced by drives_get() which handsout DriveInfo pointers instead of a table index. This needs adaption in...
Add SCM_RIGHTS support to unix socket character devices
If a file descriptor is passed via a message with SCM_RIGHTS ancillarydata on a unix socket, store the file descriptor for use in thechr_read() handler. Close the file descriptor if it was not used....
Make tcp_chr_read() use recvmsg()
Split out tcp_chr_recv() out of tcp_chr_read() and implement it onnon-win32 using recvmsg(). This is needed for a subsequent patchwhich implements SCM_RIGHTS support.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>...
mux-term: Localize timestamps
As we can have multiple multiplexed terminals, timestamp control andtracking should better take place per MuxDriver.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
mux-term: Fix timestamp association
So far a new timestamp was generated after a full line had beenprinted. Fix this.