* [PATCH 1/3] kvm tools, ui: Add framebuffer infrastructure @ 2011-06-03 15:59 Pekka Enberg 2011-06-03 15:59 ` [PATCH 2/3] kvm tools, ui: Move VNC specific framebuffer code to ui/vnc.c Pekka Enberg 2011-06-03 15:59 ` [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target Pekka Enberg 0 siblings, 2 replies; 17+ messages in thread From: Pekka Enberg @ 2011-06-03 15:59 UTC (permalink / raw) To: kvm; +Cc: Pekka Enberg, Cyrill Gorcunov, Ingo Molnar, John Floren, Sasha Levin This patch introduces 'struct framebuffer' and related API as a preparational step to killing libvnc dependency from hw/vesa.c. Cc: Cyrill Gorcunov <gorcunov@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: John Floren <john@jfloren.net> Cc: Sasha Levin <levinsasha928@gmail.com> Signed-off-by: Pekka Enberg <penberg@kernel.org> --- 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 diff --git a/tools/kvm/Makefile b/tools/kvm/Makefile index a05a6b1..3f06dab 100644 --- a/tools/kvm/Makefile +++ b/tools/kvm/Makefile @@ -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 diff --git a/tools/kvm/framebuffer.c b/tools/kvm/framebuffer.c new file mode 100644 index 0000000..eae0a92 --- /dev/null +++ b/tools/kvm/framebuffer.c @@ -0,0 +1,87 @@ +#include "kvm/framebuffer.h" + +#include <linux/kernel.h> +#include <linux/list.h> +#include <stdlib.h> + +static LIST_HEAD(framebuffers); + +struct framebuffer *fb__register(struct framebuffer *fb) +{ + INIT_LIST_HEAD(&fb->node); + list_add(&fb->node, &framebuffers); + + return fb; +} + +int fb__attach(struct framebuffer *fb, struct fb_target_operations *ops) +{ + if (fb->nr_targets >= FB_MAX_TARGETS) + return -1; + + fb->targets[fb->nr_targets++] = ops; + + return 0; +} + +static int start_targets(struct framebuffer *fb) +{ + unsigned long i; + + for (i = 0; i < fb->nr_targets; i++) { + struct fb_target_operations *ops = fb->targets[i]; + int err = 0; + + if (ops->start) + err = ops->start(fb); + + if (err) + return err; + } + + return 0; +} + +int fb__start(void) +{ + struct framebuffer *fb; + + list_for_each_entry(fb, &framebuffers, node) { + int err; + + err = start_targets(fb); + if (err) + return err; + } + + return 0; +} + +void fb__stop(void) +{ + struct framebuffer *fb; + + list_for_each_entry(fb, &framebuffers, node) { + free(fb->mem); + } +} + +static void write_to_targets(struct framebuffer *fb, u64 addr, u8 *data, u32 len) +{ + unsigned long i; + + for (i = 0; i < fb->nr_targets; i++) { + struct fb_target_operations *ops = fb->targets[i]; + + ops->write(fb, addr, data, len); + } +} + +void fb__write(u64 addr, u8 *data, u32 len) +{ + struct framebuffer *fb; + + list_for_each_entry(fb, &framebuffers, node) { + write_to_targets(fb, addr, data, len); + } +} diff --git a/tools/kvm/include/kvm/framebuffer.h b/tools/kvm/include/kvm/framebuffer.h new file mode 100644 index 0000000..e2273c5 --- /dev/null +++ b/tools/kvm/include/kvm/framebuffer.h @@ -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 */ -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 2/3] kvm tools, ui: Move VNC specific framebuffer code to ui/vnc.c 2011-06-03 15:59 [PATCH 1/3] kvm tools, ui: Add framebuffer infrastructure Pekka Enberg @ 2011-06-03 15:59 ` Pekka Enberg 2011-06-03 15:59 ` [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target Pekka Enberg 1 sibling, 0 replies; 17+ messages in thread From: Pekka Enberg @ 2011-06-03 15:59 UTC (permalink / raw) To: kvm; +Cc: Pekka Enberg, Cyrill Gorcunov, Ingo Molnar, John Floren, Sasha Levin This patch makes use of 'struct framebuffer' and moves the VNC code to ui/vnc.c in preparation for other framebuffer output targets. Cc: Cyrill Gorcunov <gorcunov@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: John Floren <john@jfloren.net> Cc: Sasha Levin <levinsasha928@gmail.com> Signed-off-by: Pekka Enberg <penberg@kernel.org> --- 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 diff --git a/tools/kvm/Makefile b/tools/kvm/Makefile index 3f06dab..17c795b 100644 --- a/tools/kvm/Makefile +++ b/tools/kvm/Makefile @@ -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 diff --git a/tools/kvm/hw/vesa.c b/tools/kvm/hw/vesa.c index b99f2de..ad12d08 100644 --- a/tools/kvm/hw/vesa.c +++ b/tools/kvm/hw/vesa.c @@ -1,32 +1,19 @@ #include "kvm/vesa.h" #include "kvm/virtio-pci-dev.h" +#include "kvm/framebuffer.h" #include "kvm/kvm-cpu.h" #include "kvm/ioport.h" #include "kvm/util.h" #include "kvm/irq.h" #include "kvm/kvm.h" #include "kvm/pci.h" -#include "kvm/i8042.h" #include <sys/types.h> #include <sys/ioctl.h> #include <inttypes.h> #include <unistd.h> -#include <rfb/rfb.h> - -#define VESA_QUEUE_SIZE 128 -#define VESA_IRQ 14 - -/* - * This "6000" value is pretty much the result of experimentation - * It seems that around this value, things update pretty smoothly - */ -#define VESA_UPDATE_TIME 6000 - -static char videomem[VESA_MEM_SIZE]; - static bool vesa_pci_io_in(struct ioport *ioport, struct kvm *kvm, u16 port, void *data, int size, u32 count) { return true; @@ -53,23 +40,24 @@ static struct pci_device_header vesa_pci_device = { .bar[1] = VESA_MEM_ADDR | PCI_BASE_ADDRESS_SPACE_MEMORY, }; - -void vesa_mmio_callback(u64 addr, u8 *data, u32 len, u8 is_write) +static void vesa_mmio_callback(u64 addr, u8 *data, u32 len, u8 is_write) { if (!is_write) return; - memcpy(&videomem[addr - VESA_MEM_ADDR], data, len); + fb__write(addr, data, len); } -void vesa__init(struct kvm *kvm) +static struct framebuffer vesafb; + +struct framebuffer *vesa__init(struct kvm *kvm) { - u8 dev, line, pin; - pthread_t thread; u16 vesa_base_addr; + u8 dev, line, pin; + char *mem; if (irq__register_device(PCI_DEVICE_ID_VESA, &dev, &pin, &line) < 0) - return; + return NULL; vesa_pci_device.irq_pin = pin; vesa_pci_device.irq_line = line; @@ -79,34 +67,16 @@ void vesa__init(struct kvm *kvm) kvm__register_mmio(VESA_MEM_ADDR, VESA_MEM_SIZE, &vesa_mmio_callback); - pthread_create(&thread, NULL, vesa__dovnc, kvm); -} - -/* - * This starts a VNC server to display the framebuffer. - * It's not altogether clear this belongs here rather than in kvm-run.c - */ -void *vesa__dovnc(void *v) -{ - /* - * Make a fake argc and argv because the getscreen function - * seems to want it. - */ - char argv[1][1] = {{0}}; - int argc = 1; - - rfbScreenInfoPtr server; - - server = rfbGetScreen(&argc, (char **) argv, VESA_WIDTH, VESA_HEIGHT, 8, 3, 4); - server->frameBuffer = videomem; - server->alwaysShared = TRUE; - server->kbdAddEvent = kbd_handle_key; - server->ptrAddEvent = kbd_handle_ptr; - rfbInitServer(server); - - while (rfbIsActive(server)) { - rfbMarkRectAsModified(server, 0, 0, VESA_WIDTH, VESA_HEIGHT); - rfbProcessEvents(server, server->deferUpdateTime * VESA_UPDATE_TIME); - } - return NULL; + mem = calloc(1, VESA_MEM_SIZE); + if (!mem) + return NULL; + + vesafb = (struct framebuffer) { + .width = VESA_WIDTH, + .height = VESA_HEIGHT, + .depth = VESA_BPP, + .mem = mem, + .mem_addr = VESA_MEM_ADDR, + }; + return fb__register(&vesafb); } diff --git a/tools/kvm/include/kvm/i8042.h b/tools/kvm/include/kvm/i8042.h index 3416b64..066a8cc 100644 --- a/tools/kvm/include/kvm/i8042.h +++ b/tools/kvm/include/kvm/i8042.h @@ -1,6 +1,8 @@ #ifndef KVM__PCKBD_H #define KVM__PCKBD_H +struct kvm; + void kbd__init(struct kvm *kvm); #ifdef CONFIG_HAS_VNCSERVER diff --git a/tools/kvm/include/kvm/vesa.h b/tools/kvm/include/kvm/vesa.h index e9522a5..6621f68 100644 --- a/tools/kvm/include/kvm/vesa.h +++ b/tools/kvm/include/kvm/vesa.h @@ -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 diff --git a/tools/kvm/include/kvm/vnc.h b/tools/kvm/include/kvm/vnc.h new file mode 100644 index 0000000..da2f635 --- /dev/null +++ b/tools/kvm/include/kvm/vnc.h @@ -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 */ diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c index 034a3ba..e6e180b 100644 --- a/tools/kvm/kvm-run.c +++ b/tools/kvm/kvm-run.c @@ -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); diff --git a/tools/kvm/ui/vnc.c b/tools/kvm/ui/vnc.c new file mode 100644 index 0000000..086cf82 --- /dev/null +++ b/tools/kvm/ui/vnc.c @@ -0,0 +1,68 @@ +#include "kvm/vnc.h" + +#include "kvm/framebuffer.h" +#include "kvm/i8042.h" + +#include <linux/types.h> +#include <rfb/rfb.h> +#include <pthread.h> + +#define VESA_QUEUE_SIZE 128 +#define VESA_IRQ 14 + +/* + * This "6000" value is pretty much the result of experimentation + * It seems that around this value, things update pretty smoothly + */ +#define VESA_UPDATE_TIME 6000 + +static void vnc__write(struct framebuffer *fb, u64 addr, u8 *data, u32 len) +{ + memcpy(&fb->mem[addr - fb->mem_addr], data, len); +} + +static void *vnc__thread(void *p) +{ + struct framebuffer *fb = p; + /* + * Make a fake argc and argv because the getscreen function + * seems to want it. + */ + char argv[1][1] = {{0}}; + int argc = 1; + + rfbScreenInfoPtr server; + + server = rfbGetScreen(&argc, (char **) argv, fb->width, fb->height, 8, 3, 4); + server->frameBuffer = fb->mem; + server->alwaysShared = TRUE; + server->kbdAddEvent = kbd_handle_key; + server->ptrAddEvent = kbd_handle_ptr; + rfbInitServer(server); + + while (rfbIsActive(server)) { + rfbMarkRectAsModified(server, 0, 0, fb->width, fb->height); + rfbProcessEvents(server, server->deferUpdateTime * VESA_UPDATE_TIME); + } + return NULL; +} + +static int vnc__start(struct framebuffer *fb) +{ + pthread_t thread; + + if (pthread_create(&thread, NULL, vnc__thread, fb) != 0) + return -1; + + return 0; +} + +static struct fb_target_operations vnc_ops = { + .start = vnc__start, + .write = vnc__write, +}; + +void vnc__init(struct framebuffer *fb) +{ + fb__attach(fb, &vnc_ops); +} -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target 2011-06-03 15:59 [PATCH 1/3] kvm tools, ui: Add framebuffer infrastructure Pekka Enberg 2011-06-03 15:59 ` [PATCH 2/3] kvm tools, ui: Move VNC specific framebuffer code to ui/vnc.c Pekka Enberg @ 2011-06-03 15:59 ` Pekka Enberg 2011-06-03 16:26 ` Ingo Molnar 1 sibling, 1 reply; 17+ messages in thread From: Pekka Enberg @ 2011-06-03 15:59 UTC (permalink / raw) To: kvm; +Cc: Pekka Enberg, Cyrill Gorcunov, Ingo Molnar, John Floren, Sasha Levin This patch adds support for SDL based framebuffer. Use the '--sdl' command line option to enable the feature. Cc: Cyrill Gorcunov <gorcunov@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: John Floren <john@jfloren.net> Cc: Sasha Levin <levinsasha928@gmail.com> Signed-off-by: Pekka Enberg <penberg@kernel.org> --- 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 diff --git a/tools/kvm/Makefile b/tools/kvm/Makefile index 17c795b..55949aa 100644 --- a/tools/kvm/Makefile +++ b/tools/kvm/Makefile @@ -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. diff --git a/tools/kvm/config/feature-tests.mak b/tools/kvm/config/feature-tests.mak index 0801b54..bfd10ca 100644 --- a/tools/kvm/config/feature-tests.mak +++ b/tools/kvm/config/feature-tests.mak @@ -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 diff --git a/tools/kvm/include/kvm/sdl.h b/tools/kvm/include/kvm/sdl.h new file mode 100644 index 0000000..7057770 --- /dev/null +++ b/tools/kvm/include/kvm/sdl.h @@ -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 */ diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c index e6e180b..8398287 100644 --- a/tools/kvm/kvm-run.c +++ b/tools/kvm/kvm-run.c @@ -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(); diff --git a/tools/kvm/ui/sdl.c b/tools/kvm/ui/sdl.c new file mode 100644 index 0000000..8bc3f68 --- /dev/null +++ b/tools/kvm/ui/sdl.c @@ -0,0 +1,71 @@ +#include "kvm/sdl.h" + +#include "kvm/framebuffer.h" +#include "kvm/util.h" + +#include <SDL/SDL.h> +#include <pthread.h> + +static void sdl__write(struct framebuffer *fb, u64 addr, u8 *data, u32 len) +{ + memcpy(&fb->mem[addr - fb->mem_addr], data, len); +} + +static void *sdl__thread(void *p) +{ + Uint32 rmask, gmask, bmask, amask; + struct framebuffer *fb = p; + SDL_Surface *guest_screen; + SDL_Surface *screen; + SDL_Event ev; + + if (SDL_Init(SDL_INIT_VIDEO) != 0) + die("Unable to initialize SDL"); + + rmask = 0x000000ff; + gmask = 0x0000ff00; + bmask = 0x00ff0000; + amask = 0x00000000; + + guest_screen = SDL_CreateRGBSurfaceFrom(fb->mem, fb->width, fb->height, fb->depth, fb->width * fb->depth / 8, rmask, gmask, bmask, amask); + if (!guest_screen) + die("Unable to create SDL RBG surface"); + + screen = SDL_SetVideoMode(fb->width, fb->height, fb->depth, SDL_SWSURFACE); + if (!screen) + die("Unable to set SDL video mode"); + + for (;;) { + SDL_BlitSurface(guest_screen, NULL, screen, NULL); + SDL_Flip(screen); + + while (SDL_PollEvent(&ev)) { + switch (ev.type) { + case SDL_QUIT: + goto exit; + } + } + } +exit: + return NULL; +} + +static int sdl__start(struct framebuffer *fb) +{ + pthread_t thread; + + if (pthread_create(&thread, NULL, sdl__thread, fb) != 0) + return -1; + + return 0; +} + +static struct fb_target_operations sdl_ops = { + .start = sdl__start, + .write = sdl__write, +}; + +void sdl__init(struct framebuffer *fb) +{ + fb__attach(fb, &sdl_ops); +} -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target 2011-06-03 15:59 ` [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target Pekka Enberg @ 2011-06-03 16:26 ` Ingo Molnar 2011-06-03 16:28 ` Ingo Molnar 2011-06-03 16:30 ` Pekka Enberg 0 siblings, 2 replies; 17+ messages in thread From: Ingo Molnar @ 2011-06-03 16:26 UTC (permalink / raw) To: Pekka Enberg; +Cc: kvm, Cyrill Gorcunov, John Floren, Sasha Levin * Pekka Enberg <penberg@kernel.org> wrote: > 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 ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target 2011-06-03 16:26 ` Ingo Molnar @ 2011-06-03 16:28 ` Ingo Molnar 2011-06-03 16:33 ` Ingo Molnar 2011-06-03 16:30 ` Pekka Enberg 1 sibling, 1 reply; 17+ messages in thread From: Ingo Molnar @ 2011-06-03 16:28 UTC (permalink / raw) To: Pekka Enberg; +Cc: kvm, Cyrill Gorcunov, John Floren, Sasha Levin * Ingo Molnar <mingo@elte.hu> wrote: > 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? Ok, found it, the guest kernel needs CONFIG_FB_VESA=y set. Thanks, Ingo ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target 2011-06-03 16:28 ` Ingo Molnar @ 2011-06-03 16:33 ` Ingo Molnar 2011-06-03 16:37 ` Pekka Enberg 0 siblings, 1 reply; 17+ messages in thread From: Ingo Molnar @ 2011-06-03 16:33 UTC (permalink / raw) To: Pekka Enberg; +Cc: kvm, Cyrill Gorcunov, John Floren, Sasha Levin 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 ��� Thanks, Ingo ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target 2011-06-03 16:33 ` Ingo Molnar @ 2011-06-03 16:37 ` Pekka Enberg 2011-06-03 16:40 ` Ingo Molnar 2011-06-03 16:45 ` Ingo Molnar 0 siblings, 2 replies; 17+ messages in thread From: Pekka Enberg @ 2011-06-03 16:37 UTC (permalink / raw) To: Ingo Molnar; +Cc: kvm, Cyrill Gorcunov, John Floren, Sasha Levin On Fri, 3 Jun 2011, Ingo Molnar wrote: > > 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 ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target 2011-06-03 16:37 ` Pekka Enberg @ 2011-06-03 16:40 ` Ingo Molnar 2011-06-03 16:44 ` Pekka Enberg 2011-06-03 16:45 ` Ingo Molnar 1 sibling, 1 reply; 17+ messages in thread From: Ingo Molnar @ 2011-06-03 16:40 UTC (permalink / raw) To: Pekka Enberg; +Cc: kvm, Cyrill Gorcunov, John Floren, Sasha Levin * Pekka Enberg <penberg@kernel.org> wrote: > 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 ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target 2011-06-03 16:40 ` Ingo Molnar @ 2011-06-03 16:44 ` Pekka Enberg 0 siblings, 0 replies; 17+ messages in thread From: Pekka Enberg @ 2011-06-03 16:44 UTC (permalink / raw) To: Ingo Molnar; +Cc: kvm, Cyrill Gorcunov, John Floren, Sasha Levin On Fri, 3 Jun 2011, Ingo Molnar wrote: > 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. Yup. I tried ssh -X localhost and ran 'kvm run --sdl' there and it worked fine. Hmm. Pekka ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target 2011-06-03 16:37 ` Pekka Enberg 2011-06-03 16:40 ` Ingo Molnar @ 2011-06-03 16:45 ` Ingo Molnar 2011-06-03 16:46 ` Pekka Enberg 1 sibling, 1 reply; 17+ messages in thread From: Ingo Molnar @ 2011-06-03 16:45 UTC (permalink / raw) To: Pekka Enberg; +Cc: kvm, Cyrill Gorcunov, John Floren, Sasha Levin i tried this patch: diff --git a/tools/kvm/ui/sdl.c b/tools/kvm/ui/sdl.c index 8bc3f68..403563c 100644 --- a/tools/kvm/ui/sdl.c +++ b/tools/kvm/ui/sdl.c @@ -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 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target 2011-06-03 16:45 ` Ingo Molnar @ 2011-06-03 16:46 ` Pekka Enberg 2011-06-03 16:52 ` Ingo Molnar 2011-06-03 16:54 ` Ingo Molnar 0 siblings, 2 replies; 17+ messages in thread From: Pekka Enberg @ 2011-06-03 16:46 UTC (permalink / raw) To: Ingo Molnar; +Cc: kvm, Cyrill Gorcunov, John Floren, Sasha Levin On Fri, 3 Jun 2011, Ingo Molnar wrote: > 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? ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target 2011-06-03 16:46 ` Pekka Enberg @ 2011-06-03 16:52 ` Ingo Molnar 2011-06-03 16:54 ` Pekka Enberg 2011-06-03 16:54 ` Ingo Molnar 1 sibling, 1 reply; 17+ messages in thread From: Ingo Molnar @ 2011-06-03 16:52 UTC (permalink / raw) To: Pekka Enberg; +Cc: kvm, Cyrill Gorcunov, John Floren, Sasha Levin * Pekka Enberg <penberg@kernel.org> wrote: > On Fri, 3 Jun 2011, Ingo Molnar wrote: > >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 ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target 2011-06-03 16:52 ` Ingo Molnar @ 2011-06-03 16:54 ` Pekka Enberg 2011-06-03 16:58 ` Ingo Molnar 0 siblings, 1 reply; 17+ messages in thread From: Pekka Enberg @ 2011-06-03 16:54 UTC (permalink / raw) To: Ingo Molnar; +Cc: kvm, Cyrill Gorcunov, John Floren, Sasha Levin On Fri, 3 Jun 2011, Ingo Molnar wrote: > 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 ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target 2011-06-03 16:54 ` Pekka Enberg @ 2011-06-03 16:58 ` Ingo Molnar 0 siblings, 0 replies; 17+ messages in thread From: Ingo Molnar @ 2011-06-03 16:58 UTC (permalink / raw) To: Pekka Enberg; +Cc: kvm, Cyrill Gorcunov, John Floren, Sasha Levin * Pekka Enberg <penberg@kernel.org> wrote: > On Fri, 3 Jun 2011, Ingo Molnar wrote: > >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. Yeah! I'd suggest such a wording: Fatal: SDL support not compiled in. (install the SDL-dev[el] package) Thanks, Ingo ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target 2011-06-03 16:46 ` Pekka Enberg 2011-06-03 16:52 ` Ingo Molnar @ 2011-06-03 16:54 ` Ingo Molnar 2011-06-03 16:56 ` Ingo Molnar 1 sibling, 1 reply; 17+ messages in thread From: Ingo Molnar @ 2011-06-03 16:54 UTC (permalink / raw) To: Pekka Enberg; +Cc: kvm, Cyrill Gorcunov, John Floren, Sasha Levin so, 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 ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target 2011-06-03 16:54 ` Ingo Molnar @ 2011-06-03 16:56 ` Ingo Molnar 0 siblings, 0 replies; 17+ messages in thread From: Ingo Molnar @ 2011-06-03 16:56 UTC (permalink / raw) To: Pekka Enberg; +Cc: kvm, Cyrill Gorcunov, John Floren, Sasha Levin * Ingo Molnar <mingo@elte.hu> wrote: > 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. btw., we never execute ->start(): diff --git a/tools/kvm/ui/sdl.c b/tools/kvm/ui/sdl.c index 8bc3f68..43734e4 100644 --- a/tools/kvm/ui/sdl.c +++ b/tools/kvm/ui/sdl.c @@ -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 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target 2011-06-03 16:26 ` Ingo Molnar 2011-06-03 16:28 ` Ingo Molnar @ 2011-06-03 16:30 ` Pekka Enberg 1 sibling, 0 replies; 17+ messages in thread From: Pekka Enberg @ 2011-06-03 16:30 UTC (permalink / raw) To: Ingo Molnar; +Cc: kvm, Cyrill Gorcunov, John Floren, Sasha Levin On Fri, 3 Jun 2011, Ingo Molnar wrote: > 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. > # 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? 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 <john@jfloren.net> 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=y CONFIG_FB_VESA=y CONFIG_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. Signed-off-by: John Floren <john@jfloren.net> [ turning code into patches and cleanup ] Signed-off-by: Sasha Levin <levinsasha928@gmail.com> Signed-off-by: Pekka Enberg <penberg@kernel.org> Pekka ^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2011-06-03 16:58 UTC | newest] Thread overview: 17+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-06-03 15:59 [PATCH 1/3] kvm tools, ui: Add framebuffer infrastructure Pekka Enberg 2011-06-03 15:59 ` [PATCH 2/3] kvm tools, ui: Move VNC specific framebuffer code to ui/vnc.c Pekka Enberg 2011-06-03 15:59 ` [PATCH 3/3] kvm tools, ui: Add support for SDL framebuffer output target Pekka Enberg 2011-06-03 16:26 ` Ingo Molnar 2011-06-03 16:28 ` Ingo Molnar 2011-06-03 16:33 ` Ingo Molnar 2011-06-03 16:37 ` Pekka Enberg 2011-06-03 16:40 ` Ingo Molnar 2011-06-03 16:44 ` Pekka Enberg 2011-06-03 16:45 ` Ingo Molnar 2011-06-03 16:46 ` Pekka Enberg 2011-06-03 16:52 ` Ingo Molnar 2011-06-03 16:54 ` Pekka Enberg 2011-06-03 16:58 ` Ingo Molnar 2011-06-03 16:54 ` Ingo Molnar 2011-06-03 16:56 ` Ingo Molnar 2011-06-03 16:30 ` Pekka Enberg
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox