All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] kvm tools: Add BIOS INT10 handler
@ 2011-05-23  8:44 Sasha Levin
  2011-05-23  8:44 ` [PATCH 2/5] kvm tools: Add video mode to kernel initialization Sasha Levin
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Sasha Levin @ 2011-05-23  8:44 UTC (permalink / raw)
  To: penberg
  Cc: john, kvm, mingo, asias.hejun, gorcunov, prasadjoshi124, Sasha Levin

INT10 handler is a basic implementation of BIOS video services.

The handler implements a VESA interface which is initialized at
the very beginning of loading the kernel.

Signed-off-by: John Floren <john@jfloren.net>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 tools/kvm/bios/bios-rom.S |   56 ++++++++--------
 tools/kvm/bios/int10.c    |  161 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 189 insertions(+), 28 deletions(-)
 create mode 100644 tools/kvm/bios/int10.c

diff --git a/tools/kvm/bios/bios-rom.S b/tools/kvm/bios/bios-rom.S
index 8a53dcd..b636cb8 100644
--- a/tools/kvm/bios/bios-rom.S
+++ b/tools/kvm/bios/bios-rom.S
@@ -27,36 +27,36 @@ ENTRY_END(bios_intfake)
  * We ignore bx settings
  */
 ENTRY(bios_int10)
-	test $0x0e, %ah
-	jne 1f
+	pushw	%fs
+	pushl	%es
+	pushl	%edi
+	pushl	%esi
+	pushl	%ebp
+	pushl	%esp
+	pushl	%edx
+	pushl	%ecx
+	pushl	%ebx
+	pushl	%eax
+
+	movl		%esp, %eax
+	/* this is way easier than doing it in assembly */
+	/* just push all the regs and jump to a C handler */
+	call	int10handler
+
+	popl	%eax
+	popl	%ebx
+	popl	%ecx
+	popl	%edx
+	popl	%esp
+	popl	%ebp
+	popl	%esi
+	popl	%edi
+	popl	%es
+	popw	%fs
 
-/*
- * put char in AL at current cursor and
- * increment cursor position
- */
-putchar:
-	stack_swap
-
-	push %fs
-	push %bx
-
-	mov $VGA_RAM_SEG, %bx
-	mov %bx, %fs
-	mov %cs:(cursor), %bx
-	mov %al, %fs:(%bx)
-	inc %bx
-	test $VGA_PAGE_SIZE, %bx
-	jb putchar_new
-	xor %bx, %bx
-putchar_new:
-	mov %bx, %fs:(cursor)
-
-	pop %bx
-	pop %fs
-
-	stack_restore
-1:
 	IRET
+
+
 /*
  * private IRQ data
  */
diff --git a/tools/kvm/bios/int10.c b/tools/kvm/bios/int10.c
new file mode 100644
index 0000000..98205c3
--- /dev/null
+++ b/tools/kvm/bios/int10.c
@@ -0,0 +1,161 @@
+#include "kvm/segment.h"
+#include "kvm/bios.h"
+#include "kvm/util.h"
+#include "kvm/vesa.h"
+#include <stdint.h>
+
+#define VESA_MAGIC ('V' + ('E' << 8) + ('S' << 16) + ('A' << 24))
+
+struct int10args {
+	u32	eax;
+	u32	ebx;
+	u32	ecx;
+	u32	edx;
+	u32	esp;
+	u32	ebp;
+	u32	esi;
+	u32	edi;
+	u32	es;
+};
+
+/* VESA General Information table */
+struct vesa_general_info {
+	u32 signature;			/* 0 Magic number = "VESA" */
+	u16 version;			/* 4 */
+	void *vendor_string;		/* 6 */
+	u32 capabilities;		/* 10 */
+	void *video_mode_ptr;		/* 14 */
+	u16 total_memory;		/* 18 */
+
+	u8 reserved[236];		/* 20 */
+} __attribute__ ((packed));
+
+
+struct vminfo {
+	u16	mode_attr;		/* 0 */
+	u8	win_attr[2];		/* 2 */
+	u16	win_grain;		/* 4 */
+	u16	win_size;		/* 6 */
+	u16	win_seg[2];		/* 8 */
+	u32	win_scheme;		/* 12 */
+	u16	logical_scan;		/* 16 */
+
+	u16	h_res;			/* 18 */
+	u16	v_res;			/* 20 */
+	u8	char_width;		/* 22 */
+	u8	char_height;		/* 23 */
+	u8	memory_planes;		/* 24 */
+	u8	bpp;			/* 25 */
+	u8	banks;			/* 26 */
+	u8	memory_layout;		/* 27 */
+	u8	bank_size;		/* 28 */
+	u8	image_planes;		/* 29 */
+	u8	page_function;		/* 30 */
+
+	u8	rmask;			/* 31 */
+	u8	rpos;			/* 32 */
+	u8	gmask;			/* 33 */
+	u8	gpos;			/* 34 */
+	u8	bmask;			/* 35 */
+	u8	bpos;			/* 36 */
+	u8	resv_mask;		/* 37 */
+	u8	resv_pos;		/* 38 */
+	u8	dcm_info;		/* 39 */
+
+	u32	lfb_ptr;		/* 40 Linear frame buffer address */
+	u32	offscreen_ptr;		/* 44 Offscreen memory address */
+	u16	offscreen_size;		/* 48 */
+
+	u8	reserved[206];		/* 50 */
+};
+
+char oemstring[11] = "KVM VESA";
+u16 modes[2] = { 0x0112, 0xffff };
+
+static inline void outb(unsigned short port, unsigned char val)
+{
+	asm volatile("outb %0, %1" : : "a"(val), "Nd"(port));
+}
+
+/*
+ * It's probably much more useful to make this print to the serial
+ * line rather than print to a non-displayed VGA memory
+ */
+static inline void int10putchar(struct int10args *args)
+{
+	u8 al, ah;
+
+	al = args->eax & 0xFF;
+	ah = (args->eax & 0xFF00) >> 8;
+
+	outb(0x3f8, al);
+}
+
+static void int10vesa(struct int10args *args)
+{
+	u8 al, ah;
+	struct vesa_general_info *destination;
+	struct vminfo *vi;
+
+	al = args->eax;
+	ah = args->eax >> 8;
+
+	switch (al) {
+	case 0:
+		/* Set controller info */
+
+		destination = (struct vesa_general_info *)args->edi;
+		*destination = (struct vesa_general_info) {
+			.signature	= VESA_MAGIC,
+			.version	= 0x102,
+			.vendor_string	= oemstring,
+			.capabilities	= 0x10,
+			.video_mode_ptr	= modes,
+			.total_memory	= (4*VESA_WIDTH * VESA_HEIGHT) / 0x10000,
+		};
+
+		break;
+	case 1:
+		vi = (struct vminfo *)args->edi;
+		*vi = (struct vminfo) {
+			.mode_attr	= 0xd9, /* 11011011 */
+			.logical_scan	= VESA_WIDTH*4,
+			.h_res		= VESA_WIDTH,
+			.v_res		= VESA_HEIGHT,
+			.bpp		= VESA_BPP,
+			.memory_layout	= 6,
+			.memory_planes	= 1,
+			.lfb_ptr	= VESA_MEM_ADDR,
+			.rmask		= 8,
+			.gmask		= 8,
+			.bmask		= 8,
+			.resv_mask	= 8,
+			.resv_pos	= 24,
+			.bpos		= 16,
+			.gpos		= 8,
+		};
+
+		break;
+	}
+
+	args->eax			= 0x004f; /* return success every time */
+
+}
+
+bioscall void int10handler(struct int10args *args)
+{
+	u8 ah;
+
+	ah = (args->eax & 0xff00) >> 8;
+
+	switch (ah) {
+	case 0x0e:
+		int10putchar(args);
+		break;
+	case 0x4f:
+		int10vesa(args);
+		break;
+	}
+
+}
+
-- 
1.7.5.rc3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/5] kvm tools: Add video mode to kernel initialization
  2011-05-23  8:44 [PATCH 1/5] kvm tools: Add BIOS INT10 handler Sasha Levin
@ 2011-05-23  8:44 ` Sasha Levin
  2011-05-23  8:44 ` [PATCH 3/5] kvm tools: Add VESA device Sasha Levin
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2011-05-23  8:44 UTC (permalink / raw)
  To: penberg
  Cc: john, kvm, mingo, asias.hejun, gorcunov, prasadjoshi124, Sasha Levin

Allow setting video mode in guest kernel.

For possible values see Documentation/fb/vesafb.txt

Signed-off-by: John Floren <john@jfloren.net>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 tools/kvm/include/kvm/kvm.h |    2 +-
 tools/kvm/kvm.c             |    7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/tools/kvm/include/kvm/kvm.h b/tools/kvm/include/kvm/kvm.h
index 3cf6e6c..49ebd95 100644
--- a/tools/kvm/include/kvm/kvm.h
+++ b/tools/kvm/include/kvm/kvm.h
@@ -39,7 +39,7 @@ int kvm__max_cpus(struct kvm *kvm);
 void kvm__init_ram(struct kvm *kvm);
 void kvm__delete(struct kvm *kvm);
 bool kvm__load_kernel(struct kvm *kvm, const char *kernel_filename,
-			const char *initrd_filename, const char *kernel_cmdline);
+			const char *initrd_filename, const char *kernel_cmdline, u16 vidmode);
 void kvm__setup_bios(struct kvm *kvm);
 void kvm__start_timer(struct kvm *kvm);
 void kvm__stop_timer(struct kvm *kvm);
diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c
index 4393a41..7284211 100644
--- a/tools/kvm/kvm.c
+++ b/tools/kvm/kvm.c
@@ -320,7 +320,7 @@ static int load_flat_binary(struct kvm *kvm, int fd)
 static const char *BZIMAGE_MAGIC	= "HdrS";
 
 static bool load_bzimage(struct kvm *kvm, int fd_kernel,
-			int fd_initrd, const char *kernel_cmdline)
+			int fd_initrd, const char *kernel_cmdline, u16 vidmode)
 {
 	struct boot_params *kern_boot;
 	unsigned long setup_sects;
@@ -383,6 +383,7 @@ static bool load_bzimage(struct kvm *kvm, int fd_kernel,
 	kern_boot->hdr.type_of_loader	= 0xff;
 	kern_boot->hdr.heap_end_ptr	= 0xfe00;
 	kern_boot->hdr.loadflags	|= CAN_USE_HEAP;
+	kern_boot->hdr.vid_mode		= vidmode;
 
 	/*
 	 * Read initrd image into guest memory
@@ -441,7 +442,7 @@ static bool initrd_check(int fd)
 }
 
 bool kvm__load_kernel(struct kvm *kvm, const char *kernel_filename,
-		const char *initrd_filename, const char *kernel_cmdline)
+		const char *initrd_filename, const char *kernel_cmdline, u16 vidmode)
 {
 	bool ret;
 	int fd_kernel = -1, fd_initrd = -1;
@@ -459,7 +460,7 @@ bool kvm__load_kernel(struct kvm *kvm, const char *kernel_filename,
 			die("%s is not an initrd", initrd_filename);
 	}
 
-	ret = load_bzimage(kvm, fd_kernel, fd_initrd, kernel_cmdline);
+	ret = load_bzimage(kvm, fd_kernel, fd_initrd, kernel_cmdline, vidmode);
 
 	if (initrd_filename)
 		close(fd_initrd);
-- 
1.7.5.rc3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/5] kvm tools: Add VESA device
  2011-05-23  8:44 [PATCH 1/5] kvm tools: Add BIOS INT10 handler Sasha Levin
  2011-05-23  8:44 ` [PATCH 2/5] kvm tools: Add video mode to kernel initialization Sasha Levin
