Skip to content

Replace current_machine by qdev_get_machine()

Philippe Mathieu-Daudé kvm qemu-arm qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest15 patches 26 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/15target/arm/kvm: Use CPUState::kvm_state in kvm_arm_pmu_supported()target/arm/kvm.c+1 -31 reply
2/15hw/ppc/spapr_rtas: Use local MachineState variablehw/ppc/spapr_rtas.c+1 -12 replies
3/15hw/ppc/spapr_rtas: Access MachineState via SpaprMachineState argumenthw/ppc/spapr_rtas.c+1 -12 replies
4/15hw/ppc/spapr_rtas: Restrict variables scope to single switch casehw/ppc/spapr_rtas.c+2 -25 replies
5/15device-hotplug: Replace current_machine by qdev_get_machine()device-hotplug.c+1 -11 reply
6/15migration/savevm: Replace current_machine by qdev_get_machine()migration/savevm.c+5 -53 replies
7/15hw/core/machine-qmp-cmds: Replace current_machine by qdev_get_machine()hw/core/machine-qmp-cmds.c+2 -21 reply
8/15target/arm/monitor: Replace current_machine by qdev_get_machine()target/arm/monitor.c+2 -11 reply
9/15device_tree: Replace current_machine by qdev_get_machine()device_tree.c+3 -11 reply
10/15memory: Replace current_machine by qdev_get_machine()memory.c+3 -13 replies
11/15exec: Replace current_machine by qdev_get_machine()exec.c+6 -41 reply
12/15accel: Introduce the current_accel() methodaccel/accel.c include/sysemu/accel.h+7 -01 reply
13/15accel: Replace current_machine->accelerator by current_accel() methodaccel/kvm/kvm-all.c accel/tcg/tcg-all.c memory.c +4 more+9 -91 reply
14/15accel/accel: Replace current_machine by qdev_get_machine()accel/accel.c+3 -11 reply
15/15vl: Make current_machine a local variableinclude/hw/boards.h vl.c+2 -41 reply

Reviews trailers per patch

14 of 15 patches have a Reviewed-by or Acked-by.

PatchDr. David Alan GilbertGreg KurzAlistair FrancisDavid GibsonJuan Quintela
1/15R-b
2/15R-b A-b
3/15R-b A-b
4/15
5/15R-b
6/15A-b R-b R-b
7/15R-b
8/15R-b
9/15R-b
10/15R-b
11/15R-b
12/15R-b
13/15R-b
14/15R-b
15/15R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 5 reviewers.

Read the v1 thread

Cover letter [PATCH 00/15] Replace current_machine by qdev_get_machine()

Blurb from previous question [1]:

"hw/boards.h" declare current_machine, and vl.c defines it:

    current_machine = MACHINE(object_new_with_class(OBJECT_CLASS(machine_class)));
    object_property_add_child(object_get_root(), "machine",
                              OBJECT(current_machine), &error_abort);

The bigger user of 'current_machine' is the accel/KVM code.

Recently in a0628599f..cc7d44c2e0 "Replace global smp variables with machine smp properties" we started to use MACHINE(qdev_get_machine()). Following a0628599f..cc7d44c2e0, a5e0b33119 use 'current_machine' again.

qdev_get_machine() resolves the machine in the QOM composition tree.

Paolo answered [2]:

Quoted 3 lines

I would always use MACHINE(qdev_get_machine()), espeecially outside vl.c. Ideally, current_machine would be static within vl.c or even unused outside the object_property_add_child() that you quote above.

Let's remove the global current_machine.

I am still confused by this comment:

/* qdev_get_machine() can return something that's not TYPE_MACHINE
* if this is one of the user-only emulators; in that case there's
* no need to check the ignore_memory_transaction_failures board flag. */

[1] https://www.mail-archive.com/[email protected]/msg669475.html
[2] https://www.mail-archive.com/[email protected]/msg669493.html

Philippe Mathieu-Daudé (15):
target/arm/kvm: Use CPUState::kvm_state in kvm_arm_pmu_supported() hw/ppc/spapr_rtas: Use local MachineState variable hw/ppc/spapr_rtas: Access MachineState via SpaprMachineState argument hw/ppc/spapr_rtas: Restrict variables scope to single switch case
device-hotplug: Replace current_machine by qdev_get_machine() migration/savevm: Replace current_machine by qdev_get_machine() hw/core/machine-qmp-cmds: Replace current_machine by
qdev_get_machine()
target/arm/monitor: Replace current_machine by qdev_get_machine()
device_tree: Replace current_machine by qdev_get_machine()
memory: Replace current_machine by qdev_get_machine()
exec: Replace current_machine by qdev_get_machine()
accel: Introduce the current_accel() method
accel: Replace current_machine->accelerator by current_accel() method accel/accel: Replace current_machine by qdev_get_machine()
vl: Make current_machine a local variable

 include/hw/boards.h        |  2 --
 include/sysemu/accel.h     |  2 ++
 accel/accel.c              |  7 +++++++
 accel/kvm/kvm-all.c        |  4 ++--
 accel/tcg/tcg-all.c        |  2 +-
 device-hotplug.c           |  2 +-
 device_tree.c              |  4 +++-
 exec.c                     | 10 ++++++----
 hw/core/machine-qmp-cmds.c |  4 ++--
 hw/ppc/spapr_rtas.c        |  6 +++---
 memory.c                   |  6 ++++--
 migration/savevm.c         | 10 +++++-----
 target/arm/kvm.c           |  4 +---
 target/arm/kvm64.c         |  4 ++--
 target/arm/monitor.c       |  3 ++-
 target/i386/kvm.c          |  2 +-
 target/ppc/kvm.c           |  2 +-
 vl.c                       |  6 +++---
 18 files changed, 46 insertions(+), 34 deletions(-)
Signature · 1 line
2.21.1