All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/4] arm: add device tree support (via machine opts)
@ 2012-02-08  5:41 Peter Maydell
  2012-02-08  5:41 ` [Qemu-devel] [PATCH 1/4] qemu-option: Add support for merged QemuOptsLists Peter Maydell
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Peter Maydell @ 2012-02-08  5:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: Grant Likely, Anthony Liguori, Alexander Graf, patches

This patch series is basically Grant's v2 "arm: add device tree support"
patch (http://patchwork.ozlabs.org/patch/138883/) rearranged to use
qemu -machine options rather than a global to pass through the device
tree blob filename. This is based on a suggestion by Anthony in IRC;
I'm a bit sceptical myself, but anyway here's the code...

Patches 1 and 2 are pure bugfixes to the existing -machine handling
and should be applied anyway IMHO: they fix a bug where only the last
of any "-enable-kvm" and "-machine foo=bar" options have effect.

Differences between Grant's v2 and this:
 * use -machine options rather than a global
 * patch 1/2 bug fixes
 * some rearrangement/cleanup of arm_load_kernel() code

Grant Likely (1):
  arm: add device tree support

Peter Maydell (3):
  qemu-option: Add support for merged QemuOptsLists
  Make -machine/-enable-kvm options merge into a single list
  Make kernel, initrd and append be machine_opts

 Makefile.target |    1 +
 configure       |    1 +
 hw/arm-misc.h   |    1 +
 hw/arm_boot.c   |   96 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 qemu-config.c   |   17 ++++++++++
 qemu-option.c   |    7 +++-
 qemu-option.h   |    1 +
 qemu-options.hx |    9 +++++
 vl.c            |   35 ++++++++++++++------
 9 files changed, 151 insertions(+), 17 deletions(-)

-- 
1.7.5.4

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 1/4] qemu-option: Add support for merged QemuOptsLists
  2012-02-08  5:41 [Qemu-devel] [PATCH 0/4] arm: add device tree support (via machine opts) Peter Maydell
@ 2012-02-08  5:41 ` Peter Maydell
  2012-02-08  5:41 ` [Qemu-devel] [PATCH 2/4] Make -machine/-enable-kvm options merge into a single list Peter Maydell
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Peter Maydell @ 2012-02-08  5:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: Grant Likely, Anthony Liguori, Alexander Graf, patches

Add support for option lists which are merged together, so that
"-listname foo=bar -listname bar=baz" is equivalent to "-listname
foo=bar,bar=baz" rather than generating two separate lists of options.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 qemu-option.c |    7 ++++++-
 qemu-option.h |    1 +
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/qemu-option.c b/qemu-option.c
index 4626ccf..35cd609 100644
--- a/qemu-option.c
+++ b/qemu-option.c
@@ -741,13 +741,18 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, int fail_if_exist
         }
         opts = qemu_opts_find(list, id);
         if (opts != NULL) {
-            if (fail_if_exists) {
+            if (fail_if_exists && !list->merge_lists) {
                 qerror_report(QERR_DUPLICATE_ID, id, list->name);
                 return NULL;
             } else {
                 return opts;
             }
         }
+    } else if (list->merge_lists) {
+        opts = qemu_opts_find(list, NULL);
+        if (opts) {
+            return opts;
+        }
     }
     opts = g_malloc0(sizeof(*opts));
     if (id) {
diff --git a/qemu-option.h b/qemu-option.h
index e6f61e6..3ca00c3 100644
--- a/qemu-option.h
+++ b/qemu-option.h
@@ -100,6 +100,7 @@ typedef struct QemuOptDesc {
 struct QemuOptsList {
     const char *name;
     const char *implied_opt_name;
+    bool merge_lists;  /* Merge multiple uses of option into a single list? */
     QTAILQ_HEAD(, QemuOpts) head;
     QemuOptDesc desc[];
 };
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 2/4] Make -machine/-enable-kvm options merge into a single list
  2012-02-08  5:41 [Qemu-devel] [PATCH 0/4] arm: add device tree support (via machine opts) Peter Maydell
  2012-02-08  5:41 ` [Qemu-devel] [PATCH 1/4] qemu-option: Add support for merged QemuOptsLists Peter Maydell
