On 2/14/25 16:31, Mark Nesky wrote:
Hello,

I am new to the QEMU code base and I am working on a project involving a custom hardware model representing a customized ppc board.  What is the best way to add command line arguments applicable to my model?

I see options in qemu-options.hx + vl.c, but I am not sure if that is the right place for arguments that only apply to one model, and I am not sure how to access those options from my model.

Hi,

options that apply to only a machine or device can use, respectively, the -machine or -device options.

For -device this is done using the DEFINE_PROP_* macros.

For -machine, which I assume is the case for you, the process is a bit more complex. A good example, including a varied set of types, can be found in the spapr_instance_init function of hw/ppc/spapr.c.

Another possibility for -machine is to pass the option down to a specific device, which usually will be created at startup. For example this snipped from hw/i386/pc.c adds a "-machine pcspk-audiodev" option:

    pcms->pcspk = isa_new(TYPE_PC_SPEAKER);
    object_property_add_alias(OBJECT(pcms), "pcspk-audiodev",
                              OBJECT(pcms->pcspk), "audiodev");

Thanks,

Paolo

I also see the function qemu_opts_create which looks like it can add command line arguments at runtime, but I am not sure where to use this in my model since it seems like my model code (machine state, class, and instance functions) does not run when invoking "qemu-system-ppc -machine mymodel -help".

If there is some good documentation or examples, please point me in the right direction.

thanks for your help,
Mark


Reply via email to