@ 2011-05-23  8:44 ` Sasha Levin
  2011-05-23  8:44 ` [PATCH 4/5] kvm tools: Update makefile and feature tests Sasha Levin
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2011-05-23  8:44 UTC (permalink / raw)
  To: penberg
  Cc: john, kvm, mingo, asias.hejun, gorcunov, prasadjoshi124, Sasha Levin

Add a simple VESA device which simply moves a framebuffer
from guest kernel to a VNC server.

VESA device PCI code is very similar to virtio-* PCI code.

Signed-off-by: John Floren <john@jfloren.net>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 tools/kvm/hw/vesa.c                    |  106 ++++++++++++++++++++++++++++++++
 tools/kvm/include/kvm/ioport.h         |    2 +
 tools/kvm/include/kvm/vesa.h           |   31 +++++++++
 tools/kvm/include/kvm/virtio-pci-dev.h |    3 +
 4 files changed, 142 insertions(+), 0 deletions(-)
 create mode 100644 tools/kvm/hw/vesa.c
 create mode 100644 tools/kvm/include/kvm/vesa.h

diff --git a/tools/kvm/hw/vesa.c b/tools/kvm/hw/vesa.c
new file mode 100644
index 0000000..c1a4c64
--- /dev/null
+++ b/tools/kvm/hw/vesa.c
@@ -0,0 +1,106 @@
+#include "kvm/vesa.h"
+#include "kvm/ioport.h"
+#include "kvm/util.h"
+#include "kvm/kvm.h"
+#include "kvm/pci.h"
+#include "kvm/kvm-cpu.h"
+#include "kvm/irq.h"
+#include "kvm/virtio-pci-dev.h"
+
+#include <rfb/rfb.h>
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <inttypes.h>
+#include <unistd.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
+
+u8 videomem[VESA_MEM_SIZE];
+
+static bool vesa_pci_io_in(struct kvm *kvm, u16 port, void *data, int size, u32 count)
+{
+	printf("vesa in port=%u\n", port);
+	return true;
+}
+
+static bool vesa_pci_io_out(struct kvm *kvm, u16 port, void *data, int size, u32 count)
+{
+	printf("vesa out port=%u\n", port);
+	return true;
+}
+
+static struct ioport_operations vesa_io_ops = {
+	.io_in	= vesa_pci_io_in,
+	.io_out	= vesa_pci_io_out,
+};
+
+static struct pci_device_header vesa_pci_device = {
+	.vendor_id		= PCI_VENDOR_ID_REDHAT_QUMRANET,
+	.device_id		= PCI_DEVICE_ID_VESA,
+	.header_type		= PCI_HEADER_TYPE_NORMAL,
+	.revision_id		= 0,
+	.class			= 0x030000,
+	.subsys_vendor_id	= PCI_SUBSYSTEM_VENDOR_ID_REDHAT_QUMRANET,
+	.subsys_id		= PCI_SUBSYSTEM_ID_VESA,
+	.bar[0]			= IOPORT_VESA | PCI_BASE_ADDRESS_SPACE_IO,
+	.bar[1]			= VESA_MEM_ADDR | PCI_BASE_ADDRESS_SPACE_MEMORY,
+};
+
+
+void vesa_mmio_callback(u64 addr, u8 *data, u32 len, u8 is_write)
+{
+	if (is_write)
+		memcpy(&videomem[addr - VESA_MEM_ADDR], data, len);
+
+	return;
+}
+
+void vesa__init(struct kvm *kvm)
+{
+	u8 dev, line, pin;
+
+	if (irq__register_device(PCI_DEVICE_ID_VESA, &dev, &pin, &line) < 0)
+		return;
+
+	vesa_pci_device.irq_pin = pin;
+	vesa_pci_device.irq_line = line;
+	pci__register(&vesa_pci_device, dev);
+	ioport__register(IOPORT_VESA, &vesa_io_ops, IOPORT_VESA_SIZE);
+
+	kvm__register_mmio(VESA_MEM_ADDR, VESA_MEM_SIZE, &vesa_mmio_callback);
+}
+
+/*
+ * 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.
+	 */
+	int ac = 1;
+	char av[1][1] = {{0} };
+	rfbScreenInfoPtr server;
+
+	server = rfbGetScreen(&ac, (char **)av, VESA_WIDTH, VESA_HEIGHT, 8, 3, 4);
+	server->frameBuffer = (char *)videomem;
+	server->alwaysShared = TRUE;
+	rfbInitServer(server);
+
+	while (rfbIsActive(server)) {
+		rfbMarkRectAsModified(server, 0, 0, VESA_WIDTH, VESA_HEIGHT);
+		rfbProcessEvents(server, server->deferUpdateTime * VESA_UPDATE_TIME);
+	}
+	return NULL;
+}
+
diff --git a/tools/kvm/include/kvm/ioport.h b/tools/kvm/include/kvm/ioport.h
index 218530c..8253938 100644
--- a/tools/kvm/include/kvm/ioport.h
+++ b/tools/kvm/include/kvm/ioport.h
@@ -7,6 +7,8 @@
 
 /* some ports we reserve for own use */
 #define IOPORT_DBG			0xe0