@ 2012-02-08  5:41 ` Peter Maydell
  2012-02-17  8:11   ` andrzej zaborowski
  2012-02-08  5:41 ` [Qemu-devel] [PATCH 3/4] Make kernel, initrd and append be machine_opts Peter Maydell
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Peter Maydell @ 2012-02-08  5:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: Grant Likely, Anthony Liguori, Alexander Graf, patches

Make the "machine" option list use list merging, so that multiple
-machine arguments (and the -enable-kvm argument) all merge together
into a single list. Drop the calls to qemu_opts_reset() which meant
that only the last -machine or -enable-kvm option had any effect.

This fixes the bug where "-enable-kvm -machine foo" would ignore
the '-enable-kvm' option, and "-machine foo -enable-kvm" would
ignore the '-machine foo' option.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 qemu-config.c |    1 +
 vl.c          |    2 --
 2 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/qemu-config.c b/qemu-config.c
index b030205..c938470 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -521,6 +521,7 @@ QemuOptsList qemu_option_rom_opts = {
 static QemuOptsList qemu_machine_opts = {
     .name = "machine",
     .implied_opt_name = "type",
+    .merge_lists = true,
     .head = QTAILQ_HEAD_INITIALIZER(qemu_machine_opts.head),
     .desc = {
         {
diff --git a/vl.c b/vl.c
index 63dd725..fe24ef8 100644
--- a/vl.c
+++ b/vl.c
@@ -2874,12 +2874,10 @@ int main(int argc, char **argv, char **envp)
                 break;
             case QEMU_OPTION_enable_kvm:
                 olist = qemu_find_opts("machine");
-                qemu_opts_reset(olist);
                 qemu_opts_parse(olist, "accel=kvm", 0);
                 break;
             case QEMU_OPTION_machine:
                 olist = qemu_find_opts("machine");
-                qemu_opts_reset(olist);
                 opts = qemu_opts_parse(olist, optarg, 1);
                 if (!opts) {
                     fprintf(stderr, "parse error: %s\n", optarg);
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 3/4] Make kernel, initrd and append be machine_opts
  2012-02-08  5:41 [Qemu-devel] [PATCH 0/4] arm: add device tree support (via machine opts) Peter Maydell
  2012-02-08  5:41 ` [Qemu-devel] [PATCH 1/4] qemu-option: Add support for merged QemuOptsLists Peter Maydell
  2012-02-08  5:41 ` [Qemu-devel] [PATCH 2/4] Make -machine/-enable-kvm options merge into a single list Peter Maydell
@ 2012-02-08  5:41 ` Peter Maydell
  2012-02-22 18:31   ` Anthony Liguori
  2012-02-08  5:41 ` [Qemu-devel] [PATCH 4/4] arm: add device tree support Peter Maydell
  2012-02-08  8:16 ` [Qemu-devel] [PATCH 0/4] arm: add device tree support (via machine opts) Peter Crosthwaite
  4 siblings, 1 reply; 10+ messages in thread
From: Peter Maydell @ 2012-02-08  5:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: Grant Likely, Anthony Liguori, Alexander Graf, patches

Make kernel, initrd, append be machine opts (ie -machine kernel=foo)
with the old plain command line arguments as legacy/convenience
equivalents.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 qemu-config.c |   12 ++++++++++++
 vl.c          |   24 ++++++++++++++++--------
 2 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/qemu-config.c b/qemu-config.c
index c938470..07480a4 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -536,6 +536,18 @@ static QemuOptsList qemu_machine_opts = {
             .name = "kernel_irqchip",
             .type = QEMU_OPT_BOOL,
             .help = "use KVM in-kernel irqchip",
+        }, {
+            .name = "kernel",
+            .type = QEMU_OPT_STRING,
+            .help = "Linux kernel image file",
+        }, {
+            .name = "initrd",
+            .type = QEMU_OPT_STRING,
+            .help = "Linux initial ramdisk file",
+        }, {
+            .name = "append",
+            .type = QEMU_OPT_STRING,
+            .help = "Linux kernel command line",
         },
         { /* End of list */ }
     },
diff --git a/vl.c b/vl.c
index fe24ef8..b8bb955 100644
--- a/vl.c
+++ b/vl.c
@@ -2238,11 +2238,8 @@ int main(int argc, char **argv, char **envp)
     module_call_init(MODULE_INIT_MACHINE);
     machine = find_default_machine();
     cpu_model = NULL;
-    initrd_filename = NULL;
     ram_size = 0;
     snapshot = 0;
-    kernel_filename = NULL;
-    kernel_cmdline = "";
     cyls = heads = secs = 0;
     translation = BIOS_ATA_TRANSLATION_AUTO;
 
@@ -2318,9 +2315,6 @@ int main(int argc, char **argv, char **envp)
                     cpu_model = optarg;
                 }
                 break;
-            case QEMU_OPTION_initrd:
-                initrd_filename = optarg;
-                break;
             case QEMU_OPTION_hda:
                 {
                     char buf[256];
@@ -2451,10 +2445,13 @@ int main(int argc, char **argv, char **envp)
                 }
                 break;
             case QEMU_OPTION_kernel:
-                kernel_filename = optarg;
+                qemu_opts_set(qemu_find_opts("machine"), 0, "kernel", optarg);
+                break;
+            case QEMU_OPTION_initrd:
+                qemu_opts_set(qemu_find_opts("machine"), 0, "initrd", optarg);
                 break;
             case QEMU_OPTION_append:
-                kernel_cmdline = optarg;
+                qemu_opts_set(qemu_find_opts("machine"), 0, "append", optarg);
                 break;
             case QEMU_OPTION_cdrom:
                 drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS);
@@ -3241,6 +3238,17 @@ int main(int argc, char **argv, char **envp)
         fprintf(stderr, "qemu_init_main_loop failed\n");
         exit(1);
     }
+
+    kernel_filename = qemu_opt_get(qemu_opts_find(qemu_find_opts("machine"),
+                                                  0), "kernel");
+    initrd_filename = qemu_opt_get(qemu_opts_find(qemu_find_opts("machine"),
+                                                  0), "initrd");
+    kernel_cmdline = qemu_opt_get(qemu_opts_find(qemu_find_opts("machine"),
+                                                 0), "append");
+    if (!kernel_cmdline) {
+        kernel_cmdline = "";
+    }
+
     linux_boot = (kernel_filename != NULL);
 
     if (!linux_boot && *kernel_cmdline != '\0') {
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 4/4] arm: add device tree support
  2012-02-08  5:41 [Qemu-devel] [PATCH 0/4] arm: add device tree support (via machine opts) Peter Maydell
                   ` (2 preceding siblings ...)
  2012-02-08  5:41 ` [Qemu-devel] [PATCH 3/4] Make kernel, initrd and append be machine_opts Peter Maydell
@ 2012-02-08  5:41 ` Peter Maydell
  2012-02-20 19:47   ` Peter Maydell
  2012-02-08  8:16 ` [Qemu-devel] [PATCH 0/4] arm: add device tree support (via machine opts) Peter Crosthwaite
  4 siblings, 1 reply; 10+ messages in thread
From: Peter Maydell @ 2012-02-08  5:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: Grant Likely, Anthony Liguori, Alexander Graf, patches

From: Grant Likely <grant.likely@secretlab.ca>

If compiled with CONFIG_FDT, allow user to specify a device tree file using
the -dtb argument.  If the machine supports it then the dtb will be loaded
into memory and passed to the kernel on boot.

Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
[Peter Maydell: Use machine opt rather than global to pass dtb filename]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 Makefile.target |    1 +
 configure       |    1 +
 hw/arm-misc.h   |    1 +
 hw/arm_boot.c   |   96 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 qemu-config.c   |    4 ++
 qemu-options.hx |    9 +++++
 vl.c            |    9 +++++
 7 files changed, 115 insertions(+), 6 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index 68481a3..5e465ec 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -363,6 +363,7 @@ obj-arm-y += vexpress.o
 obj-arm-y += strongarm.o
 obj-arm-y += collie.o
 obj-arm-y += pl041.o lm4549.o
+obj-arm-$(CONFIG_FDT) += device_tree.o
 
 obj-sh4-y = shix.o r2d.o sh7750.o sh7750_regnames.o tc58128.o
 obj-sh4-y += sh_timer.o sh_serial.o sh_intc.o sh_pci.o sm501.o
diff --git a/configure b/configure
index 763db24..1d8b3ac 100755
--- a/configure
+++ b/configure
@@ -3458,6 +3458,7 @@ case "$target_arch2" in
     gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
     target_phys_bits=32
     target_llong_alignment=4
+    target_libs_softmmu="$fdt_libs"
   ;;
   cris)
     target_nptl="yes"
