kvm tools, ui: Add framebuffer infrastructure
PATCH 1/3 kvm tools, ui: Add framebuffer infrastructure
This patch introduces 'struct framebuffer' and related API as a preparational step to killing libvnc dependency from hw/vesa.c.
--- tools/kvm/Makefile | 1 + tools/kvm/framebuffer.c | 87 +++++++++++++++++++++++++++++++++++ tools/kvm/include/kvm/framebuffer.h | 35 ++++++++++++++ 3 files changed, 123 insertions(+), 0 deletions(-) create mode 100644 tools/kvm/framebuffer.c create mode 100644 tools/kvm/include/kvm/framebuffer.h
tools/kvm/Makefile +1 -0
@@ -17,6 +17,7 @@ TAGS = ctags OBJS += cpuid.o OBJS += disk/core.o +OBJS += framebuffer.o OBJS += hw/rtc.o OBJS += hw/serial.o OBJS += interrupt.o
tools/kvm/framebuffer.c new file +87 -0
87 lines not on this page · raw message
tools/kvm/include/kvm/framebuffer.h new file +35 -0
@@ -0,0 +1,35 @@ +#ifndef KVM__FRAMEBUFFER_H +#define KVM__FRAMEBUFFER_H + +#include <linux/types.h> +#include <linux/list.h> + +struct framebuffer ; + +struct fb_target_operations { +int (*start)(struct framebuffer *fb); +void (*write)(struct framebuffer *fb,u64 addr,u8 *data,u32 len); +}; + +#define FB_MAX_TARGETS 2 + +struct framebuffer { +u32 width; +u32 height; +u8 depth; +char *mem; +u64 mem_addr; + +unsigned long nr_targets; +struct fb_target_operations *targets[FB_MAX_TARGETS ]; + +struct list_head node; +}; + +struct framebuffer *fb__register (struct framebuffer *fb); +int fb__attach (struct framebuffer *fb,struct fb_target_operations *ops); +int fb__start (void ); +void fb__stop (void ); +void fb__write (u64 addr,u8 *data,u32 len); + +#endif /* KVM__FRAMEBUFFER_H */
Signature · 1 line
1.7.0.4
PATCH 2/3 kvm tools, ui: Move VNC specific framebuffer code to ui/vnc.c
This patch makes use of 'struct framebuffer' and moves the VNC code to ui/vnc.c in preparation for other framebuffer output targets.
--- tools/kvm/Makefile | 3 +- tools/kvm/hw/vesa.c | 72 ++++++++++++----------------------------- tools/kvm/include/kvm/i8042.h | 2 + tools/kvm/include/kvm/vesa.h | 8 +---- tools/kvm/include/kvm/vnc.h | 14 ++++++++ tools/kvm/kvm-run.c | 14 +++++++- tools/kvm/ui/vnc.c | 68 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 120 insertions(+), 61 deletions(-) create mode 100644 tools/kvm/include/kvm/vnc.h create mode 100644 tools/kvm/ui/vnc.c
tools/kvm/Makefile +2 -1
@@ -51,6 +51,7 @@ OBJS += util/parse-options.o OBJS += util/rbtree-interval.o OBJS += util/strbuf.o OBJS += virtio/9p.o +OBJS += hw/vesa.o FLAGS_BFD=$(CFLAGS) -lbfd
@@ -64,8 +65,8 @@ endif FLAGS_VNCSERVER=$(CFLAGS) -lvncserver has_vncserver := $(call try-cc,$(SOURCE_VNCSERVER),$(FLAGS_VNCSERVER)) ifeq ($(has_vncserver),y) + OBJS += ui/vnc.o CFLAGS += -DCONFIG_HAS_VNCSERVER - OBJS += hw/vesa.o OBJS += hw/i8042.o LIBS += -lvncserver endif
tools/kvm/hw/vesa.c +21 -51
110 lines not on this page · raw message
tools/kvm/include/kvm/i8042.h +2 -0
@@ -1,6 +1,8 @@#ifndef KVM__PCKBD_H #define KVM__PCKBD_H +struct kvm ; +void kbd__init (struct kvm *kvm);#ifdef CONFIG_HAS_VNCSERVER
tools/kvm/include/kvm/vesa.h +1 -7
@@ -13,13 +13,7 @@struct kvm ;struct int10_args ; -void vesa_mmio_callback (u64 ,u8 *,u32 ,u8 ); -void vesa__init (struct kvm *self); -void *vesa__dovnc (void *); +struct framebuffer *vesa__init (struct kvm *self);void int10_handler (struct int10_args *args); -#ifndef CONFIG_HAS_VNCSERVER -void vesa__init (struct kvm *self) { } -#endif -#endif
tools/kvm/include/kvm/vnc.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef KVM__VNC_H +#define KVM__VNC_H + +struct framebuffer ; + +#ifdef CONFIG_HAS_VNCSERVER +void vnc__init (struct framebuffer *fb); +#else +static inline void vnc__init (struct framebuffer *fb) +{ +} +#endif + +#endif /* KVM__VNC_H */
tools/kvm/kvm-run.c +12 -2
@@ -31,6 +31,8 @@#include <kvm/vesa.h> #include <kvm/ioeventfd.h> #include <kvm/i8042.h> +#include <kvm/vnc.h> +#include <kvm/framebuffer.h> /* header files for gitish interface */ #include <kvm/kvm-run.h>
@@ -426,13 +428,14 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix) {struct virtio_net_parameters net_params;static char real_cmdline[2048 ]; +struct framebuffer *fb =NULL ;unsigned int nr_online_cpus;int exit_code =0 ; +u16 vidmode =0 ;int max_cpus;char *hi;int i;void *ret; -u16 vidmode =0 ;signal (SIGALRM , handle_sigalrm);signal (SIGQUIT , handle_sigquit);
@@ -629,9 +632,14 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)if (vnc) {kbd__init (kvm); -vesa__init (kvm); + fb =vesa__init (kvm); } +if (fb) +vnc__init (fb); + +fb__start (); +thread_pool__init (nr_online_cpus);ioeventfd__start ();
@@ -653,6 +661,8 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix) exit_code =1 ; } +fb__stop (); +virtio_blk__delete_all (kvm);virtio_rng__delete_all (kvm);
tools/kvm/ui/vnc.c new file +68 -0
68 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH 3/3 kvm tools, ui: Add support for SDL framebuffer output target
In reply to Pekka EnbergThis patch adds support for SDL based framebuffer. Use the '--sdl' command line option to enable the feature.
--- tools/kvm/Makefile | 8 ++++ tools/kvm/config/feature-tests.mak | 10 +++++ tools/kvm/include/kvm/sdl.h | 14 +++++++ tools/kvm/kvm-run.c | 17 +++++++-- tools/kvm/ui/sdl.c | 71 ++++++++++++++++++++++++++++++++++++ 5 files changed, 116 insertions(+), 4 deletions(-) create mode 100644 tools/kvm/include/kvm/sdl.h create mode 100644 tools/kvm/ui/sdl.c
tools/kvm/Makefile +8 -0
@@ -71,6 +71,14 @@ ifeq ($(has_vncserver),y) LIBS += -lvncserver endif +FLAGS_SDL=$(CFLAGS) -lSDL +has_SDL := $(call try-cc,$(SOURCE_SDL),$(FLAGS_SDL)) +ifeq ($(has_SDL),y) + OBJS += ui/sdl.o + CFLAGS += -DCONFIG_HAS_SDL + LIBS += -lSDL +endif + DEPS := $(patsubst %.o,%.d,$(OBJS)) # Exclude BIOS object files from header dependencies.
tools/kvm/config/feature-tests.mak +10 -0
@@ -136,3 +136,13 @@ int main(void) return 0; } endef + +define SOURCE_SDL +#include <SDL/SDL.h> + +int main(void) +{ + SDL_Init(SDL_INIT_VIDEO); + return 0; +} +endef
tools/kvm/include/kvm/sdl.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef KVM__SDL_H +#define KVM__SDL_H + +struct framebuffer ; + +#ifdef CONFIG_HAS_SDL +void sdl__init (struct framebuffer *fb); +#else +static inline void sdl__init (struct framebuffer *fb) +{ +} +#endif + +#endif /* KVM__SDL_H */
tools/kvm/kvm-run.c +13 -4
@@ -32,6 +32,7 @@#include <kvm/ioeventfd.h> #include <kvm/i8042.h> #include <kvm/vnc.h> +#include <kvm/sdl.h> #include <kvm/framebuffer.h> /* header files for gitish interface */
@@ -72,6 +73,7 @@ static const char *virtio_9p_dir;static bool single_step;static bool readonly_image[MAX_DISK_IMAGES ];static bool vnc; +static bool sdl;extern bool ioport_debug;extern int active_console;
@@ -117,6 +119,7 @@ static const struct option options[] = {OPT_STRING ('\0' ,"virtio-9p" , &virtio_9p_dir,"root dir" ,"Enable 9p over virtio" ),OPT_BOOLEAN ('\0' ,"vnc" , &vnc,"Enable VNC framebuffer" ), +OPT_BOOLEAN ('\0' ,"sdl" , &sdl,"Enable SDL framebuffer" ),OPT_GROUP ("Kernel options:" ), OPT_STRING('k', "kernel", &kernel_filename, "kernel",
@@ -538,7 +541,7 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)memset (real_cmdline,0 ,sizeof (real_cmdline));strcpy (real_cmdline,"notsc noapic noacpi pci=conf1" ); -if (vnc) { +if (vnc || sdl) {strcat (real_cmdline," video=vesafb console=tty0" ); vidmode =0x312 ; }else {
@@ -630,13 +633,19 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)kvm__init_ram (kvm); +if (vnc || sdl) + fb =vesa__init (kvm); +if (vnc) {kbd__init (kvm); - fb =vesa__init (kvm); +if (fb) +vnc__init (fb); } -if (fb) -vnc__init (fb); +if (sdl) { +if (fb) +sdl__init (fb); + }fb__start ();
tools/kvm/ui/sdl.c new file +71 -0
71 lines not on this page · raw message
Signature · 1 line
1.7.0.4
Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target
Quoted 2 lines · Pekka Enberg
This patch adds support for SDL based framebuffer. Use the '--sdl' command line option to enable the feature.
Very nice!
I tried them out - but i'm unsure how to activate the feature.
Right now 'kvm run' will run the guest and it outputs to the serial console. If i try 'kvm run --sdl' i get:
linux/tools/kvm> ./kvm run --sdl
# kvm run -k ../../arch/x86/boot/bzImage -m 1216 -c 16 Warning: Unable to open /dev/net/tun Undefined video mode number: 312 Press <ENTER> to see video modes available, <SPACE> to continue, or wait 30 sec
What kind of options should i select on the guest kernel image side to be able to boot via the SDL framebuffer?
Ingo
Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target
Quoted 11 lines · Ingo Molnar
Right now 'kvm run' will run the guest and it outputs to the serial console. If i try 'kvm run --sdl' i get:
linux/tools/kvm> ./kvm run --sdl
# kvm run -k ../../arch/x86/boot/bzImage -m 1216 -c 16 Warning: Unable to open /dev/net/tun Undefined video mode number: 312 Press <ENTER> to see video modes available, <SPACE> to continue, or wait 30 secWhat kind of options should i select on the guest kernel image side to be able to boot via the SDL framebuffer?
Ok, found it, the guest kernel needs CONFIG_FB_VESA=y set.
Thanks,
Ingo
Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target
In reply to Ingo MolnarQuoted 8 lines · Ingo Molnar
Very nice!
I tried them out - but i'm unsure how to activate the feature.
Right now 'kvm run' will run the guest and it outputs to the serial console. If i try 'kvm run --sdl' i get:
linux/tools/kvm> ./kvm run --sdl
That's correct.
Quoted 7 lines
# kvm run -k ../../arch/x86/boot/bzImage -m 1216 -c 16 Warning: Unable to open /dev/net/tun Undefined video mode number: 312 Press <ENTER> to see video modes available, <SPACE> to continue, or wait 30 secWhat kind of options should i select on the guest kernel image side to be able to boot via the SDL framebuffer?
That's not related to the SDL code but to the VESA code. I suppose you never tried the VNC version so you need to make sure the following config options are there:
From: John Floren <[email protected]>
Date: Mon, 23 May 2011 12:15:18 +0000 (+0300)
Subject: kvm tools: Initialize and use VESA and VNC
X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Fpenberg%2Fslab-2.6.git;a=commitdiff_plain;h=20a2b9bbed84df6d734f5566709b0501467e3c68
kvm tools: Initialize and use VESA and VNC
Requirements - Kernel compiled with:CONFIG_FB_BOOT_VESA_SUPPORT=yCONFIG_FB_VESA=yCONFIG_FRAMEBUFFER_CONSOLE=y
Start VNC server by starting kvm tools with "--vnc". Connect to the VNC server by running: "vncviewer :0".
Since there is no support for input devices at this time, it may be useful starting kvm tools with an additional ' -p "console=ttyS0" ' parameter so that it would be possible to use a serial console alongside with a graphic one.
Pekka
Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target
In reply to Ingo Molnari don't seem to be able to get the SDL window to inizialize over ssh X-forwarding:
linux/tools/kvm> ./kvm run --sdl
# kvm run -k ../../arch/x86/boot/bzImage -m 1216 -c 16 Warning: Unable to open /dev/net/tun ���
Thanks,
Ingo
Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target
Quoted 8 lines · Ingo Molnar
i don't seem to be able to get the SDL window to inizialize over ssh X-forwarding:
linux/tools/kvm> ./kvm run --sdl
# kvm run -k ../../arch/x86/boot/bzImage -m 1216 -c 16 Warning: Unable to open /dev/net/tun ?????????
Please pass
-p "console=ttyS0"
to 'kvm' to see if there's error messages in dmesg. I suppose we should enable that by default.
Pekka
Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target
Quoted 6 lines · Pekka Enberg
Please pass
-p "console=ttyS0"
to 'kvm' to see if there's error messages in dmesg. I suppose we should enable that by default.
It says:
[ 0.639000] vesafb: mode is 640x480x32, linelength=2560, pages=0 [ 0.640000] vesafb: scrolling: redraw [ 0.641000] vesafb: Truecolor: size=8:8:8:8, shift=24:0:8:16 [ 0.642000] vesafb: framebuffer at 0xd0000000, mapped to 0xffffc90000900000, using 1200k, total 1200k [ 1.899000] Console: switching to colour frame buffer device 80x30 [ 3.955000] fb0: VESA VGA frame buffer device [ 4.681000] virtio-pci 0000:00:01.0: enabling device (0000 -> 0001)
An SDL window should have been created at that point, right? But it does not show up.
Thanks,
Ingo
Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target
Quoted 10 lines · Ingo Molnar
It says:
[ 0.639000] vesafb: mode is 640x480x32, linelength=2560, pages=0 [ 0.640000] vesafb: scrolling: redraw [ 0.641000] vesafb: Truecolor: size=8:8:8:8, shift=24:0:8:16 [ 0.642000] vesafb: framebuffer at 0xd0000000, mapped to 0xffffc90000900000, using 1200k, total 1200k [ 1.899000] Console: switching to colour frame buffer device 80x30 [ 3.955000] fb0: VESA VGA frame buffer device [ 4.681000] virtio-pci 0000:00:01.0: enabling device (0000 -> 0001)
Quoted 2 lines
An SDL window should have been created at that point, right? But it does not show up.
Yup. I tried
ssh -X localhost
and ran 'kvm run --sdl' there and it worked fine. Hmm.
Pekka
Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target
In reply to Pekka Enbergi tried this patch:
tools/kvm/ui/sdl.c +2 -0
@@ -19,6 +19,8 @@ static void *sdl__thread(void *p)SDL_Surface *screen;SDL_Event ev; +BUG_ON (1 ); +if (SDL_Init (SDL_INIT_VIDEO ) !=0 )die ("Unable to initialize SDL" );
but it does not trigger.
Oh ... because the SDL library is not present on that box and it silently did not get built.
Now *that* is not an obvious failure pattern ;-)
Thanks,
Ingo
Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target
Quoted 4 lines · Ingo Molnar
Oh ... because the SDL library is not present on that box and it silently did not get built.
Now *that* is not an obvious failure pattern ;-)
Oh, sorry about that. I'll just drop the '--sdl' command line option if the library is not present. Does that sound OK to you?
Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target
Quoted 8 lines · Pekka Enberg
Quoted 4 lines · Ingo Molnar
Oh ... because the SDL library is not present on that box and it silently did not get built.
Now *that* is not an obvious failure pattern ;-)
Oh, sorry about that. I'll just drop the '--sdl' command line option if the library is not present. Does that sound OK to you?
it would be better to display a meaningful error message in that case and not run, the user very likely has added --sdl expecting a framebuffer to pop up!
Thanks,
Ingo
Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target
Quoted 3 lines · Ingo Molnar
it would be better to display a meaningful error message in that case and not run, the user very likely has added --sdl expecting a framebuffer to pop up!
Is this better?
penberg@tiger:~/linux/tools/kvm$ ./kvm run --sdl -p "root=/dev/vda1" -d ~/images/debian_squeeze_amd64_standard.img # kvm run -k ../../arch/x86/boot/bzImage -m 320 -c 2 Warning: Config tap device error. Are you root? Fatal: SDL support not compiled in.
Pekka
Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target
In reply to Pekka Enbergso, i still don't have a GUI. What happens is that once the framebuffer initializes in the guest the bootup gets *real* slow, like only printk-ing two lines per second.
Then it gets even slower and stops around here:
[ 20.040000] No RTC device found, ALARM timers will not wake from suspend [ 20.040000] registered taskstats version 1 [ 20.040000] Magic number: 15:707:842 [ 41.601000] md: Waiting for all devices to be available before autodetect [ 41.601000] md: If you don't use raid, use raid=noautodetect
not much CPU used after this point - just the SIGALRM hitting the kvm thread every now and then.
here is how the slowdown looks like with printk timestamps:
[ 0.677000] uvesafb: failed to execute /sbin/v86d [ 0.678000] uvesafb: make sure that the v86d helper is installed and executable [ 0.679000] uvesafb: Getting VBE info block failed (eax=0x4f00, err=-2) [ 0.680000] uvesafb: vbe_init() failed with -22 [ 0.680000] uvesafb: probe of uvesafb.0 failed with error -22 [ 0.681000] vesafb: mode is 640x480x32, linelength=2560, pages=0 [ 0.682000] vesafb: scrolling: redraw [ 0.682000] vesafb: Truecolor: size=8:8:8:8, shift=24:0:8:16 [ 0.683000] vesafb: framebuffer at 0xd0000000, mapped to 0xffffc90000900000, using 1200k, total 1200k [ 1.855000] Console: switching to colour frame buffer device 80x30 [ 3.635000] fb0: VESA VGA frame buffer device [ 4.268000] virtio-pci 0000:00:01.0: enabling device (0000 -> 0001) �[ 4.269000] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled [ 4.535000] serial8250: ttyS0 at I/O 0x3f8 (irq = 0) is a 16550A �[ 7.270000] serial8250: ttyS1 at I/O 0x2f8 (irq = 0) is a 16550A �[ 8.190000] serial8250: ttyS2 at I/O 0x3e8 (irq = 0) is a 16550A [ 8.818000] Non-volatile memory driver v1.3 [ 9.419000] Linux agpgart interface v0.103 [ 9.420000] [drm] Initialized drm 1.1.0 20060810 [ 9.420000] [drm:i915_init] *ERROR* drm/i915 can't work without intel_agp module!
so the badness starts after the 'framebuffer mapped' message.
Thanks,
Ingo
Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target
Quoted 23 lines · Ingo Molnar
here is how the slowdown looks like with printk timestamps:
[ 0.677000] uvesafb: failed to execute /sbin/v86d [ 0.678000] uvesafb: make sure that the v86d helper is installed and executable [ 0.679000] uvesafb: Getting VBE info block failed (eax=0x4f00, err=-2) [ 0.680000] uvesafb: vbe_init() failed with -22 [ 0.680000] uvesafb: probe of uvesafb.0 failed with error -22 [ 0.681000] vesafb: mode is 640x480x32, linelength=2560, pages=0 [ 0.682000] vesafb: scrolling: redraw [ 0.682000] vesafb: Truecolor: size=8:8:8:8, shift=24:0:8:16 [ 0.683000] vesafb: framebuffer at 0xd0000000, mapped to 0xffffc90000900000, using 1200k, total 1200k [ 1.855000] Console: switching to colour frame buffer device 80x30 [ 3.635000] fb0: VESA VGA frame buffer device [ 4.268000] virtio-pci 0000:00:01.0: enabling device (0000 -> 0001) �[ 4.269000] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled [ 4.535000] serial8250: ttyS0 at I/O 0x3f8 (irq = 0) is a 16550A �[ 7.270000] serial8250: ttyS1 at I/O 0x2f8 (irq = 0) is a 16550A �[ 8.190000] serial8250: ttyS2 at I/O 0x3e8 (irq = 0) is a 16550A [ 8.818000] Non-volatile memory driver v1.3 [ 9.419000] Linux agpgart interface v0.103 [ 9.420000] [drm] Initialized drm 1.1.0 20060810 [ 9.420000] [drm:i915_init] *ERROR* drm/i915 can't work without intel_agp module!
Quoted 1 line
so the badness starts after the 'framebuffer mapped' message.
btw., we never execute ->start():
tools/kvm/ui/sdl.c +2 -0
@@ -35,6 +35,8 @@ static void *sdl__thread(void *p)if (!screen)die ("Unable to set SDL video mode" ); +die ("die!" ); +for (;;) {SDL_BlitSurface (guest_screen,NULL , screen,NULL );SDL_Flip (screen);
I'll send you my .config and bzImage in private.
Thanks,
Ingo
Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target
In reply to Pekka EnbergQuoted 5 lines · Pekka Enberg
Quoted 3 lines · Ingo Molnar
it would be better to display a meaningful error message in that case and not run, the user very likely has added --sdl expecting a framebuffer to pop up!
Quoted 7 lines
Is this better?
penberg@tiger:~/linux/tools/kvm$ ./kvm run --sdl -p "root=/dev/vda1" -d ~/images/debian_squeeze_amd64_standard.img # kvm run -k ../../arch/x86/boot/bzImage -m 320 -c 2 Warning: Config tap device error. Are you root? Fatal: SDL support not compiled in.
Yeah! I'd suggest such a wording:
Fatal: SDL support not compiled in. (install the SDL-dev[el] package)
Thanks,
Ingo