+#define IOPORT_VESA			0xa200
+#define IOPORT_VESA_SIZE		256
 #define IOPORT_VIRTIO_P9		0xb200	/* Virtio 9P device */
 #define IOPORT_VIRTIO_P9_SIZE		256
 #define IOPORT_VIRTIO_BLK		0xc200	/* Virtio block device */
diff --git a/tools/kvm/include/kvm/vesa.h b/tools/kvm/include/kvm/vesa.h
new file mode 100644
index 0000000..dfa3d941
--- /dev/null
+++ b/tools/kvm/include/kvm/vesa.h
@@ -0,0 +1,31 @@
+#ifndef KVM__VESA_H
+#define KVM__VESA_H
+
+#include <linux/types.h>
+
+#define VESA_WIDTH	640
+#define VESA_HEIGHT	480
+
+#define VESA_MEM_ADDR	0xd0000000
+#define VESA_MEM_SIZE	(4*VESA_WIDTH*VESA_HEIGHT)
+#define VESA_BPP	32
+
+struct kvm;
+struct int10args;
+
+#ifdef CONFIG_HAS_VNCSERVER
+void vesa_mmio_callback(u64, u8*, u32, u8);
+void vesa__init(struct kvm *self);
+void *vesa__dovnc(void *);
+#else
+void vesa__init(struct kvm *self);
+void *vesa__dovnc(void *);
+void vesa__init(struct kvm *self) { }
+void *vesa__dovnc(void *param) { return NULL; }
+#endif
+
+void int10handler(struct int10args *args);
+extern u8 videomem[VESA_MEM_SIZE];
+
+
+#endif
diff --git a/tools/kvm/include/kvm/virtio-pci-dev.h b/tools/kvm/include/kvm/virtio-pci-dev.h
index 1b7862e..ca373df 100644
--- a/tools/kvm/include/kvm/virtio-pci-dev.h
+++ b/tools/kvm/include/kvm/virtio-pci-dev.h
@@ -13,8 +13,11 @@
 #define PCI_DEVICE_ID_VIRTIO_CONSOLE		0x1003
 #define PCI_DEVICE_ID_VIRTIO_RNG		0x1004
 #define PCI_DEVICE_ID_VIRTIO_P9			0x1009
