[PATCH 03/14] x86: allow pipes for bzImage kernel images

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Streamline the x86 kernel loading implementation by removing unneeded
seeks and thus allow an x86 bzImage to be loaded from a pipe.
"Flat binaries" are taken care of in a separate patch.

Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx>
---
 x86/kvm.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/x86/kvm.c b/x86/kvm.c
index a0204b8..8fe5585 100644
--- a/x86/kvm.c
+++ b/x86/kvm.c
@@ -245,9 +245,6 @@ static bool load_bzimage(struct kvm *kvm, int fd_kernel, int fd_initrd,
 	 * memory layout.
 	 */
 
-	if (lseek(fd_kernel, 0, SEEK_SET) < 0)
-		die_perror("lseek");
-
 	if (read(fd_kernel, &boot, sizeof(boot)) != sizeof(boot))
 		return false;
 
@@ -257,9 +254,6 @@ static bool load_bzimage(struct kvm *kvm, int fd_kernel, int fd_initrd,
 	if (boot.hdr.version < BOOT_PROTOCOL_REQUIRED)
 		die("Too old kernel");
 
-	if (lseek(fd_kernel, 0, SEEK_SET) < 0)
-		die_perror("lseek");
-
 	if (!boot.hdr.setup_sects)
 		boot.hdr.setup_sects = BZ_DEFAULT_SETUP_SECTS;
 	setup_sects = boot.hdr.setup_sects + 1;
@@ -267,7 +261,10 @@ static bool load_bzimage(struct kvm *kvm, int fd_kernel, int fd_initrd,
 	setup_size = setup_sects << 9;
 	p = guest_real_to_host(kvm, BOOT_LOADER_SELECTOR, BOOT_LOADER_IP);
 
-	/* copy setup.bin to mem*/
+	/* copy setup.bin to mem */
+	memcpy(p, &boot, sizeof(boot));
+	p += sizeof(boot);
+	setup_size -= sizeof(boot);
 	if (read(fd_kernel, p, setup_size) != setup_size)
 		die_perror("read");
 
-- 
2.3.5

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux