Markus Armbruster <[email protected]> writes:

> Daniel P. Berrangé <[email protected]> writes:

[...]

>> Normal practice is for types to be unconditionally registered.  Do we
>> have any examples outside of this SGX case where we conditionally
>> register types ?   Should we change this to follow normal practice ?
>
> Loosely related: conditional *class* properties.  Example:
>
>     static void
>     memfd_backend_class_init(ObjectClass *oc, const void *data)
>     {
>         HostMemoryBackendClass *bc = MEMORY_BACKEND_CLASS(oc);
>
>         bc->alloc = memfd_backend_memory_alloc;
>
>         if (qemu_memfd_check(MFD_HUGETLB)) {
>             object_class_property_add_bool(oc, "hugetlb",
>                                            memfd_backend_get_hugetlb,
>                                            memfd_backend_set_hugetlb);
>             object_class_property_set_description(oc, "hugetlb",
>                                                   "Use huge pages");
>             object_class_property_add(oc, "hugetlbsize", "uint64",
>                                       &uint64_type_info,
>                                       memfd_backend_get_hugetlbsize,
>                                       memfd_backend_set_hugetlbsize,
>                                       NULL, NULL);
>             object_class_property_set_description(oc, "hugetlbsize",
>                                                   "Huge pages size (ex: 2M, 
> 1G)");
>         }
>
>         [...]
>     }
>
> These properties are also declared in qapi/qom.json if CONFIG_LINUX.
> QAPI introspection (query-qmp-schema) shows them then.  QOM
> introspection (qom-list-properties etc.) only shows them when the
> MFD_HUGETLB check succeeded.
>
> Feels undesirable to me.

[...]

Conditional turned out to be unnecessary here:

    Subject: [PATCH 7/7] backends/hostmem-memfd: Add huge TLB properties 
unconditionally
    Date: Wed, 11 Nov 2026 13:23:42 +0100
    Message-ID: <[email protected]>

I found a few more:

* Property "loadparm" of scsi-cd, scsi-hd, virtio-blk-pci,
  virtio-net-pci only if target_s390x()

* Several properties of xenpvh-machine on ARM and i386 only if
  ->has_virtio_mmio, ->has_pci, ->has_tpm

I don't plan to examine these.


Reply via email to