This was implemented at:
https://gitlab.com/ehabkost/qemu/-/commits/work/qdev-make-generic
This is the interface I'd like to submit as v3:
static Property machine_props[] = {
DEFINE_PROP_STRING("kernel", MachineState, kernel_filename,
.description = "Linux kernel image file"),
DEFINE_PROP_STRING("initrd", MachineState, initrd_filename,
.description = "Linux initial ramdisk file"),
DEFINE_PROP_STRING("append", MachineState, kernel_cmdline,
.description = "Linux kernel command line"),
DEFINE_PROP_STRING("dtb", MachineState, dtb,
.description = "Linux kernel device tree file"),
DEFINE_PROP_STRING("dumpdtb", MachineState, dumpdtb,
.description = "Dump current dtb to a file and quit"),
DEFINE_PROP_STRING("dt-compatible", MachineState, dt_compatible,
.description = "Overrides the \"compatible\" "
"property of the dt root node"),
DEFINE_PROP_STRING("firmware", MachineState, firmware,
.description = "Firmware image"),
DEFINE_PROP_STRING("memory-backend", MachineState, ram_memdev_id,
.description = "ID of memory backend object"),
DEFINE_PROP_BOOL("dump-guest-core", MachineState, dump_guest_core, true,
.description = "Include guest memory in a core dump"),
DEFINE_PROP_BOOL("mem-merge", MachineState, mem_merge, true,
.description = "Enable/disable memory merge support"),
DEFINE_PROP_BOOL("graphics", MachineState, enable_graphics, true,
.description = "Set on/off to enable/disable graphics
emulation"),
DEFINE_PROP_BOOL("suppress-vmdesc", MachineState, suppress_vmdesc, false,
.description = "Set on to disable self-describing
migration"),
DEFINE_PROP_UINT32("phandle-start", MachineState, phandle_start, 0,
.description = "The first phandle ID we may generate
dynamically"),
DEFINE_PROP_END_OF_LIST(),
};
static void machine_class_init(ObjectClass *oc, void *data)
{
...
object_class_add_field_properties(oc, machine_props,
prop_allow_set_always);
...
}