summaryrefslogtreecommitdiff
path: root/console.c
AgeCommit message (Collapse)AuthorFilesLines
2012-02-24optimize screendump for the common non-switch caseGerd Hoffmann1-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>
2012-02-24Remove screendump dummy functions.Gerd Hoffmann1-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>
2012-02-24console: Eliminate text_consoles[]Markus Armbruster1-14/+4
Simply use consoles[] instead. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-02-24Revert "qemu-char: Print strerror message on failure" and depsMarkus Armbruster1-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>
2012-01-03console: Fix segfault on screendump without VGA adapterAlexander Graf1-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>
2011-12-06console: Fix qemu_default_pixelformat() for 24 bppMarkus Armbruster1-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>
2011-12-06console: Fix console_putchar() for CSI JMarkus Armbruster1-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>
2011-12-06console: Clean up confusing indentation in console_putchar()Markus Armbruster1-9/+9
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-11-07console: Fix rendering of VGA underlineMarkus Armbruster1-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>
2011-10-05Fix mismatching allocation and deallocationStefan Weil1-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>
2011-09-16console: Properly switch consoles for screen dumpsJan Kiszka1-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>
2011-09-09curses: fix garbling when chtype != longDevin J. Pohly1-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>
2011-08-22char: remove qemu_chr_send_event()Anthony Liguori1-16/+0
It's dead code. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22char: rename qemu_chr_can_read() -> qemu_chr_be_can_read()Anthony Liguori1-1/+1
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22char: rename qemu_chr_read() -> qemu_chr_be_write()Anthony Liguori1-1/+1
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-20Use glib memory allocation and free functionsAnthony Liguori1-13/+13
qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-07-23qemu-char: Print strerror message on failureKevin Wolf1-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>
2011-06-24Align dummy display to fixed-size active consoleJan Kiszka1-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>
2011-06-03Fix segfault on screendump with -nographicAlexander Graf1-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>
2011-03-22Consolidate DisplaySurface allocation in qemu_alloc_display()Jes Sorensen1-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>
2011-03-21change all rt_clock references to use millisecond resolution accessorsPaolo Bonzini1-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>
2011-02-01remove text_console_optsPaolo Bonzini1-6/+2
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-02-01add set_echo implementation for text consolesPaolo Bonzini1-1/+16
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-02-01create TextConsole together with the CharDeviceStatePaolo Bonzini1-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>
2010-10-03console: Avoid dereferencing NULL active_consoleStefan Hajnoczi1-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>
2010-06-01Add support for depth 15 to qemu_default_pixelformat()Gerd Hoffmann1-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>
2010-06-01check for active_console before using itGerd Hoffmann1-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>
2010-04-25Remove dead assignments in various common files, spotted by clang analyzerBlue Swirl1-1/+0
Value stored is never read. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-02-19move default allocator to console.cPaolo Bonzini1-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>
2009-12-12vc: colorize chardev title line with blue background.Gerd Hoffmann1-0/+2
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-12chardev: move greeting into vc backend.Gerd Hoffmann1-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>
2009-11-17char: rename qemu_chr_reset to qemu_chr_generic_openAmit Shah1-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>
2009-10-01Revert "Get rid of _t suffix"Anthony Liguori1-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>
2009-10-01Get rid of _t suffixmalc1-5/+5
Some not so obvious bits, slirp and Xen were left alone for the time being. Signed-off-by: malc <av1474@comtv.ru>
2009-09-11convert vc chardev to QemuOpts.Gerd Hoffmann1-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>
2009-07-27rename WORDS_BIGENDIAN to HOST_WORDS_BIGENDIANJuan Quintela1-4/+4
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-03-16Delete some unused macros detected with -Wp,-Wunused-macros useblueswir11-1/+0
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6856 c046a42c-6fe2-441c-8c8c-71466251a162
2009-03-13DisplayAllocator interface (Stefano Stabellini)aliguori1-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
2009-03-07Sparse fixes: NULL use, header order, ANSI prototypes, staticblueswir11-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
2009-02-05toplevel: remove error handling from qemu_malloc() callers (Avi Kivity)aliguori1-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
2009-01-26vnc fixes and improvements (Stefano Stabellini)aliguori1-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
2009-01-23fix endianness problem sharing the videoram buffermalc1-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
2009-01-21re-fix screendump (Stefano Stabellini)aliguori1-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
2009-01-21fix curses interface (Stefano Stabellini)aliguori1-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
2009-01-21Coalesce virtual console screen updates.pbrook1-7/+33
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6374 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-18add an init function parameter to qemu_chr_open()aurel321-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
2009-01-16console: remove trailing spacesaurel321-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
2009-01-16Squash warnings in console.caliguori1-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
2009-01-16Remove assumption about a single graphic console.aliguori1-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
2009-01-16Fix character devices after DisplayState refactoringaliguori1-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