On 22.11.24 03:40, Xiaoyao Li wrote:
On 11/22/2024 2:52 AM, Paolo Bonzini wrote:
On 11/21/24 17:24, Xiaoyao Li wrote:
Could it go into cpu_common_initfn()?

It can, I think.

I'll move them into cpu_common_initfn() in v2 to avoid touching all
the ARCHes.

It does look better than the alternative of duplicating code.

On the other hand qemu_init_vcpu is already duplicated and I'm not sure
I like relying on qdev_get_machine() inside the instance_init function...


Good point.

I had the same concern.

But it seems all the ARCHes should create MACHINE before VCPUs. So it
seems OK to qdev_get_machine() inside the instance_init function. But
I'm not sure if there is any case to create VCPU standalone.

There are, for example on s390x in create_cpu_model_list(). I recall there are ways to start QEMU without any machine and trigger that code. (or maybe this was just for the test environment with a special test machine ...)


I think we can check if qdev_get_machine() gets a valid result. If not,
fall back to assign nr_cores and nr_threads to 1.

That sounds reasonable to me.

--
Cheers,

David / dhildenb


Reply via email to