qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2] vl.c: make current_machine as non-global var


From: Eduardo Habkost
Subject: Re: [Qemu-devel] [PATCH v2] vl.c: make current_machine as non-global variable
Date: Tue, 2 Apr 2019 16:16:02 -0300
User-agent: Mutt/1.10.1 (2018-07-13)

On Tue, Apr 02, 2019 at 11:23:42PM +0700, Peter Maydell wrote:
> On Tue, 2 Apr 2019 at 23:13, Markus Armbruster <address@hidden> wrote:
> >
> > Igor Mammedov <address@hidden> writes:
> > > maybe we can assert in qdev_get_machine() if machine hasn't been created 
> > > yet?
> > > with this at least it will be hard to misuse function or catch invalid 
> > > users.
> > > (but it still might miss some use cases/CLI options which are not tested)
> >
> > Good idea.  When my code created "/machine" as a container, debugging
> > the resulting crash took me a bit of time.  The assertion you propose
> > would've saved me some.
> 
> One wrinkle to watch out for is code paths that are used in the
> linux-user emulator, where there is no machine at all... For instance
> cpu_common_realizefn() handles this case by explicitly checking
> whether the thing it gets back from qdev_get_machine() is a
> TYPE_MACHINE or not.

Is there a real use case for calling qdev_get_machine() in user
mode?

I'd prefer to make qdev_get_machine() unavailable in user mode,
so we could detect these cases at compile time (and treat them as
bugs).

-- 
Eduardo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]