aboutsummaryrefslogtreecommitdiff
path: root/hw/core/machine.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2022-04-14 12:52:56 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2022-05-12 12:29:43 +0200
commit97ec4d21e09b5e4a59f00c471a7f76533b08ce56 (patch)
tree0cdc9be29ebd39560f7b8266c2e8ed685ec477a1 /hw/core/machine.c
parent70be1d93f9c2dbf6793830d482e91bb33f921348 (diff)
machine: use QAPI struct for boot configuration
As part of converting -boot to a property with a QAPI type, define the struct and use it throughout QEMU to access boot configuration. machine_boot_parse takes care of doing the QemuOpts->QAPI conversion by hand, for now. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20220414165300.555321-2-pbonzini@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/core/machine.c')
-rw-r--r--hw/core/machine.c68
1 files changed, 65 insertions, 3 deletions
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 700c1e76b8..b3deb8146f 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -784,6 +784,68 @@ static void machine_set_smp(Object *obj, Visitor *v, const char *name,
machine_parse_smp_config(ms, config, errp);
}
+void machine_boot_parse(MachineState *ms, QemuOpts *opts, Error **errp)
+{
+ MachineClass *machine_class = MACHINE_GET_CLASS(ms);
+ const char *s;
+ ERRP_GUARD();
+
+ ms->boot_config = (BootConfiguration) {
+ .has_order = true,
+ .order = (char *)machine_class->default_boot_order,
+ .has_strict = true,
+ .strict = false,
+ };
+ if (!opts) {
+ return;
+ }
+
+ s = qemu_opt_get(opts, "order");
+ if (s) {
+ validate_bootdevices(s, errp);
+ if (*errp) {
+ return;
+ }
+ ms->boot_config.order = (char *)s;
+ }
+
+ s = qemu_opt_get(opts, "once");
+ if (s) {
+ validate_bootdevices(s, errp);
+ if (*errp) {
+ return;
+ }
+ ms->boot_config.has_once = true;
+ ms->boot_config.once = (char *)s;
+ }
+
+ s = qemu_opt_get(opts, "splash");
+ if (s) {
+ ms->boot_config.has_splash = true;
+ ms->boot_config.splash = (char *)s;
+ }
+
+ s = qemu_opt_get(opts, "splash-time");
+ if (s) {
+ ms->boot_config.has_splash_time = true;
+ ms->boot_config.splash_time = qemu_opt_get_number(opts, "splash-time", -1);
+ }
+
+ s = qemu_opt_get(opts, "reboot-timeout");
+ if (s) {
+ ms->boot_config.has_reboot_timeout = true;
+ ms->boot_config.reboot_timeout = qemu_opt_get_number(opts, "reboot-timeout", -1);
+ }
+
+ s = qemu_opt_get(opts, "menu");
+ if (s) {
+ ms->boot_config.has_menu = true;
+ ms->boot_config.menu = qemu_opt_get_bool(opts, "menu", false);
+ }
+
+ ms->boot_config.strict = qemu_opt_get_bool(opts, "strict", false);
+}
+
static void machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -1229,9 +1291,9 @@ void qdev_machine_creation_done(void)
{
cpu_synchronize_all_post_init();
- if (current_machine->boot_once) {
- qemu_boot_set(current_machine->boot_once, &error_fatal);
- qemu_register_reset(restore_boot_order, g_strdup(current_machine->boot_order));
+ if (current_machine->boot_config.has_once) {
+ qemu_boot_set(current_machine->boot_config.once, &error_fatal);
+ qemu_register_reset(restore_boot_order, g_strdup(current_machine->boot_config.order));
}
/*