On Tue, May 20, 2025 at 07:07:06PM +0000, Wei Liu wrote:
> On Tue, May 20, 2025 at 01:30:01PM +0200, Magnus Kulke wrote:
> > Create the MSHV virtual machine by opening a partition and issuing
> > the necessary ioctl to initialize it. This sets up the basic VM
> > structure and initial configuration used by MSHV to manage guest state.
> > 
> > Signed-off-by: Magnus Kulke <magnusku...@linux.microsoft.com>
> > ---
> [...]
> 
> mshv_fd is neither stashed into a state structure nor freed after this
> point.  Is it leaked?
> 
> Thanks,
> Wei.
> 

AFAIK the accelerator should not be initialized multiple times at runtime,
so under normal circumstances the fd wouldn't leak. But in certain debug
scenarios that would be the case. So, yes, we should make this more solid
and exit early if MSHV_STATE has been previously initialized.

> >      s->nr_as = 1;
> >      s->as = g_new0(MshvAddressSpace, s->nr_as);
> >  
> >      mshv_state = s;
> >  
> > +    qemu_register_reset(mshv_reset, NULL);
> > +
> >      register_mshv_memory_listener(s, &s->memory_listener, 
> > &address_space_memory,
> >                                    0, "mshv-memory");
> >      memory_listener_register(&mshv_io_listener, &address_space_io);

Reply via email to