+#define PCI_DEVICE_ID_VESA			0x2000
 
 #define PCI_VENDOR_ID_REDHAT_QUMRANET		0x1af4
 #define PCI_SUBSYSTEM_VENDOR_ID_REDHAT_QUMRANET	0x1af4
 
+#define PCI_SUBSYSTEM_ID_VESA			0x0004
+
 #endif /* VIRTIO_PCI_DEV_H_ */
-- 
1.7.5.rc3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/5] kvm tools: Update makefile and feature tests
  2011-05-23  8:44 [PATCH 1/5] kvm tools: Add BIOS INT10 handler Sasha Levin
  2011-05-23  8:44 ` [PATCH 2/5] kvm tools: Add video mode to kernel initialization Sasha Levin
  2011-05-23  8:44 ` [PATCH 3/5] kvm tools: Add VESA device Sasha Levin
@ 2011-05-23  8:44 ` Sasha Levin
  2011-05-23  8:44 ` [PATCH 5/5] kvm tools: Initialize and use VESA and VNC Sasha Levin
  2011-05-23  9:38 ` [PATCH 1/5] kvm tools: Add BIOS INT10 handler Ingo Molnar
  4 siblings, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2011-05-23  8:44 UTC (permalink / raw)
  To: penberg
  Cc: john, kvm, mingo, asias.hejun, gorcunov, prasadjoshi124, Sasha Levin

Update feature tests to test for libvncserver.

VESA support doesn't get compiled in unless libvncserver
is installed.

Signed-off-by: John Floren <john@jfloren.net>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 tools/kvm/Makefile                 |   11 ++++++++++-
 tools/kvm/config/feature-tests.mak |   10 ++++++++++
 2 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/tools/kvm/Makefile b/tools/kvm/Makefile
index e6e8d4e..2ebc86c 100644
--- a/tools/kvm/Makefile
+++ b/tools/kvm/Makefile
@@ -58,6 +58,14 @@ ifeq ($(has_bfd),y)
 	LIBS	+= -lbfd
 endif
 
+FLAGS_VNCSERVER=$(CFLAGS) -lvncserver
+has_vncserver := $(call try-cc,$(SOURCE_VNCSERVER),$(FLAGS_VNCSERVER))
+ifeq ($(has_vncserver),y)
+	CFLAGS	+= -DCONFIG_HAS_VNCSERVER
+	OBJS	+= hw/vesa.o
+	LIBS	+= -lvncserver
+endif
+
 DEPS	:= $(patsubst %.o,%.d,$(OBJS))
 
 # Exclude BIOS object files from header dependencies.
@@ -153,9 +161,10 @@ bios/bios.o: bios/bios.S bios/bios-rom.bin
 bios/bios-rom.bin: bios/bios-rom.S bios/e820.c
 	$(E) "  CC      " $@
 	$(Q) $(CC) -include code16gcc.h $(CFLAGS) $(BIOS_CFLAGS) -c -s bios/e820.c -o bios/e820.o
+	$(Q) $(CC) -include code16gcc.h $(CFLAGS) $(BIOS_CFLAGS) -c -s bios/int10.c -o bios/int10.o
 	$(Q) $(CC) $(CFLAGS) $(BIOS_CFLAGS) -c -s bios/bios-rom.S -o bios/bios-rom.o
 	$(E) "  LD      " $@
-	$(Q) ld -T bios/rom.ld.S -o bios/bios-rom.bin.elf bios/bios-rom.o bios/e820.o
+	$(Q) ld -T bios/rom.ld.S -o bios/bios-rom.bin.elf bios/bios-rom.o bios/e820.o bios/int10.o
 	$(E) "  OBJCOPY " $@
 	$(Q) objcopy -O binary -j .text bios/bios-rom.bin.elf bios/bios-rom.bin
 	$(E) "  NM      " $@
diff --git a/tools/kvm/config/feature-tests.mak b/tools/kvm/config/feature-tests.mak
index 6170fd2..0801b54 100644
--- a/tools/kvm/config/feature-tests.mak
+++ b/tools/kvm/config/feature-tests.mak
@@ -126,3 +126,13 @@ int main(void)
 	return 0;
 }
 endef
+
+define SOURCE_VNCSERVER
+#include <rfb/rfb.h>
+
+int main(void)
+{
+	rfbIsActive((void *)0);
+	return 0;
+}
+endef
-- 
1.7.5.rc3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/5] kvm tools: Initialize and use VESA and VNC
  2011-05-23  8:44 [PATCH 1/5] kvm tools: Add BIOS INT10 handler Sasha Levin
                   ` (2 preceding siblings ...)
  2011-05-23  8:44 ` [PATCH 4/5] kvm tools: Update makefile and feature tests Sasha Levin
@ 2011-05-23  8:44 ` Sasha Levin
  2011-05-23  9:32   ` Ingo Molnar
  2011-05-23  9:38 ` [PATCH 1/5] kvm tools: Add BIOS INT10 handler Ingo Molnar
  4 siblings, 1 reply; 7+ messages in thread
