mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-09-04 04:31:27 +00:00
kvm: Fix kernel loading error messages
This patch fixes kernel loading error messages. We expect users to try to load bzImage most of the time and. However, if the user passes a binary that's not a bzImage, lets just print out the following warning: Warning: vmlinux is not a bzImage. Trying to load it as a flat binary... and pass the control to the binary. Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:
committed by
Will Deacon
parent
537d428a53
commit
0b62d2bb6a
@@ -299,19 +299,14 @@ static bool load_bzimage(struct kvm *self, int fd_kernel,
|
||||
if (lseek(fd_kernel, 0, SEEK_SET) < 0)
|
||||
die_perror("lseek");
|
||||
|
||||
if (read(fd_kernel, &boot, sizeof(boot)) != sizeof(boot)) {
|
||||
warning("Failed to read kernel boot area");
|
||||
if (read(fd_kernel, &boot, sizeof(boot)) != sizeof(boot))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (memcmp(&boot.hdr.header, BZIMAGE_MAGIC, strlen(BZIMAGE_MAGIC))) {
|
||||
warning("Kernel header corrupted");
|
||||
if (memcmp(&boot.hdr.header, BZIMAGE_MAGIC, strlen(BZIMAGE_MAGIC)))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (boot.hdr.version < BOOT_PROTOCOL_REQUIRED) {
|
||||
warning("Too old kernel");
|
||||
return false;
|
||||
die("Too old kernel");
|
||||
}
|
||||
|
||||
if (lseek(fd_kernel, 0, SEEK_SET) < 0)
|
||||
@@ -403,18 +398,20 @@ bool kvm__load_kernel(struct kvm *kvm, const char *kernel_filename,
|
||||
|
||||
fd_kernel = open(kernel_filename, O_RDONLY);
|
||||
if (fd_kernel < 0)
|
||||
die("unable to open kernel");
|
||||
die("Unable to open kernel %s", kernel_filename);
|
||||
|
||||
if (initrd_filename) {
|
||||
fd_initrd = open(initrd_filename, O_RDONLY);
|
||||
if (fd_initrd < 0)
|
||||
die("unable to open initrd");
|
||||
die("Unable to open initrd %s", initrd_filename);
|
||||
}
|
||||
|
||||
ret = load_bzimage(kvm, fd_kernel, fd_initrd, kernel_cmdline);
|
||||
if (ret)
|
||||
goto found_kernel;
|
||||
|
||||
warning("%s is not a bzImage. Trying to load it as a flat binary...", kernel_filename);
|
||||
|
||||
ret = load_flat_binary(kvm, fd_kernel);
|
||||
if (ret)
|
||||
goto found_kernel;
|
||||
|
||||
Reference in New Issue
Block a user