@@ -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,
};
@@ -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
@@ -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)