> On 18 Nov 2025, at 5:51 PM, Gerd Hoffmann <[email protected]> wrote:
>
> Add TYPE_RESETTABLE_INTERFACE to interfaces. Register callbacks for the
> reset phases. Add trace points for logging and debugging. No
> functional change, that will come in followup patches.
>
> Signed-off-by: Gerd Hoffmann <[email protected]>
Reviewed-by: Ani Sinha <[email protected]>
> ---
> include/system/igvm-cfg.h | 2 ++
> backends/igvm-cfg.c | 36 +++++++++++++++++++++++++++++++++++-
> backends/trace-events | 5 +++++
> 3 files changed, 42 insertions(+), 1 deletion(-)
>
> diff --git a/include/system/igvm-cfg.h b/include/system/igvm-cfg.h
> index 944f23a814dd..312f77c092b0 100644
> --- a/include/system/igvm-cfg.h
> +++ b/include/system/igvm-cfg.h
> @@ -13,6 +13,7 @@
> #define QEMU_IGVM_CFG_H
>
> #include "qom/object.h"
> +#include "hw/resettable.h"
>
> typedef struct IgvmCfg {
> ObjectClass parent_class;
> @@ -23,6 +24,7 @@ typedef struct IgvmCfg {
> * format.
> */
> char *filename;
> + ResettableState reset_state;
> } IgvmCfg;
>
> typedef struct IgvmCfgClass {
> diff --git a/backends/igvm-cfg.c b/backends/igvm-cfg.c
> index d00acf351249..4e3ef88ffc27 100644
> --- a/backends/igvm-cfg.c
> +++ b/backends/igvm-cfg.c
> @@ -13,8 +13,11 @@
>
> #include "system/igvm-cfg.h"
> #include "system/igvm.h"
> +#include "system/reset.h"
> #include "qom/object_interfaces.h"
>
> +#include "trace.h"
> +
> static char *get_igvm(Object *obj, Error **errp)
> {
> IgvmCfg *igvm = IGVM_CFG(obj);
> @@ -28,24 +31,55 @@ static void set_igvm(Object *obj, const char *value,
> Error **errp)
> igvm->filename = g_strdup(value);
> }
>
> +static ResettableState *igvm_reset_state(Object *obj)
> +{
> + IgvmCfg *igvm = IGVM_CFG(obj);
> + return &igvm->reset_state;
> +}
> +
> +static void igvm_reset_enter(Object *obj, ResetType type)
> +{
> + trace_igvm_reset_enter(type);
> +}
> +
> +static void igvm_reset_hold(Object *obj, ResetType type)
> +{
> + trace_igvm_reset_hold(type);
> +}
> +
> +static void igvm_reset_exit(Object *obj, ResetType type)
> +{
> + trace_igvm_reset_exit(type);
> +}
> +
> OBJECT_DEFINE_TYPE_WITH_INTERFACES(IgvmCfg, igvm_cfg, IGVM_CFG, OBJECT,
> - { TYPE_USER_CREATABLE }, { NULL })
> + { TYPE_USER_CREATABLE },
> + { TYPE_RESETTABLE_INTERFACE },
> + { NULL })
>
> static void igvm_cfg_class_init(ObjectClass *oc, const void *data)
> {
> IgvmCfgClass *igvmc = IGVM_CFG_CLASS(oc);
> + ResettableClass *rc = RESETTABLE_CLASS(oc);
>
> object_class_property_add_str(oc, "file", get_igvm, set_igvm);
> object_class_property_set_description(oc, "file",
> "Set the IGVM filename to use");
>
> igvmc->process = qigvm_process_file;
> +
> + rc->get_state = igvm_reset_state;
> + rc->phases.enter = igvm_reset_enter;
> + rc->phases.hold = igvm_reset_hold;
> + rc->phases.exit = igvm_reset_exit;
> }
>
> static void igvm_cfg_init(Object *obj)
> {
> + qemu_register_resettable(obj);
> }
>
> static void igvm_cfg_finalize(Object *obj)
> {
> + qemu_unregister_resettable(obj);
> }
> diff --git a/backends/trace-events b/backends/trace-events
> index 56132d3fd22b..45ac46dc2454 100644
> --- a/backends/trace-events
> +++ b/backends/trace-events
> @@ -21,3 +21,8 @@ iommufd_backend_free_id(int iommufd, uint32_t id, int ret)
> " iommufd=%d id=%d (%
> iommufd_backend_set_dirty(int iommufd, uint32_t hwpt_id, bool start, int ret)
> " iommufd=%d hwpt=%u enable=%d (%d)"
> iommufd_backend_get_dirty_bitmap(int iommufd, uint32_t hwpt_id, uint64_t
> iova, uint64_t size, uint64_t page_size, int ret) " iommufd=%d hwpt=%u
> iova=0x%"PRIx64" size=0x%"PRIx64" page_size=0x%"PRIx64" (%d)"
> iommufd_backend_invalidate_cache(int iommufd, uint32_t id, uint32_t
> data_type, uint32_t entry_len, uint32_t entry_num, uint32_t done_num,
> uint64_t data_ptr, int ret) " iommufd=%d id=%u data_type=%u entry_len=%u
> entry_num=%u done_num=%u data_ptr=0x%"PRIx64" (%d)"
> +
> +# igvm-cfg.c
> +igvm_reset_enter(int type) "type=%u"
> +igvm_reset_hold(int type) "type=%u"
> +igvm_reset_exit(int type) "type=%u"
> --
> 2.51.1
>