kvm tools: Allow to load ELF binary

Signed-off-by: Andreas Herrmann <andreas.herrmann@caviumnetworks.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:
Andreas Herrmann
2015-06-01 16:39:55 +01:00
committed by Will Deacon
parent 1d52535d9c
commit f9dee795b9
2 changed files with 12 additions and 0 deletions
+1
View File
@@ -109,6 +109,7 @@ void *guest_flat_to_host(struct kvm *kvm, u64 offset);
u64 host_to_guest_flat(struct kvm *kvm, void *ptr);
int load_flat_binary(struct kvm *kvm, int fd_kernel, int fd_initrd, const char *kernel_cmdline);
int load_elf_binary(struct kvm *kvm, int fd_kernel, int fd_initrd, const char *kernel_cmdline);
bool load_bzimage(struct kvm *kvm, int fd_kernel, int fd_initrd, const char *kernel_cmdline);
/*
+11
View File
@@ -349,6 +349,12 @@ static bool initrd_check(int fd)
!memcmp(id, CPIO_MAGIC, 4);
}
int __attribute__((__weak__)) load_elf_binary(struct kvm *kvm, int fd_kernel,
int fd_initrd, const char *kernel_cmdline)
{
return false;
}
bool kvm__load_kernel(struct kvm *kvm, const char *kernel_filename,
const char *initrd_filename, const char *kernel_cmdline)
{
@@ -375,6 +381,11 @@ bool kvm__load_kernel(struct kvm *kvm, const char *kernel_filename,
pr_warning("%s is not a bzImage. Trying to load it as a flat binary...", kernel_filename);
ret = load_elf_binary(kvm, fd_kernel, fd_initrd, kernel_cmdline);
if (ret)
goto found_kernel;
ret = load_flat_binary(kvm, fd_kernel, fd_initrd, kernel_cmdline);
if (ret)