On 19.06.2012, at 22:51, Peter Maydell wrote:

> On 19 June 2012 20:15, Alexander Graf <ag...@suse.de> wrote:
>> Now that we are dynamically creating the dtb, it's really useful to
>> be able to dump the created blob for debugging.
> 
>> @@ -300,6 +302,22 @@ static int mpc8544_load_device_tree(CPUPPCState *env,
>>     qemu_devtree_setprop_cell(fdt, pci, "#address-cells", 3);
>>     qemu_devtree_setprop_string(fdt, "/aliases", "pci0", pci);
>> 
>> +    machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
>> +    if (machine_opts) {
>> +        dumpdtb = qemu_opt_get(machine_opts, "dumpdtb");
>> +    }
>> +    if (dumpdtb) {
>> +        /* Dump the dtb to a file and quit */
>> +        FILE *f = fopen(dumpdtb, "wb");
>> +        size_t len;
>> +        len = fwrite(fdt, fdt_size, 1, f);
>> +        fclose(f);
>> +        if (len != fdt_size) {
>> +            exit(1);
>> +        }
>> +        exit(0);
>> +    }
>> +
> 
> Maybe this should be abstracted out into a subfunction somewhere?
> I'm guessing there might be more than one machine in the future
> that wants a dumpable device tree.

Yup, that should be done with the second machine that allows this option. 
Basically the second one that implements dynamic device tree generation. If you 
beat me to it, that'd mean you generalize it. Otherwise I'd do it on bamboo :).


Alex


Reply via email to