> > Either add the I386 dependency or don't use PC_MACHINE, because on
> > non-x86 targets PC_MACHINE(qdev_get_machine()) will crash.
>
> Ah this is where we have a disconnect. I assumed that
> > pcms = PC_MACHINE(m_obj)
>
> would return NULL on non-x86.
>
> Seems a better way to do this (as is done in vga.c) is to use
> object_dynamic_cast()
> How about
>
> diff --git a/hw/misc/vmfwupdate.c b/hw/misc/vmfwupdate.c
> index 0e90bd10e1..19d042b929 100644
> --- a/hw/misc/vmfwupdate.c
> +++ b/hw/misc/vmfwupdate.c
> @@ -32,9 +32,11 @@ static inline VMFwUpdateState *vmfwupdate_find(void)
> static uint64_t get_max_fw_size(void)
> {
> Object *m_obj = qdev_get_machine();
> - PCMachineState *pcms = PC_MACHINE(m_obj);
> + MachineState *ms = MACHINE(m_obj);
> + PCMachineState *pcms;
> - if (pcms) {
> + if (object_dynamic_cast(OBJECT(ms), TYPE_X86_MACHINE)) {
> + pcms = PC_MACHINE(m_obj);
> return pcms->max_fw_size;
> } else {
> return 0;
>
For the records, I tested this with arm and the following command line
does not crash QEMU;
./qemu-system-arm -machine virt-9.2 -device vmfwupdate
I have also added a separate functional test to exercise basic device
creation which will be part of v5 when I send it out.