mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-09-06 18:05:37 +00:00
vl: Create (most) objects before creating chardev backends
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 <berrange@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
parent
b9174d4f25
commit
f08f9271bf
40
vl.c
40
vl.c
|
@ -2671,6 +2671,33 @@ static int machine_set_property(void *opaque,
|
||||||
return 0;
|
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(void *opaque, QemuOpts *opts, Error **errp)
|
static int object_create(void *opaque, QemuOpts *opts, Error **errp)
|
||||||
{
|
{
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
|
@ -2679,6 +2706,7 @@ static int object_create(void *opaque, QemuOpts *opts, Error **errp)
|
||||||
void *dummy = NULL;
|
void *dummy = NULL;
|
||||||
OptsVisitor *ov;
|
OptsVisitor *ov;
|
||||||
QDict *pdict;
|
QDict *pdict;
|
||||||
|
bool (*type_predicate)(const char *) = opaque;
|
||||||
|
|
||||||
ov = opts_visitor_new(opts);
|
ov = opts_visitor_new(opts);
|
||||||
pdict = qemu_opts_to_qdict(opts, NULL);
|
pdict = qemu_opts_to_qdict(opts, NULL);
|
||||||
|
@ -2693,6 +2721,9 @@ static int object_create(void *opaque, QemuOpts *opts, Error **errp)
|
||||||
if (err) {
|
if (err) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
if (!type_predicate(type)) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
qdict_del(pdict, "id");
|
qdict_del(pdict, "id");
|
||||||
visit_type_str(opts_get_visitor(ov), &id, "id", &err);
|
visit_type_str(opts_get_visitor(ov), &id, "id", &err);
|
||||||
|
@ -4114,6 +4145,12 @@ int main(int argc, char **argv, char **envp)
|
||||||
|
|
||||||
socket_init();
|
socket_init();
|
||||||
|
|
||||||
|
if (qemu_opts_foreach(qemu_find_opts("object"),
|
||||||
|
object_create,
|
||||||
|
object_create_initial, NULL)) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
if (qemu_opts_foreach(qemu_find_opts("chardev"),
|
if (qemu_opts_foreach(qemu_find_opts("chardev"),
|
||||||
chardev_init_func, NULL, NULL)) {
|
chardev_init_func, NULL, NULL)) {
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -4137,7 +4174,8 @@ int main(int argc, char **argv, char **envp)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemu_opts_foreach(qemu_find_opts("object"),
|
if (qemu_opts_foreach(qemu_find_opts("object"),
|
||||||
object_create, NULL, NULL)) {
|
object_create,
|
||||||
|
object_create_delayed, NULL)) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue