[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 4/8] vl: add -late-object to create QOM objects afte
From: |
Amit Shah |
Subject: |
[Qemu-devel] [PATCH 4/8] vl: add -late-object to create QOM objects after machine init |
Date: |
Fri, 26 Oct 2012 16:31:40 +0530 |
From: Anthony Liguori <address@hidden>
In order to create qdev objects via -late-object, we almost always have to
specify the parent_bus which is usually created during machine init. Until we
properly support two stage init, introduce a -late-object option that allows for
creation of objects post-machine init.
Signed-off-by: Anthony Liguori <address@hidden>
---
qemu-config.c | 10 ++++++++++
qemu-options.hx | 12 ++++++++++++
vl.c | 14 +++++++++++---
3 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/qemu-config.c b/qemu-config.c
index d695bdf..537acd1 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -662,6 +662,15 @@ QemuOptsList qemu_object_opts = {
},
};
+QemuOptsList qemu_late_object_opts = {
+ .name = "late-object",
+ .implied_opt_name = "qom-type",
+ .head = QTAILQ_HEAD_INITIALIZER(qemu_late_object_opts.head),
+ .desc = {
+ { }
+ },
+};
+
static QemuOptsList *vm_config_groups[32] = {
&qemu_drive_opts,
&qemu_chardev_opts,
@@ -679,6 +688,7 @@ static QemuOptsList *vm_config_groups[32] = {
&qemu_iscsi_opts,
&qemu_sandbox_opts,
&qemu_object_opts,
+ &qemu_late_object_opts,
NULL,
};
diff --git a/qemu-options.hx b/qemu-options.hx
index b72151e..a0fe038 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2860,6 +2860,18 @@ DEF("object", HAS_ARG, QEMU_OPTION_object,
" '/objects' path.\n",
QEMU_ARCH_ALL)
+DEF("late-object", HAS_ARG, QEMU_OPTION_late_object,
+ "-late-object TYPENAME[,PROP1=VALUE1,...]\n"
+ " create an new object of type TYPENAME setting
properties\n"
+ " in the order they are specified. Note that the 'id'\n"
+ " property must be set. These objects are placed in the\n"
+ " '/objects' path.\n"
+ "\n"
+ " Late objects are made after machine\n"
+ " initialization so they can refer to objects created by\n"
+ " the machine init function.\n",
+ QEMU_ARCH_ALL)
+
HXCOMM This is the last statement. Insert new options before this line!
STEXI
@end table
diff --git a/vl.c b/vl.c
index eabf47b..61b4666 100644
--- a/vl.c
+++ b/vl.c
@@ -2395,13 +2395,14 @@ static int object_create(QemuOpts *opts, void *opaque)
}
obj = object_new(type);
- if (qemu_opt_foreach(opts, object_set_property, obj, 1) < 0) {
- return -1;
- }
object_property_add_child(container_get(object_get_root(), "/objects"),
id, obj, NULL);
+ if (qemu_opt_foreach(opts, object_set_property, obj, 1) < 0) {
+ return -1;
+ }
+
return 0;
}
@@ -3360,6 +3361,9 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_object:
opts = qemu_opts_parse(qemu_find_opts("object"), optarg, 1);
break;
+ case QEMU_OPTION_late_object:
+ opts = qemu_opts_parse(qemu_find_opts("late-object"), optarg,
1);
+ break;
default:
os_parse_cmd_args(popt->index, optarg);
}
@@ -3706,6 +3710,10 @@ int main(int argc, char **argv, char **envp)
current_machine = machine;
+ if (qemu_opts_foreach(qemu_find_opts("late-object"), object_create, NULL,
0) != 0) {
+ exit(1);
+ }
+
/* init USB devices */
if (usb_enabled) {
if (foreach_device_config(DEV_USB, usb_parse) < 0)
--
1.7.7.6
- [Qemu-devel] [PATCH 0/8] virtio-rng: hardware random number generator device, Amit Shah, 2012/10/26
- [Qemu-devel] [PATCH 1/8] object: add object_property_add_bool (v2), Amit Shah, 2012/10/26
- [Qemu-devel] [PATCH 2/8] qdev: add realized property and make adding child bus implied by realize, Amit Shah, 2012/10/26
- [Qemu-devel] [PATCH 3/8] vl: add -object option to create QOM objects from the command line, Amit Shah, 2012/10/26
- [Qemu-devel] [PATCH 4/8] vl: add -late-object to create QOM objects after machine init,
Amit Shah <=
- [Qemu-devel] [PATCH 5/8] rng: add RndBackend abstract object class, Amit Shah, 2012/10/26
- [Qemu-devel] [PATCH 6/8] rng-urandom: add an RNG backend that uses /dev/urandom, Amit Shah, 2012/10/26
- [Qemu-devel] [PATCH 7/8] rng-egd: introduce EGD compliant RNG backend, Amit Shah, 2012/10/26
- [Qemu-devel] [PATCH 8/8] virtio-rng: hardware random number generator device, Amit Shah, 2012/10/26
- Re: [Qemu-devel] [PATCH 0/8] virtio-rng: hardware random number generator device, Paolo Bonzini, 2012/10/26