From: Sasha Levin @ 2011-05-23  8:44 UTC (permalink / raw)
  To: penberg
  Cc: john, kvm, mingo, asias.hejun, gorcunov, prasadjoshi124, Sasha Levin

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>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 tools/kvm/kvm-run.c |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c
index f7de0fb..5acddb2 100644
--- a/tools/kvm/kvm-run.c
+++ b/tools/kvm/kvm-run.c
@@ -28,6 +28,7 @@
 #include <kvm/barrier.h>
 #include <kvm/symbol.h>
 #include <kvm/virtio-9p.h>
+#include <kvm/vesa.h>
 
 /* header files for gitish interface  */
 #include <kvm/kvm-run.h>
@@ -67,6 +68,7 @@ static const char *virtio_9p_dir;
 static bool single_step;
 static bool readonly_image[MAX_DISK_IMAGES];
 static bool virtio_rng;
+static bool vnc;
 extern bool ioport_debug;
 extern int  active_console;
 
@@ -111,6 +113,7 @@ static const struct option options[] = {
 	OPT_STRING('\0', "kvm-dev", &kvm_dev, "kvm-dev", "KVM device file"),
 	OPT_STRING('\0', "virtio-9p", &virtio_9p_dir, "root dir",
 			"Enable 9p over virtio"),
+	OPT_BOOLEAN('\0', "vnc", &vnc, "Enable VNC framebuffer"),
 
 	OPT_GROUP("Kernel options:"),
 	OPT_STRING('k', "kernel", &kernel_filename, "kernel",
@@ -414,6 +417,7 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
 	char *hi;
 	int i;
 	void *ret;
+	u16 vidmode = 0;
 
 	signal(SIGALRM, handle_sigalrm);
 	signal(SIGQUIT, handle_sigquit);
@@ -512,7 +516,13 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
 	kvm->nrcpus = nrcpus;
 
 	memset(real_cmdline, 0, sizeof(real_cmdline));
-	strcpy(real_cmdline, "notsc noapic noacpi pci=conf1 console=ttyS0 earlyprintk=serial");
+	strcpy(real_cmdline, "notsc noapic noacpi pci=conf1");
+	if (vnc) {
+		strcat(real_cmdline, " video=vesafb:ypan console=tty0");
+		vidmode = 0x312;
+	} else {
+		strcat(real_cmdline, " console=ttyS0 earlyprintk=serial");
+	}
 	strcat(real_cmdline, " ");
 	if (kernel_cmdline)
 		strlcat(real_cmdline, kernel_cmdline, sizeof(real_cmdline));
@@ -544,7 +554,7 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
 	printf("  # kvm run -k %s -m %Lu -c %d\n", kernel_filename, ram_size / 1024 / 1024, nrcpus);
 
 	if (!kvm__load_kernel(kvm, kernel_filename, initrd_filename,
-				real_cmdline))
+				real_cmdline, vidmode))
 		die("unable to load kernel %s", kernel_filename);
 
 	kvm->vmlinux		= vmlinux_filename;