diff --git a/hw/arm-misc.h b/hw/arm-misc.h
index 5e5204b..4b55fb8 100644
--- a/hw/arm-misc.h
+++ b/hw/arm-misc.h
@@ -29,6 +29,7 @@ struct arm_boot_info {
     const char *kernel_filename;
     const char *kernel_cmdline;
     const char *initrd_filename;
+    const char *dtb_filename;
     target_phys_addr_t loader_start;
     /* multicore boards that use the default secondary core boot functions
      * need to put the address of the secondary boot code, the boot reg,
diff --git a/hw/arm_boot.c b/hw/arm_boot.c
index 5f163fd..769fe2e 100644
--- a/hw/arm_boot.c
+++ b/hw/arm_boot.c
@@ -7,11 +7,14 @@
  * This code is licensed under the GPL.
  */
 
+#include "config.h"
 #include "hw.h"
 #include "arm-misc.h"
 #include "sysemu.h"
+#include "boards.h"
 #include "loader.h"
 #include "elf.h"
+#include "device_tree.h"
 
 #define KERNEL_ARGS_ADDR 0x100
 #define KERNEL_LOAD_ADDR 0x00010000
@@ -207,6 +210,67 @@ static void set_kernel_args_old(const struct arm_boot_info *info,
     }
 }
 
+static int load_dtb(target_phys_addr_t addr, const struct arm_boot_info *binfo)
+{
+#ifdef CONFIG_FDT
+    uint32_t mem_reg_property[] = { cpu_to_be32(binfo->loader_start),
+                                    cpu_to_be32(binfo->ram_size) };
+    void *fdt = NULL;
+    char *filename;
+    int size, rc;
+
+    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, binfo->dtb_filename);
+    if (!filename) {
+        fprintf(stderr, "Couldn't open dtb file %s\n", binfo->dtb_filename);
+        return -1;
+    }
+
+    fdt = load_device_tree(filename, &size);
+    if (!fdt) {
+        fprintf(stderr, "Couldn't open dtb file %s\n", filename);
+        g_free(filename);
+        return -1;
+    }
+    g_free(filename);
+
+    rc = qemu_devtree_setprop(fdt, "/memory", "reg", mem_reg_property,
+                               sizeof(mem_reg_property));
+    if (rc < 0) {
+        fprintf(stderr, "couldn't set /memory/reg\n");
+    }
+
+    rc = qemu_devtree_setprop_string(fdt, "/chosen", "bootargs",
+                                      binfo->kernel_cmdline);
+    if (rc < 0) {
+        fprintf(stderr, "couldn't set /chosen/bootargs\n");
+    }
+
+    if (binfo->initrd_size) {
+        rc = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-start",
+                binfo->loader_start + INITRD_LOAD_ADDR);
+        if (rc < 0) {
+            fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n");
+        }
+
+        rc = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-end",
+                    binfo->loader_start + INITRD_LOAD_ADDR +
+                    binfo->initrd_size);
+        if (rc < 0) {
+            fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n");
+        }
+    }
+
+    cpu_physical_memory_write(addr, fdt, size);
+
+    return 0;
+
+#else
+    fprintf(stderr, "Device tree requested, "
+                "but qemu was compiled without fdt support\n");
+    return -1;
+#endif
+}
+
 static void do_cpu_reset(void *opaque)
 {
     CPUState *env = opaque;
@@ -221,12 +285,14 @@ static void do_cpu_reset(void *opaque)
         } else {
             if (env == first_cpu) {
                 env->regs[15] = info->loader_start;
-                if (old_param) {
-                    set_kernel_args_old(info, info->initrd_size,
+                if (!info->dtb_filename) {
+                    if (old_param) {
+                        set_kernel_args_old(info, info->initrd_size,
+                                            info->loader_start);
+                    } else {
+                        set_kernel_args(info, info->initrd_size,
                                         info->loader_start);
-                } else {
-                    set_kernel_args(info, info->initrd_size,
-                                    info->loader_start);
+                    }
                 }
             } else {
                 info->secondary_cpu_reset_hook(env, info);
@@ -251,6 +317,9 @@ void arm_load_kernel(CPUState *env, struct arm_boot_info *info)
         exit(1);
     }
 
+    info->dtb_filename = qemu_opt_get(qemu_opts_find(qemu_find_opts("machine"),
+                                                     0), "dtb");
+
     if (!info->secondary_cpu_reset_hook) {
         info->secondary_cpu_reset_hook = default_reset_secondary;
     }
@@ -302,7 +371,22 @@ void arm_load_kernel(CPUState *env, struct arm_boot_info *info)
             initrd_size = 0;
         }
         bootloader[4] = info->board_id;
-        bootloader[5] = info->loader_start + KERNEL_ARGS_ADDR;
+
+        /* for device tree boot, we pass the DTB directly in r2. Otherwise
+         * we point to the kernel args.
+         */
+        if (info->dtb_filename) {
+            /* Place the DTB after the initrd in memory */
+            target_phys_addr_t dtb_start = TARGET_PAGE_ALIGN(info->loader_start
+                                                             + INITRD_LOAD_ADDR
+                                                             + initrd_size);
+            if (load_dtb(dtb_start, info)) {
+                exit(1);
+            }
+            bootloader[5] = dtb_start;
+        } else {
+            bootloader[5] = info->loader_start + KERNEL_ARGS_ADDR;
+        }
         bootloader[6] = entry;
         for (n = 0; n < sizeof(bootloader) / 4; n++) {
             bootloader[n] = tswap32(bootloader[n]);
diff --git a/qemu-config.c b/qemu-config.c
index 07480a4..151a61a 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -548,6 +548,10 @@ static QemuOptsList qemu_machine_opts = {
             .name = "append",
             .type = QEMU_OPT_STRING,
             .help = "Linux kernel command line",
+        }, {
+            .name = "dtb",
+            .type = QEMU_OPT_STRING,
+            .help = "Linux kernel device tree file",
         },
         { /* End of list */ }
     },
diff --git a/qemu-options.hx b/qemu-options.hx
index 19906e5..80316ed 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2011,6 +2011,15 @@ Use @var{file1} and @var{file2} as modules and pass arg=foo as parameter to the
 first module.
 ETEXI
 
+DEF("dtb", HAS_ARG, QEMU_OPTION_dtb, \
+    "-dtb    file    use 'file' as device tree image\n", QEMU_ARCH_ARM)
+STEXI
+@item -dtb @var{file}
+@findex -dtb
+Use @var{file} as a device tree binary (dtb) image and pass it to the kernel
+on boot.
+ETEXI
+
 STEXI
 @end table
 ETEXI
diff --git a/vl.c b/vl.c
index b8bb955..03c17d6 100644
--- a/vl.c
+++ b/vl.c
@@ -2453,6 +2453,9 @@ int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_append:
                 qemu_opts_set(qemu_find_opts("machine"), 0, "append", optarg);
                 break;
+            case QEMU_OPTION_dtb:
+                qemu_opts_set(qemu_find_opts("machine"), 0, "dtb", optarg);
+                break;
             case QEMU_OPTION_cdrom:
                 drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS);
                 break;
@@ -3261,6 +3264,12 @@ int main(int argc, char **argv, char **envp)
         exit(1);
     }
 
