kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pekka Enberg <penberg@kernel.org>
To: Matt Evans <matt@ozlabs.org>
Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org,
	Asias He <asias.hejun@gmail.com>,
	Cyrill Gorcunov <gorcunov@gmail.com>, Ingo Molnar <mingo@elte.hu>,
	Sasha Levin <levinsasha928@gmail.com>
Subject: Re: [PATCH 16/28] kvm tools: Allow load_flat_binary() to load an initrd alongside
Date: Tue, 6 Dec 2011 12:29:48 +0200	[thread overview]
Message-ID: <CAOJsxLEVcPgD4mXUqd2A24q-JSqaR6PYbNovdGtTovc2+sjOYQ@mail.gmail.com> (raw)
In-Reply-To: <4EDD8ED3.8010608@ozlabs.org>

On Tue, Dec 6, 2011 at 5:41 AM, Matt Evans <matt@ozlabs.org> wrote:
> This patch passes the initrd fd and commandline to load_flat_binary(), which may
> be used to load both the kernel & an initrd (stashing or inserting the
> commandline as appropriate) in the same way that load_bzimage() does.  This is
> especially useful when load_bzimage() is unused for a particular
> architecture. :-)
>
> Signed-off-by: Matt Evans <matt@ozlabs.org>
> ---
>  tools/kvm/include/kvm/kvm.h |    2 +-
>  tools/kvm/kvm.c             |   10 ++++++----
>  tools/kvm/x86/kvm.c         |   12 +++++++++---
>  3 files changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/tools/kvm/include/kvm/kvm.h b/tools/kvm/include/kvm/kvm.h
> index fae2ba9..5fe6e75 100644
> --- a/tools/kvm/include/kvm/kvm.h
> +++ b/tools/kvm/include/kvm/kvm.h
> @@ -59,7 +59,7 @@ void kvm__arch_setup_firmware(struct kvm *kvm);
>  bool kvm__arch_cpu_supports_vm(void);
>  void kvm__arch_periodic_poll(struct kvm *kvm);
>
> -int load_flat_binary(struct kvm *kvm, int fd);
> +int load_flat_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, u16 vidmode);
>
>  /*
> diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c
> index 457de1a..6f33e1a 100644
> --- a/tools/kvm/kvm.c
> +++ b/tools/kvm/kvm.c
> @@ -354,23 +354,25 @@ bool kvm__load_kernel(struct kvm *kvm, const char *kernel_filename,
>
>        ret = load_bzimage(kvm, fd_kernel, fd_initrd, kernel_cmdline, vidmode);
>
> -       if (initrd_filename)
> -               close(fd_initrd);
> -
>        if (ret)
>                goto found_kernel;
>
>        pr_warning("%s is not a bzImage. Trying to load it as a flat binary...", kernel_filename);
>
> -       ret = load_flat_binary(kvm, fd_kernel);
> +       ret = load_flat_binary(kvm, fd_kernel, fd_initrd, kernel_cmdline);
> +
>        if (ret)
>                goto found_kernel;
>
> +       if (initrd_filename)
> +               close(fd_initrd);
>        close(fd_kernel);
>
>        die("%s is not a valid bzImage or flat binary", kernel_filename);
>
>  found_kernel:
> +       if (initrd_filename)
> +               close(fd_initrd);
>        close(fd_kernel);
>
>        return ret;
> diff --git a/tools/kvm/x86/kvm.c b/tools/kvm/x86/kvm.c
> index 7071dc6..4ac21c0 100644
> --- a/tools/kvm/x86/kvm.c
> +++ b/tools/kvm/x86/kvm.c
> @@ -227,17 +227,23 @@ void kvm__irq_trigger(struct kvm *kvm, int irq)
>  #define BOOT_PROTOCOL_REQUIRED 0x206
>  #define LOAD_HIGH              0x01
>
> -int load_flat_binary(struct kvm *kvm, int fd)
> +int load_flat_binary(struct kvm *kvm, int fd_kernel, int fd_initrd, const char *kernel_cmdline)
>  {
>        void *p;
>        int nr;
>
> -       if (lseek(fd, 0, SEEK_SET) < 0)
> +       /* Some architectures may support loading an initrd alongside the flat kernel,
> +        * but we do not.
> +        */

Minor nit - we use comment format where the first line is left empty from text:

       /*
        * Some architectures may support loading an initrd alongside
the flat kernel,
        * but we do not.
        */

