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

2019-04-04 Thread Peter Maydell
On Thu, 4 Apr 2019 at 17:05, Igor Mammedov wrote: > On Tue, 2 Apr 2019 23:23:42 +0700 > Peter Maydell wrote: > > 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 b

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

2019-04-04 Thread Igor Mammedov
On Tue, 2 Apr 2019 23:23:42 +0700 Peter Maydell wrote: > On Tue, 2 Apr 2019 at 23:13, Markus Armbruster wrote: > > > > Igor Mammedov 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 o

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

2019-04-04 Thread Like Xu
On 2019/4/3 0:13, Markus Armbruster wrote: Igor Mammedov writes: On Tue, 2 Apr 2019 21:09:39 +0800 Like Xu wrote: On 2019/4/2 19:27, Markus Armbruster wrote: Like Xu writes: This patch makes the remaining dozen or so uses of the global current_machine outside vl.c use qdev_get_machin

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

2019-04-02 Thread Peter Maydell
On Wed, 3 Apr 2019 at 02:16, Eduardo Habkost wrote: > > On Tue, Apr 02, 2019 at 11:23:42PM +0700, Peter Maydell wrote: > > 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 th

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

2019-04-02 Thread Eduardo Habkost
On Tue, Apr 02, 2019 at 11:23:42PM +0700, Peter Maydell wrote: > On Tue, 2 Apr 2019 at 23:13, Markus Armbruster wrote: > > > > Igor Mammedov 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 functi

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

2019-04-02 Thread Peter Maydell
On Tue, 2 Apr 2019 at 23:13, Markus Armbruster wrote: > > Igor Mammedov 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

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

2019-04-02 Thread Markus Armbruster
Igor Mammedov writes: > On Tue, 2 Apr 2019 21:09:39 +0800 > Like Xu wrote: > >> On 2019/4/2 19:27, Markus Armbruster wrote: >> > Like Xu writes: >> > >> >> This patch makes the remaining dozen or so uses of the global >> >> current_machine outside vl.c use qdev_get_machine() instead, >> >> a

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

2019-04-02 Thread Igor Mammedov
On Tue, 2 Apr 2019 21:09:39 +0800 Like Xu wrote: > On 2019/4/2 19:27, Markus Armbruster wrote: > > Like Xu writes: > > > >> This patch makes the remaining dozen or so uses of the global > >> current_machine outside vl.c use qdev_get_machine() instead, > >> and then make current_machine local

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

2019-04-02 Thread Like Xu
On 2019/4/2 19:27, Markus Armbruster wrote: Like Xu writes: This patch makes the remaining dozen or so uses of the global current_machine outside vl.c use qdev_get_machine() instead, and then make current_machine local to vl.c instead of global. Signed-off-by: Like Xu You effectively repla

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

2019-04-02 Thread Markus Armbruster
Like Xu writes: > This patch makes the remaining dozen or so uses of the global > current_machine outside vl.c use qdev_get_machine() instead, > and then make current_machine local to vl.c instead of global. > > Signed-off-by: Like Xu You effectively replace current_machine by MACHIN

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

2019-04-02 Thread Like Xu
This patch makes the remaining dozen or so uses of the global current_machine outside vl.c use qdev_get_machine() instead, and then make current_machine local to vl.c instead of global. Signed-off-by: Like Xu --- Changes in v2: - make the variable current_machine "static" (Thomas Huth) ---