@@ -598,6 +608,13 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
 
 	kvm__init_ram(kvm);
 
+	if (vnc) {
+		pthread_t thread;
+
+		vesa__init(kvm);
+		pthread_create(&thread, NULL, vesa__dovnc, kvm);
+	}
+
 	thread_pool__init(nr_online_cpus);
 
 	for (i = 0; i < nrcpus; i++) {
-- 
1.7.5.rc3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 5/5] kvm tools: Initialize and use VESA and VNC
  2011-05-23  8:44 ` [PATCH 5/5] kvm tools: Initialize and use VESA and VNC Sasha Levin
@ 2011-05-23  9:32   ` Ingo Molnar
  0 siblings, 0 replies; 7+ messages in thread
From: Ingo Molnar @ 2011-05-23  9:32 UTC (permalink / raw)
  To: Sasha Levin; +Cc: penberg, john, kvm, asias.hejun, gorcunov, prasadjoshi124


* Sasha Levin <levinsasha928@gmail.com> wrote:

> @@ -598,6 +608,13 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
>  
>  	kvm__init_ram(kvm);
>  
> +	if (vnc) {
> +		pthread_t thread;
> +
> +		vesa__init(kvm);
> +		pthread_create(&thread, NULL, vesa__dovnc, kvm);
> +	}
> +

