]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm: Fix kernel loading error messages
authorPekka Enberg <penberg@kernel.org>
Sun, 29 Aug 2010 14:11:17 +0000 (17:11 +0300)
committerPekka Enberg <penberg@kernel.org>
Sun, 29 Aug 2010 14:11:17 +0000 (17:11 +0300)
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>
tools/kvm/kvm.c

index 4174c28c6eed9c9493f5910b4a35ba58bcfb31f3..38f6a7a4faadcb8a993b3022ba6497405db26254 100644 (file)
@@ -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;