[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
- Re: [RFC 41/52] machine: Introduce core_type() hook, (continued)
- [RFC 42/52] hw/machine: Add hybrid_supported in generic topo properties, Zhao Liu, 2023/02/13
- [RFC 40/52] qapi: Introduce hybrid options, Zhao Liu, 2023/02/13
- [RFC 39/52] i386/cpu: Add Intel hybrid related CPUID support, Zhao Liu, 2023/02/13
- [RFC 43/52] hw/machine: Rename MachineClass.smp_props to MachineClass.topo_props, Zhao Liu, 2023/02/13
- [RFC 44/52] machine: Add "-hybrid" parsing rule, Zhao Liu, 2023/02/13
- [RFC 45/52] hw/machine: Add hybrid cpu topology validation, Zhao Liu, 2023/02/13
- [RFC 47/52] hw/machine: Use opts_visitor to parse hybrid topo,
Zhao Liu <=
- [RFC 46/52] hw/machine: build core level hybrid topology form HybridCorePack, Zhao Liu, 2023/02/13
- [RFC 48/52] machine: Support "-hybrid" command, Zhao Liu, 2023/02/13
- [RFC 49/52] i386/pc: Support hybrid cpu topology, Zhao Liu, 2023/02/13
- [RFC 50/52] qemu-options: Add the document of hybrid command, Zhao Liu, 2023/02/13
- [RFC 51/52] qapi: Expose CPU topology info in query_cpus_fast, Zhao Liu, 2023/02/13
- [RFC 52/52] i386: Support cpu_index_to_core_type() for x86, Zhao Liu, 2023/02/13
- Re: [RFC 00/52] Introduce hybrid CPU topology, Alex Bennée, 2023/02/13
- Re: [RFC 00/52] Introduce hybrid CPU topology, Daniel P . Berrangé, 2023/02/13