+    if (!linux_boot
+        && qemu_opt_get(qemu_opts_find(qemu_find_opts("machine"), 0), "dtb")) {
+        fprintf(stderr, "-dtb only allowed with -kernel option\n");
+        exit(1);
+    }
+
     os_set_line_buffering();
 
     if (init_timer_alarm() < 0) {
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 0/4] arm: add device tree support (via machine opts)
  2012-02-08  5:41 [Qemu-devel] [PATCH 0/4] arm: add device tree support (via machine opts) Peter Maydell
                   ` (3 preceding siblings ...)
  2012-02-08  5:41 ` [Qemu-devel] [PATCH 4/4] arm: add device tree support Peter Maydell
@ 2012-02-08  8:16 ` Peter Crosthwaite
  4 siblings, 0 replies; 10+ messages in thread
From: Peter Crosthwaite @ 2012-02-08  8:16 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Grant Likely, Anthony Liguori, patches, qemu-devel, Alexander Graf

[-- Attachment #1: Type: text/plain, Size: 2101 bytes --]

Hi Peter,

Anthony suggested to us the Idea of setting up bootloaders as devices in
order to solve this command line argument problem. I have posted a patch to
the mailing list ([RFC PATCH] arm boot: added QOM device definition) which
is my first attempt at this for arm_boot, i.e. arm_boot.c is now a device
model and boot command line arguments (e.g. like the new dtb argument this
series introduces) can be added as device model properties without
requiring a change pattern to vl.c and friends. Could I get a review of
that in the context of what you are trying to do with command line
arguments here?

Regards,
Peter

On Wed, Feb 8, 2012 at 3:41 PM, Peter Maydell <peter.maydell@linaro.org>wrote:

> This patch series is basically Grant's v2 "arm: add device tree support"
> patch (http://patchwork.ozlabs.org/patch/138883/) rearranged to use
> qemu -machine options rather than a global to pass through the device
> tree blob filename. This is based on a suggestion by Anthony in IRC;
> I'm a bit sceptical myself, but anyway here's the code...
>
> Patches 1 and 2 are pure bugfixes to the existing -machine handling
> and should be applied anyway IMHO: they fix a bug where only the last
> of any "-enable-kvm" and "-machine foo=bar" options have effect.
>
> Differences between Grant's v2 and this:
>  * use -machine options rather than a global
>  * patch 1/2 bug fixes
>  * some rearrangement/cleanup of arm_load_kernel() code
>
> Grant Likely (1):
>  arm: add device tree support
>
> Peter Maydell (3):
>  qemu-option: Add support for merged QemuOptsLists
>  Make -machine/-enable-kvm options merge into a single list
>  Make kernel, initrd and append be machine_opts
>
>  Makefile.target |    1 +
>  configure       |    1 +
>  hw/arm-misc.h   |    1 +
>  hw/arm_boot.c   |   96
> +++++++++++++++++++++++++++++++++++++++++++++++++++---
>  qemu-config.c   |   17 ++++++++++
>  qemu-option.c   |    7 +++-
>  qemu-option.h   |    1 +
>  qemu-options.hx |    9 +++++
>  vl.c            |   35 ++++++++++++++------
>  9 files changed, 151 insertions(+), 17 deletions(-)
>
> --
> 1.7.5.4
>
>
>

[-- Attachment #2: Type: text/html, Size: 2952 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 2/4] Make -machine/-enable-kvm options merge into a single list
  2012-02-08  5:41 ` [Qemu-devel] [PATCH 2/4] Make -machine/-enable-kvm options merge into a single list Peter Maydell
@ 2012-02-17  8:11   ` andrzej zaborowski
  0 siblings, 0 replies; 10+ messages in thread
From: andrzej zaborowski @ 2012-02-17  8:11 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Grant Likely, Anthony Liguori, patches, qemu-devel, Alexander Graf

On 8 February 2012 06:41, Peter Maydell <peter.maydell@linaro.org> wrote:
> Make the "machine" option list use list merging, so that multiple
> -machine arguments (and the -enable-kvm argument) all merge together
> into a single list. Drop the calls to qemu_opts_reset() which meant
> that only the last -machine or -enable-kvm option had any effect.
>
> This fixes the bug where "-enable-kvm -machine foo" would ignore
> the '-enable-kvm' option, and "-machine foo -enable-kvm" would
> ignore the '-machine foo' option.

Applied this patch and the first one as a bug fix, thank you.

Cheers

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 4/4] arm: add device tree support
  2012-02-08  5:41 ` [Qemu-devel] [PATCH 4/4] arm: add device tree support Peter Maydell
@ 2012-02-20 19:47   ` Peter Maydell
  2012-02-21  9:23     ` Peter Crosthwaite
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Maydell @ 2012-02-20 19:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: Grant Likely, Anthony Liguori, Alexander Graf, patches

Ping re patch 3 and 4 here -- I know there was some discussion under the
thread on Peter Crosthwaite's 'qomify arm_boot' patch series, but it's a
bit hard to disentangle from the comments on that patch series.

Specifically, does anybody (a) dislike the user-facing command line
interface here or (b) otherwise think it's misguided? I'm not a huge
fan of the -machine options (they seem to be a bit of a grab-bag of
stuff) but I can live with them as a mechanism for passing the data
to the right place...

thanks
-- PMM