> +       if (fd_initrd != -1)
> +               pr_warning("Loading initrd with flat binary not supported.");
> +
> +       if (lseek(fd_kernel, 0, SEEK_SET) < 0)
>                die_perror("lseek");
>
>        p = guest_real_to_host(kvm, BOOT_LOADER_SELECTOR, BOOT_LOADER_IP);
>
> -       while ((nr = read(fd, p, 65536)) > 0)
> +       while ((nr = read(fd_kernel, p, 65536)) > 0)
>                p += nr;
>
>        kvm->boot_selector      = BOOT_LOADER_SELECTOR;
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Otherwise looks OK to me. Cyrill?

  reply	other threads:[~2011-12-06 10:29 UTC|newest]

Thread overview: 105+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1323141075.git.matt@ozlabs.org>
2011-12-06  3:37 ` [PATCH 01/28] kvm tools: Split x86 arch-specific bits into x86/ Matt Evans
2011-12-06  8:07   ` Sasha Levin
2011-12-06 10:10     ` Pekka Enberg
2011-12-06  3:37 ` [PATCH 02/28] kvm tools: Only build/init i8042 on x86 Matt Evans
2011-12-06  8:11   ` Sasha Levin
2011-12-06 18:59   ` Scott Wood
2011-12-07  7:39     ` Matt Evans
2011-12-06  3:37 ` [PATCH 03/28] kvm tools: Add Makefile parameter for kernel include path Matt Evans
2011-12-06  3:38 ` [PATCH 04/28] kvm tools: Re-arrange Makefile to heed CFLAGS before checking for optional libs Matt Evans
2011-12-06  3:38 ` [PATCH 05/28] kvm tools: 64-bit tidy; use PRIx64 when printf'ing u64s and link appropriately Matt Evans
2011-12-06  8:13   ` Sasha Levin
2011-12-06  8:28     ` Ingo Molnar
2011-12-06 10:05       ` Paul Mackerras
2011-12-06 10:24         ` Ingo Molnar
2011-12-07  7:01           ` Matt Evans
2011-12-07  8:16             ` Ingo Molnar
2011-12-07 12:49               ` Paolo Bonzini
2011-12-07 17:21                 ` Pekka Enberg
2011-12-07 17:14               ` Pekka Enberg
2011-12-08  3:14                 ` Matt Evans
2011-12-08  4:49                   ` Ingo Molnar
2011-12-08  4:56                     ` Matt Evans
2011-12-08  5:47                       ` Matt Evans
2011-12-08  5:49                         ` Ingo Molnar
2011-12-08  6:17                           ` Matt Evans
2011-12-06  3:39 ` [PATCH 06/28] kvm tools: Add arch-specific KVM_RUN exit handling via kvm_cpu__handle_exit() Matt Evans
2011-12-06  3:39 ` [PATCH 07/28] kvm tools: Move 'kvm__recommended_cpus' to arch-specific code Matt Evans
2011-12-06  8:20   ` Sasha Levin
2011-12-07  6:17     ` Matt Evans
2011-12-07  6:34       ` Sasha Levin
2011-12-07  7:19         ` Matt Evans
2011-12-07  7:24           ` Alexander Graf
2011-12-07  7:28             ` Matt Evans
2011-12-07  8:29               ` Sasha Levin
2011-12-07 14:11                 ` Avi Kivity
2011-12-07 14:22                   ` Sasha Levin
2011-12-07 14:25                     ` Avi Kivity
2011-12-07 15:00                       ` Alexander Graf
2011-12-07 15:25                         ` Sasha Levin
2011-12-07 15:58                           ` Alexander Graf
2011-12-20 15:23                 ` Alexander Graf
2011-12-21 22:17                   ` Paul Mackerras
2011-12-23 14:05                     ` Alexander Graf
2011-12-20 15:20           ` Alexander Graf
2011-12-06  3:39 ` [PATCH 08/28] kvm tools: Fix KVM_RUN exit code check Matt Evans
2011-12-06  8:22   ` Sasha Levin
2011-12-07  0:32     ` Matt Evans
2011-12-07  6:44       ` Alexander Graf
2011-12-07 14:12         ` Avi Kivity
2011-12-07 15:01           ` Alexander Graf
2011-12-07 15:05             ` Avi Kivity
2011-12-08  3:03     ` Matt Evans
2011-12-08  5:31       ` Sasha Levin
2011-12-22 10:03         ` Avi Kivity
2011-12-22 10:18           ` Sasha Levin
2011-12-22 10:21             ` Avi Kivity
2011-12-22 10:34               ` Sasha Levin
2011-12-06  3:39 ` [PATCH 09/28] kvm tools: Add kvm__arch_periodic_poll() Matt Evans
2011-12-06  3:40 ` [PATCH 10/28] kvm tools: term.h needs to include stdbool.h Matt Evans
2011-12-06  3:40 ` [PATCH 11/28] kvm tools: kvm.c needs to include sys/stat.h for mkdir Matt Evans
2011-12-06  3:40 ` [PATCH 12/28] kvm tools: Move arch-specific cmdline init into kvm__arch_set_cmdline() Matt Evans
2011-12-06  3:40 ` [PATCH 13/28] kvm tools: Add CONSOLE_HV term type and allow it to be selected Matt Evans
2011-12-06  3:40 ` [PATCH 14/28] kvm tools: Fix term_getc(), term_getc_iov() endian bugs Matt Evans
2011-12-06 10:24   ` Pekka Enberg
2011-12-06 12:00     ` Asias He
2011-12-07  2:39       ` Matt Evans
2011-12-06  3:40 ` [PATCH 15/28] kvm tools: Allow initrd_check() to match a cpio Matt Evans
2011-12-06 10:26   ` Pekka Enberg
2011-12-06  3:41 ` [PATCH 16/28] kvm tools: Allow load_flat_binary() to load an initrd alongside Matt Evans
2011-12-06 10:29   ` Pekka Enberg [this message]
2011-12-06 12:04     ` Cyrill Gorcunov
2011-12-07  0:42       ` Matt Evans
2011-12-07  6:33         ` Cyrill Gorcunov
2011-12-06  3:41 ` [PATCH 17/28] kvm tools: Only call symbol__init() if we have BFD Matt Evans
2011-12-06  8:26   ` Sasha Levin
2011-12-07  3:03     ` Matt Evans
2011-12-06  3:41 ` [PATCH 18/28] kvm tools: Initialise PCI before devices start getting registered with PCI Matt Evans
2011-12-06  3:41 ` [PATCH 19/28] kvm tools: Perform CPU and firmware setup after devices are added Matt Evans
2011-12-06  3:41 ` [PATCH 20/28] kvm tools: Init IRQs after determining nrcpus Matt Evans
2011-12-06  3:41 ` [PATCH 21/28] kvm tools: Add --hugetlbfs option to specify memory path Matt Evans
2011-12-06  8:32   ` Sasha Levin
2011-12-07  0:35     ` Matt Evans
2011-12-07  6:01       ` Sasha Levin
2011-12-06  3:42 ` [PATCH 22/28] kvm tools: Move PCI_MAX_DEVICES to pci.h Matt Evans
2011-12-06  3:42 ` [PATCH 23/28] kvm tools: Endian-sanitise pci.h and PCI device setup Matt Evans
2011-12-06 10:25   ` Pekka Enberg
2011-12-06 10:28     ` Cyrill Gorcunov
2011-12-06 11:41       ` Pekka Enberg
2011-12-06 11:47         ` Cyrill Gorcunov
2011-12-06 11:58           ` Pekka Enberg
2011-12-06 12:10             ` Cyrill Gorcunov
2011-12-06 13:29               ` Pekka Enberg
2011-12-06 13:38                 ` Cyrill Gorcunov
2011-12-07  2:58                   ` Matt Evans
2011-12-06  3:42 ` [PATCH 24/28] kvm tools: Fix virtio-pci endian bug when reading VIRTIO_PCI_QUEUE_NUM Matt Evans
2011-12-06 10:26   ` Pekka Enberg
2011-12-06 11:28     ` Asias He
2011-12-06 11:39       ` Pekka Enberg
2011-12-06 13:15     ` Sasha Levin
2011-12-06  3:42 ` [PATCH 25/28] kvm tools: Correctly set virtio-pci bar_size and remove hardwired address Matt Evans
2011-12-06  3:42 ` [PATCH 26/28] kvm tools: Add pci__config_{rd,wr}(), pci__find_dev() and fix PCI config register addressing Matt Evans
2011-12-06  3:43 ` [PATCH 27/28] kvm tools: Arch-specific define for PCI MMIO allocation area Matt Evans
2011-12-06  3:43 ` [PATCH 28/28] kvm tools: Create arch-specific kvm_cpu__emulate_io() Matt Evans
2011-12-06  8:54   ` Sasha Levin
2011-12-07  6:36     ` Matt Evans

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOJsxLEVcPgD4mXUqd2A24q-JSqaR6PYbNovdGtTovc2+sjOYQ@mail.gmail.com \
    --to=penberg@kernel.org \
    --cc=asias.hejun@gmail.com \
    --cc=gorcunov@gmail.com \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=levinsasha928@gmail.com \
    --cc=matt@ozlabs.org \
    --cc=mingo@elte.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).