summaryrefslogtreecommitdiffstats
path: root/console.c
Commit message (Collapse)AuthorAgeFilesLines
* optimize screendump for the common non-switch caseGerd Hoffmann2012-02-241-3/+7
| | | | | | | | | switch console only if needed, also pass down whenever the console was switched or not because a displaysurface redraw is only needed in case the console was switched. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Remove screendump dummy functions.Gerd Hoffmann2012-02-241-0/+2
| | | | | | | | | The code in console.c verifies whenever a screen_dump function pointer is present before calling it, so there is no need to supply an dummy function. Remove them. Also report an error to notify the user that he didn't got a screenshot. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* console: Eliminate text_consoles[]Markus Armbruster2012-02-241-14/+4
| | | | | | | Simply use consoles[] instead. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Revert "qemu-char: Print strerror message on failure" and depsMarkus Armbruster2012-02-241-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The commit's purpose is laudable: 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_. It attempts to achieve it by changing the interface to return 0/-errno and update qemu_chr_open_opts() to use strerror() to display a more helpful error message. Unfortunately, it has serious flaws: 1. Backends "socket" and "udp" return bogus error codes, because qemu_chr_open_socket() and qemu_chr_open_udp() assume that unix_listen_opts(), unix_connect_opts(), inet_listen_opts(), inet_connect_opts() and inet_dgram_opts() fail with errno set appropriately. That assumption is wrong, and the commit turns unspecific error messages into misleading error messages. For instance: $ qemu-system-x86_64 -nodefaults -vnc :0 -chardev socket,id=bar,host=xxx inet_connect: host and/or port not specified chardev: opening backend "socket" failed: No such file or directory ENOENT is what happens to be in my errno when the backend returns -errno. Let's put ERANGE there just for giggles: $ qemu-system-x86_64 -nodefaults -vnc :0 -chardev socket,id=bar,host=xxx -drive if=none,iops=99999999999999999999 inet_connect: host and/or port not specified chardev: opening backend "socket" failed: Numerical result out of range Worse: when errno happens to be zero, return -errno erroneously signals success, and qemu_chr_new_from_opts() dies dereferencing uninitialized chr. I observe this with "-serial unix:". 2. All qemu_chr_open_opts() knows about the error is an errno error code. That's simply not enough for a decent message. For instance, when inet_dgram() can't resolve the parameter host, which errno code should it use? What if it can't resolve parameter localaddr? Clue: many backends already report errors in their open methods. Let's revert the flawed commit along with its dependencies, and fix up the silent error paths instead. This reverts commit 6e1db57b2ac9025c2443c665a0d9e78748637b26. Conflicts: console.c hw/baum.c qemu-char.c This reverts commit aad04cd024f0c59f0b96f032cde2e24eb3abba6d. The parts of commit db418a0a "Add stdio char device on windows" that depend on the reverted change fixed up. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* console: Fix segfault on screendump without VGA adapterAlexander Graf2012-01-031-1/+3
| | | | | | | | | | | | | | | When trying to create a screen dump without having any VGA adapter inside the guest, QEMU segfaults. This is because it's trying to switch back to the "previous" screen it was on before dumping the VGA screen. Unfortunately, in my case there simply is no previous screen so it accesses a NULL pointer. Fix it by checking if previous_active_console is actually available. This is 1.0 material. Signed-off-by: Alexander Graf <agraf@suse.de>
* console: Fix qemu_default_pixelformat() for 24 bppMarkus Armbruster2011-12-061-0/+1
| | | | | | | | | Falls through to 32 bpp. Harmless, because the only difference is the alpha component, and we're not using that. Spotted by Coverity. Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* console: Fix console_putchar() for CSI JMarkus Armbruster2011-12-061-0/+1
| | | | | | | | | | It falls through to the code for CSI K. "Erase Down" also does "Erase End of Line", "Erase Up" also does "Erase Start of Line", and "Erase Screen" also does "Erase Line". Happens not to be visible. Fix it anyway. Spotted by Coverity. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* console: Clean up confusing indentation in console_putchar()Markus Armbruster2011-12-061-9/+9
| | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* console: Fix rendering of VGA underlineMarkus Armbruster2011-11-071-3/+3
| | | | | | | | | | | | | | | | | vga_putcharxy()'s underline code sets font_data to 0xffff instead of 0xff. vga_putcharxy() then reads dmask16[0xffff >> 4] and dmask4[0xffff >> 6]. In practice, these out-of-bounds subscripts "only" put a few crap bits into the display surface. For 32 bit pixels, there's no array access. font_data's extra bits go straight into the display surface. Broken when commit 6d6f7c28 implemented underline. Spotted by Coverity. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Fix mismatching allocation and deallocationStefan Weil2011-10-051-1/+1
| | | | | | | This error was reported by cppcheck. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* console: Properly switch consoles for screen dumpsJan Kiszka2011-09-161-3/+10
| | | | | | | | Do not mess with active_console, use console_select instead. This fixes corrupt virtual monitor consoles after issuing the screendump command. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* curses: fix garbling when chtype != longDevin J. Pohly2011-09-091-0/+2
| | | | | | | | | | | | Qemu currently assumes that chtype is typedef'd to unsigned long, but this is not necessarily the case (ncurses, for instance, can configure this at build-time). This patch uses the predefined chtype if qemu is configured for curses support and falls back to unsigned long otherwise. Fixes bug 568614. Signed-off-by: Devin J. Pohly <djpohly+launchpad@gmail.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* char: remove qemu_chr_send_event()Anthony Liguori2011-08-221-16/+0
| | | | | | It's dead code. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* char: rename qemu_chr_can_read() -> qemu_chr_be_can_read()Anthony Liguori2011-08-221-1/+1
| | | | Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* char: rename qemu_chr_read() -> qemu_chr_be_write()Anthony Liguori2011-08-221-1/+1
| | | | Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Use glib memory allocation and free functionsAnthony Liguori2011-08-201-13/+13
| | | | | | qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu-char: Print strerror message on failureKevin Wolf2011-07-231-3/+5
| | | | | | | | | | | | 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>
* Align dummy display to fixed-size active consoleJan Kiszka2011-06-241-1/+8
| | | | | | | This fixes e.g. '-vga none -monitor vc:120Cx50C'. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* Fix segfault on screendump with -nographicAlexander Graf2011-06-031-1/+1
| | | | | | | When running -nographic and calling "screendump" on the monitor, qemu segfaults. Fix the invalid pointer dereference by checking for NULL. Signed-off-by: Alexander Graf <agraf@suse.de>
* Consolidate DisplaySurface allocation in qemu_alloc_display()Jes Sorensen2011-03-221-22/+24
| | | | | | | This removes various code duplication from console.e and sdl.c Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* change all rt_clock references to use millisecond resolution accessorsPaolo Bonzini2011-03-211-2/+2
| | | | | | | | | | | | | | | 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>
* remove text_console_optsPaolo Bonzini2011-02-011-6/+2
| | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* add set_echo implementation for text consolesPaolo Bonzini2011-02-011-1/+16
| | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* create TextConsole together with the CharDeviceStatePaolo Bonzini2011-02-011-25/+31
| | | | | | | | A nicer solution would be to get rid of the opaque pointer and use containment, but it would also be a much bigger patch. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* console: Avoid dereferencing NULL active_consoleStefan Hajnoczi2010-10-031-2/+4
| | | | | | | | | | | | | | The console_select() function does not check that active_console is non-NULL before dereferencing it. When invoked with qemu -nodefaults it is possible to hit this case. This patch checks that active_console is non-NULL before stashing away the old console dimensions in console_select(). Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Acked-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Add support for depth 15 to qemu_default_pixelformat()Gerd Hoffmann2010-06-011-0/+16
| | | | | | | | Makes qemu_default_pixelformat(15) return pixelformat filled for 15 bit color depth (16 bpp, 5 bits for red,green,blue each, 1 bit unused). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* check for active_console before using itGerd Hoffmann2010-06-011-1/+1
| | | | | | | | | Other vga_hw_* functions do the same. Fixes a segmentation fault. Trigger: boot with -nodefaults, then connect via vnc. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Remove dead assignments in various common files, spotted by clang analyzerBlue Swirl2010-04-251-1/+0
| | | | | | Value stored is never read. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* move default allocator to console.cPaolo Bonzini2010-02-191-64/+112
| | | | | | | | Moving stuff in console.c to avoid the need for prototypes makes this patch a bit bigger, but there's no change in the code. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* vc: colorize chardev title line with blue background.Gerd Hoffmann2009-12-121-0/+2
| | | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* chardev: move greeting into vc backend.Gerd Hoffmann2009-12-121-0/+8
| | | | | | | | | | Make the 'vc' chardev backend print a title line with the chardev name after initialization, using CharDriverState->label. This replaces the banner printing code in vl.c. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* char: rename qemu_chr_reset to qemu_chr_generic_openAmit Shah2009-11-171-1/+1
| | | | | | | | | | 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>
* Revert "Get rid of _t suffix"Anthony Liguori2009-10-011-5/+5
| | | | | | | | | | | | In the very least, a change like this requires discussion on the list. The naming convention is goofy and it causes a massive merge problem. Something like this _must_ be presented on the list first so people can provide input and cope with it. This reverts commit 99a0949b720a0936da2052cb9a46db04ffc6db29. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Get rid of _t suffixmalc2009-10-011-5/+5
| | | | | | | Some not so obvious bits, slirp and Xen were left alone for the time being. Signed-off-by: malc <av1474@comtv.ru>
* convert vc chardev to QemuOpts.Gerd Hoffmann2009-09-111-24/+23
| | | | | | | | | | new cmd line syntax: -chardev vc,id=name -chardev vc,id=name,width=pixels,height=pixels -chardev vc,id=name,cols=chars,rows=chars Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* rename WORDS_BIGENDIAN to HOST_WORDS_BIGENDIANJuan Quintela2009-07-271-4/+4
| | | | | Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Delete some unused macros detected with -Wp,-Wunused-macros useblueswir12009-03-161-1/+0
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6856 c046a42c-6fe2-441c-8c8c-71466251a162
* DisplayAllocator interface (Stefano Stabellini)aliguori2009-03-131-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hi all, this patch adds a DisplayAllocator interface that allows display frontends (sdl in particular) to provide a preallocated display buffer for the graphical backend to use. Whenever a graphical backend cannot use qemu_create_displaysurface_from because its own internal pixel format cannot be exported directly (text mode or graphical mode with color depth 8 or 24), it creates another display buffer in memory using qemu_create_displaysurface and does the conversion. This new buffer needs to be blitted into the sdl surface buffer every time we need to update portions of the screen. We can avoid this using the DisplayAllocator interace: sdl provides its own implementation of qemu_create_displaysurface, giving back the sdl surface buffer directly (as we used to do before the DisplayState changes). Since the buffer returned by sdl could be in bgr format we need to put back in the handlers of that case. This approach is good if the two following conditions are true: 1) the sdl surface is a software surface that resides in main memory; 2) the host display color depth is either 16 or 32 bpp. If first condition is false we can have bad performances using sdl and vnc together. If the second condition is false performances are certainly not going to improve but they shouldn't get worse either. The first condition is always true, at least on linux/X11 systems; but I believe is true also on other platforms. The second condition is true in the vast majority of the cases. This patch should also have the good side effect of solving the sdl 2D slowness malc was reporting on MacOS, because SDL_BlitSurface is not going to be called anymore when the guest is in text mode or 24bpp. However the root problem is still present so I suspect we may still see some slowness on MacOS when the guest is in 32 or 16 bpp. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6839 c046a42c-6fe2-441c-8c8c-71466251a162
* Sparse fixes: NULL use, header order, ANSI prototypes, staticblueswir12009-03-071-2/+2
| | | | | | | | | | | | | Fix Sparse warnings: * use NULL instead of plain 0 * rearrange header include order to avoid redefining types accidentally * ANSIfy SLIRP * avoid "restrict" keyword * add static git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6736 c046a42c-6fe2-441c-8c8c-71466251a162
* toplevel: remove error handling from qemu_malloc() callers (Avi Kivity)aliguori2009-02-051-23/+0
| | | | | | | | Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6531 c046a42c-6fe2-441c-8c8c-71466251a162
* vnc fixes and improvements (Stefano Stabellini)aliguori2009-01-261-0/+17
| | | | | | | | | | | | | | | | | this patch fixes a bug and improves the generic pixel conversion function in vnc.c. The bug is that when a new vnc client connects we need to reset the flag has_WMVi but currently we don't. The generic pixel conversion function is vnc_convert_pixel and currently is not very efficient since uses the division and multiplication operators. To make it more efficient I changed to use bit shift operators instead. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6441 c046a42c-6fe2-441c-8c8c-71466251a162
* fix endianness problem sharing the videoram buffermalc2009-01-231-11/+53
| | | | | | | | | | | | | | | | [ The following text is in the "UTF-8" character set. ] [ Your display is set for the "koi8-r" character set. ] [ Some characters may be displayed incorrectly. ] This patch fixes vga rendering when the guest endianness differs from the host endianness: in this case we can only share the buffer if the bpp is 32 and we must change the pixelformat accordingly. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6413 c046a42c-6fe2-441c-8c8c-71466251a162
* re-fix screendump (Stefano Stabellini)aliguori2009-01-211-0/+2
| | | | | | | | | | | | | | | Removing the assumption about a single graphic console made get_graphic_console return NULL when called by vga_screen_dump. In this case returning NULL is correct but since NULL is not handled in qemu_console_resize it causes a segmentation fault. Just returning immediately from qemu_console_resize is sufficient to fix the problem. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6390 c046a42c-6fe2-441c-8c8c-71466251a162
* fix curses interface (Stefano Stabellini)aliguori2009-01-211-2/+12
| | | | | | | | | | | | | | | | Hi all, this patch fixes the curses interface: when we switch from one console to another we need to change the displaystate width and height even though in the curses case the backing buffer remains of the same size. I am also putting back the call to text_console_resize in text_console_invalidate so that resizeable text consoles can be properly handled. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6389 c046a42c-6fe2-441c-8c8c-71466251a162
* Coalesce virtual console screen updates.pbrook2009-01-211-7/+33
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6374 c046a42c-6fe2-441c-8c8c-71466251a162
* add an init function parameter to qemu_chr_open()aurel322009-01-181-0/+2
| | | | | | | | | And use it for the malta emulation. Fix segfault introduced in revision 6352. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6365 c046a42c-6fe2-441c-8c8c-71466251a162
* console: remove trailing spacesaurel322009-01-161-3/+3
| | | | | | Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6355 c046a42c-6fe2-441c-8c8c-71466251a162
* Squash warnings in console.caliguori2009-01-161-3/+1
| | | | | | | | Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6354 c046a42c-6fe2-441c-8c8c-71466251a162
* Remove assumption about a single graphic console.aliguori2009-01-161-3/+3
| | | | | | | | | | This fixes a fault with the jazz_led since it has two graphic consoles. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6353 c046a42c-6fe2-441c-8c8c-71466251a162
* Fix character devices after DisplayState refactoringaliguori2009-01-161-6/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The DisplayState refactoring changed the machine init function to create a DisplayState for each VGA device instead of being passed an existing DisplayState. This change is critical to enable multiple graphics device support. Unfortunately, the serial/parallel/console code is structured today to run before machine init to fill out the CharDriverState table which the machine init function uses to determine whether to create the required devices. Since a 'vc' is a type of CharDriverState, the CharDriverState code requires that a DisplayState exist before it runs creating a circular dependency. To fix this, this splits the creation of the initial CharDriverState from the initialization of the text console. We can then in a second step associate a DisplayState with all TextConsoles. This allows us to create the CharDriverState's first, machine init, then associate the TextConsoles with a DisplayState. This code screams for more cleanup. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6352 c046a42c-6fe2-441c-8c8c-71466251a162
OpenPOWER on IntegriCloud