From nobody Sat May 18 22:31:20 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=1684761463; cv=none; d=zohomail.com; s=zohoarc; b=jnPv/4Qn1GMXTNQd3wMm0drD7u7aeQIk3lrpeHV1pC3UXfVi4mHH3XeXJ0SeK4IClblkFbgZntBfJLAhwroJPXGAFxJaDFF0hPdVhWcMLRXSNnQmANVZsDWqgNwXT/ZcPGjvHbiqXCxeDKd5tvMmiwwY2AJIHUpyl8NTUSIHD/4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684761463; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=6On8HcWnRqf9TY4SPdSjN+Twjwtzn/93XLhDyEInlpE=; b=kfCflBemZ+KPS5sdw/R/eNUzhnrFQByCUDUGQ+0vVFU94bR9Fe9aap3giEeF/DgdeNyp93bt1fKW5oBR8GpaYs0Va7Y4dWI0+8LdlW0J6ooaaUiV4bY5svBoBtmz6zhZePUcWlE/FKln8hXcm1Fi+WpL0OswiTxJwkefeNT/Rew= 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 1684761463614260.4506970758181; Mon, 22 May 2023 06:17:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q15Po-0004Kw-TC; Mon, 22 May 2023 09:17:32 -0400 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 1q15Pn-0004Jc-AN for qemu-devel@nongnu.org; Mon, 22 May 2023 09:17:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q15Pj-0000Hh-JN for qemu-devel@nongnu.org; Mon, 22 May 2023 09:17:31 -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-668-xNI-Up_dMG6iPE_FWhRPsw-1; Mon, 22 May 2023 09:17:20 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3D66E185A794; Mon, 22 May 2023 13:17:20 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5726FC1ED99; Mon, 22 May 2023 13:17:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684761442; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6On8HcWnRqf9TY4SPdSjN+Twjwtzn/93XLhDyEInlpE=; b=LoHIyIYE94gVKq8nJszhffkEnsYaKkd2mhM6O7FZxyh3ku4/WYOrwRnl2rvBH1fHRShkd7 cyMwAqJTGNFklV2ah5rLOFOXz9SKCy11xBn+JpFg8VvzJUbFZ4N/H4wPRTPPyJ7/HgFX+5 K/IqCzaYLxcXxif/GBv1P8IeQVp4ToQ= X-MC-Unique: xNI-Up_dMG6iPE_FWhRPsw-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: philmd@linaro.org, wangyanan55@huawei.com, pbonzini@redhat.com, thuth@redhat.com Subject: [PATCH] machine: do not crash if default RAM backend name has been stollen Date: Mon, 22 May 2023 15:17:17 +0200 Message-Id: <20230522131717.3780533-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1684761465397100003 QEMU aborts when default RAM backend should be used (i.e. no explicit '-machine memory-backend=3D' specified) but user has created an object which 'id' equals to default RAM backend name used by board. $QEMU -machine pc \ -object memory-backend-ram,id=3Dpc.ram,size=3D4294967296 Actual results: QEMU 7.2.0 monitor - type 'help' for more information (qemu) Unexpected error in object_property_try_add() at ../qom/object.c:12= 39: qemu-kvm: attempt to add duplicate property 'pc.ram' to object (type 'cont= ainer') Aborted (core dumped) Instead of abort, check for the conflicting 'id' and exit with an error, suggesting how to remedy the issue. Signed-off-by: Igor Mammedov CC: thuth@redhat.com Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Shaoqin Huang Reviewed-by: Thomas Huth Tested-by: Thomas Huth --- hw/core/machine.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/core/machine.c b/hw/core/machine.c index 07f763eb2e..1000406211 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -1338,6 +1338,14 @@ void machine_run_board_init(MachineState *machine, c= onst char *mem_path, Error * } } else if (machine_class->default_ram_id && machine->ram_size && numa_uses_legacy_mem()) { + if (object_property_find(object_get_objects_root(), + machine_class->default_ram_id)) { + error_setg(errp, "object name '%s' is reserved for the default" + " RAM backend, it can't be used for any other purposes." + " Change the object's 'id' to something else", + machine_class->default_ram_id); + return; + } if (!create_default_memdev(current_machine, mem_path, errp)) { return; } --=20 2.39.3