On 8 February 2012 05:41, Peter Maydell <peter.maydell@linaro.org> wrote:
> From: Grant Likely <grant.likely@secretlab.ca>
>
> If compiled with CONFIG_FDT, allow user to specify a device tree file using
> the -dtb argument.  If the machine supports it then the dtb will be loaded
> into memory and passed to the kernel on boot.
>
> Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
> [Peter Maydell: Use machine opt rather than global to pass dtb filename]
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  Makefile.target |    1 +
>  configure       |    1 +
>  hw/arm-misc.h   |    1 +
>  hw/arm_boot.c   |   96 +++++++++++++++++++++++++++++++++++++++++++++++++++---
>  qemu-config.c   |    4 ++
>  qemu-options.hx |    9 +++++
>  vl.c            |    9 +++++
>  7 files changed, 115 insertions(+), 6 deletions(-)
>
> diff --git a/Makefile.target b/Makefile.target
> index 68481a3..5e465ec 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -363,6 +363,7 @@ obj-arm-y += vexpress.o
>  obj-arm-y += strongarm.o
>  obj-arm-y += collie.o
>  obj-arm-y += pl041.o lm4549.o
> +obj-arm-$(CONFIG_FDT) += device_tree.o
>
>  obj-sh4-y = shix.o r2d.o sh7750.o sh7750_regnames.o tc58128.o
>  obj-sh4-y += sh_timer.o sh_serial.o sh_intc.o sh_pci.o sm501.o
> diff --git a/configure b/configure
> index 763db24..1d8b3ac 100755
> --- a/configure
> +++ b/configure
> @@ -3458,6 +3458,7 @@ case "$target_arch2" in
>     gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
>     target_phys_bits=32
>     target_llong_alignment=4
> +    target_libs_softmmu="$fdt_libs"
>   ;;
>   cris)
>     target_nptl="yes"
> diff --git a/hw/arm-misc.h b/hw/arm-misc.h
> index 5e5204b..4b55fb8 100644
> --- a/hw/arm-misc.h
> +++ b/hw/arm-misc.h
> @@ -29,6 +29,7 @@ struct arm_boot_info {
>     const char *kernel_filename;
>     const char *kernel_cmdline;
>     const char *initrd_filename;
> +    const char *dtb_filename;
>     target_phys_addr_t loader_start;
>     /* multicore boards that use the default secondary core boot functions
>      * need to put the address of the secondary boot code, the boot reg,
> diff --git a/hw/arm_boot.c b/hw/arm_boot.c
> index 5f163fd..769fe2e 100644
> --- a/hw/arm_boot.c
> +++ b/hw/arm_boot.c
> @@ -7,11 +7,14 @@
>  * This code is licensed under the GPL.
>  */
>
> +#include "config.h"
>  #include "hw.h"
>  #include "arm-misc.h"
>  #include "sysemu.h"
> +#include "boards.h"
>  #include "loader.h"
>  #include "elf.h"
> +#include "device_tree.h"
>
>  #define KERNEL_ARGS_ADDR 0x100
>  #define KERNEL_LOAD_ADDR 0x00010000
> @@ -207,6 +210,67 @@ static void set_kernel_args_old(const struct arm_boot_info *info,
>     }
>  }
>
> +static int load_dtb(target_phys_addr_t addr, const struct arm_boot_info *binfo)
> +{
> +#ifdef CONFIG_FDT
> +    uint32_t mem_reg_property[] = { cpu_to_be32(binfo->loader_start),
> +                                    cpu_to_be32(binfo->ram_size) };
> +    void *fdt = NULL;
> +    char *filename;
> +    int size, rc;
> +
> +    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, binfo->dtb_filename);
> +    if (!filename) {
> +        fprintf(stderr, "Couldn't open dtb file %s\n", binfo->dtb_filename);
> +        return -1;
> +    }
> +
> +    fdt = load_device_tree(filename, &size);
> +    if (!fdt) {
> +        fprintf(stderr, "Couldn't open dtb file %s\n", filename);
> +        g_free(filename);
> +        return -1;
> +    }
> +    g_free(filename);
> +
> +    rc = qemu_devtree_setprop(fdt, "/memory", "reg", mem_reg_property,
> +                               sizeof(mem_reg_property));
> +    if (rc < 0) {
> +        fprintf(stderr, "couldn't set /memory/reg\n");
> +    }
> +
> +    rc = qemu_devtree_setprop_string(fdt, "/chosen", "bootargs",
> +                                      binfo->kernel_cmdline);
> +    if (rc < 0) {
> +        fprintf(stderr, "couldn't set /chosen/bootargs\n");
> +    }
> +
> +    if (binfo->initrd_size) {
> +        rc = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-start",
> +                binfo->loader_start + INITRD_LOAD_ADDR);
> +        if (rc < 0) {
> +            fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n");
> +        }
> +
> +        rc = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-end",
> +                    binfo->loader_start + INITRD_LOAD_ADDR +
> +                    binfo->initrd_size);
> +        if (rc < 0) {
> +            fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n");
> +        }
> +    }
> +
> +    cpu_physical_memory_write(addr, fdt, size);
> +
> +    return 0;
> +
> +#else
> +    fprintf(stderr, "Device tree requested, "
> +                "but qemu was compiled without fdt support\n");
> +    return -1;
> +#endif
> +}
> +
>  static void do_cpu_reset(void *opaque)
>  {
>     CPUState *env = opaque;
> @@ -221,12 +285,14 @@ static void do_cpu_reset(void *opaque)
>         } else {
>             if (env == first_cpu) {
>                 env->regs[15] = info->loader_start;
> -                if (old_param) {
> -                    set_kernel_args_old(info, info->initrd_size,
> +                if (!info->dtb_filename) {
> +                    if (old_param) {
> +                        set_kernel_args_old(info, info->initrd_size,
> +                                            info->loader_start);
> +                    } else {
> +                        set_kernel_args(info, info->initrd_size,
>                                         info->loader_start);
> -                } else {
> -                    set_kernel_args(info, info->initrd_size,
> -                                    info->loader_start);
> +                    }
>                 }
>             } else {
>                 info->secondary_cpu_reset_hook(env, info);
> @@ -251,6 +317,9 @@ void arm_load_kernel(CPUState *env, struct arm_boot_info *info)
>         exit(1);
>     }
>
> +    info->dtb_filename = qemu_opt_get(qemu_opts_find(qemu_find_opts("machine"),
> +                                                     0), "dtb");
> +
>     if (!info->secondary_cpu_reset_hook) {
>         info->secondary_cpu_reset_hook = default_reset_secondary;
>     }
> @@ -302,7 +371,22 @@ void arm_load_kernel(CPUState *env, struct arm_boot_info *info)
>             initrd_size = 0;
>         }
>         bootloader[4] = info->board_id;
> -        bootloader[5] = info->loader_start + KERNEL_ARGS_ADDR;
> +
> +        /* for device tree boot, we pass the DTB directly in r2. Otherwise
> +         * we point to the kernel args.
> +         */
> +        if (info->dtb_filename) {
> +            /* Place the DTB after the initrd in memory */
> +            target_phys_addr_t dtb_start = TARGET_PAGE_ALIGN(info->loader_start
> +                                                             + INITRD_LOAD_ADDR
> +                                                             + initrd_size);
> +            if (load_dtb(dtb_start, info)) {
> +                exit(1);
> +            }
> +            bootloader[5] = dtb_start;
> +        } else {
> +            bootloader[5] = info->loader_start + KERNEL_ARGS_ADDR;
> +        }
>         bootloader[6] = entry;
>         for (n = 0; n < sizeof(bootloader) / 4; n++) {
>             bootloader[n] = tswap32(bootloader[n]);
> diff --git a/qemu-config.c b/qemu-config.c
> index 07480a4..151a61a 100644
> --- a/qemu-config.c
> +++ b/qemu-config.c
> @@ -548,6 +548,10 @@ static QemuOptsList qemu_machine_opts = {
>             .name = "append",
>             .type = QEMU_OPT_STRING,
>             .help = "Linux kernel command line",
> +        }, {
> +            .name = "dtb",
> +            .type = QEMU_OPT_STRING,
> +            .help = "Linux kernel device tree file",
>         },
>         { /* End of list */ }
>     },
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 19906e5..80316ed 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -2011,6 +2011,15 @@ Use @var{file1} and @var{file2} as modules and pass arg=foo as parameter to the
>  first module.
>  ETEXI
>
> +DEF("dtb", HAS_ARG, QEMU_OPTION_dtb, \
> +    "-dtb    file    use 'file' as device tree image\n", QEMU_ARCH_ARM)
> +STEXI
> +@item -dtb @var{file}
> +@findex -dtb
> +Use @var{file} as a device tree binary (dtb) image and pass it to the kernel
> +on boot.
> +ETEXI
> +
>  STEXI
>  @end table
>  ETEXI
> diff --git a/vl.c b/vl.c
> index b8bb955..03c17d6 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2453,6 +2453,9 @@ int main(int argc, char **argv, char **envp)
>             case QEMU_OPTION_append:
>                 qemu_opts_set(qemu_find_opts("machine"), 0, "append", optarg);
>                 break;
> +            case QEMU_OPTION_dtb:
> +                qemu_opts_set(qemu_find_opts("machine"), 0, "dtb", optarg);
> +                break;
>             case QEMU_OPTION_cdrom:
>                 drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS);
>                 break;
> @@ -3261,6 +3264,12 @@ int main(int argc, char **argv, char **envp)
>         exit(1);
>     }
>
> +    if (!linux_boot
> +        && qemu_opt_get(qemu_opts_find(qemu_find_opts("machine"), 0), "dtb")) {
> +        fprintf(stderr, "-dtb only allowed with -kernel option\n");
> +        exit(1);
> +    }
> +
>     os_set_line_buffering();
>
>     if (init_timer_alarm() < 0) {
> --
> 1.7.5.4
>
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 4/4] arm: add device tree support
  2012-02-20 19:47   ` Peter Maydell
@ 2012-02-21  9:23     ` Peter Crosthwaite
  0 siblings, 0 replies; 10+ messages in thread
