> > memset(&ctx, 0, sizeof(ctx));
> > - ctx.file = qigvm_file_init(cfg->filename, errp);
> > - if (ctx.file < 0) {
> > + if (!cfg->file) {
>
> This is not right I think. qigvm_file_init() returns -1 if
> igvm_new_from_binary() fails and returns < 0. Looking at
> https://docs.rs/igvm/latest/igvm/c_api/fn.igvm_new_from_binary.html this
> seems correct.
Good catch. We also have to initialize cfg->file with -1 then, to make
sure we catch the case of qigvm_file_init not being called.
take care,
Gerd
---------------------------- incremental fix -----------------------------
diff --git a/backends/igvm-cfg.c b/backends/igvm-cfg.c
index c1b45401f429..08e64cdd367e 100644
--- a/backends/igvm-cfg.c
+++ b/backends/igvm-cfg.c
@@ -93,6 +93,9 @@ static void igvm_cfg_class_init(ObjectClass *oc, const void
*data)
static void igvm_cfg_init(Object *obj)
{
+ IgvmCfg *igvm = IGVM_CFG(obj);
+
+ igvm->file = -1;
qemu_register_resettable(obj);
}
diff --git a/backends/igvm.c b/backends/igvm.c
index a350c890cc95..b32c84cf4b30 100644
--- a/backends/igvm.c
+++ b/backends/igvm.c
@@ -900,7 +900,7 @@ int qigvm_process_file(IgvmCfg *cfg,
ConfidentialGuestSupport *cgs,
QIgvm ctx;
memset(&ctx, 0, sizeof(ctx));
- if (!cfg->file) {
+ if (cfg->file < 0) {
error_setg(errp, "No IGVM file loaded.");
return -1;
}