diff mbox series

[RFC,v2,19/35] multi-process: store info about the remote process

Message ID 20190617181617.30002-1-elena.ufimtseva@oracle.com (mailing list archive)
State New, archived
Headers show
Series Initial support of multi-process qemu | expand

Commit Message

Elena Ufimtseva June 17, 2019, 6:16 p.m. UTC
From: Elena Ufimtseva <elena.ufimtseva@oracle.com>

Store info about the remote process in a hash table, so that
it could be used later for QMP/HMP commands.

Signed-off-by: John G Johnson <john.g.johnson@oracle.com>
Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com>
Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
---
 Changes in v2:
 - moved the “remote_devs” object from “pcms” (PCMachineState)
 to “ms” (MachineState).
---
 hw/core/machine.c     | 12 ++++++++++++
 hw/proxy/qemu-proxy.c |  7 +++++++
 include/hw/boards.h   |  4 ++++
 3 files changed, 23 insertions(+)
diff mbox series

Patch

diff --git a/hw/core/machine.c b/hw/core/machine.c
index 743fef2898..0e6e6c0829 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -821,6 +821,14 @@  static void machine_class_base_init(ObjectClass *oc, void *data)
     }
 }
 
+#ifdef CONFIG_MPQEMU
+static void rem_list_destroy_key(gpointer data)
+{
+    void *key = data;
+    g_free(key);
+}
+#endif
+
 static void machine_initfn(Object *obj)
 {
     MachineState *ms = MACHINE(obj);
@@ -854,6 +862,10 @@  static void machine_initfn(Object *obj)
                                         NULL);
     }
 
+#ifdef CONFIG_MPQEMU
+    ms->remote_devs = g_hash_table_new_full(g_str_hash, g_str_equal,
+                                            rem_list_destroy_key, NULL);
+#endif
 
     /* Register notifier when init is done for sysbus sanity checks */
     ms->sysbus_notifier.notify = machine_init_notify;
diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c
index 6e65600c45..c691a05dac 100644
--- a/hw/proxy/qemu-proxy.c
+++ b/hw/proxy/qemu-proxy.c
@@ -50,6 +50,7 @@ 
 #include "qemu/event_notifier.h"
 #include "sysemu/kvm.h"
 #include "util/event_notifier-posix.c"
+#include "hw/boards.h"
 
 /*
  * TODO: kvm_vm_ioctl is only available for per-target objects (NEED_CPU_H).
@@ -299,6 +300,12 @@  static void pci_proxy_dev_realize(PCIDevice *device, Error **errp)
     PCIProxyDev *dev = PCI_PROXY_DEV(device);
     PCIProxyDevClass *k = PCI_PROXY_DEV_GET_CLASS(dev);
     Error *local_err = NULL;
+    MachineState *ms = MACHINE(current_machine);
+    DeviceState *d = DEVICE(dev);
+
+
+    (void)g_hash_table_insert(ms->remote_devs, (gpointer)g_strdup(d->id),
+                              (gpointer)dev);
 
     if (k->realize) {
         k->realize(dev, &local_err);
diff --git a/include/hw/boards.h b/include/hw/boards.h
index e231860666..bdc519aba9 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -3,6 +3,8 @@ 
 #ifndef HW_BOARDS_H
 #define HW_BOARDS_H
 
+#include <gmodule.h>
+
 #include "sysemu/blockdev.h"
 #include "sysemu/accel.h"
 #include "hw/qdev.h"
@@ -274,6 +276,8 @@  struct MachineState {
     AccelState *accelerator;
     CPUArchIdList *possible_cpus;
     struct NVDIMMState *nvdimms_state;
+
+    GHashTable *remote_devs;
 };
 
 #define DEFINE_MACHINE(namestr, machine_initfn) \