mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-06-15 18:05:49 +00:00
Merge branch 'upstream'
Signed-off-by: James Hunt <james.o.hunt@intel.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
/lkvm
|
||||
/lkvm-static
|
||||
/vm
|
||||
*.o
|
||||
*.d
|
||||
@@ -9,6 +10,7 @@ include/common-cmds.h
|
||||
tests/boot/boot_test.iso
|
||||
tests/boot/rootfs/
|
||||
guest/init
|
||||
guest/pre_init
|
||||
guest/init_stage2
|
||||
KVMTOOLS-VERSION-FILE
|
||||
/x86/bios/bios.bin
|
||||
|
||||
@@ -15,9 +15,7 @@ include config/utilities.mak
|
||||
include config/feature-tests.mak
|
||||
|
||||
CC := $(CROSS_COMPILE)gcc
|
||||
CFLAGS :=
|
||||
LD := $(CROSS_COMPILE)ld
|
||||
LDFLAGS :=
|
||||
|
||||
FIND := find
|
||||
CSCOPE := cscope
|
||||
@@ -110,6 +108,7 @@ endif
|
||||
ifeq ($(ARCH),x86_64)
|
||||
ARCH := x86
|
||||
DEFINES += -DCONFIG_X86_64
|
||||
ARCH_PRE_INIT = x86/init.S
|
||||
endif
|
||||
|
||||
### Arch-specific stuff
|
||||
@@ -161,7 +160,7 @@ ifeq ($(ARCH), arm)
|
||||
OBJS += arm/aarch32/kvm-cpu.o
|
||||
ARCH_INCLUDE := $(HDRS_ARM_COMMON)
|
||||
ARCH_INCLUDE += -Iarm/aarch32/include
|
||||
CFLAGS += -march=armv7-a
|
||||
override CFLAGS += -march=armv7-a
|
||||
|
||||
ARCH_WANT_LIBFDT := y
|
||||
endif
|
||||
@@ -197,12 +196,12 @@ endif
|
||||
# On a given system, some libs may link statically, some may not; so, check
|
||||
# both and only build those that link!
|
||||
|
||||
ifeq ($(call try-build,$(SOURCE_STRLCPY),$(CFLAGS),),y)
|
||||
ifeq ($(call try-build,$(SOURCE_STRLCPY),$(CFLAGS),$(LDFLAGS)),y)
|
||||
CFLAGS_DYNOPT += -DHAVE_STRLCPY
|
||||
CFLAGS_STATOPT += -DHAVE_STRLCPY
|
||||
endif
|
||||
|
||||
ifeq ($(call try-build,$(SOURCE_BFD),$(CFLAGS),-lbfd -static),y)
|
||||
ifeq ($(call try-build,$(SOURCE_BFD),$(CFLAGS),$(LDFLAGS) -lbfd -static),y)
|
||||
CFLAGS_STATOPT += -DCONFIG_HAS_BFD
|
||||
OBJS_STATOPT += symbol.o
|
||||
LIBS_STATOPT += -lbfd
|
||||
@@ -213,7 +212,7 @@ endif
|
||||
ifeq (y,$(ARCH_HAS_FRAMEBUFFER))
|
||||
CFLAGS_GTK3 := $(shell pkg-config --cflags gtk+-3.0 2>/dev/null)
|
||||
LDFLAGS_GTK3 := $(shell pkg-config --libs gtk+-3.0 2>/dev/null)
|
||||
ifeq ($(call try-build,$(SOURCE_GTK3),$(CFLAGS) $(CFLAGS_GTK3),$(LDFLAGS_GTK3)),y)
|
||||
ifeq ($(call try-build,$(SOURCE_GTK3),$(CFLAGS) $(CFLAGS_GTK3),$(LDFLAGS) $(LDFLAGS_GTK3)),y)
|
||||
OBJS_DYNOPT += ui/gtk3.o
|
||||
CFLAGS_DYNOPT += -DCONFIG_HAS_GTK3 $(CFLAGS_GTK3)
|
||||
LIBS_DYNOPT += $(LDFLAGS_GTK3)
|
||||
@@ -221,67 +220,74 @@ ifeq (y,$(ARCH_HAS_FRAMEBUFFER))
|
||||
NOTFOUND += GTK3
|
||||
endif
|
||||
|
||||
ifeq ($(call try-build,$(SOURCE_VNCSERVER),$(CFLAGS),-lvncserver),y)
|
||||
ifeq ($(call try-build,$(SOURCE_VNCSERVER),$(CFLAGS),$(LDFLAGS) -lvncserver),y)
|
||||
OBJS_DYNOPT += ui/vnc.o
|
||||
CFLAGS_DYNOPT += -DCONFIG_HAS_VNCSERVER
|
||||
LIBS_DYNOPT += -lvncserver
|
||||
else
|
||||
NOTFOUND += vncserver
|
||||
endif
|
||||
ifeq ($(call try-build,$(SOURCE_VNCSERVER),$(CFLAGS),-lvncserver -static),y)
|
||||
ifeq ($(call try-build,$(SOURCE_VNCSERVER),$(CFLAGS),$(LDFLAGS) -lvncserver -static),y)
|
||||
OBJS_STATOPT += ui/vnc.o
|
||||
CFLAGS_STATOPT += -DCONFIG_HAS_VNCSERVER
|
||||
LIBS_STATOPT += -lvncserver
|
||||
endif
|
||||
|
||||
ifeq ($(call try-build,$(SOURCE_SDL),$(CFLAGS),-lSDL),y)
|
||||
ifeq ($(call try-build,$(SOURCE_SDL),$(CFLAGS),$(LDFLAGS) -lSDL),y)
|
||||
OBJS_DYNOPT += ui/sdl.o
|
||||
CFLAGS_DYNOPT += -DCONFIG_HAS_SDL
|
||||
LIBS_DYNOPT += -lSDL
|
||||
else
|
||||
NOTFOUND += SDL
|
||||
endif
|
||||
ifeq ($(call try-build,$(SOURCE_SDL),$(CFLAGS),-lSDL -static), y)
|
||||
ifeq ($(call try-build,$(SOURCE_SDL),$(CFLAGS),$(LDFLAGS) -lSDL -static), y)
|
||||
OBJS_STATOPT += ui/sdl.o
|
||||
CFLAGS_STATOPT += -DCONFIG_HAS_SDL
|
||||
LIBS_STATOPT += -lSDL
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(call try-build,$(SOURCE_ZLIB),$(CFLAGS),-lz),y)
|
||||
ifeq ($(call try-build,$(SOURCE_ZLIB),$(CFLAGS),$(LDFLAGS) -lz),y)
|
||||
CFLAGS_DYNOPT += -DCONFIG_HAS_ZLIB
|
||||
LIBS_DYNOPT += -lz
|
||||
else
|
||||
NOTFOUND += zlib
|
||||
endif
|
||||
ifeq ($(call try-build,$(SOURCE_ZLIB),$(CFLAGS),-lz -static),y)
|
||||
ifeq ($(call try-build,$(SOURCE_ZLIB),$(CFLAGS),$(LDFLAGS) -lz -static),y)
|
||||
CFLAGS_STATOPT += -DCONFIG_HAS_ZLIB
|
||||
LIBS_STATOPT += -lz
|
||||
endif
|
||||
|
||||
ifeq ($(call try-build,$(SOURCE_AIO),$(CFLAGS),-laio),y)
|
||||
ifeq ($(call try-build,$(SOURCE_AIO),$(CFLAGS),$(LDFLAGS) -laio),y)
|
||||
CFLAGS_DYNOPT += -DCONFIG_HAS_AIO
|
||||
LIBS_DYNOPT += -laio
|
||||
else
|
||||
NOTFOUND += aio
|
||||
endif
|
||||
ifeq ($(call try-build,$(SOURCE_AIO),$(CFLAGS),-laio -static),y)
|
||||
ifeq ($(call try-build,$(SOURCE_AIO),$(CFLAGS),$(LDFLAGS) -laio -static),y)
|
||||
CFLAGS_STATOPT += -DCONFIG_HAS_AIO
|
||||
LIBS_STATOPT += -laio
|
||||
endif
|
||||
|
||||
ifeq ($(LTO),1)
|
||||
FLAGS_LTO := -flto
|
||||
ifeq ($(call try-build,$(SOURCE_HELLO),$(CFLAGS),$(FLAGS_LTO)),y)
|
||||
CFLAGS += $(FLAGS_LTO)
|
||||
ifeq ($(call try-build,$(SOURCE_HELLO),$(CFLAGS),$(LDFLAGS) $(FLAGS_LTO)),y)
|
||||
override CFLAGS += $(FLAGS_LTO)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(call try-build,$(SOURCE_STATIC),,-static),y)
|
||||
CFLAGS += -DCONFIG_GUEST_INIT
|
||||
CFLAGS += -DCONFIG_HAS_LIBC
|
||||
GUEST_INIT := guest/init
|
||||
GUEST_OBJS = guest/guest_init.o
|
||||
ifeq ($(call try-build,$(SOURCE_STATIC),$(CFLAGS),$(LDFLAGS) -static),y)
|
||||
override CFLAGS += -DCONFIG_GUEST_INIT
|
||||
GUEST_INIT := guest/init
|
||||
GUEST_OBJS = guest/guest_init.o
|
||||
ifeq ($(ARCH_PRE_INIT),)
|
||||
GUEST_INIT_FLAGS += -static
|
||||
else
|
||||
CFLAGS += -DCONFIG_GUEST_PRE_INIT
|
||||
GUEST_INIT_FLAGS += -DCONFIG_GUEST_PRE_INIT
|
||||
GUEST_PRE_INIT := guest/pre_init
|
||||
GUEST_OBJS += guest/guest_pre_init.o
|
||||
endif
|
||||
else
|
||||
$(warning No static libc found. Skipping guest init)
|
||||
NOTFOUND += static-libc
|
||||
@@ -325,7 +331,8 @@ DEFINES += -DKVMTOOLS_VERSION='"$(KVMTOOLS_VERSION)"'
|
||||
DEFINES += -DBUILD_ARCH='"$(ARCH)"'
|
||||
|
||||
KVM_INCLUDE := include
|
||||
CFLAGS += $(CPPFLAGS) $(DEFINES) -I$(KVM_INCLUDE) -I$(ARCH_INCLUDE) -O2 -fno-strict-aliasing -g
|
||||
override CFLAGS += $(CPPFLAGS) $(DEFINES) -I$(KVM_INCLUDE) -I$(ARCH_INCLUDE)
|
||||
override CFLAGS += -O2 -fno-strict-aliasing -g
|
||||
|
||||
WARNINGS += -Wall
|
||||
WARNINGS += -Wformat=2
|
||||
@@ -343,13 +350,13 @@ WARNINGS += -Wvolatile-register-var
|
||||
WARNINGS += -Wwrite-strings
|
||||
WARNINGS += -Wno-format-nonliteral
|
||||
|
||||
CFLAGS += $(WARNINGS)
|
||||
override CFLAGS += $(WARNINGS)
|
||||
|
||||
ifneq ($(WERROR),0)
|
||||
CFLAGS += -Werror
|
||||
override CFLAGS += -Werror
|
||||
endif
|
||||
|
||||
all: $(PROGRAM) $(PROGRAM_ALIAS) $(GUEST_INIT)
|
||||
all: $(PROGRAM) $(PROGRAM_ALIAS) $(GUEST_INIT) $(GUEST_PRE_INIT)
|
||||
|
||||
# CFLAGS used when building objects
|
||||
# This is intentionally not assigned using :=
|
||||
@@ -363,24 +370,28 @@ c_flags = -Wp,-MD,$(depfile) $(CFLAGS)
|
||||
#
|
||||
STATIC_OBJS = $(patsubst %.o,%.static.o,$(OBJS) $(OBJS_STATOPT))
|
||||
|
||||
STATIC_DEPS := $(foreach obj,$(STATIC_OBJS),\
|
||||
$(subst $(comma),_,$(dir $(obj)).$(notdir $(obj)).d))
|
||||
|
||||
$(PROGRAM)-static: $(STATIC_OBJS) $(OTHEROBJS) $(GUEST_INIT)
|
||||
$(PROGRAM)-static: $(STATIC_OBJS) $(OTHEROBJS) $(GUEST_INIT) $(GUEST_PRE_INIT)
|
||||
$(E) " LINK " $@
|
||||
$(Q) $(CC) -static $(CFLAGS) $(STATIC_OBJS) $(OTHEROBJS) $(GUEST_OBJS) $(LIBS) $(LIBS_STATOPT) -o $@
|
||||
$(Q) $(CC) -static $(CFLAGS) $(STATIC_OBJS) $(OTHEROBJS) $(GUEST_OBJS) $(LDFLAGS) $(LIBS) $(LIBS_STATOPT) -o $@
|
||||
|
||||
$(PROGRAM): $(OBJS) $(OBJS_DYNOPT) $(OTHEROBJS) $(GUEST_INIT)
|
||||
$(PROGRAM): $(OBJS) $(OBJS_DYNOPT) $(OTHEROBJS) $(GUEST_INIT) $(GUEST_PRE_INIT)
|
||||
$(E) " LINK " $@
|
||||
$(Q) $(CC) $(CFLAGS) $(OBJS) $(OBJS_DYNOPT) $(OTHEROBJS) $(GUEST_OBJS) $(LIBS) $(LIBS_DYNOPT) -o $@
|
||||
$(Q) $(CC) $(CFLAGS) $(OBJS) $(OBJS_DYNOPT) $(OTHEROBJS) $(GUEST_OBJS) $(LDFLAGS) $(LIBS) $(LIBS_DYNOPT) -o $@
|
||||
|
||||
$(PROGRAM_ALIAS): $(PROGRAM)
|
||||
$(E) " LN " $@
|
||||
$(Q) ln -f $(PROGRAM) $@
|
||||
|
||||
ifneq ($(ARCH_PRE_INIT),)
|
||||
$(GUEST_PRE_INIT): $(ARCH_PRE_INIT)
|
||||
$(E) " LINK " $@
|
||||
$(Q) $(CC) -s -nostdlib $(ARCH_PRE_INIT) -o $@
|
||||
$(Q) $(LD) $(LDFLAGS) -r -b binary -o guest/guest_pre_init.o $(GUEST_PRE_INIT)
|
||||
endif
|
||||
|
||||
$(GUEST_INIT): guest/init.c
|
||||
$(E) " LINK " $@
|
||||
$(Q) $(CC) -static guest/init.c -o $@
|
||||
$(Q) $(CC) $(GUEST_INIT_FLAGS) guest/init.c -o $@
|
||||
$(Q) $(LD) $(LDFLAGS) -r -b binary -o guest/guest_init.o $(GUEST_INIT)
|
||||
|
||||
%.s: %.c
|
||||
@@ -479,7 +490,7 @@ clean:
|
||||
$(Q) rm -f x86/bios/bios-rom.h
|
||||
$(Q) rm -f tests/boot/boot_test.iso
|
||||
$(Q) rm -rf tests/boot/rootfs/
|
||||
$(Q) rm -f $(DEPS) $(STATIC_DEPS) $(OBJS) $(OTHEROBJS) $(OBJS_DYNOPT) $(STATIC_OBJS) $(PROGRAM) $(PROGRAM_ALIAS) $(PROGRAM)-static $(GUEST_INIT) $(GUEST_OBJS)
|
||||
$(Q) rm -f $(DEPS) $(OBJS) $(OTHEROBJS) $(OBJS_DYNOPT) $(STATIC_OBJS) $(PROGRAM) $(PROGRAM_ALIAS) $(PROGRAM)-static $(GUEST_INIT) $(GUEST_PRE_INIT) $(GUEST_OBJS)
|
||||
$(Q) rm -f cscope.*
|
||||
$(Q) rm -f tags
|
||||
$(Q) rm -f TAGS
|
||||
|
||||
@@ -97,6 +97,9 @@ project:
|
||||
|
||||
http://thread.gmane.org/gmane.linux.kernel/962051/focus=962620
|
||||
|
||||
Another detailed example can be found in the lwn.net article:
|
||||
|
||||
http://lwn.net/Articles/658511/
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
+11
-16
@@ -59,14 +59,6 @@ static int kvm_run_wrapper;
|
||||
|
||||
bool do_debug_print = false;
|
||||
|
||||
#ifdef CONFIG_HAS_LIBC
|
||||
extern char _binary_guest_init_start;
|
||||
extern char _binary_guest_init_size;
|
||||
#else
|
||||
static char _binary_guest_init_start=0;
|
||||
static char _binary_guest_init_size=0;
|
||||
#endif
|
||||
|
||||
static const char * const run_usage[] = {
|
||||
"lkvm run [<options>] [<kernel image>]",
|
||||
NULL
|
||||
@@ -575,12 +567,6 @@ static struct kvm *kvm_cmd_run_init(int argc, const char **argv)
|
||||
memset(real_cmdline, 0, sizeof(real_cmdline));
|
||||
kvm__arch_set_cmdline(real_cmdline, kvm->cfg.vnc || kvm->cfg.sdl || kvm->cfg.gtk);
|
||||
|
||||
if (strlen(real_cmdline) > 0)
|
||||
strcat(real_cmdline, " ");
|
||||
|
||||
if (kvm->cfg.kernel_cmdline)
|
||||
strlcat(real_cmdline, kvm->cfg.kernel_cmdline, sizeof(real_cmdline));
|
||||
|
||||
if (!kvm->cfg.guest_name) {
|
||||
if (kvm->cfg.custom_rootfs) {
|
||||
kvm->cfg.guest_name = kvm->cfg.custom_rootfs_name;
|
||||
@@ -605,21 +591,30 @@ static struct kvm *kvm_cmd_run_init(int argc, const char **argv)
|
||||
}
|
||||
|
||||
if (kvm->cfg.using_rootfs) {
|
||||
strcat(real_cmdline, " root=/dev/root rw rootflags=rw,trans=virtio,version=9p2000.L rootfstype=9p");
|
||||
strcat(real_cmdline, " rw rootflags=trans=virtio,version=9p2000.L,cache=loose rootfstype=9p");
|
||||
if (kvm->cfg.custom_rootfs) {
|
||||
kvm_run_set_sandbox(kvm);
|
||||
|
||||
#ifdef CONFIG_GUEST_PRE_INIT
|
||||
strcat(real_cmdline, " init=/virt/pre_init");
|
||||
#else
|
||||
strcat(real_cmdline, " init=/virt/init");
|
||||
#endif
|
||||
|
||||
if (!kvm->cfg.no_dhcp)
|
||||
strcat(real_cmdline, " ip=dhcp");
|
||||
if (kvm_setup_guest_init(kvm->cfg.custom_rootfs_name))
|
||||
die("Failed to setup init for guest.");
|
||||
}
|
||||
} else if (!strstr(real_cmdline, "root=")) {
|
||||
} else if (!kvm->cfg.kernel_cmdline || !strstr(kvm->cfg.kernel_cmdline, "root=")) {
|
||||
strlcat(real_cmdline, " root=/dev/vda rw ", sizeof(real_cmdline));
|
||||
}
|
||||
|
||||
if (kvm->cfg.kernel_cmdline) {
|
||||
strcat(real_cmdline, " ");
|
||||
strlcat(real_cmdline, kvm->cfg.kernel_cmdline, sizeof(real_cmdline));
|
||||
}
|
||||
|
||||
kvm->cfg.real_cmdline = real_cmdline;
|
||||
|
||||
if (do_debug_print) {
|
||||
|
||||
+33
-15
@@ -122,32 +122,50 @@ static const char *guestfs_symlinks[] = {
|
||||
};
|
||||
|
||||
#ifdef CONFIG_GUEST_INIT
|
||||
extern char _binary_guest_init_start;
|
||||
extern char _binary_guest_init_size;
|
||||
|
||||
int kvm_setup_guest_init(const char *guestfs_name)
|
||||
static int extract_file(const char *guestfs_name, const char *filename,
|
||||
const void *data, const void *_size)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
size_t size;
|
||||
int fd, ret;
|
||||
char *data;
|
||||
|
||||
if (!_binary_guest_init_size)
|
||||
die("Guest init not compiled");
|
||||
size = (size_t)&_binary_guest_init_size;
|
||||
data = (char *)&_binary_guest_init_start;
|
||||
snprintf(path, PATH_MAX, "%s%s/virt/init", kvm__get_dir(), guestfs_name);
|
||||
remove(path);
|
||||
fd = open(path, O_CREAT | O_WRONLY, 0755);
|
||||
if (fd < 0)
|
||||
snprintf(path, PATH_MAX, "%s%s/%s", kvm__get_dir(),
|
||||
guestfs_name, filename);
|
||||
|
||||
fd = open(path, O_EXCL | O_CREAT | O_WRONLY, 0755);
|
||||
if (fd < 0) {
|
||||
if (errno == EEXIST)
|
||||
return 0;
|
||||
die("Fail to setup %s", path);
|
||||
ret = xwrite(fd, data, size);
|
||||
}
|
||||
|
||||
ret = xwrite(fd, data, (size_t)_size);
|
||||
if (ret < 0)
|
||||
die("Fail to setup %s", path);
|
||||
close(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern char _binary_guest_init_start;
|
||||
extern char _binary_guest_init_size;
|
||||
extern char _binary_guest_pre_init_start;
|
||||
extern char _binary_guest_pre_init_size;
|
||||
|
||||
int kvm_setup_guest_init(const char *guestfs_name)
|
||||
{
|
||||
int err;
|
||||
|
||||
#ifdef CONFIG_GUEST_PRE_INIT
|
||||
err = extract_file(guestfs_name, "virt/pre_init",
|
||||
&_binary_guest_pre_init_start,
|
||||
&_binary_guest_pre_init_size);
|
||||
if (err)
|
||||
return err;
|
||||
#endif
|
||||
err = extract_file(guestfs_name, "virt/init",
|
||||
&_binary_guest_init_start,
|
||||
&_binary_guest_init_size);
|
||||
return err;
|
||||
}
|
||||
#else
|
||||
int kvm_setup_guest_init(const char *guestfs_name)
|
||||
|
||||
@@ -30,7 +30,9 @@ static int run_process_sandbox(char *filename)
|
||||
|
||||
static void do_mounts(void)
|
||||
{
|
||||
#ifndef CONFIG_GUEST_PRE_INIT
|
||||
mount("hostfs", "/host", "9p", MS_RDONLY, "trans=virtio,version=9p2000.L");
|
||||
#endif
|
||||
mount("", "/sys", "sysfs", 0, NULL);
|
||||
mount("proc", "/proc", "proc", 0, NULL);
|
||||
mount("devtmpfs", "/dev", "devtmpfs", 0, NULL);
|
||||
|
||||
@@ -18,9 +18,6 @@ int term_putc(char *addr, int cnt, int term);
|
||||
int term_getc(struct kvm *kvm, int term);
|
||||
|
||||
bool term_readable(int term);
|
||||
void term_set_tty(int term);
|
||||
int term_init(struct kvm *kvm);
|
||||
int term_exit(struct kvm *kvm);
|
||||
int tty_parser(const struct option *opt, const char *arg, int unset);
|
||||
|
||||
#endif /* KVM__TERM_H */
|
||||
|
||||
@@ -266,4 +266,4 @@ int kvm_cpu__exit(struct kvm *kvm)
|
||||
|
||||
return r;
|
||||
}
|
||||
late_exit(kvm_cpu__exit);
|
||||
core_exit(kvm_cpu__exit);
|
||||
|
||||
@@ -19,15 +19,16 @@
|
||||
|
||||
static struct termios orig_term;
|
||||
|
||||
int term_escape_char = 0x01; /* ctrl-a is used for escape */
|
||||
bool term_got_escape = false;
|
||||
|
||||
int term_fds[TERM_MAX_DEVS][2];
|
||||
static int term_fds[TERM_MAX_DEVS][2];
|
||||
|
||||
static pthread_t term_poll_thread;
|
||||
|
||||
/* ctrl-a is used for escape */
|
||||
#define term_escape_char 0x01
|
||||
|
||||
int term_getc(struct kvm *kvm, int term)
|
||||
{
|
||||
static bool term_got_escape = false;
|
||||
unsigned char c;
|
||||
|
||||
if (read_in_full(term_fds[term][TERM_FD_IN], &c, 1) < 0)
|
||||
@@ -137,7 +138,7 @@ static void term_sig_cleanup(int sig)
|
||||
raise(sig);
|
||||
}
|
||||
|
||||
void term_set_tty(int term)
|
||||
static void term_set_tty(int term)
|
||||
{
|
||||
struct termios orig_term;
|
||||
int master, slave;
|
||||
@@ -167,7 +168,7 @@ int tty_parser(const struct option *opt, const char *arg, int unset)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int term_init(struct kvm *kvm)
|
||||
static int term_init(struct kvm *kvm)
|
||||
{
|
||||
struct termios term;
|
||||
int i, r;
|
||||
@@ -204,7 +205,7 @@ int term_init(struct kvm *kvm)
|
||||
}
|
||||
dev_init(term_init);
|
||||
|
||||
int term_exit(struct kvm *kvm)
|
||||
static int term_exit(struct kvm *kvm)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
.data
|
||||
|
||||
.m_dev:
|
||||
.string "hostfs"
|
||||
.m_dir:
|
||||
.string "/host"
|
||||
.m_typ:
|
||||
.string "9p"
|
||||
.m_opt:
|
||||
.string "trans=virtio,version=9p2000.L"
|
||||
|
||||
.e_nam:
|
||||
.string "/virt/init"
|
||||
|
||||
.text
|
||||
.globl _start
|
||||
_start:
|
||||
|
||||
mov $165, %rax # __NR_mount
|
||||
mov $.m_dev, %rdi
|
||||
mov $.m_dir, %rsi
|
||||
mov $.m_typ, %rdx
|
||||
mov $1, %r10 # MS_RDONLY
|
||||
mov $.m_opt, %r8
|
||||
syscall
|
||||
|
||||
mov $59, %rax # __NR_execve
|
||||
mov $.e_nam, %rdi
|
||||
lea 8(%rsp), %rsi # argv[]
|
||||
mov %rdi, (%rsi) # change argv[0]
|
||||
pop %rcx # argc
|
||||
inc %rcx
|
||||
lea (%rsi,%rcx,8), %rdx # envp[]
|
||||
syscall
|
||||
|
||||
mov $60, %rax # __NR_exit
|
||||
mov $1, %rdi
|
||||
syscall # panic
|
||||
Reference in New Issue
Block a user