qemu-devel
[Top][All Lists]
Advanced

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

[RFC 47/52] hw/machine: Use opts_visitor to parse hybrid topo


From: Zhao Liu
Subject: [RFC 47/52] hw/machine: Use opts_visitor to parse hybrid topo
Date: Mon, 13 Feb 2023 17:50:30 +0800

From: Zhao Liu <zhao1.liu@intel.com>

Because of the "-hybrid" format, it cannot be defined as the machine
property to use input_visitor to parse as what "-smp" did.

So here we use opts_visitor to parse hybrid topology.

Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
 hw/core/machine-topo.c | 36 +++++++++++++++++++++++++++++++++---
 include/hw/boards.h    |  4 +---
 2 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/hw/core/machine-topo.c b/hw/core/machine-topo.c
index ebd2c40396a2..9e37de04ce75 100644
--- a/hw/core/machine-topo.c
+++ b/hw/core/machine-topo.c
@@ -20,6 +20,8 @@
 #include "qemu/osdep.h"
 #include "hw/boards.h"
 #include "qapi/error.h"
+#include "qapi/opts-visitor.h"
+#include "qapi/qapi-visit-machine.h"
 
 unsigned int machine_topo_get_sockets(const MachineState *ms)
 {
@@ -571,9 +573,9 @@ static void parse_hybrid_core(MachineState *ms,
     }
 }
 
-void set_hybrid_options(MachineState *ms,
-                        const HybridOptions *config,
-                        Error **errp)
+static void set_hybrid_options(MachineState *ms,
+                               const HybridOptions *config,
+                               Error **errp)
 {
     MachineClass *mc = MACHINE_GET_CLASS(ms);
 
@@ -601,6 +603,34 @@ void set_hybrid_options(MachineState *ms,
     }
 }
 
+static int parse_hybrid(void *opaque, QemuOpts *opts, Error **errp)
+{
+    g_autoptr(HybridOptions) config = NULL;
+    MachineState *ms = MACHINE(opaque);
+    Error *err = NULL;
+    Visitor *v = opts_visitor_new(opts);
+
+    visit_type_HybridOptions(v, NULL, &config, errp);
+    visit_free(v);
+    if (!config) {
+        return -1;
+    }
+
+    set_hybrid_options(ms, config, &err);
+
+    if (err) {
+        error_propagate(errp, err);
+        return -1;
+    }
+
+    return 0;
+}
+
+void parse_hybrid_opts(MachineState *ms)
+{
+    qemu_opts_foreach(qemu_find_opts("hybrid"), parse_hybrid, ms, 
&error_fatal);
+}
+
 void machine_free_hybrid_topology(MachineState *ms)
 {
     HybridCluster *cluster;
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 0f865c21e2a8..0395990139bc 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -37,9 +37,7 @@ void machine_set_cpu_numa_node(MachineState *machine,
 void machine_parse_smp_config(MachineState *ms,
                               const SMPConfiguration *config, Error **errp);
 int machine_parse_hybrid_core_type(MachineState *ms, const char *coretype);
-void set_hybrid_options(MachineState *ms,
-                        const HybridOptions *config,
-                        Error **errp);
+void parse_hybrid_opts(MachineState *ms);
 void machine_free_hybrid_topology(MachineState *ms);
 void machine_validate_hybrid_topology(MachineState *ms, Error **errp);
 void machine_consolidate_hybrid_topology(MachineState *ms);
-- 
2.34.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]