From nobody Thu May 9 17:25:51 2024 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=1649955518; cv=none; d=zohomail.com; s=zohoarc; b=Jvd8NetTSill6dq1nFFjarYCYQptKGPNVa7aRNp6pAv8BYMffB738UzOwE8kydcEl+vlTYSwP0NcSdo/OeBR4FNJlpqMd5Ql3hAl8K25mzoeAo10AlEsAB8S6dl83lG1aB73hgNpPW0KDZV1XpmPl6x0uvoLCBAfrQCau88EVWE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649955518; 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=XtfRDbss55GendRj5Y2j6p0OpwSZU+pyRYEZeJtl7Io=; b=StchF5AzosgF7QNVPFwFuN7kc53jSIJ+78epEiLNmhlieaRMeKdoQ9sLvxfepdqiovQxfpg5EgEjj56k3ikJ9ZqSVrNL1RaXR5ueXWFwJsQgifseYzUko8weGFvAJerQLl4OtecNKFasiWakWDMsL68N0BETP9DGNNaxvcwQHnY= 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 1649955518598923.6334082718914; Thu, 14 Apr 2022 09:58:38 -0700 (PDT) Received: from localhost ([::1]:41040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nf2nl-0001aQ-63 for importer@patchew.org; Thu, 14 Apr 2022 12:58:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40860) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nf2iU-0002hp-59 for qemu-devel@nongnu.org; Thu, 14 Apr 2022 12:53:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24960) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nf2iO-00047q-93 for qemu-devel@nongnu.org; Thu, 14 Apr 2022 12:53:08 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-454-JdeJzsBLMBOfMk_crq84Zw-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 B28C03C13A09 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 9ADB7145831F 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=XtfRDbss55GendRj5Y2j6p0OpwSZU+pyRYEZeJtl7Io=; b=CxJQ+dheHJHDOx7lLVWq5WBB918TBlNnBA3XqbManMC80FsSnM/So60DOziEvnzZrR69bv x5deK9hNpvZl6VpxPGhUtoAWamm3TJwdoRNLYvStHNtuwu8i0Fe4votmr1tltGLTMO6mGK EfUOoHNUYjCVwjCRYQPwjupthSnDLy8= X-MC-Unique: JdeJzsBLMBOfMk_crq84Zw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH for-7.1 1/5] machine: use QAPI struct for boot configuration Date: Thu, 14 Apr 2022 12:52:56 -0400 Message-Id: <20220414165300.555321-2-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.133.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_H5=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: 1649955520416100003 Content-Type: text/plain; charset="utf-8" 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 --- hw/arm/nseries.c | 2 +- hw/core/machine.c | 68 +++++++++++++++++++++++++++++++++++++++-- hw/hppa/machine.c | 6 ++-- hw/i386/pc.c | 2 +- hw/nvram/fw_cfg.c | 27 +++++----------- hw/ppc/mac_newworld.c | 2 +- hw/ppc/mac_oldworld.c | 2 +- hw/ppc/prep.c | 2 +- hw/ppc/spapr.c | 4 +-- hw/s390x/ipl.c | 20 ++++-------- hw/sparc/sun4m.c | 4 +-- hw/sparc64/sun4u.c | 4 +-- include/hw/boards.h | 4 +-- include/sysemu/sysemu.h | 2 -- qapi/machine.json | 30 ++++++++++++++++++ softmmu/bootdevice.c | 3 +- softmmu/globals.c | 2 -- softmmu/vl.c | 25 +-------------- 18 files changed, 127 insertions(+), 82 deletions(-) diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c index 9c1cafae86..692c94ceb4 100644 --- a/hw/arm/nseries.c +++ b/hw/arm/nseries.c @@ -1365,7 +1365,7 @@ static void n8x0_init(MachineState *machine, } =20 if (option_rom[0].name && - (machine->boot_order[0] =3D=3D 'n' || !machine->kernel_filename)) { + (machine->boot_config.order[0] =3D=3D 'n' || !machine->kernel_file= name)) { uint8_t *nolo_tags =3D g_new(uint8_t, 0x10000); /* No, wait, better start at the ROM. */ s->mpu->cpu->env.regs[15] =3D OMAP2_Q2_BASE + 0x400000; diff --git a/hw/core/machine.c b/hw/core/machine.c index 1e23fdc14b..dc059cfab5 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -771,6 +771,68 @@ static void machine_set_smp(Object *obj, Visitor *v, c= onst char *name, machine_parse_smp_config(ms, config, errp); } =20 +void machine_boot_parse(MachineState *ms, QemuOpts *opts, Error **errp) +{ + MachineClass *machine_class =3D MACHINE_GET_CLASS(ms); + const char *s; + ERRP_GUARD(); + + 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) { + return; + } + + s =3D qemu_opt_get(opts, "order"); + if (s) { + validate_bootdevices(s, errp); + if (*errp) { + return; + } + ms->boot_config.order =3D (char *)s; + } + + s =3D qemu_opt_get(opts, "once"); + if (s) { + validate_bootdevices(s, errp); + if (*errp) { + return; + } + ms->boot_config.has_once =3D true; + ms->boot_config.once =3D (char *)s; + } + + 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); + } + + 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); +} + static void machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); @@ -1210,9 +1272,9 @@ void qdev_machine_creation_done(void) { cpu_synchronize_all_post_init(); =20 - 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)); } =20 /* diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 98b30e0395..716a831464 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -116,7 +116,7 @@ static FWCfgState *create_fw_cfg(MachineState *ms) fw_cfg_add_file(fw_cfg, "/etc/power-button-addr", g_memdup(&val, sizeof(val)), sizeof(val)); =20 - fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ms->boot_order[0]); + fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ms->boot_config.order[0]); qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); =20 return fw_cfg; @@ -309,8 +309,8 @@ static void machine_hppa_init(MachineState *machine) * mode (kernel_entry=3D1), and to boot from CD (gr[24]=3D'd') * or hard disc * (gr[24]=3D'c'). */ - kernel_entry =3D boot_menu ? 1 : 0; - cpu[0]->env.gr[24] =3D machine->boot_order[0]; + kernel_entry =3D machine->boot_config.has_menu ? machine->boot_con= fig.menu : 0; + cpu[0]->env.gr[24] =3D machine->boot_config.order[0]; } =20 /* We jump to the firmware entry routine and pass the diff --git a/hw/i386/pc.c b/hw/i386/pc.c index fd55fc725c..ca191dff2b 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -672,7 +672,7 @@ void pc_cmos_init(PCMachineState *pcms, object_property_set_link(OBJECT(pcms), "rtc_state", OBJECT(s), &error_abort); =20 - set_boot_dev(s, MACHINE(pcms)->boot_order, &error_fatal); + set_boot_dev(s, MACHINE(pcms)->boot_config.order, &error_fatal); =20 val =3D 0; val |=3D 0x02; /* FPU is there */ diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index e5f3c98184..fb91f9e047 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -179,21 +179,13 @@ error: =20 static void fw_cfg_bootsplash(FWCfgState *s) { - const char *boot_splash_filename =3D NULL; - const char *boot_splash_time =3D NULL; char *filename, *file_data; gsize file_size; int file_type; =20 - /* get user configuration */ - QemuOptsList *plist =3D qemu_find_opts("boot-opts"); - QemuOpts *opts =3D QTAILQ_FIRST(&plist->head); - boot_splash_filename =3D qemu_opt_get(opts, "splash"); - boot_splash_time =3D qemu_opt_get(opts, "splash-time"); - /* insert splash time if user configurated */ - if (boot_splash_time) { - int64_t bst_val =3D qemu_opt_get_number(opts, "splash-time", -1); + if (current_machine->boot_config.has_splash_time) { + int64_t bst_val =3D current_machine->boot_config.splash_time; uint16_t bst_le16; =20 /* validate the input */ @@ -209,7 +201,8 @@ static void fw_cfg_bootsplash(FWCfgState *s) } =20 /* insert splash file if user configurated */ - if (boot_splash_filename) { + if (current_machine->boot_config.has_splash) { + const char *boot_splash_filename =3D current_machine->boot_config.= splash; filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, boot_splash_filen= ame); if (filename =3D=3D NULL) { error_report("failed to find file '%s'", boot_splash_filename); @@ -239,17 +232,11 @@ static void fw_cfg_bootsplash(FWCfgState *s) =20 static void fw_cfg_reboot(FWCfgState *s) { - const char *reboot_timeout =3D NULL; uint64_t rt_val =3D -1; uint32_t rt_le32; =20 - /* get user configuration */ - QemuOptsList *plist =3D qemu_find_opts("boot-opts"); - QemuOpts *opts =3D QTAILQ_FIRST(&plist->head); - reboot_timeout =3D qemu_opt_get(opts, "reboot-timeout"); - - if (reboot_timeout) { - rt_val =3D qemu_opt_get_number(opts, "reboot-timeout", -1); + if (current_machine->boot_config.has_reboot_timeout) { + rt_val =3D current_machine->boot_config.reboot_timeout; =20 /* validate the input */ if (rt_val > 0xffff && rt_val !=3D (uint64_t)-1) { @@ -1134,7 +1121,7 @@ static void fw_cfg_common_realize(DeviceState *dev, E= rror **errp) fw_cfg_add_bytes(s, FW_CFG_SIGNATURE, (char *)"QEMU", 4); fw_cfg_add_bytes(s, FW_CFG_UUID, &qemu_uuid, 16); fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)!machine->enable_graphic= s); - fw_cfg_add_i16(s, FW_CFG_BOOT_MENU, (uint16_t)boot_menu); + fw_cfg_add_i16(s, FW_CFG_BOOT_MENU, (uint16_t)(machine->boot_config.ha= s_menu && machine->boot_config.menu)); fw_cfg_bootsplash(s); fw_cfg_reboot(s); =20 diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index 4bddb529c2..f9b2cc50ad 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -112,7 +112,7 @@ static void ppc_core99_init(MachineState *machine) const char *kernel_filename =3D machine->kernel_filename; const char *kernel_cmdline =3D machine->kernel_cmdline; const char *initrd_filename =3D machine->initrd_filename; - const char *boot_device =3D machine->boot_order; + const char *boot_device =3D machine->boot_config.order; Core99MachineState *core99_machine =3D CORE99_MACHINE(machine); PowerPCCPU *cpu =3D NULL; CPUPPCState *env =3D NULL; diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index 7016979a7c..fd0aebeaf3 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -83,7 +83,7 @@ static void ppc_heathrow_init(MachineState *machine) { ram_addr_t ram_size =3D machine->ram_size; const char *bios_name =3D machine->firmware ?: PROM_FILENAME; - const char *boot_device =3D machine->boot_order; + const char *boot_device =3D machine->boot_config.order; PowerPCCPU *cpu =3D NULL; CPUPPCState *env =3D NULL; char *filename; diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c index bf622aa38f..a1cd4505cc 100644 --- a/hw/ppc/prep.c +++ b/hw/ppc/prep.c @@ -381,7 +381,7 @@ static void ibm_40p_init(MachineState *machine) } boot_device =3D 'm'; } else { - boot_device =3D machine->boot_order[0]; + boot_device =3D machine->boot_config.order[0]; } =20 fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)machine->smp.max_cpu= s); diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index a4372ba189..4bb694ca3a 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1045,8 +1045,8 @@ static void spapr_dt_chosen(SpaprMachineState *spapr,= void *fdt, bool reset) _FDT(fdt_setprop(fdt, chosen, "qemu,boot-kernel-le", NULL,= 0)); } } - if (boot_menu) { - _FDT((fdt_setprop_cell(fdt, chosen, "qemu,boot-menu", boot_men= u))); + if (machine->boot_config.has_menu && machine->boot_config.menu) { + _FDT((fdt_setprop_cell(fdt, chosen, "qemu,boot-menu", true))); } _FDT(fdt_setprop_cell(fdt, chosen, "qemu,graphic-width", graphic_w= idth)); _FDT(fdt_setprop_cell(fdt, chosen, "qemu,graphic-height", graphic_= height)); diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index eb7fc4c4ae..e4d567c915 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -288,13 +288,10 @@ static Property s390_ipl_properties[] =3D { =20 static void s390_ipl_set_boot_menu(S390IPLState *ipl) { - QemuOptsList *plist =3D qemu_find_opts("boot-opts"); - QemuOpts *opts =3D QTAILQ_FIRST(&plist->head); - const char *tmp; unsigned long splash_time =3D 0; =20 if (!get_boot_device(0)) { - if (boot_menu) { + if (current_machine->boot_config.has_menu && current_machine->boot= _config.menu) { error_report("boot menu requires a bootindex to be specified f= or " "the IPL device"); } @@ -304,7 +301,7 @@ static void s390_ipl_set_boot_menu(S390IPLState *ipl) switch (ipl->iplb.pbt) { case S390_IPL_TYPE_CCW: /* In the absence of -boot menu, use zipl parameters */ - if (!qemu_opt_get(opts, "menu")) { + if (!current_machine->boot_config.has_menu) { ipl->qipl.qipl_flags |=3D QIPL_FLAG_BM_OPTS_ZIPL; return; } @@ -312,26 +309,21 @@ static void s390_ipl_set_boot_menu(S390IPLState *ipl) case S390_IPL_TYPE_QEMU_SCSI: break; default: - if (boot_menu) { + if (current_machine->boot_config.has_menu && current_machine->boot= _config.menu) { error_report("boot menu is not supported for this device type"= ); } return; } =20 - if (!boot_menu) { + if (!current_machine->boot_config.has_menu || !current_machine->boot_c= onfig.menu) { return; } =20 ipl->qipl.qipl_flags |=3D QIPL_FLAG_BM_OPTS_CMD; =20 - tmp =3D qemu_opt_get(opts, "splash-time"); - - if (tmp && qemu_strtoul(tmp, NULL, 10, &splash_time)) { - error_report("splash-time is invalid, forcing it to 0"); - ipl->qipl.boot_menu_timeout =3D 0; - return; + if (current_machine->boot_config.has_splash_time) { + splash_time =3D current_machine->boot_config.splash_time; } - if (splash_time > 0xffffffff) { error_report("splash-time is too large, forcing it to max value"); ipl->qipl.boot_menu_timeout =3D 0xffffffff; diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index 7f3a7c0027..fb58e19e4b 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -1049,7 +1049,7 @@ static void sun4m_hw_init(MachineState *machine) machine->ram_size, &initrd_size); =20 nvram_init(nvram, (uint8_t *)&nd->macaddr, machine->kernel_cmdline, - machine->boot_order, machine->ram_size, kernel_size, + machine->boot_config.order, machine->ram_size, kernel_size, graphic_width, graphic_height, graphic_depth, hwdef->nvram_machine_id, "Sun4m"); =20 @@ -1090,7 +1090,7 @@ static void sun4m_hw_init(MachineState *machine) } fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR); fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); - fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, machine->boot_order[0]); + fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, machine->boot_config.order[= 0]); qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); } =20 diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index cda7df36e3..0d578534c5 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -695,7 +695,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem, &kernel_addr, &kernel_entry); =20 sun4u_NVRAM_set_params(nvram, NVRAM_SIZE, "Sun4u", machine->ram_size, - machine->boot_order, + machine->boot_config.order, kernel_addr, kernel_size, machine->kernel_cmdline, initrd_addr, initrd_size, @@ -727,7 +727,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem, } fw_cfg_add_i64(fw_cfg, FW_CFG_INITRD_ADDR, initrd_addr); fw_cfg_add_i64(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); - fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, machine->boot_order[0]); + fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, machine->boot_config.order[= 0]); =20 fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_WIDTH, graphic_width); fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_HEIGHT, graphic_height); diff --git a/include/hw/boards.h b/include/hw/boards.h index c92ac8815c..4b4e8d6991 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -26,6 +26,7 @@ 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); @@ -350,8 +351,7 @@ struct MachineState { ram_addr_t ram_size; ram_addr_t maxram_size; uint64_t ram_slots; - const char *boot_order; - const char *boot_once; + BootConfiguration boot_config; char *kernel_filename; char *kernel_cmdline; char *initrd_filename; diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index b9421e03ff..d73de54836 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -43,8 +43,6 @@ extern int alt_grab; extern int ctrl_grab; extern int graphic_rotate; extern int old_param; -extern int boot_menu; -extern bool boot_strict; extern uint8_t *boot_splash_filedata; extern bool enable_mlock; extern bool enable_cpu_pm; diff --git a/qapi/machine.json b/qapi/machine.json index d25a481ce4..fb06f02ed1 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1393,6 +1393,36 @@ 'data': { 'device': 'str', 'msg': 'str' }, 'features': ['deprecated'] } =20 +## +# @BootConfiguration: +# +# Schema for virtual machine boot configuration. +# +# @order: Boot order (a=3Dfloppy, c=3Dhard disk, d=3DCD-ROM, n=3Dnetwork) +# +# @once: Boot order to apply on first boot +# +# @menu: Whether to show a boot menu +# +# @splash: The name of the file to be passed to the firmware as logo pictu= re, if @menu is true. +# +# @splash-time: How long to show the logo picture, in milliseconds +# +# @reboot-timeout: Timeout before guest reboots after boot fails +# +# @strict: Whether to attempt booting from devices not included in the boo= t order +# +# Since: 6.1 +## +{ 'struct': 'BootConfiguration', 'data': { + '*order': 'str', + '*once': 'str', + '*menu': 'bool', + '*splash': 'str', + '*splash-time': 'int', + '*reboot-timeout': 'int', + '*strict': 'bool' } } + ## # @SMPConfiguration: # diff --git a/softmmu/bootdevice.c b/softmmu/bootdevice.c index c0713bfa9f..2106f1026f 100644 --- a/softmmu/bootdevice.c +++ b/softmmu/bootdevice.c @@ -268,7 +268,8 @@ char *get_boot_devices_list(size_t *size) =20 *size =3D total; =20 - if (boot_strict && *size > 0) { + if (current_machine->boot_config.has_strict && + current_machine->boot_config.strict && *size > 0) { list[total-1] =3D '\n'; list =3D g_realloc(list, total + 5); memcpy(&list[total], "HALT", 5); diff --git a/softmmu/globals.c b/softmmu/globals.c index 3ebd718e35..24b360fba9 100644 --- a/softmmu/globals.c +++ b/softmmu/globals.c @@ -53,8 +53,6 @@ int alt_grab; int ctrl_grab; unsigned int nb_prom_envs; const char *prom_envs[MAX_PROM_ENVS]; -int boot_menu; -bool boot_strict; uint8_t *boot_splash_filedata; int only_migratable; /* turn it off unless user states otherwise */ int icount_align_option; diff --git a/softmmu/vl.c b/softmmu/vl.c index 6f646531a0..5759df3664 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -1878,9 +1878,6 @@ static bool object_create_early(const char *type) =20 static void qemu_apply_machine_options(QDict *qdict) { - MachineClass *machine_class =3D MACHINE_GET_CLASS(current_machine); - const char *boot_order =3D NULL; - const char *boot_once =3D NULL; QemuOpts *opts; =20 object_set_properties_from_keyval(OBJECT(current_machine), qdict, fals= e, &error_fatal); @@ -1889,27 +1886,7 @@ static void qemu_apply_machine_options(QDict *qdict) current_machine->ram_slots =3D ram_slots; =20 opts =3D qemu_opts_find(qemu_find_opts("boot-opts"), NULL); - if (opts) { - boot_order =3D qemu_opt_get(opts, "order"); - if (boot_order) { - validate_bootdevices(boot_order, &error_fatal); - } - - boot_once =3D qemu_opt_get(opts, "once"); - if (boot_once) { - validate_bootdevices(boot_once, &error_fatal); - } - - boot_menu =3D qemu_opt_get_bool(opts, "menu", boot_menu); - boot_strict =3D qemu_opt_get_bool(opts, "strict", false); - } - - if (!boot_order) { - boot_order =3D machine_class->default_boot_order; - } - - current_machine->boot_order =3D boot_order; - current_machine->boot_once =3D boot_once; + machine_boot_parse(current_machine, opts, &error_fatal); =20 if (semihosting_enabled() && !semihosting_get_argc()) { /* fall back to the -kernel/-append */ --=20 2.31.1 From nobody Thu May 9 17:25:51 2024 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 From nobody Thu May 9 17:25:51 2024 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=1649955517; cv=none; d=zohomail.com; s=zohoarc; b=kw7WO5G2Ek1YhqgAjOnWq/+I1aJNNONPZ01QKmy9QW1wRYhvx7vfzesPUp0pi/TljxJ+19wxvsCRxrYi3EYAOpnQLoNEvW4NJ+hPuoopyJll8Fuh6is9C18Oz8wGoHdG0hLoMe5TJjGJG+YAjgiBKEGMbUPO26qzCGBuN0xD0gw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649955517; 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=vKRQRyipDkYHVePAF27aNBDPbP60W9gShxjcX6v2J3A=; b=OWVfcNNFTn2aeGfUMM1BhKHAHAOba4iKcHUvm6ToOvn+9ArBJoa4iVRJLWeAmUiVyxQFjXgqgvtqyOyJFBKD9aibHgdXI9tMZLSXM21P/VkVZuN1OJZogvco2vNHTCk/3UtJ7vQkEyHiyOdbXoWfWFQynaxjVZ1P/Z/r8EhIFP0= 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 1649955517261624.2691767722783; Thu, 14 Apr 2022 09:58:37 -0700 (PDT) Received: from localhost ([::1]:40998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nf2nk-0001Z5-63 for importer@patchew.org; Thu, 14 Apr 2022 12:58:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40846) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nf2iS-0002hV-Oe for qemu-devel@nongnu.org; Thu, 14 Apr 2022 12:53:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23454) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nf2iO-00047r-9t for qemu-devel@nongnu.org; Thu, 14 Apr 2022 12:53:07 -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-610-OipfeEaNOcOCkp9ixmJGmA-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 E9425800B21 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 D6A1B14583C1 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=vKRQRyipDkYHVePAF27aNBDPbP60W9gShxjcX6v2J3A=; b=XmLWe8V4WhdZn8SdvE4kIjMHzU/UVX/hfZWvUEItLKpRrdMip78bdbAOWSbC8JdzOVCYYE a5NsOJxZQolyD9lOMSgQOUaoEb5kRMgXNlXRdZ+D83vCdZ7l6v3fXNjk8ECJKDY6vomtTS dWXxtMMwfFZWbOMuxegYdOWt+KV/xhM= X-MC-Unique: OipfeEaNOcOCkp9ixmJGmA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH for-7.1 3/5] machine: add mem compound property Date: Thu, 14 Apr 2022 12:52:58 -0400 Message-Id: <20220414165300.555321-4-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.133.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_H5=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: 1649955518433100001 Content-Type: text/plain; charset="utf-8" Make -m syntactic sugar for a compound property "-machine mem.{size,max-size,slots}". The new property does not have the magic conversion to megabytes of unsuffixed arguments, and also does not understand that "0" means the default size (you have to leave it out to get the default). This means that we need to convert the QemuOpts by hand to a QDict. Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 80 ++++++++++++++++++++++++++++++ qapi/machine.json | 18 +++++++ softmmu/vl.c | 123 +++++++++++++++------------------------------- 3 files changed, 138 insertions(+), 83 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 710dfbd982..d5cfffe8a0 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -520,6 +520,78 @@ static void machine_set_hmat(Object *obj, bool value, = Error **errp) ms->numa_state->hmat_enabled =3D value; } =20 +static void machine_get_mem(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + MachineState *ms =3D MACHINE(obj); + MemorySizeConfiguration mem =3D { + .has_size =3D true, + .size =3D ms->ram_size, + .has_max_size =3D !!ms->ram_slots, + .max_size =3D ms->maxram_size, + .has_slots =3D !!ms->ram_slots, + .slots =3D ms->ram_slots, + }; + MemorySizeConfiguration *p_mem =3D &mem; + + visit_type_MemorySizeConfiguration(v, name, &p_mem, &error_abort); +} + +static void machine_set_mem(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + MachineState *ms =3D MACHINE(obj); + MachineClass *mc =3D MACHINE_GET_CLASS(obj); + MemorySizeConfiguration *mem; + + ERRP_GUARD(); + + if (!visit_type_MemorySizeConfiguration(v, name, &mem, errp)) { + return; + } + + if (!mem->has_size) { + mem->has_size =3D true; + mem->size =3D mc->default_ram_size; + } + mem->size =3D QEMU_ALIGN_UP(mem->size, 8192); + if (mc->fixup_ram_size) { + mem->size =3D mc->fixup_ram_size(mem->size); + } + if ((ram_addr_t)mem->size !=3D mem->size) { + error_setg(errp, "ram size too large"); + goto out_free; + } + + if (mem->has_max_size) { + if (mem->max_size < mem->size) { + error_setg(errp, "invalid value of maxmem: " + "maximum memory size (0x%" PRIx64 ") must be at lea= st " + "the initial memory size (0x%" PRIx64 ")", + mem->max_size, mem->size); + goto out_free; + } + if (mem->has_slots && mem->slots && mem->max_size =3D=3D mem->size= ) { + error_setg(errp, "invalid value of maxmem: " + "memory slots were specified but maximum memory siz= e " + "(0x%" PRIx64 ") is equal to the initial memory siz= e " + "(0x%" PRIx64 ")", mem->max_size, mem->size); + goto out_free; + } + ms->maxram_size =3D mem->max_size; + } else { + if (mem->has_slots) { + error_setg(errp, "slots specified but no max-size"); + goto out_free; + } + ms->maxram_size =3D mem->size; + } + ms->ram_size =3D mem->size; + ms->ram_slots =3D mem->has_slots ? mem->slots : 0; +out_free: + qapi_free_MemorySizeConfiguration(mem); +} + static char *machine_get_nvdimm_persistence(Object *obj, Error **errp) { MachineState *ms =3D MACHINE(obj); @@ -940,6 +1012,12 @@ static void machine_class_init(ObjectClass *oc, void = *data) object_class_property_set_description(oc, "memory-backend", "Set RAM backend" "Valid value is ID of hostmem ba= sed backend"); + + object_class_property_add(oc, "memory", "MemorySizeConfiguration", + machine_get_mem, machine_set_mem, + NULL, NULL); + object_class_property_set_description(oc, "memory", + "Memory size configuration"); } =20 static void machine_class_base_init(ObjectClass *oc, void *data) @@ -970,6 +1048,8 @@ static void machine_initfn(Object *obj) ms->mem_merge =3D true; ms->enable_graphics =3D true; ms->kernel_cmdline =3D g_strdup(""); + ms->ram_size =3D mc->default_ram_size; + ms->maxram_size =3D mc->default_ram_size; =20 if (mc->nvdimm_supported) { Object *obj =3D OBJECT(ms); diff --git a/qapi/machine.json b/qapi/machine.json index fb06f02ed1..ca6b854670 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1612,3 +1612,21 @@ ## { 'enum': 'SmbiosEntryPointType', 'data': [ '32', '64' ] } + +## +# @MemorySizeConfiguration: +# +# Schema for memory size configuration. +# +# @size: memory size in bytes +# +# @max-size: maximum hotpluggable memory size in bytes +# +# @slots: number of available memory slots for hotplug +# +# Since: 6.1 +## +{ 'struct': 'MemorySizeConfiguration', 'data': { + '*size': 'size', + '*max-size': 'size', + '*slots': 'uint64' } } diff --git a/softmmu/vl.c b/softmmu/vl.c index 80936e595f..c908c3af95 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -156,11 +156,10 @@ static const char *mem_path; static const char *incoming; static const char *loadvm; static const char *accelerators; +static bool have_custom_ram_size; static QDict *machine_opts_dict; static QTAILQ_HEAD(, ObjectOption) object_opts =3D QTAILQ_HEAD_INITIALIZER= (object_opts); static QTAILQ_HEAD(, DeviceOption) device_opts =3D QTAILQ_HEAD_INITIALIZER= (device_opts); -static ram_addr_t maxram_size; -static uint64_t ram_slots; static int display_remote; static int snapshot; static bool preconfig_requested; @@ -168,7 +167,6 @@ static QemuPluginList plugin_list =3D QTAILQ_HEAD_INITI= ALIZER(plugin_list); static BlockdevOptionsQueue bdo_queue =3D QSIMPLEQ_HEAD_INITIALIZER(bdo_qu= eue); static bool nographic =3D false; static int mem_prealloc; /* force preallocation of physical target memory = */ -static ram_addr_t ram_size; static const char *vga_model =3D NULL; static DisplayOptions dpy; static int num_serial_hds; @@ -1730,6 +1728,7 @@ static void keyval_dashify(QDict *qdict, Error **errp) static void qemu_apply_legacy_machine_options(QDict *qdict) { const char *value; + QObject *prop; =20 keyval_dashify(qdict, &error_fatal); =20 @@ -1762,6 +1761,13 @@ static void qemu_apply_legacy_machine_options(QDict = *qdict) false); qdict_del(qdict, "kernel-irqchip"); } + + prop =3D qdict_get(qdict, "memory"); + if (prop) { + have_custom_ram_size =3D + qobject_type(prop) =3D=3D QTYPE_QDICT && + qdict_haskey(qobject_to(QDict, prop), "size"); + } } =20 static void object_option_foreach_add(bool (*type_opt_predicate)(const cha= r *)) @@ -1879,9 +1885,6 @@ static bool object_create_early(const char *type) static void qemu_apply_machine_options(QDict *qdict) { 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 if (semihosting_enabled() && !semihosting_get_argc()) { /* fall back to the -kernel/-append */ @@ -1992,12 +1995,6 @@ static void qemu_create_late_backends(void) qemu_semihosting_console_init(); } =20 -static bool have_custom_ram_size(void) -{ - QemuOpts *opts =3D qemu_find_opts_singleton("memory"); - return !!qemu_opt_get_size(opts, "size", 0); -} - static void qemu_resolve_machine_memdev(void) { if (current_machine->ram_memdev_id) { @@ -2012,7 +2009,7 @@ static void qemu_resolve_machine_memdev(void) exit(EXIT_FAILURE); } backend_size =3D object_property_get_uint(backend, "size", &error= _abort); - if (have_custom_ram_size() && backend_size !=3D ram_size) { + if (have_custom_ram_size && backend_size !=3D current_machine->ram= _size) { error_report("Size specified by -m option must match size = of " "explicitly specified 'memory-backend' proper= ty"); exit(EXIT_FAILURE); @@ -2022,95 +2019,58 @@ static void qemu_resolve_machine_memdev(void) "'-machine memory-backend'"); exit(EXIT_FAILURE); } - ram_size =3D backend_size; + current_machine->ram_size =3D backend_size; } =20 if (!xen_enabled()) { /* On 32-bit hosts, QEMU is limited by virtual address space */ - if (ram_size > (2047 << 20) && HOST_LONG_BITS =3D=3D 32) { + if (current_machine->ram_size > (2047 << 20) && HOST_LONG_BITS =3D= =3D 32) { error_report("at most 2047 MB RAM can be simulated"); exit(1); } } } =20 -static void set_memory_options(MachineClass *mc) +static void parse_memory_options(const char *arg) { - uint64_t sz; + QemuOpts *opts; + QDict *dict, *prop; const char *mem_str; - const ram_addr_t default_ram_size =3D mc->default_ram_size; - QemuOpts *opts =3D qemu_find_opts_singleton("memory"); - Location loc; =20 - loc_push_none(&loc); - qemu_opts_loc_restore(opts); + opts =3D qemu_opts_parse_noisily(qemu_find_opts("memory"), arg, true); + if (!opts) { + exit(EXIT_FAILURE); + } + + prop =3D qdict_new(); =20 - sz =3D 0; - mem_str =3D qemu_opt_get(opts, "size"); - if (mem_str) { + if (qemu_opt_get_size(opts, "size", 0) !=3D 0) { + mem_str =3D qemu_opt_get(opts, "size"); if (!*mem_str) { error_report("missing 'size' option value"); exit(EXIT_FAILURE); } =20 - sz =3D qemu_opt_get_size(opts, "size", ram_size); - /* Fix up legacy suffix-less format */ if (g_ascii_isdigit(mem_str[strlen(mem_str) - 1])) { - uint64_t overflow_check =3D sz; - - sz *=3D MiB; - if (sz / MiB !=3D overflow_check) { - error_report("too large 'size' option value"); - exit(EXIT_FAILURE); - } + g_autofree char *mib_str =3D g_strdup_printf("%sM", mem_str); + qdict_put_str(prop, "size", mib_str); + } else { + qdict_put_str(prop, "size", mem_str); } } =20 - /* backward compatibility behaviour for case "-m 0" */ - if (sz =3D=3D 0) { - sz =3D default_ram_size; - } - - sz =3D QEMU_ALIGN_UP(sz, 8192); - if (mc->fixup_ram_size) { - sz =3D mc->fixup_ram_size(sz); - } - ram_size =3D sz; - if (ram_size !=3D sz) { - error_report("ram size too large"); - exit(EXIT_FAILURE); - } - - maxram_size =3D ram_size; - if (qemu_opt_get(opts, "maxmem")) { - uint64_t slots; - - sz =3D qemu_opt_get_size(opts, "maxmem", 0); - slots =3D qemu_opt_get_number(opts, "slots", 0); - if (sz < ram_size) { - error_report("invalid value of -m option maxmem: " - "maximum memory size (0x%" PRIx64 ") must be at l= east " - "the initial memory size (0x" RAM_ADDR_FMT ")", - sz, ram_size); - exit(EXIT_FAILURE); - } else if (slots && sz =3D=3D ram_size) { - error_report("invalid value of -m option maxmem: " - "memory slots were specified but maximum memory s= ize " - "(0x%" PRIx64 ") is equal to the initial memory s= ize " - "(0x" RAM_ADDR_FMT ")", sz, ram_size); - exit(EXIT_FAILURE); - } - - maxram_size =3D sz; - ram_slots =3D slots; - } else if (qemu_opt_get(opts, "slots")) { - error_report("invalid -m option value: missing 'maxmem' option"); - exit(EXIT_FAILURE); + qdict_put_str(prop, "max-size", qemu_opt_get(opts, "maxmem")); + } + if (qemu_opt_get(opts, "slots")) { + qdict_put_str(prop, "slots", qemu_opt_get(opts, "slots")); } =20 - loc_pop(&loc); + dict =3D qdict_new(); + qdict_put(dict, "memory", prop); + keyval_merge(machine_opts_dict, dict, &error_fatal); + qobject_unref(dict); } =20 static void qemu_create_machine(QDict *qdict) @@ -2118,8 +2078,6 @@ static void qemu_create_machine(QDict *qdict) MachineClass *machine_class =3D select_machine(qdict, &error_fatal); object_set_machine_compat_props(machine_class->compat_props); =20 - set_memory_options(machine_class); - current_machine =3D MACHINE(object_new_with_class(OBJECT_CLASS(machine= _class))); object_property_add_child(object_get_root(), "machine", OBJECT(current_machine)); @@ -2179,7 +2137,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, "boot-opts")) { + g_str_equal(group, "boot-opts") || + g_str_equal(group, "memory")) { return false; } return true; @@ -2203,6 +2162,8 @@ static void qemu_record_config_group(const char *grou= p, QDict *dict, machine_merge_property("smp", dict, &error_fatal); } else if (g_str_equal(group, "boot-opts")) { machine_merge_property("boot", dict, &error_fatal); + } else if (g_str_equal(group, "memory")) { + machine_merge_property("memory", dict, &error_fatal); } else { abort(); } @@ -3000,11 +2961,7 @@ void qemu_init(int argc, char **argv, char **envp) exit(0); break; case QEMU_OPTION_m: - opts =3D qemu_opts_parse_noisily(qemu_find_opts("memory"), - optarg, true); - if (!opts) { - exit(EXIT_FAILURE); - } + parse_memory_options(optarg); break; #ifdef CONFIG_TPM case QEMU_OPTION_tpmdev: --=20 2.31.1 From nobody Thu May 9 17:25:51 2024 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=1649955323; cv=none; d=zohomail.com; s=zohoarc; b=a33vm6/LD5t9AmhjD8JTUwX6nqkXNDIxAkOOR6ghR0paU/cmnlYncQT7nwyJ2hTWPfag/6AR2v3I6fDpwwBY7rGyDKr2gSn79fIzyHFRPhLsyj2jfgJKPuyPtzGPcE+9uhVAELt/rPd5YyhoyffTpE4wc/FOBHQ2LTIrbcVRTgg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649955323; 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=hjzHbo/x3OYy4t2hYx0utDmUA9Po6wcLkDqSpAtS58s=; b=afJH9Scb+FJBfzuT+jAAvSqCfPgqNHI+BQsyusWoPxuEnvmXsn3kpQIvAwU6H1eLURSHt2YqIFn2+LKDBHxLKJrBhzy+hUSyzXOtp1FwaSs88RzaglDAAIW6mjOaUr1ijfQkWCEhWFAH3BhpDZVTTFgYQk/FPJH6PraDarAAszk= 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 1649955323317632.6914982983519; Thu, 14 Apr 2022 09:55:23 -0700 (PDT) Received: from localhost ([::1]:34400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nf2kb-0005Te-Tb for importer@patchew.org; Thu, 14 Apr 2022 12:55:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40850) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nf2iU-0002he-74 for qemu-devel@nongnu.org; Thu, 14 Apr 2022 12:53:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:38296) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nf2iO-000482-AY for qemu-devel@nongnu.org; Thu, 14 Apr 2022 12:53:07 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-461-XIbm9pjuM1KXtjPNJwLExQ-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 10CF43838C8B for ; Thu, 14 Apr 2022 16:53:02 +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 F234E14583C1 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=hjzHbo/x3OYy4t2hYx0utDmUA9Po6wcLkDqSpAtS58s=; b=H8P0hB+ORaGabL1tAFHuagU3+fhdV1GajREzG+jCt6RNaT9fZpvkOJXvNI3PROawNETEe9 eGy2a43hZbigLhHChd5YbjlyBkzKJO5EsRq5xCdJmWOKUFohc6/dsVhwbB4meSReozfxdP IJS07RnC6wh6ZALAdAVN2NkavmpSy/c= X-MC-Unique: XIbm9pjuM1KXtjPNJwLExQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH for-7.1 4/5] machine: make memory-backend a link property Date: Thu, 14 Apr 2022 12:52:59 -0400 Message-Id: <20220414165300.555321-5-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: 1649955325469100007 Content-Type: text/plain; charset="utf-8" Handle HostMemoryBackend creation and setting of ms->ram entirely in machine_run_board_init. Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 70 ++++++++++++++++++++++++++++++--------------- hw/core/numa.c | 2 +- hw/sparc/sun4m.c | 5 ++-- include/hw/boards.h | 4 +-- softmmu/vl.c | 62 ++++++++++++++------------------------- 5 files changed, 74 insertions(+), 69 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index d5cfffe8a0..3dca927e3f 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -36,6 +36,7 @@ #include "exec/confidential-guest-support.h" #include "hw/virtio/virtio.h" #include "hw/virtio/virtio-pci.h" +#include "qom/object_interfaces.h" =20 GlobalProperty hw_compat_6_2[] =3D { { "PIIX4_PM", "x-not-migrate-acpi-index", "on"}, @@ -650,21 +651,6 @@ bool device_type_is_dynamic_sysbus(MachineClass *mc, c= onst char *type) return allowed; } =20 -static char *machine_get_memdev(Object *obj, Error **errp) -{ - MachineState *ms =3D MACHINE(obj); - - return g_strdup(ms->ram_memdev_id); -} - -static void machine_set_memdev(Object *obj, const char *value, Error **err= p) -{ - MachineState *ms =3D MACHINE(obj); - - g_free(ms->ram_memdev_id); - ms->ram_memdev_id =3D g_strdup(value); -} - HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine) { int i; @@ -1007,8 +993,9 @@ static void machine_class_init(ObjectClass *oc, void *= data) object_class_property_set_description(oc, "memory-encryption", "Set memory encryption object to use"); =20 - object_class_property_add_str(oc, "memory-backend", - machine_get_memdev, machine_set_memdev); + object_class_property_add_link(oc, "memory-backend", TYPE_MEMORY_BACKE= ND, + offsetof(MachineState, memdev), object_= property_allow_set_link, + OBJ_PROP_LINK_STRONG); object_class_property_set_description(oc, "memory-backend", "Set RAM backend" "Valid value is ID of hostmem ba= sed backend"); @@ -1252,7 +1239,40 @@ MemoryRegion *machine_consume_memdev(MachineState *m= achine, return ret; } =20 -void machine_run_board_init(MachineState *machine) +static bool create_default_memdev(MachineState *ms, const char *path, Erro= r **errp) +{ + Object *obj; + MachineClass *mc =3D MACHINE_GET_CLASS(ms); + bool r =3D false; + + obj =3D object_new(path ? TYPE_MEMORY_BACKEND_FILE : TYPE_MEMORY_BACKE= ND_RAM); + if (path) { + if (!object_property_set_str(obj, "mem-path", path, errp)) { + goto out; + } + } + if (!object_property_set_int(obj, "size", ms->ram_size, errp)) { + goto out; + } + object_property_add_child(object_get_objects_root(), mc->default_ram_i= d, + obj); + /* Ensure backend's memory region name is equal to mc->default_ram_id = */ + if (!object_property_set_bool(obj, "x-use-canonical-path-for-ramblock-= id", + false, errp)) { + goto out; + } + if (!user_creatable_complete(USER_CREATABLE(obj), errp)) { + goto out; + } + r =3D object_property_set_link(OBJECT(ms), "memory-backend", obj, errp= ); + +out: + object_unref(obj); + return r; +} + + +void machine_run_board_init(MachineState *machine, const char *mem_path, E= rror **errp) { MachineClass *machine_class =3D MACHINE_GET_CLASS(machine); ObjectClass *oc =3D object_class_by_name(machine->cpu_type); @@ -1263,11 +1283,11 @@ void machine_run_board_init(MachineState *machine) clock values from the log. */ replay_checkpoint(CHECKPOINT_INIT); =20 - if (machine->ram_memdev_id) { - Object *o; - o =3D object_resolve_path_type(machine->ram_memdev_id, - TYPE_MEMORY_BACKEND, NULL); - machine->ram =3D machine_consume_memdev(machine, MEMORY_BACKEND(o)= ); + if (machine_class->default_ram_id && machine->ram_size && + numa_uses_legacy_mem() && !machine->memdev) { + if (!create_default_memdev(current_machine, mem_path, errp)) { + return; + } } =20 if (machine->numa_state) { @@ -1277,6 +1297,10 @@ void machine_run_board_init(MachineState *machine) } } =20 + if (!machine->ram && machine->memdev) { + machine->ram =3D machine_consume_memdev(machine, machine->memdev); + } + /* If the machine supports the valid_cpu_types check and the user * specified a CPU with -cpu check here that the user CPU is supported. */ diff --git a/hw/core/numa.c b/hw/core/numa.c index 1aa05dcf42..26d8e5f616 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -695,7 +695,7 @@ void numa_complete_configuration(MachineState *ms) } =20 if (!numa_uses_legacy_mem() && mc->default_ram_id) { - if (ms->ram_memdev_id) { + if (ms->memdev) { error_report("'-machine memory-backend' and '-numa memdev'" " properties are mutually exclusive"); exit(1); diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index fb58e19e4b..98a94a87d5 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -832,8 +832,7 @@ static void sun4m_hw_init(MachineState *machine) SysBusDevice *s; unsigned int smp_cpus =3D machine->smp.cpus; unsigned int max_cpus =3D machine->smp.max_cpus; - Object *ram_memdev =3D object_resolve_path_type(machine->ram_memdev_id, - TYPE_MEMORY_BACKEND, NUL= L); + HostMemoryBackend *ram_memdev =3D machine->memdev; NICInfo *nd =3D &nd_table[0]; =20 if (machine->ram_size > hwdef->max_mem) { @@ -853,7 +852,7 @@ static void sun4m_hw_init(MachineState *machine) =20 /* Create and map RAM frontend */ dev =3D qdev_new("memory"); - object_property_set_link(OBJECT(dev), "memdev", ram_memdev, &error_fat= al); + object_property_set_link(OBJECT(dev), "memdev", OBJECT(ram_memdev), &e= rror_fatal); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0); =20 diff --git a/include/hw/boards.h b/include/hw/boards.h index 8994f6c93b..3390de80ff 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -25,7 +25,7 @@ OBJECT_DECLARE_TYPE(MachineState, MachineClass, MACHINE) =20 extern MachineState *current_machine; =20 -void machine_run_board_init(MachineState *machine); +void machine_run_board_init(MachineState *machine, const char *mem_path, E= rror **errp); bool machine_usb(MachineState *machine); int machine_phandle_start(MachineState *machine); bool machine_dump_guest_core(MachineState *machine); @@ -339,7 +339,7 @@ struct MachineState { bool suppress_vmdesc; bool enable_graphics; ConfidentialGuestSupport *cgs; - char *ram_memdev_id; + HostMemoryBackend *memdev; /* * convenience alias to ram_memdev_id backend memory region * or to numa container memory region diff --git a/softmmu/vl.c b/softmmu/vl.c index c908c3af95..03494760d5 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -157,6 +157,7 @@ static const char *incoming; static const char *loadvm; static const char *accelerators; static bool have_custom_ram_size; +static const char *ram_memdev_id; static QDict *machine_opts_dict; static QTAILQ_HEAD(, ObjectOption) object_opts =3D QTAILQ_HEAD_INITIALIZER= (object_opts); static QTAILQ_HEAD(, DeviceOption) device_opts =3D QTAILQ_HEAD_INITIALIZER= (device_opts); @@ -1762,6 +1763,19 @@ static void qemu_apply_legacy_machine_options(QDict = *qdict) qdict_del(qdict, "kernel-irqchip"); } =20 + value =3D qdict_get_try_str(qdict, "memory-backend"); + if (value) { + if (mem_path) { + error_report("'-mem-path' can't be used together with" + "'-machine memory-backend'"); + exit(EXIT_FAILURE); + } + + /* Resolved later. */ + ram_memdev_id =3D g_strdup(value); + qdict_del(qdict, "memory-backend"); + } + prop =3D qdict_get(qdict, "memory"); if (prop) { have_custom_ram_size =3D @@ -1997,29 +2011,25 @@ static void qemu_create_late_backends(void) =20 static void qemu_resolve_machine_memdev(void) { - if (current_machine->ram_memdev_id) { + if (ram_memdev_id) { Object *backend; ram_addr_t backend_size; =20 - backend =3D object_resolve_path_type(current_machine->ram_memdev_i= d, + backend =3D object_resolve_path_type(ram_memdev_id, TYPE_MEMORY_BACKEND, NULL); if (!backend) { - error_report("Memory backend '%s' not found", - current_machine->ram_memdev_id); + error_report("Memory backend '%s' not found", ram_memdev_id); exit(EXIT_FAILURE); } backend_size =3D object_property_get_uint(backend, "size", &error= _abort); if (have_custom_ram_size && backend_size !=3D current_machine->ram= _size) { - error_report("Size specified by -m option must match size = of " - "explicitly specified 'memory-backend' proper= ty"); - exit(EXIT_FAILURE); - } - if (mem_path) { - error_report("'-mem-path' can't be used together with" - "'-machine memory-backend'"); + error_report("Size specified by -m option must match size of " + "explicitly specified 'memory-backend' property"); exit(EXIT_FAILURE); } current_machine->ram_size =3D backend_size; + object_property_set_link(OBJECT(current_machine), + "memory-backend", backend, &error_fatal); } =20 if (!xen_enabled()) { @@ -2370,27 +2380,6 @@ static void configure_accelerators(const char *progn= ame) } } =20 -static void create_default_memdev(MachineState *ms, const char *path) -{ - Object *obj; - MachineClass *mc =3D MACHINE_GET_CLASS(ms); - - obj =3D object_new(path ? TYPE_MEMORY_BACKEND_FILE : TYPE_MEMORY_BACKE= ND_RAM); - if (path) { - object_property_set_str(obj, "mem-path", path, &error_fatal); - } - object_property_set_int(obj, "size", ms->ram_size, &error_fatal); - object_property_add_child(object_get_objects_root(), mc->default_ram_i= d, - obj); - /* Ensure backend's memory region name is equal to mc->default_ram_id = */ - object_property_set_bool(obj, "x-use-canonical-path-for-ramblock-id", - false, &error_fatal); - user_creatable_complete(USER_CREATABLE(obj), &error_fatal); - object_unref(obj); - object_property_set_str(OBJECT(ms), "memory-backend", mc->default_ram_= id, - &error_fatal); -} - static void qemu_validate_options(const QDict *machine_opts) { const char *kernel_filename =3D qdict_get_try_str(machine_opts, "kerne= l"); @@ -2578,18 +2567,11 @@ static void qemu_init_displays(void) =20 static void qemu_init_board(void) { - MachineClass *machine_class =3D MACHINE_GET_CLASS(current_machine); - - if (machine_class->default_ram_id && current_machine->ram_size && - numa_uses_legacy_mem() && !current_machine->ram_memdev_id) { - create_default_memdev(current_machine, mem_path); - } - /* process plugin before CPUs are created, but once -smp has been pars= ed */ qemu_plugin_load_list(&plugin_list, &error_fatal); =20 /* From here on we enter MACHINE_PHASE_INITIALIZED. */ - machine_run_board_init(current_machine); + machine_run_board_init(current_machine, mem_path, &error_fatal); =20 drive_check_orphaned(); =20 --=20 2.31.1 From nobody Thu May 9 17:25:51 2024 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=1649955322; cv=none; d=zohomail.com; s=zohoarc; b=PVZEQSiEIcUAlVwe0DtB6BrP5qw2eYe+JWpHh1jMR+kGUcM98Pq6Sr6UDHoMs/BXgi3uQNfB+pseaCpuh6Srcw1bWJO1a7PuWvTQotQx7W0xhfj1xlwjufioS0Dr1LfNUGcrW41TtPHyu1nB9YWfHGzHN44HJ8pf85cI9QP+KUQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649955322; 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=fQwmV/TfBYT5mdt44r5U9ydRvFnQPZeudFAcWiyKzeU=; b=ArEwXAeJqVlxbSym7xspKf8HrZC73FChdfjL11uG1D8iLCmBbJRcD/xHWTfNHR6M76c4pGQXaszhL3ADrk1LyeQFSbI+yayWMuHWNEifj7x+pt8Phhx7o6HAXDl4WEErCOu7bdEcK+ks7vuXdo2HA7pYKIUhcOQpaBWRwbdQsJM= 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 1649955322479875.3775818598226; Thu, 14 Apr 2022 09:55:22 -0700 (PDT) Received: from localhost ([::1]:34310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nf2kb-0005Q8-Du for importer@patchew.org; Thu, 14 Apr 2022 12:55:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40770) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nf2iR-0002gy-Bh for qemu-devel@nongnu.org; Thu, 14 Apr 2022 12:53:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57277) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nf2iO-00047y-Ao for qemu-devel@nongnu.org; Thu, 14 Apr 2022 12:53:06 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-382-I4NiztE9MfahOm8OApOWTA-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 2B38A1C05AE2 for ; Thu, 14 Apr 2022 16:53:02 +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 18E0F14583C3 for ; Thu, 14 Apr 2022 16:53:02 +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=fQwmV/TfBYT5mdt44r5U9ydRvFnQPZeudFAcWiyKzeU=; b=PM4x8MWPNBgv/rBCWniL++F6HONGt96ZSpYc7PiiQjPwHt4WIoYYeuS+kcg1XJK4GwM8m7 DC4RLcTGg9R8RMkP78Np+4vFejUTZSpOhVYp+ARBmvQFeI2AY+oNxmWPLyBoStJLrtf77O eo2rfRArZF1hCUL+6BeeLrm0WxOS4As= X-MC-Unique: I4NiztE9MfahOm8OApOWTA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH for-7.1 5/5] machine: move more memory validation to Machine object Date: Thu, 14 Apr 2022 12:53:00 -0400 Message-Id: <20220414165300.555321-6-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.133.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_H5=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: 1649955323782100001 Content-Type: text/plain; charset="utf-8" This allows setting memory properties without going through vl.c, and have them validated just the same. Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 21 +++++++++++++++++++-- softmmu/vl.c | 17 +++-------------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 3dca927e3f..4f537c10c7 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -21,12 +21,14 @@ #include "qapi/qapi-visit-common.h" #include "qapi/qapi-visit-machine.h" #include "qapi/visitor.h" +#include "qom/object_interfaces.h" #include "hw/sysbus.h" #include "sysemu/cpus.h" #include "sysemu/sysemu.h" #include "sysemu/reset.h" #include "sysemu/runstate.h" #include "sysemu/numa.h" +#include "sysemu/xen.h" #include "qemu/error-report.h" #include "sysemu/qtest.h" #include "hw/pci/pci.h" @@ -1283,8 +1285,23 @@ void machine_run_board_init(MachineState *machine, c= onst char *mem_path, Error * clock values from the log. */ replay_checkpoint(CHECKPOINT_INIT); =20 - if (machine_class->default_ram_id && machine->ram_size && - numa_uses_legacy_mem() && !machine->memdev) { + if (!xen_enabled()) { + /* On 32-bit hosts, QEMU is limited by virtual address space */ + if (machine->ram_size > (2047 << 20) && HOST_LONG_BITS =3D=3D 32) { + error_setg(errp, "at most 2047 MB RAM can be simulated"); + return; + } + } + + if (machine->memdev) { + ram_addr_t backend_size =3D object_property_get_uint(OBJECT(machin= e->memdev), + "size", &error= _abort); + if (backend_size !=3D machine->ram_size) { + error_setg(errp, "Machine memory size does not match the size = of the memory backend"); + return; + } + } else if (machine_class->default_ram_id && machine->ram_size && + numa_uses_legacy_mem()) { if (!create_default_memdev(current_machine, mem_path, errp)) { return; } diff --git a/softmmu/vl.c b/softmmu/vl.c index 03494760d5..a9913f0ae1 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2021,24 +2021,13 @@ static void qemu_resolve_machine_memdev(void) error_report("Memory backend '%s' not found", ram_memdev_id); exit(EXIT_FAILURE); } - backend_size =3D object_property_get_uint(backend, "size", &error= _abort); - if (have_custom_ram_size && backend_size !=3D current_machine->ram= _size) { - error_report("Size specified by -m option must match size of " - "explicitly specified 'memory-backend' property"); - exit(EXIT_FAILURE); + if (!have_custom_ram_size) { + backend_size =3D object_property_get_uint(backend, "size", &e= rror_abort); + current_machine->ram_size =3D backend_size; } - current_machine->ram_size =3D backend_size; object_property_set_link(OBJECT(current_machine), "memory-backend", backend, &error_fatal); } - - if (!xen_enabled()) { - /* On 32-bit hosts, QEMU is limited by virtual address space */ - if (current_machine->ram_size > (2047 << 20) && HOST_LONG_BITS =3D= =3D 32) { - error_report("at most 2047 MB RAM can be simulated"); - exit(1); - } - } } =20 static void parse_memory_options(const char *arg) --=20 2.31.1