From: Peter Crosthwaite @ 2012-02-21  9:23 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Grant Likely, Anthony Liguori, patches, qemu-devel, Alexander Graf

On Tue, Feb 21, 2012 at 5:47 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
> Ping re patch 3 and 4 here -- I know there was some discussion under the
> thread on Peter Crosthwaite's 'qomify arm_boot' patch series, but it's a
> bit hard to disentangle from the comments on that patch series.

Conclusion reached over there was the yet to be implemented --property
command line argument should work for this. But blocking dtb support
while waiting for this seems excessive to me. Can we push this
regardless of the issues identifed in that thread considering the the
groundwork for the ideal solution is yet to be implemented?

> Specifically, does anybody (a) dislike the user-facing command line
> interface here or (b) otherwise think it's misguided? I'm not a huge
> fan of the -machine options (they seem to be a bit of a grab-bag of
> stuff) but I can live with them as a mechanism for passing the data
> to the right place...
>
> thanks
> -- PMM
>
> On 8 February 2012 05:41, Peter Maydell <peter.maydell@linaro.org> wrote:
>> From: Grant Likely <grant.likely@secretlab.ca>
>>
>> If compiled with CONFIG_FDT, allow user to specify a device tree file using
>> the -dtb argument.  If the machine supports it then the dtb will be loaded
>> into memory and passed to the kernel on boot.
>>
>> Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
>> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
>> [Peter Maydell: Use machine opt rather than global to pass dtb filename]
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>>  Makefile.target |    1 +
>>  configure       |    1 +
>>  hw/arm-misc.h   |    1 +
>>  hw/arm_boot.c   |   96 +++++++++++++++++++++++++++++++++++++++++++++++++++---
>>  qemu-config.c   |    4 ++
>>  qemu-options.hx |    9 +++++
>>  vl.c            |    9 +++++
>>  7 files changed, 115 insertions(+), 6 deletions(-)
>>
>> diff --git a/Makefile.target b/Makefile.target
>> index 68481a3..5e465ec 100644
>> --- a/Makefile.target
>> +++ b/Makefile.target
>> @@ -363,6 +363,7 @@ obj-arm-y += vexpress.o
>>  obj-arm-y += strongarm.o
>>  obj-arm-y += collie.o
>>  obj-arm-y += pl041.o lm4549.o
>> +obj-arm-$(CONFIG_FDT) += device_tree.o
>>
>>  obj-sh4-y = shix.o r2d.o sh7750.o sh7750_regnames.o tc58128.o
>>  obj-sh4-y += sh_timer.o sh_serial.o sh_intc.o sh_pci.o sm501.o
>> diff --git a/configure b/configure
>> index 763db24..1d8b3ac 100755
>> --- a/configure
>> +++ b/configure
>> @@ -3458,6 +3458,7 @@ case "$target_arch2" in
>>     gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
>>     target_phys_bits=32
>>     target_llong_alignment=4
>> +    target_libs_softmmu="$fdt_libs"
>>   ;;
>>   cris)
>>     target_nptl="yes"
>> diff --git a/hw/arm-misc.h b/hw/arm-misc.h
>> index 5e5204b..4b55fb8 100644
>> --- a/hw/arm-misc.h
>> +++ b/hw/arm-misc.h
>> @@ -29,6 +29,7 @@ struct arm_boot_info {
>>     const char *kernel_filename;
>>     const char *kernel_cmdline;
>>     const char *initrd_filename;
>> +    const char *dtb_filename;
>>     target_phys_addr_t loader_start;
>>     /* multicore boards that use the default secondary core boot functions
>>      * need to put the address of the secondary boot code, the boot reg,
>> diff --git a/hw/arm_boot.c b/hw/arm_boot.c
>> index 5f163fd..769fe2e 100644
>> --- a/hw/arm_boot.c
>> +++ b/hw/arm_boot.c
>> @@ -7,11 +7,14 @@
>>  * This code is licensed under the GPL.
>>  */
>>
>> +#include "config.h"
>>  #include "hw.h"
>>  #include "arm-misc.h"
>>  #include "sysemu.h"
>> +#include "boards.h"
>>  #include "loader.h"
>>  #include "elf.h"
>> +#include "device_tree.h"
>>
>>  #define KERNEL_ARGS_ADDR 0x100
>>  #define KERNEL_LOAD_ADDR 0x00010000
>> @@ -207,6 +210,67 @@ static void set_kernel_args_old(const struct arm_boot_info *info,
>>     }
>>  }
>>
>> +static int load_dtb(target_phys_addr_t addr, const struct arm_boot_info *binfo)
>> +{
>> +#ifdef CONFIG_FDT
>> +    uint32_t mem_reg_property[] = { cpu_to_be32(binfo->loader_start),
>> +                                    cpu_to_be32(binfo->ram_size) };
>> +    void *fdt = NULL;
>> +    char *filename;
>> +    int size, rc;
>> +
>> +    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, binfo->dtb_filename);
>> +    if (!filename) {
>> +        fprintf(stderr, "Couldn't open dtb file %s\n", binfo->dtb_filename);
>> +        return -1;
>> +    }
>> +
>> +    fdt = load_device_tree(filename, &size);
>> +    if (!fdt) {
>> +        fprintf(stderr, "Couldn't open dtb file %s\n", filename);
>> +        g_free(filename);
>> +        return -1;
>> +    }
>> +    g_free(filename);
>> +
>> +    rc = qemu_devtree_setprop(fdt, "/memory", "reg", mem_reg_property,
>> +                               sizeof(mem_reg_property));
>> +    if (rc < 0) {
>> +        fprintf(stderr, "couldn't set /memory/reg\n");
>> +    }
>> +
>> +    rc = qemu_devtree_setprop_string(fdt, "/chosen", "bootargs",
>> +                                      binfo->kernel_cmdline);
>> +    if (rc < 0) {
>> +        fprintf(stderr, "couldn't set /chosen/bootargs\n");
>> +    }
>> +
>> +    if (binfo->initrd_size) {
>> +        rc = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-start",
>> +                binfo->loader_start + INITRD_LOAD_ADDR);
>> +        if (rc < 0) {
>> +            fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n");
>> +        }
>> +
>> +        rc = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-end",
>> +                    binfo->loader_start + INITRD_LOAD_ADDR +
>> +                    binfo->initrd_size);
>> +        if (rc < 0) {
>> +            fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n");
>> +        }
>> +    }
>> +
>> +    cpu_physical_memory_write(addr, fdt, size);
>> +
>> +    return 0;
>> +
>> +#else
>> +    fprintf(stderr, "Device tree requested, "
>> +                "but qemu was compiled without fdt support\n");
>> +    return -1;
>> +#endif
>> +}
>> +
>>  static void do_cpu_reset(void *opaque)
>>  {
>>     CPUState *env = opaque;
>> @@ -221,12 +285,14 @@ static void do_cpu_reset(void *opaque)
>>         } else {
>>             if (env == first_cpu) {
>>                 env->regs[15] = info->loader_start;
>> -                if (old_param) {
>> -                    set_kernel_args_old(info, info->initrd_size,
>> +                if (!info->dtb_filename) {
>> +                    if (old_param) {
>> +                        set_kernel_args_old(info, info->initrd_size,
>> +                                            info->loader_start);
>> +                    } else {
>> +                        set_kernel_args(info, info->initrd_size,
>>                                         info->loader_start);
>> -                } else {
>> -                    set_kernel_args(info, info->initrd_size,
>> -                                    info->loader_start);
>> +                    }
>>                 }
>>             } else {
>>                 info->secondary_cpu_reset_hook(env, info);
>> @@ -251,6 +317,9 @@ void arm_load_kernel(CPUState *env, struct arm_boot_info *info)
>>         exit(1);
>>     }
>>
>> +    info->dtb_filename = qemu_opt_get(qemu_opts_find(qemu_find_opts("machine"),
>> +                                                     0), "dtb");
>> +
>>     if (!info->secondary_cpu_reset_hook) {
>>         info->secondary_cpu_reset_hook = default_reset_secondary;
>>     }
>> @@ -302,7 +371,22 @@ void arm_load_kernel(CPUState *env, struct arm_boot_info *info)
>>             initrd_size = 0;
>>         }
>>         bootloader[4] = info->board_id;
>> -        bootloader[5] = info->loader_start + KERNEL_ARGS_ADDR;
>> +
>> +        /* for device tree boot, we pass the DTB directly in r2. Otherwise
>> +         * we point to the kernel args.
>> +         */
>> +        if (info->dtb_filename) {
>> +            /* Place the DTB after the initrd in memory */
>> +            target_phys_addr_t dtb_start = TARGET_PAGE_ALIGN(info->loader_start
>> +                                                             + INITRD_LOAD_ADDR
>> +                                                             + initrd_size);
>> +            if (load_dtb(dtb_start, info)) {
>> +                exit(1);
>> +            }
>> +            bootloader[5] = dtb_start;
>> +        } else {
>> +            bootloader[5] = info->loader_start + KERNEL_ARGS_ADDR;
>> +        }
>>         bootloader[6] = entry;
>>         for (n = 0; n < sizeof(bootloader) / 4; n++) {
>>             bootloader[n] = tswap32(bootloader[n]);
>> diff --git a/qemu-config.c b/qemu-config.c
>> index 07480a4..151a61a 100644
>> --- a/qemu-config.c
>> +++ b/qemu-config.c
>> @@ -548,6 +548,10 @@ static QemuOptsList qemu_machine_opts = {
>>             .name = "append",
>>             .type = QEMU_OPT_STRING,
>>             .help = "Linux kernel command line",
>> +        }, {
>> +            .name = "dtb",
>> +            .type = QEMU_OPT_STRING,
>> +            .help = "Linux kernel device tree file",
>>         },
>>         { /* End of list */ }
>>     },
>> diff --git a/qemu-options.hx b/qemu-options.hx
>> index 19906e5..80316ed 100644
>> --- a/qemu-options.hx
>> +++ b/qemu-options.hx
>> @@ -2011,6 +2011,15 @@ Use @var{file1} and @var{file2} as modules and pass arg=foo as parameter to the
>>  first module.
>>  ETEXI
>>
>> +DEF("dtb", HAS_ARG, QEMU_OPTION_dtb, \
>> +    "-dtb    file    use 'file' as device tree image\n", QEMU_ARCH_ARM)
>> +STEXI
>> +@item -dtb @var{file}
>> +@findex -dtb
>> +Use @var{file} as a device tree binary (dtb) image and pass it to the kernel
>> +on boot.
>> +ETEXI
>> +
>>  STEXI
>>  @end table
>>  ETEXI
>> diff --git a/vl.c b/vl.c
>> index b8bb955..03c17d6 100644
>> --- a/vl.c
>> +++ b/vl.c
>> @@ -2453,6 +2453,9 @@ int main(int argc, char **argv, char **envp)
>>             case QEMU_OPTION_append:
>>                 qemu_opts_set(qemu_find_opts("machine"), 0, "append", optarg);
>>                 break;
>> +            case QEMU_OPTION_dtb:
>> +                qemu_opts_set(qemu_find_opts("machine"), 0, "dtb", optarg);
>> +                break;
>>             case QEMU_OPTION_cdrom:
>>                 drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS);
>>                 break;
>> @@ -3261,6 +3264,12 @@ int main(int argc, char **argv, char **envp)
>>         exit(1);
>>     }
>>
>> +    if (!linux_boot
>> +        && qemu_opt_get(qemu_opts_find(qemu_find_opts("machine"), 0), "dtb")) {
>> +        fprintf(stderr, "-dtb only allowed with -kernel option\n");
>> +        exit(1);
>> +    }
>> +
>>     os_set_line_buffering();
>>
>>     if (init_timer_alarm() < 0) {
>> --
>> 1.7.5.4
>>
>>
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 3/4] Make kernel, initrd and append be machine_opts
  2012-02-08  5:41 ` [Qemu-devel] [PATCH 3/4] Make kernel, initrd and append be machine_opts Peter Maydell
@ 2012-02-22 18:31   ` Anthony Liguori
  0 siblings, 0 replies; 10+ messages in thread
