bool do_debug_print = false;
-static int vidmode = -1;
-
extern char _binary_guest_init_start;
extern char _binary_guest_init_size;
in rootfs mode"), \
\
OPT_GROUP("BIOS options:"), \
- OPT_INTEGER('\0', "vidmode", &vidmode, \
+ OPT_INTEGER('\0', "vidmode", &(cfg)->vidmode, \
"Video mode"), \
\
OPT_GROUP("Debug options:"), \
static int kvm_cmd_run_init(int argc, const char **argv)
{
static char real_cmdline[2048], default_name[20];
- struct framebuffer *fb = NULL;
unsigned int nr_online_cpus;
int r;
if (!kvm->cfg.script)
kvm->cfg.script = DEFAULT_SCRIPT;
+ if (!kvm->cfg.vnc && !kvm->cfg.sdl)
+ kvm->cfg.vidmode = -1;
+
r = term_init(kvm);
if (r < 0) {
pr_err("term_init() failed with error %d\n", r);
goto fail;
}
- /*
- * vidmode should be either specified
- * either set by default
- */
- if (kvm->cfg.vnc || kvm->cfg.sdl) {
- if (vidmode == -1)
- vidmode = 0x312;
- } else {
- vidmode = 0;
- }
-
memset(real_cmdline, 0, sizeof(real_cmdline));
kvm__arch_set_cmdline(real_cmdline, kvm->cfg.vnc || kvm->cfg.sdl);
if (!kvm->cfg.firmware_filename) {
if (!kvm__load_kernel(kvm, kvm->cfg.kernel_filename,
- kvm->cfg.initrd_filename, real_cmdline, vidmode))
+ kvm->cfg.initrd_filename, real_cmdline, kvm->cfg.vidmode))
die("unable to load kernel %s", kvm->cfg.kernel_filename);
kvm->vmlinux = kvm->cfg.vmlinux_filename;
goto fail;
}
- if (kvm->cfg.vnc || kvm->cfg.sdl) {
- fb = vesa__init(kvm);
- if (IS_ERR(fb)) {
- pr_err("vesa__init() failed with error %ld\n", PTR_ERR(fb));
- goto fail;
- }
- }
-
- if (kvm->cfg.vnc && fb) {
- r = vnc__init(fb);
- if (r < 0) {
- pr_err("vnc__init() failed with error %d\n", r);
- goto fail;
- }
+ r = vnc__init(kvm);
+ if (r < 0) {
+ pr_err("vnc__init() failed with error %d\n", r);
+ goto fail;
}
- if (kvm->cfg.sdl && fb) {
- sdl__init(fb);
- if (r < 0) {
- pr_err("sdl__init() failed with error %d\n", r);
- goto fail;
- }
+ r = sdl__init(kvm);
+ if (r < 0) {
+ pr_err("sdl__init() failed with error %d\n", r);
+ goto fail;
}
r = fb__init(kvm);
struct framebuffer;
#ifdef CONFIG_HAS_SDL
-int sdl__init(struct framebuffer *fb);
-int sdl__exit(struct framebuffer *fb);
+int sdl__init(struct kvm *kvm);
+int sdl__exit(struct kvm *kvm);
#else
-static inline void sdl__init(struct framebuffer *fb)
+static inline void sdl__init(struct kvm *kvm)
{
die("SDL support not compiled in. (install the SDL-dev[el] package)");
}
-static inline void sdl__exit(struct framebuffer *fb)
+static inline void sdl__exit(struct kvm *kvm)
{
die("SDL support not compiled in. (install the SDL-dev[el] package)");
}
#ifndef KVM__VNC_H
#define KVM__VNC_H
+#include "kvm/kvm.h"
+
struct framebuffer;
#ifdef CONFIG_HAS_VNCSERVER
-int vnc__init(struct framebuffer *fb);
-int vnc__exit(struct framebuffer *fb);
+int vnc__init(struct kvm *kvm);
+int vnc__exit(struct kvm *kvm);
#else
-static inline int vnc__init(struct framebuffer *fb)
+static inline int vnc__init(struct kvm *kvm)
{
return 0;
}
-static inline int vnc__exit(struct framebuffer *fb)
+static inline int vnc__exit(struct kvm *kvm)
{
return 0;
}
#include "kvm/util.h"
#include "kvm/kvm.h"
#include "kvm/kvm-cpu.h"
+#include "kvm/vesa.h"
#include <SDL/SDL.h>
#include <pthread.h>
#include <signal.h>
+#include <linux/err.h>
#define FRAME_RATE 25
.stop = sdl__stop,
};
-int sdl__init(struct framebuffer *fb)
+int sdl__init(struct kvm *kvm)
{
+ struct framebuffer *fb;
+
+ if (!kvm->cfg.sdl)
+ return 0;
+
+ fb = vesa__init(kvm);
+ if (IS_ERR(fb)) {
+ pr_err("vesa__init() failed with error %ld\n", PTR_ERR(fb));
+ return PTR_ERR(fb);
+ }
+
return fb__attach(fb, &sdl_ops);
}
-int sdl__exit(struct framebuffer *fb)
+int sdl__exit(struct kvm *kvm)
{
- return sdl__stop(fb);
+ return sdl__stop(NULL);
}
#include "kvm/framebuffer.h"
#include "kvm/i8042.h"
+#include "kvm/vesa.h"
#include <linux/types.h>
#include <rfb/keysym.h>
#include <rfb/rfb.h>
#include <pthread.h>
+#include <linux/err.h>
#define VESA_QUEUE_SIZE 128
#define VESA_IRQ 14
.stop = vnc__stop,
};
-int vnc__init(struct framebuffer *fb)
+int vnc__init(struct kvm *kvm)
{
+ struct framebuffer *fb;
+
+ if (!kvm->cfg.vnc)
+ return 0;
+
+ fb = vesa__init(kvm);
+ if (IS_ERR(fb)) {
+ pr_err("vesa__init() failed with error %ld\n", PTR_ERR(fb));
+ return PTR_ERR(fb);
+ }
+
return fb__attach(fb, &vnc_ops);
}
-int vnc__exit(struct framebuffer *fb)
+int vnc__exit(struct kvm *kvm)
{
- return vnc__stop(fb);
-}
\ No newline at end of file
+ return vnc__stop(NULL);
+}