Re: [PATCH 10/15] memory: Replace current_machine by qdev_get_machine()

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

 



On 1/12/20 10:48 AM, Alistair Francis wrote:
On Thu, Jan 9, 2020 at 11:29 PM Philippe Mathieu-Daudé
<philmd@xxxxxxxxxx> wrote:

As we want to remove the global current_machine,
replace 'current_machine' by MACHINE(qdev_get_machine()).

Signed-off-by: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>
---
  memory.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/memory.c b/memory.c
index d7b9bb6951..57e38b1f50 100644
--- a/memory.c
+++ b/memory.c
@@ -3004,6 +3004,7 @@ static void mtree_print_flatview(gpointer key, gpointer value,
      int n = view->nr;
      int i;
      AddressSpace *as;
+    MachineState *ms;

      qemu_printf("FlatView #%d\n", fvi->counter);
      ++fvi->counter;
@@ -3026,6 +3027,7 @@ static void mtree_print_flatview(gpointer key, gpointer value,
          return;
      }

+    ms = MACHINE(qdev_get_machine());

Why not set this at the top?

Calling qdev_get_machine() is not free as it does some introspection checks. Since we can return earlier if there are no rendered FlatView, I placed the machinestate initialization just before it we need to access it.

Alistair

      while (n--) {
          mr = range->mr;
          if (range->offset_in_region) {
@@ -3057,7 +3059,7 @@ static void mtree_print_flatview(gpointer key, gpointer value,
          if (fvi->ac) {
              for (i = 0; i < fv_address_spaces->len; ++i) {
                  as = g_array_index(fv_address_spaces, AddressSpace*, i);
-                if (fvi->ac->has_memory(current_machine, as,
+                if (fvi->ac->has_memory(ms, as,
                                          int128_get64(range->addr.start),
                                          MR_SIZE(range->addr.size) + 1)) {
                      qemu_printf(" %s", fvi->ac->name);
--
2.21.1







[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux