From nobody Wed Feb 11 05:28:50 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1649955321; cv=none; d=zohomail.com; s=zohoarc; b=JKlzralIcOrE52ElpW4gk/oPjqfUZGrzHWfc/W08uTzW4hMUFN5AduD9ddHOsnFMh/1tV1u2mvUi7DmK3jTGo5eI3t5I3nUpwkDx9ZIy3h34j6mtwjlBVmZRSVyugjoBeJr2Xvn8rEMozagN3E0hjtB4zbF7TJblkoHa3zyFhe8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649955321; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3zQ1aJt93nFCv5iYcBQWQHXF42AI9uk1BQKuJmyq6Xg=; b=Q1Eetojqns79BuzyXc+Ya38Ymj3GiUMm0ePXqGT0uIpMO0CDWLileBawaWvNxPrOzr/9thospOhEKq5FTDw//m93Xfzy27nIJcyirn/46xDQyWgi6HinbAON1zWqNNelDjl8LCHtFuwnk/VqwgA9e6yhbIDfJmEXZgmRcv0kZmo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1649955321426271.8784763088356; Thu, 14 Apr 2022 09:55:21 -0700 (PDT) Received: from localhost ([::1]:34224 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nf2kZ-0005M0-Qv for importer@patchew.org; Thu, 14 Apr 2022 12:55:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nf2iR-0002gx-3K for qemu-devel@nongnu.org; Thu, 14 Apr 2022 12:53:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:26542) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nf2iO-00047m-Cu for qemu-devel@nongnu.org; Thu, 14 Apr 2022 12:53:06 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-551-nmSMSBJvM0GSu3anEXYePA-1; Thu, 14 Apr 2022 12:53:02 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CE586805F7C for ; Thu, 14 Apr 2022 16:53:01 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB3AB14583C1 for ; Thu, 14 Apr 2022 16:53:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649955183; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3zQ1aJt93nFCv5iYcBQWQHXF42AI9uk1BQKuJmyq6Xg=; b=T5T5DB/HROPr5xlFLBljiavVAT4U3A775Z8YVQQZ1kvjIunXVTM3fez4lHG/+Q8FljWHQw R4YYf69Q+xALlIf0CVvhzvdtaYzCrOCDINfwrWqp7O5A75ET/o+Xh8ZIQzq1zFrM5SwsqI 52Ha2oGhZMTJC5vUQAMacG8MBlH768c= X-MC-Unique: nmSMSBJvM0GSu3anEXYePA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH for-7.1 2/5] machine: add boot compound property Date: Thu, 14 Apr 2022 12:52:57 -0400 Message-Id: <20220414165300.555321-3-pbonzini@redhat.com> In-Reply-To: <20220414165300.555321-1-pbonzini@redhat.com> References: <20220414165300.555321-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1649955323871100005 Content-Type: text/plain; charset="utf-8" Make -boot syntactic sugar for a compound property "-machine boot.{order,me= nu,...}". machine_boot_parse is replaced by the setter for the property. Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 99 ++++++++++++++++++++++++--------------------- include/hw/boards.h | 1 - softmmu/vl.c | 16 +++----- 3 files changed, 58 insertions(+), 58 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index dc059cfab5..710dfbd982 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -771,66 +771,63 @@ static void machine_set_smp(Object *obj, Visitor *v, = const char *name, machine_parse_smp_config(ms, config, errp); } =20 -void machine_boot_parse(MachineState *ms, QemuOpts *opts, Error **errp) +static void machine_get_boot(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + MachineState *ms =3D MACHINE(obj); + BootConfiguration *config =3D &ms->boot_config; + visit_type_BootConfiguration(v, name, &config, &error_abort); +} + +static void machine_free_boot_config(MachineState *ms) +{ + g_free(ms->boot_config.order); + g_free(ms->boot_config.once); + g_free(ms->boot_config.splash); +} + +static void machine_copy_boot_config(MachineState *ms, BootConfiguration *= config) { MachineClass *machine_class =3D MACHINE_GET_CLASS(ms); - const char *s; + + machine_free_boot_config(ms); + ms->boot_config =3D *config; + if (!config->has_order) { + ms->boot_config.has_order =3D true; + ms->boot_config.order =3D g_strdup(machine_class->default_boot_ord= er); + } +} + +static void machine_set_boot(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ ERRP_GUARD(); + MachineState *ms =3D MACHINE(obj); + BootConfiguration *config =3D NULL; =20 - ms->boot_config =3D (BootConfiguration) { - .has_order =3D true, - .order =3D (char *)machine_class->default_boot_order, - .has_strict =3D true, - .strict =3D false, - }; - if (!opts) { + if (!visit_type_BootConfiguration(v, name, &config, errp)) { return; } - - s =3D qemu_opt_get(opts, "order"); - if (s) { - validate_bootdevices(s, errp); + if (config->has_order) { + validate_bootdevices(config->order, errp); if (*errp) { - return; + goto out_free; } - ms->boot_config.order =3D (char *)s; } - - s =3D qemu_opt_get(opts, "once"); - if (s) { - validate_bootdevices(s, errp); + if (config->has_once) { + validate_bootdevices(config->once, errp); if (*errp) { - return; + goto out_free; } - ms->boot_config.has_once =3D true; - ms->boot_config.once =3D (char *)s; } =20 - s =3D qemu_opt_get(opts, "splash"); - if (s) { - ms->boot_config.has_splash =3D true; - ms->boot_config.splash =3D (char *)s; - } - - s =3D qemu_opt_get(opts, "splash-time"); - if (s) { - ms->boot_config.has_splash_time =3D true; - ms->boot_config.splash_time =3D qemu_opt_get_number(opts, "splash-= time", -1); - } + machine_copy_boot_config(ms, config); + /* Strings live in ms->boot_config. */ + free(config); + return; =20 - s =3D qemu_opt_get(opts, "reboot-timeout"); - if (s) { - ms->boot_config.has_reboot_timeout =3D true; - ms->boot_config.reboot_timeout =3D qemu_opt_get_number(opts, "rebo= ot-timeout", -1); - } - - s =3D qemu_opt_get(opts, "menu"); - if (s) { - ms->boot_config.has_menu =3D true; - ms->boot_config.menu =3D qemu_opt_get_bool(opts, "menu", false); - } - - ms->boot_config.strict =3D qemu_opt_get_bool(opts, "strict", false); +out_free: + qapi_free_BootConfiguration(config); } =20 static void machine_class_init(ObjectClass *oc, void *data) @@ -871,6 +868,12 @@ static void machine_class_init(ObjectClass *oc, void *= data) object_class_property_set_description(oc, "dumpdtb", "Dump current dtb to a file and quit"); =20 + object_class_property_add(oc, "boot", "BootConfiguration", + machine_get_boot, machine_set_boot, + NULL, NULL); + object_class_property_set_description(oc, "boot", + "Boot configuration"); + object_class_property_add(oc, "smp", "SMPConfiguration", machine_get_smp, machine_set_smp, NULL, NULL); @@ -1004,12 +1007,16 @@ static void machine_initfn(Object *obj) ms->smp.clusters =3D 1; ms->smp.cores =3D 1; ms->smp.threads =3D 1; + ms->smp.sockets =3D 1; + + machine_copy_boot_config(ms, &(BootConfiguration){ 0 }); } =20 static void machine_finalize(Object *obj) { MachineState *ms =3D MACHINE(obj); =20 + machine_free_boot_config(ms); g_free(ms->kernel_filename); g_free(ms->initrd_filename); g_free(ms->kernel_cmdline); diff --git a/include/hw/boards.h b/include/hw/boards.h index 4b4e8d6991..8994f6c93b 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -26,7 +26,6 @@ OBJECT_DECLARE_TYPE(MachineState, MachineClass, MACHINE) extern MachineState *current_machine; =20 void machine_run_board_init(MachineState *machine); -void machine_boot_parse(MachineState *ms, QemuOpts *opts, Error **errp); bool machine_usb(MachineState *machine); int machine_phandle_start(MachineState *machine); bool machine_dump_guest_core(MachineState *machine); diff --git a/softmmu/vl.c b/softmmu/vl.c index 5759df3664..80936e595f 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -1878,16 +1878,11 @@ static bool object_create_early(const char *type) =20 static void qemu_apply_machine_options(QDict *qdict) { - QemuOpts *opts; - object_set_properties_from_keyval(OBJECT(current_machine), qdict, fals= e, &error_fatal); current_machine->ram_size =3D ram_size; current_machine->maxram_size =3D maxram_size; current_machine->ram_slots =3D ram_slots; =20 - opts =3D qemu_opts_find(qemu_find_opts("boot-opts"), NULL); - machine_boot_parse(current_machine, opts, &error_fatal); - if (semihosting_enabled() && !semihosting_get_argc()) { /* fall back to the -kernel/-append */ semihosting_arg_fallback(current_machine->kernel_filename, current= _machine->kernel_cmdline); @@ -2183,7 +2178,8 @@ static bool is_qemuopts_group(const char *group) { if (g_str_equal(group, "object") || g_str_equal(group, "machine") || - g_str_equal(group, "smp-opts")) { + g_str_equal(group, "smp-opts") || + g_str_equal(group, "boot-opts")) { return false; } return true; @@ -2205,6 +2201,8 @@ static void qemu_record_config_group(const char *grou= p, QDict *dict, keyval_merge(machine_opts_dict, dict, errp); } else if (g_str_equal(group, "smp-opts")) { machine_merge_property("smp", dict, &error_fatal); + } else if (g_str_equal(group, "boot-opts")) { + machine_merge_property("boot", dict, &error_fatal); } else { abort(); } @@ -2947,11 +2945,7 @@ void qemu_init(int argc, char **argv, char **envp) drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS); break; case QEMU_OPTION_boot: - opts =3D qemu_opts_parse_noisily(qemu_find_opts("boot-opts= "), - optarg, true); - if (!opts) { - exit(1); - } + machine_parse_property_opt(qemu_find_opts("boot-opts"), "b= oot", optarg); break; case QEMU_OPTION_fda: case QEMU_OPTION_fdb: --=20 2.31.1