[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 07/12] vl: Create (most) objects before creating c
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PULL v2 07/12] vl: Create (most) objects before creating chardev backends |
Date: |
Wed, 27 May 2015 20:20:18 +0200 |
From: "Daniel P. Berrange" <address@hidden>
Some types of object must be created before chardevs, other types of
object must be created after chardevs. As such there is no option but
to create objects in two phases.
This takes the decision to create as many object types as possible
right away before anyother backends are created, and only delay
creation of those few which have an explicit dependency on the
chardevs. Hopefully the set which need delaying will remain small
over time.
Signed-off-by: Daniel P. Berrange <address@hidden>
Reviewed-by: Paolo Bonzini <address@hidden>
Signed-off-by: Andreas Färber <address@hidden>
---
vl.c | 40 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
diff --git a/vl.c b/vl.c
index 15bccc4..b7c7511 100644
--- a/vl.c
+++ b/vl.c
@@ -2601,6 +2601,33 @@ static int machine_set_property(const char *name, const
char *value,
return 0;
}
+
+/*
+ * Initial object creation happens before all other
+ * QEMU data types are created. The majority of objects
+ * can be created at this point. The rng-egd object
+ * cannot be created here, as it depends on the chardev
+ * already existing.
+ */
+static bool object_create_initial(const char *type)
+{
+ if (g_str_equal(type, "rng-egd")) {
+ return false;
+ }
+ return true;
+}
+
+
+/*
+ * The remainder of object creation happens after the
+ * creation of chardev, fsdev and device data types.
+ */
+static bool object_create_delayed(const char *type)
+{
+ return !object_create_initial(type);
+}
+
+
static int object_create(QemuOpts *opts, void *opaque)
{
Error *err = NULL;
@@ -2609,6 +2636,7 @@ static int object_create(QemuOpts *opts, void *opaque)
void *dummy = NULL;
OptsVisitor *ov;
QDict *pdict;
+ bool (*type_predicate)(const char *) = opaque;
ov = opts_visitor_new(opts);
pdict = qemu_opts_to_qdict(opts, NULL);
@@ -2623,6 +2651,9 @@ static int object_create(QemuOpts *opts, void *opaque)
if (err) {
goto out;
}
+ if (!type_predicate(type)) {
+ goto out;
+ }
qdict_del(pdict, "id");
visit_type_str(opts_get_visitor(ov), &id, "id", &err);
@@ -4031,6 +4062,12 @@ int main(int argc, char **argv, char **envp)
socket_init();
+ if (qemu_opts_foreach(qemu_find_opts("object"),
+ object_create,
+ object_create_initial, 0) != 0) {
+ exit(1);
+ }
+
if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL,
1) != 0)
exit(1);
#ifdef CONFIG_VIRTFS
@@ -4050,7 +4087,8 @@ int main(int argc, char **argv, char **envp)
}
if (qemu_opts_foreach(qemu_find_opts("object"),
- object_create, NULL, 0) != 0) {
+ object_create,
+ object_create_delayed, 0) != 0) {
exit(1);
}
--
2.1.4
- [Qemu-devel] [PULL v2 00/12] QOM devices patch queue 2015-05-27, Andreas Färber, 2015/05/27
- [Qemu-devel] [PULL v2 01/12] qom: strdup() target property name on object_property_add_alias(), Andreas Färber, 2015/05/27
- [Qemu-devel] [PULL v2 04/12] scripts: Add support for path as argument of qom-tree, Andreas Färber, 2015/05/27
- [Qemu-devel] [PULL v2 05/12] backends: Fix typename of 'policy' enum property in hostmem obj, Andreas Färber, 2015/05/27
- [Qemu-devel] [PULL v2 02/12] qdev: Free property names after registering gpio aliases, Andreas Färber, 2015/05/27
- [Qemu-devel] [PULL v2 08/12] qom: Add helper method for getting user objects root, Andreas Färber, 2015/05/27
- [Qemu-devel] [PULL v2 12/12] qom: Add object_property_add_const_link(), Andreas Färber, 2015/05/27
- [Qemu-devel] [PULL v2 06/12] doc: Document user creatable object types in help text, Andreas Färber, 2015/05/27
- [Qemu-devel] [PULL v2 07/12] vl: Create (most) objects before creating chardev backends,
Andreas Färber <=
- [Qemu-devel] [PULL v2 11/12] qom: Add an object_property_add_enum() helper function, Andreas Färber, 2015/05/27
- [Qemu-devel] [PULL v2 10/12] qom: Make enum string tables const-correct, Andreas Färber, 2015/05/27
- [Qemu-devel] [PULL v2 09/12] qom: Add object_new_with_props() / object_new_withpropv() helpers, Andreas Färber, 2015/05/27
- [Qemu-devel] [PULL v2 03/12] tests: Use qtest_add_data_func() consistently, Andreas Färber, 2015/05/27
- Re: [Qemu-devel] [PULL v2 00/12] QOM devices patch queue 2015-05-27, Peter Maydell, 2015/05/28