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.
With type assertion in qdev_get_machine(), it will be hard to misuse this function if machine hasn't been created yet. For obj-common cases, qdev_get_machine_uncheck() is applied without semantic change. --- Changes in v3: - add TYPE_MACHINE assertion for qdev_get_machine() usage - apply qdev_get_machine_uncheck() for obj-common usage Changes in v2: - make the variable current_machine "static" (Thomas Huth) Like Xu (2): vl.c: refactor current_machine as non-global variable core/qdev: refactor qdev_get_machine() with type assertion accel/kvm/kvm-all.c | 6 ++++-- device-hotplug.c | 3 ++- device_tree.c | 3 ++- exec.c | 6 ++++-- hw/core/qdev.c | 16 +++++++++++++--- hw/ppc/spapr_rtas.c | 3 ++- include/hw/boards.h | 1 - include/hw/qdev-core.h | 1 + migration/savevm.c | 9 ++++++--- qmp.c | 3 ++- qom/cpu.c | 5 +++-- target/i386/kvm.c | 3 ++- target/ppc/kvm.c | 3 ++- vl.c | 4 ++-- 14 files changed, 45 insertions(+), 21 deletions(-) -- 1.8.3.1