From: Ani Sinha <anisinha@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel <qemu-devel@nongnu.org>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
Michael Tsirkin <mst@redhat.com>,
Stefano Garzarella <sgarzare@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Oliver Steffen <osteffen@redhat.com>,
Richard Henderson <richard.henderson@linaro.org>,
Eduardo Habkost <eduardo@habkost.net>,
Luigi Leonardi <leonardi@redhat.com>
Subject: Re: [PATCH v2 3/5] igvm: move file load to complete callback
Date: Thu, 11 Dec 2025 17:09:56 +0530 [thread overview]
Message-ID: <15A0701C-9973-473F-8804-812CF6B5F909@redhat.com> (raw)
In-Reply-To: <20251211105419.3573449-4-kraxel@redhat.com>
> On 11 Dec 2025, at 4:24 PM, Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> Add UserCreatableClass->complete callback function for igvm-cfg object.
>
> Move file loading and parsing of the igvm file from the process function
> to the new complete() callback function. Keep the igvm file loaded
> after processing, release it in finalize() instead, so we parse it only
> once.
LGTM.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Ani Sinha <anisinha@redhat.com>
> ---
> include/system/igvm-internal.h | 5 +++++
> backends/igvm-cfg.c | 18 ++++++++++++++++++
> backends/igvm.c | 9 ++++-----
> 3 files changed, 27 insertions(+), 5 deletions(-)
>
> diff --git a/include/system/igvm-internal.h b/include/system/igvm-internal.h
> index e0452080b127..d378d682b0fb 100644
> --- a/include/system/igvm-internal.h
> +++ b/include/system/igvm-internal.h
> @@ -12,6 +12,8 @@
> #include "qemu/typedefs.h"
> #include "qom/object.h"
>
> +#include <igvm/igvm.h>
> +
> struct IgvmCfg {
> ObjectClass parent_class;
>
> @@ -21,7 +23,10 @@ struct IgvmCfg {
> * format.
> */
> char *filename;
> + IgvmHandle file;
> ResettableState reset_state;
> };
>
> +IgvmHandle qigvm_file_init(char *filename, Error **errp);
> +
> #endif
> diff --git a/backends/igvm-cfg.c b/backends/igvm-cfg.c
> index e0df3eaa8efd..4014062e0f22 100644
> --- a/backends/igvm-cfg.c
> +++ b/backends/igvm-cfg.c
> @@ -53,6 +53,13 @@ static void igvm_reset_exit(Object *obj, ResetType type)
> trace_igvm_reset_exit(type);
> }
>
> +static void igvm_complete(UserCreatable *uc, Error **errp)
> +{
> + IgvmCfg *igvm = IGVM_CFG(uc);
> +
> + igvm->file = qigvm_file_init(igvm->filename, errp);
> +}
> +
> OBJECT_DEFINE_TYPE_WITH_INTERFACES(IgvmCfg, igvm_cfg, IGVM_CFG, OBJECT,
> { TYPE_USER_CREATABLE },
> { TYPE_RESETTABLE_INTERFACE },
> @@ -62,6 +69,7 @@ static void igvm_cfg_class_init(ObjectClass *oc, const void *data)
> {
> IgvmCfgClass *igvmc = IGVM_CFG_CLASS(oc);
> ResettableClass *rc = RESETTABLE_CLASS(oc);
> + UserCreatableClass *uc = USER_CREATABLE_CLASS(oc);
>
> object_class_property_add_str(oc, "file", get_igvm, set_igvm);
> object_class_property_set_description(oc, "file",
> @@ -73,14 +81,24 @@ static void igvm_cfg_class_init(ObjectClass *oc, const void *data)
> rc->phases.enter = igvm_reset_enter;
> rc->phases.hold = igvm_reset_hold;
> rc->phases.exit = igvm_reset_exit;
> +
> + uc->complete = igvm_complete;
> }
>
> static void igvm_cfg_init(Object *obj)
> {
> + IgvmCfg *igvm = IGVM_CFG(obj);
> +
> + igvm->file = -1;
> qemu_register_resettable(obj);
> }
>
> static void igvm_cfg_finalize(Object *obj)
> {
> + IgvmCfg *igvm = IGVM_CFG(obj);
> +
> qemu_unregister_resettable(obj);
> + if (igvm->file >= 0) {
> + igvm_free(igvm->file);
> + }
> }
> diff --git a/backends/igvm.c b/backends/igvm.c
> index fbb8300b6d01..a01e01a12a60 100644
> --- a/backends/igvm.c
> +++ b/backends/igvm.c
> @@ -869,7 +869,7 @@ static int qigvm_handle_policy(QIgvm *ctx, Error **errp)
> return 0;
> }
>
> -static IgvmHandle qigvm_file_init(char *filename, Error **errp)
> +IgvmHandle qigvm_file_init(char *filename, Error **errp)
> {
> IgvmHandle igvm;
> g_autofree uint8_t *buf = NULL;
> @@ -898,10 +898,11 @@ int qigvm_process_file(IgvmCfg *cfg, ConfidentialGuestSupport *cgs,
> QIgvm ctx;
>
> memset(&ctx, 0, sizeof(ctx));
> - ctx.file = qigvm_file_init(cfg->filename, errp);
> - if (ctx.file < 0) {
> + if (cfg->file < 0) {
> + error_setg(errp, "No IGVM file loaded.");
> return -1;
> }
> + ctx.file = cfg->file;
>
> /*
> * The ConfidentialGuestSupport object is optional and allows a confidential
> @@ -992,7 +993,5 @@ cleanup_parameters:
> g_free(ctx.id_auth);
>
> cleanup:
> - igvm_free(ctx.file);
> -
> return retval;
> }
> --
> 2.52.0
>
next prev parent reply other threads:[~2025-12-11 11:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-11 10:54 [PATCH v2 0/5] igvm: rework igvm file loading + processing, fix reset Gerd Hoffmann
2025-12-11 10:54 ` [PATCH v2 1/5] igvm: reorganize headers Gerd Hoffmann
2025-12-11 11:13 ` Luigi Leonardi
2025-12-11 10:54 ` [PATCH v2 2/5] igvm: make igvm-cfg object resettable Gerd Hoffmann
2025-12-11 10:54 ` [PATCH v2 3/5] igvm: move file load to complete callback Gerd Hoffmann
2025-12-11 11:39 ` Ani Sinha [this message]
2025-12-11 10:54 ` [PATCH v2 4/5] igvm: add trace points for igvm file loading and processing Gerd Hoffmann
2025-12-11 11:32 ` Luigi Leonardi
2025-12-11 10:54 ` [PATCH v2 5/5] igvm: move igvm file processing to reset callbacks Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=15A0701C-9973-473F-8804-812CF6B5F909@redhat.com \
--to=anisinha@redhat.com \
--cc=eduardo@habkost.net \
--cc=kraxel@redhat.com \
--cc=leonardi@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=osteffen@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=sgarzare@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).