From patchwork Thu Jul 30 10:52:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 502075 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 9E51D140D21 for ; Thu, 30 Jul 2015 20:53:41 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752024AbbG3Kw2 (ORCPT ); Thu, 30 Jul 2015 06:52:28 -0400 Received: from foss.arm.com ([217.140.101.70]:40001 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754754AbbG3Kw1 (ORCPT ); Thu, 30 Jul 2015 06:52:27 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DF63D4F0; Thu, 30 Jul 2015 03:52:34 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.203.153]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F26A33F5C3; Thu, 30 Jul 2015 03:52:25 -0700 (PDT) From: Andre Przywara To: will.deacon@arm.com, kvm@vger.kernel.org Cc: marc.zyngier@arm.com, kvmarm@lists.cs.columbia.edu, kvm-ppc@vger.kernel.org Subject: [PATCH 02/14] arm/powerpc: remove unneeded seeks in kernel loading Date: Thu, 30 Jul 2015 11:52:19 +0100 Message-Id: <1438253551-2378-3-git-send-email-andre.przywara@arm.com> X-Mailer: git-send-email 2.3.5 In-Reply-To: <1438253551-2378-1-git-send-email-andre.przywara@arm.com> References: <1438253551-2378-1-git-send-email-andre.przywara@arm.com> Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org With the introduction of kvm__arch_load_kernel_image() we are sure that nobody peeks at the kernel image files before, so rewinding the file to its beginning is unnecessary. Remove those seeks in the arm and powerpc implementations. This allows to use a pipe instead of a regular file for the kernel image, enabling on-the-fly uncompression or downloading via the command line. $ lkvm run -k <(zcat zImage.gz) ... $ lkvm run -k <(wget -O - http://foo.com/guest.zImage) ... This is limited to the kernel images for the arm/arm64 and powerpc architectures for now, other architectures and initrds need more work. Signed-off-by: Andre Przywara --- arm/fdt.c | 3 --- powerpc/kvm.c | 3 --- 2 files changed, 6 deletions(-) diff --git a/arm/fdt.c b/arm/fdt.c index ec7453f..cb4f00d 100644 --- a/arm/fdt.c +++ b/arm/fdt.c @@ -245,9 +245,6 @@ bool kvm__arch_load_kernel_image(struct kvm *kvm, int fd_kernel, int fd_initrd, void *pos, *kernel_end, *limit; unsigned long guest_addr; - if (lseek(fd_kernel, 0, SEEK_SET) < 0) - die_perror("lseek"); - /* * Linux requires the initrd and dtb to be mapped inside lowmem, * so we can't just place them at the top of memory. diff --git a/powerpc/kvm.c b/powerpc/kvm.c index 13bba30..87d0f9e 100644 --- a/powerpc/kvm.c +++ b/powerpc/kvm.c @@ -165,9 +165,6 @@ bool kvm__arch_load_kernel_image(struct kvm *kvm, int fd_kernel, int fd_initrd, void *i_start; int nr; - if (lseek(fd_kernel, 0, SEEK_SET) < 0) - die_perror("lseek"); - p = k_start = guest_flat_to_host(kvm, KERNEL_LOAD_ADDR); while ((nr = read(fd_kernel, p, 65536)) > 0)