On 10/17/24 17:14, Steve Sistare wrote:
Complete monitor connections as early as possible, prior to
qemu_create_early_backends, so the user can issue commands during the
precreate phase.

Make a list of the chardev's referenced by all monitors.  Create the
chardevs, then create the monitors.  Exclude monitor chardevs and
monitors from the later creation phases.

Signed-off-by: Steve Sistare <steven.sist...@oracle.com>
---
  system/vl.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
  1 file changed, 77 insertions(+), 4 deletions(-)

diff --git a/system/vl.c b/system/vl.c
index 3c592b9..a985ab8 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -1939,6 +1939,11 @@ static bool object_create_early(const ObjectOption *opt)
          return false;
      }
+ /* Reason: already created. */
+    if (g_str_equal(type, "mon")) {
+        return false;
+    }

This is incorrect as mentioned by Peter.

      return true;
  }
@@ -1956,6 +1961,68 @@ static void qemu_apply_machine_options(QDict *qdict)
      }
  }
+typedef struct NamedElement {
+    char *name;
+    QTAILQ_ENTRY(NamedElement) next;
+} NamedElement;
+
+static QTAILQ_HEAD(, NamedElement) monitor_chardevs =
+    QTAILQ_HEAD_INITIALIZER(monitor_chardevs);
+
+static void chardev_add(const char *name)
+{
+    NamedElement *elem = g_new0(NamedElement, 1);
+
+    elem->name = g_strdup(name);
+    QTAILQ_INSERT_TAIL(&monitor_chardevs, elem, next);
+}
+
+static bool chardev_find(const char *name)
+{
+    NamedElement *elem;
+
+    QTAILQ_FOREACH(elem, &monitor_chardevs, next) {
+        if (g_str_equal(elem->name, name)) {
+            return true;
+        }
+    }
+    return false;
+}

No new special casing and no tricky differentiation of how a single command line option is processed. If you need to create monitors so early, create _all_ chardevs and _all_ monitors; same for qtest.

Paolo


Reply via email to