This should be encapsulated better, it should probably be all be done within 
vesa__init() and the only kv_cmd_run() exposure should be:

	vesa__init(kvm);

vesa__init() would wrap to an empty inline function if the library prereqs are 
not present.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/5] kvm tools: Add BIOS INT10 handler
  2011-05-23  8:44 [PATCH 1/5] kvm tools: Add BIOS INT10 handler Sasha Levin
                   ` (3 preceding siblings ...)
  2011-05-23  8:44 ` [PATCH 5/5] kvm tools: Initialize and use VESA and VNC Sasha Levin
@ 2011-05-23  9:38 ` Ingo Molnar
  4 siblings, 0 replies; 7+ messages in thread
From: Ingo Molnar @ 2011-05-23  9:38 UTC (permalink / raw)
  To: Sasha Levin; +Cc: penberg, john, kvm, asias.hejun, gorcunov, prasadjoshi124


* Sasha Levin <levinsasha928@gmail.com> wrote:

> INT10 handler is a basic implementation of BIOS video services.
> 
> The handler implements a VESA interface which is initialized at
> the very beginning of loading the kernel.
> 
> Signed-off-by: John Floren <john@jfloren.net>
> Signed-off-by: Sasha Levin <levinsasha928@gmail.com>

Btw., the signoff chain looks broken - this will look odd in Git.

If you took most of this from John then please put this in the first line of 
the patch:

  From: John Floren <john@jfloren.net>

That way John will be marked by Git as the author and you are the patch 
maintainer who nursed along the patch.

If you did significant changes to the patch (such as splitting it off a larger 
patch, cleaning it up, etc.) you can mark this before your SOB entry:

 Signed-off-by: John Floren <john@jfloren.net>
 [ split up the patch and cleaned it up ]
 Signed-off-by: Sasha Levin <levinsasha928@gmail.com>

If you did so many changes to a patch that you can reasonably be called the 
main author then you can be the From line and can mark John's first version as:

 Originally-From: John Floren <john@jfloren.net>
 Signed-off-by: Sasha Levin <levinsasha928@gmail.com>

If John has put copyright notices into the file then those should be preserved, 
and you can add yours as well, if you so wish.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-05-23  9:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-23  8:44 [PATCH 1/5] kvm tools: Add BIOS INT10 handler Sasha Levin
2011-05-23  8:44 ` [PATCH 2/5] kvm tools: Add video mode to kernel initialization Sasha Levin
2011-05-23  8:44 ` [PATCH 3/5] kvm tools: Add VESA device Sasha Levin
2011-05-23  8:44 ` [PATCH 4/5] kvm tools: Update makefile and feature tests Sasha Levin
2011-05-23  8:44 ` [PATCH 5/5] kvm tools: Initialize and use VESA and VNC Sasha Levin
2011-05-23  9:32   ` Ingo Molnar
2011-05-23  9:38 ` [PATCH 1/5] kvm tools: Add BIOS INT10 handler Ingo Molnar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.