[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-trivial] [Qemu-devel] [PATCH v2] vl.c: make current_machine as
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-trivial] [Qemu-devel] [PATCH v2] vl.c: make current_machine as non-global variable |
Date: |
Tue, 02 Apr 2019 13:27:10 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
Like Xu <address@hidden> 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 <address@hidden>
You effectively replace
current_machine
by
MACHINE(qdev_get_machine())
qdev_get_machine() uses container_get(), which has a side effect: any
path component that doesn't exist already gets created as "container"
object. In case of qdev_get_machine(), that's just "/machine".
Creating "/machine" as "container" is of course wrong. You therefore
must not use qdev_get_machine() before main() creates "/machine". It
does like this:
object_property_add_child(object_get_root(), "machine",
OBJECT(current_machine), &error_abort);
I recently had several cases of code rearrangements explode because the
reordered code called qdev_get_machine() too early. Makes me rather
skeptical about this patch. To be frank, I consider qdev_get_machine()
a trap for the unwary. container_get(), too.
If we decide using it to make current_machine static a good idea anyway,
we need to check the new uses carefully to make sure they can't run
before main() creates "/machine".
- [Qemu-trivial] [Qemu-devel] [PATCH v2] vl.c: make current_machine as non-global variable, Like Xu, 2019/04/02
- Re: [Qemu-trivial] [Qemu-devel] [PATCH v2] vl.c: make current_machine as non-global variable,
Markus Armbruster <=
- Re: [Qemu-trivial] [Qemu-devel] [PATCH v2] vl.c: make current_machine as non-global variable, Like Xu, 2019/04/02
- Re: [Qemu-trivial] [Qemu-devel] [PATCH v2] vl.c: make current_machine as non-global variable, Igor Mammedov, 2019/04/02
- Re: [Qemu-trivial] [Qemu-devel] [PATCH v2] vl.c: make current_machine as non-global variable, Markus Armbruster, 2019/04/02
- Re: [Qemu-trivial] [Qemu-devel] [PATCH v2] vl.c: make current_machine as non-global variable, Peter Maydell, 2019/04/02
- Re: [Qemu-trivial] [Qemu-devel] [PATCH v2] vl.c: make current_machine as non-global variable, Eduardo Habkost, 2019/04/02
- Re: [Qemu-trivial] [Qemu-devel] [PATCH v2] vl.c: make current_machine as non-global variable, Peter Maydell, 2019/04/02
- Re: [Qemu-trivial] [Qemu-devel] [PATCH v2] vl.c: make current_machine as non-global variable, Igor Mammedov, 2019/04/04
- Re: [Qemu-trivial] [Qemu-devel] [PATCH v2] vl.c: make current_machine as non-global variable, Peter Maydell, 2019/04/04
- Re: [Qemu-trivial] [Qemu-devel] [PATCH v2] vl.c: make current_machine as non-global variable, Like Xu, 2019/04/04