From: Anthony Liguori @ 2012-02-22 18:31 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Grant Likely, patches, qemu-devel, Alexander Graf

On 02/07/2012 11:41 PM, Peter Maydell wrote:
> Make kernel, initrd, append be machine opts (ie -machine kernel=foo)
> with the old plain command line arguments as legacy/convenience
> equivalents.
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>

I applied this patch since Andrzej applied the first two.  The four patch 
conflicts a bit more than I feel comfortable fixing myself.  I would suggest 
that you just fold the 4th patch into your next pull request.

Regards,

Anthony Liguori

> ---
>   qemu-config.c |   12 ++++++++++++
>   vl.c          |   24 ++++++++++++++++--------
>   2 files changed, 28 insertions(+), 8 deletions(-)
>
> diff --git a/qemu-config.c b/qemu-config.c
> index c938470..07480a4 100644
> --- a/qemu-config.c
> +++ b/qemu-config.c
> @@ -536,6 +536,18 @@ static QemuOptsList qemu_machine_opts = {
>               .name = "kernel_irqchip",
>               .type = QEMU_OPT_BOOL,
>               .help = "use KVM in-kernel irqchip",
> +        }, {
> +            .name = "kernel",
> +            .type = QEMU_OPT_STRING,
> +            .help = "Linux kernel image file",
> +        }, {
> +            .name = "initrd",
> +            .type = QEMU_OPT_STRING,
> +            .help = "Linux initial ramdisk file",
> +        }, {
> +            .name = "append",
> +            .type = QEMU_OPT_STRING,
> +            .help = "Linux kernel command line",
>           },
>           { /* End of list */ }
>       },
> diff --git a/vl.c b/vl.c
> index fe24ef8..b8bb955 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2238,11 +2238,8 @@ int main(int argc, char **argv, char **envp)
>       module_call_init(MODULE_INIT_MACHINE);
>       machine = find_default_machine();
>       cpu_model = NULL;
> -    initrd_filename = NULL;
>       ram_size = 0;
>       snapshot = 0;
> -    kernel_filename = NULL;
> -    kernel_cmdline = "";
>       cyls = heads = secs = 0;
>       translation = BIOS_ATA_TRANSLATION_AUTO;
>
> @@ -2318,9 +2315,6 @@ int main(int argc, char **argv, char **envp)
>                       cpu_model = optarg;
>                   }
>                   break;
> -            case QEMU_OPTION_initrd:
> -                initrd_filename = optarg;
> -                break;
>               case QEMU_OPTION_hda:
>                   {
>                       char buf[256];
> @@ -2451,10 +2445,13 @@ int main(int argc, char **argv, char **envp)
>                   }
>                   break;
>               case QEMU_OPTION_kernel:
> -                kernel_filename = optarg;
> +                qemu_opts_set(qemu_find_opts("machine"), 0, "kernel", optarg);
> +                break;
> +            case QEMU_OPTION_initrd:
> +                qemu_opts_set(qemu_find_opts("machine"), 0, "initrd", optarg);
>                   break;
>               case QEMU_OPTION_append:
> -                kernel_cmdline = optarg;
> +                qemu_opts_set(qemu_find_opts("machine"), 0, "append", optarg);
>                   break;
>               case QEMU_OPTION_cdrom:
>                   drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS);
> @@ -3241,6 +3238,17 @@ int main(int argc, char **argv, char **envp)
>           fprintf(stderr, "qemu_init_main_loop failed\n");
>           exit(1);
>       }
> +
> +    kernel_filename = qemu_opt_get(qemu_opts_find(qemu_find_opts("machine"),
> +                                                  0), "kernel");
> +    initrd_filename = qemu_opt_get(qemu_opts_find(qemu_find_opts("machine"),
> +                                                  0), "initrd");
> +    kernel_cmdline = qemu_opt_get(qemu_opts_find(qemu_find_opts("machine"),
> +                                                 0), "append");
> +    if (!kernel_cmdline) {
> +        kernel_cmdline = "";
> +    }
> +
>       linux_boot = (kernel_filename != NULL);
>
>       if (!linux_boot&&  *kernel_cmdline != '\0') {

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-02-22 18:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-08  5:41 [Qemu-devel] [PATCH 0/4] arm: add device tree support (via machine opts) Peter Maydell
2012-02-08  5:41 ` [Qemu-devel] [PATCH 1/4] qemu-option: Add support for merged QemuOptsLists Peter Maydell
2012-02-08  5:41 ` [Qemu-devel] [PATCH 2/4] Make -machine/-enable-kvm options merge into a single list Peter Maydell
2012-02-17  8:11   ` andrzej zaborowski
2012-02-08  5:41 ` [Qemu-devel] [PATCH 3/4] Make kernel, initrd and append be machine_opts Peter Maydell
2012-02-22 18:31   ` Anthony Liguori
2012-02-08  5:41 ` [Qemu-devel] [PATCH 4/4] arm: add device tree support Peter Maydell
2012-02-20 19:47   ` Peter Maydell
2012-02-21  9:23     ` Peter Crosthwaite
2012-02-08  8:16 ` [Qemu-devel] [PATCH 0/4] arm: add device tree support (via machine opts) Peter Crosthwaite

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.