From nobody Sat Nov 23 18:18:28 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=1732217022; cv=none; d=zohomail.com; s=zohoarc; b=kt6+o3UBd6nb8svgKC8dsaVZkCSZQM7pNq/mWFQjxFgogw3OBcNa/+kN1+7uOxNschWq7in39sh58PZoMjLj1fgE+u+rzQdgOk+Ww1warhRYzPVTBhy/a3A2VlLxmCo1pYZ0J1Re/z/RR8IAcrLoBogXK6XHwQYkWx6jDOfhr68= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732217022; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6wi3a24EwlWSm8KKlUNodK3qOGR7+qV5BdxljVXUq0A=; b=aWN79ZOyDSmgmWWNEURU0h6ncPWgvhSaIubvAiM1lEehMIm0ilEh9NcZ7da2y4SU66EuWPMDPmfq58TN9rk/5A4xtkj5Oi+/hStH/9OJ1poWUHogbcFKzjWrTJ2YlvU7TUsur8IKNxw1bL+dRqF3dzRAoSNIca8Mhbkq4daVB6g= 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 1732217022201252.4844110169122; Thu, 21 Nov 2024 11:23:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tECkw-0006Nl-C0; Thu, 21 Nov 2024 14:22:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tECku-0006N7-Td for qemu-devel@nongnu.org; Thu, 21 Nov 2024 14:22:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tECkt-0002XF-GE for qemu-devel@nongnu.org; Thu, 21 Nov 2024 14:22:20 -0500 Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-145-6G1CYKsPPYWa_qnNXqmg4A-1; Thu, 21 Nov 2024 14:22:17 -0500 Received: by mail-io1-f70.google.com with SMTP id ca18e2360f4ac-83ab369a523so126960439f.3 for ; Thu, 21 Nov 2024 11:22:17 -0800 (PST) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e1cfe345f0sm102939173.45.2024.11.21.11.22.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2024 11:22:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732216938; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6wi3a24EwlWSm8KKlUNodK3qOGR7+qV5BdxljVXUq0A=; b=JXelRqa7qtpmbtKU6KcCNyh/EPz4TEf3akaZbtjAUZCOzgHk7F05IOR1isKNgQEEcMTGXE aWwh6gk0TU4N3Ac1XNtCmCt7KI6BhKAtbGRwiS8a+I9gTh9LyvV9ySet6WKMUI/c5hxxgN dAYFaY+WYG4MijHpeSiZOO14fYkKqbk= X-MC-Unique: 6G1CYKsPPYWa_qnNXqmg4A-1 X-Mimecast-MFC-AGG-ID: 6G1CYKsPPYWa_qnNXqmg4A X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732216936; x=1732821736; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6wi3a24EwlWSm8KKlUNodK3qOGR7+qV5BdxljVXUq0A=; b=ceAFLYe8dyoV4/MER1DXyN54BjNe1xdQqbrL/fL2P6kRJ6HUJxSDME8YbnLVozjQa0 wDwF64uZak5zusRGjdx3Ad/8mUBVYYGza4ez6WIx8j8Lifiue3mR+wWqewO9rUSEhlUh sXZW1YiTxVwlVfgOqXIbNIwluysof7SbHCIiLSgk8kDHQDCQM0BJMlgoClyskDZZoyiu fhg/oN2R054lGtUpgrPBLVXazHj73ar/3oJdmMlzOGPc4mCEYvHHcrYkrRsNwg2uMn4t GptZt0tZmO2oXObpAcLDKJx8NauPHypSrmAzPyvfOYzwWjtw4QItt5Ay9mvnFTUipmas kCSw== X-Gm-Message-State: AOJu0Yzhg+5ZdGaUnqbDt+GS+QaWMSAE9jA1Y8ClR96UackmWn8ptUpZ XXkHJ8uvWVytkJQgZ3TN43BvQUrOERI8VK621KC/lLk3iB9fnt/f73JuIR6eUtfNRQlCxD2zQMP BFu1s+fVIHAFuWnx2vTKbe1DkwIewRpF6Z4d0XKPkVyzHn4FyfGMtrAYxYFm2igwjXzmOF1OaHo RespSLtVcASOmItiq8LWW57KrA6o0YtHassQ== X-Gm-Gg: ASbGncvwjgcAuiaCtXTj2tfZ4c6AAH698NZ+QHTLJLg3x/cZ9vAuopgLLrqUYzF9seF MytPxtFcNJ3cH6vstSpxvybkoR++KGLD8I/hlR1tlaoYVl/3l+v2728yZKZLa6gYnq2Ov97BAMn wLKzH/wAnSiiUydj1Sfxtekss3f5AN0jQ64Yszygj8IMW+YQkU0tqQHjBL0pP+qPbkMzYO8SqX2 DtPVlN5XMEM35Dsc7j6HD6iznOu2Bsi9fxmtobgKr47e6XVGoLnK5N0YAzeDHYdcqan+WMs+I/q iLX4Rk+hvtj6B/ap1hoGs8ClMA== X-Received: by 2002:a05:6602:164d:b0:83a:b98e:9240 with SMTP id ca18e2360f4ac-83ecdd0751bmr6807339f.10.1732216936482; Thu, 21 Nov 2024 11:22:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IFJ2nr+VQz8EEpvGGMyts+ZkYQGr3pmeRUDUDSvsyNCf9o4CqS30t7FCPl8FyT1JWnu5ol00g== X-Received: by 2002:a05:6602:164d:b0:83a:b98e:9240 with SMTP id ca18e2360f4ac-83ecdd0751bmr6804739f.10.1732216936148; Thu, 21 Nov 2024 11:22:16 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Peter Maydell , Juraj Marcin , peterx@redhat.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Eduardo Habkost Subject: [PATCH v2 07/13] qom: Create system containers explicitly Date: Thu, 21 Nov 2024 14:21:56 -0500 Message-ID: <20241121192202.4155849-8-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241121192202.4155849-1-peterx@redhat.com> References: <20241121192202.4155849-1-peterx@redhat.com> MIME-Version: 1.0 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=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.14, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1732217023037116600 Content-Type: text/plain; charset="utf-8" Always explicitly create QEMU system containers upfront. Root containers will be created when trying to fetch the root object the 1st time. They are: /objects /chardevs /backend Machine sub-containers will be created only until machine is being initialized. They are: /machine/unattached /machine/peripheral /machine/peripheral-anon Signed-off-by: Peter Xu Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/core/machine.c | 3 --- qom/object.c | 24 +++++++++++++++++++++++- system/vl.c | 16 ++++++++++++++++ 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index a35c4a8fae..a72c001c3d 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -1198,9 +1198,6 @@ static void machine_initfn(Object *obj) MachineState *ms =3D MACHINE(obj); MachineClass *mc =3D MACHINE_GET_CLASS(obj); =20 - container_get(obj, "/peripheral"); - container_get(obj, "/peripheral-anon"); - ms->dump_guest_core =3D true; ms->mem_merge =3D (QEMU_MADV_MERGEABLE !=3D QEMU_MADV_INVALID); ms->enable_graphics =3D true; diff --git a/qom/object.c b/qom/object.c index 214d6eb4c1..2fb0b8418e 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1734,12 +1734,34 @@ const char *object_property_get_type(Object *obj, c= onst char *name, Error **errp return prop->type; } =20 +static const char *const root_containers[] =3D { + "chardevs", + "objects", + "backend" +}; + +static Object *object_root_initialize(void) +{ + Object *root =3D object_new(TYPE_CONTAINER); + int i; + + /* + * Create all QEMU system containers. "machine" and its sub-containers + * are only created when machine initializes (qemu_create_machine()). + */ + for (i =3D 0; i < ARRAY_SIZE(root_containers); i++) { + object_property_add_new_container(root, root_containers[i]); + } + + return root; +} + Object *object_get_root(void) { static Object *root; =20 if (!root) { - root =3D object_new(TYPE_CONTAINER); + root =3D object_root_initialize(); } =20 return root; diff --git a/system/vl.c b/system/vl.c index 3bb8f2db9a..15e35162c6 100644 --- a/system/vl.c +++ b/system/vl.c @@ -2112,6 +2112,21 @@ static void parse_memory_options(void) loc_pop(&loc); } =20 +static const char *const machine_containers[] =3D { + "unattached", + "peripheral", + "peripheral-anon" +}; + +static void qemu_create_machine_containers(Object *machine) +{ + int i; + + for (i =3D 0; i < ARRAY_SIZE(machine_containers); i++) { + object_property_add_new_container(machine, machine_containers[i]); + } +} + static void qemu_create_machine(QDict *qdict) { MachineClass *machine_class =3D select_machine(qdict, &error_fatal); @@ -2120,6 +2135,7 @@ static void qemu_create_machine(QDict *qdict) current_machine =3D MACHINE(object_new_with_class(OBJECT_CLASS(machine= _class))); object_property_add_child(object_get_root(), "machine", OBJECT(current_machine)); + qemu_create_machine_containers(OBJECT(current_machine)); object_property_add_child(container_get(OBJECT(current_machine), "/unattached"), "sysbus", OBJECT(sysbus_get_default())); --=20 2.45.0