From patchwork Mon May 23 08:44:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 808112 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4N8jq4b008996 for ; Mon, 23 May 2011 08:45:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751776Ab1EWIpr (ORCPT ); Mon, 23 May 2011 04:45:47 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:63394 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752992Ab1EWIpq (ORCPT ); Mon, 23 May 2011 04:45:46 -0400 Received: by mail-bw0-f46.google.com with SMTP id 15so4514519bwz.19 for ; Mon, 23 May 2011 01:45:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=m+K4de9F8VQXiJuDwCw8f1SCmrXCpnNeCqjNdI+PacA=; b=iWZcb1RETbfz/dKUkWj+ldgFJKslibllwPUXNEk5DpRA3CasruUNCdQJOp0RekNzDa qguKIMeUJHTeMNh+us+YWwb04liC5MnENBp0B7K4kuUMZu/CEs6Wx5hw8klMjuVQtQSR dSKsGopoIeBTbnET5QwqadLWDL2APUToho4ME= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=N9zRY25MhyjOJLlGWO83fUzpawqjTQlarNleZEjkGYFLyY79ORPARwlwml0WbXpCl2 i+WKqefJj+beJZ34xFYFBjUxKjn0MOFfrm/rNwB9mEvRLoaflUFx0ShhMDSEJo49mW1o e4OpMeG1gNWrJqgpWY4PYiEA72v7U2TC9W/bc= Received: by 10.205.81.76 with SMTP id zx12mr1927281bkb.82.1306140345533; Mon, 23 May 2011 01:45:45 -0700 (PDT) Received: from localhost.localdomain (bzq-79-179-199-121.red.bezeqint.net [79.179.199.121]) by mx.google.com with ESMTPS id q18sm3742392bka.15.2011.05.23.01.45.43 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 May 2011 01:45:45 -0700 (PDT) From: Sasha Levin To: penberg@kernel.org Cc: john@jfloren.net, kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com, prasadjoshi124@gmail.com, Sasha Levin Subject: [PATCH 5/5] kvm tools: Initialize and use VESA and VNC Date: Mon, 23 May 2011 11:44:51 +0300 Message-Id: <1306140291-17493-5-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.5.rc3 In-Reply-To: <1306140291-17493-1-git-send-email-levinsasha928@gmail.com> References: <1306140291-17493-1-git-send-email-levinsasha928@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 23 May 2011 08:45:52 +0000 (UTC) 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 Signed-off-by: Sasha Levin --- 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 #include #include +#include /* header files for gitish interface */ #include @@ -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++) {