From patchwork Thu Jan 2 21:17:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854756 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7968747wrq; Thu, 2 Jan 2025 13:19:42 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUpXhvU/rKsRFE81kBfsg7MSkUjH0OENIJxTgYxuI+9mw96UDIz0NzQZehh84z+Llm7XlpTxw==@linaro.org X-Google-Smtp-Source: AGHT+IESkOJzgBWiW0rvD/DR8ku8NUtyIacrGlKw+REiAV7yTZv853UYuUiBLfqouNBHEK/GW2sw X-Received: by 2002:a05:622a:15c9:b0:467:5082:74bd with SMTP id d75a77b69052e-46a4a976c4emr710491861cf.34.1735852782428; Thu, 02 Jan 2025 13:19:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735852782; cv=none; d=google.com; s=arc-20240605; b=GnuwvOVKz/W3V7ai/TX9moehAWDAzh54mHqcd2gx5vomVIc3vFKqX3B2cQph4y7kaJ vJMBhyS5jgJ7Ui0hKC0w3eLT196d1fs8BnUxs1uELV/5gyhesOzOqj1rn65nU5Rr0OrI 8ul5pvrtRZ0R14DJvOB50jfuQllzAkTJ1RLYzItUtDnKQVjz6oyjaVWc3bjwuqI3aZG0 2aFFsh2rqf12O+b7RLxBQqop1Cmj62OX9xFPGBu1/qqXyymR6bJtW4o5zIrbo4cWKRAV Zx/3jWdyUgc9v7mnW7rDWU0rDT2ukeOYvEnc2r27gfiS3/4ut2eRPeQqLP02mN3/NPNI MoPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yFrtobX5dEs1+8eScAKkWEL068+5vqZlHD9HfY3Xigw=; fh=Yr6y3Q7nw9Pkn2BMoDtN0XGcR8Ktn+gkbMNk1sAP+Hw=; b=SAuW++qX7nU3OZ4DGCfS4NlLWt50P1n4+htOFIn2mVr29o7vScFrcZseWDimtnB8v8 E2qs1vXFui0VE4rMAnyEc5jSK0DzWc/SAU0FGKvBk3S/uexz+ipkv4iSTQvwcG3BoCjX Hx6tivEORZm6XCw9vyj98iWlCUO8z011fcJFZIHl8FSEd/NBLcwNJSPcCdauiEUo4FtP XbJ/spi7iKEbifSyji+Q89bSTU7TYzopRu13dGH7v8kjcPE1Yr80YVbPYm1/+H8vrtQs O3aUiin/caJva8R+tHJyXsaE70JoRle6l3of8Efalywwv4E/KLbffZmiyUp2hkjaMq1q jj6g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qoFfRBOk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-46a3eb9970asi390609471cf.248.2025.01.02.13.19.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Jan 2025 13:19:42 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qoFfRBOk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tTSaI-00044X-6d; Thu, 02 Jan 2025 16:18:26 -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 1tTSa8-00040l-Ql for qemu-devel@nongnu.org; Thu, 02 Jan 2025 16:18:17 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tTSa7-0001N1-9i for qemu-devel@nongnu.org; Thu, 02 Jan 2025 16:18:16 -0500 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-385de9f789cso8786960f8f.2 for ; Thu, 02 Jan 2025 13:18:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735852693; x=1736457493; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yFrtobX5dEs1+8eScAKkWEL068+5vqZlHD9HfY3Xigw=; b=qoFfRBOkUgjTk2l94gRw+R9DQ4aeyL16PZOxfIvJojzj+oq0Bc2KuwkN37aEbmE5dj O6GcLKp/OaB5roXIiSGQHGXopvv9l67M4XKgSyidAQR4lnL/vbPZ8RX7p7QRMhILYN9W XiBGq5HgoDhuD/CF3lKzrvWtYe9hVcqRgDb6gVYltxcItogBr1eEmHsKgOmmqIbv1PVJ QtiV6KrvEQuX71CQYBfcRT0RijjchdqthKdBw4NOoNQoejTSK1rxVrXXUoo1jbCBeu8K VAkmMw8OLtx8LMgjSRyHZnSeYvrdjA49ubqAQBdbyaRo944EZEqTqGk6LysepvcbWKtg TpRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735852693; x=1736457493; 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=yFrtobX5dEs1+8eScAKkWEL068+5vqZlHD9HfY3Xigw=; b=YuF39WHRvO8yRBs4K2t5tpmuMaH8V+7veROzFFfUnqoS8TOt7fLHdFKz6/CChD9LdZ 66B4as3JD136px6tyIaYTYwFgdHbghzDL9rrFnK7OHexNocSOU0gY2ZZTMTcB2kG7N2S efEr7Qhk6+xDr/Rlx+C7H27N8UvgejezJV7J99B8fp4wIANqRmaQDZcz0cUu4L6OrTrK 0zZD01Uy31QtRd2kGdkf5ySAx+AAmD8D8tRfMOUjYx/z8ibJUroPTHFJbLdu2Dq9S0T9 50ZAnakZ/Zg+Mq2syJXaGIahfBejaYaPJnLfA0pEff5+gq98rnH55d8yn1sPc19hHy4E PakA== X-Gm-Message-State: AOJu0YzpkD/W0624dseD21+l07gRnytjon0VEEJmEYBfFdV93xhgkKD7 xDee1Rb6cwqRoXDMCemF3/BaW2QvT0dIMzGDZE7Io5WlDo7s5TPSHogP73LoTB3894lFTV8vJys JinkBDA== X-Gm-Gg: ASbGnctg24/2weYEiinQ9K77x4UuDHAq47P2XfXcXvL4VV5qpoJxVhKiwhsEtA/GRZy 6oSDKrQ2t9cc78bJyDOoZMIOefJ8ixG7tVHrkhcwAthocyOsdSw4s3qT7eL+TXIbTIp3Us6WfUS 364K0L0VRaBi2N92stUVwvT22k/AnxZXszdvBK57e4D36DA6j+gX9+E4idP8mDDC/ZOzmPzwjgB RGpeco1J2fFiC/ixHzRiOi3Dm3EK5gI3wE78xXzc5Bymz4Yosu317u+2jrUPZzRnlyh1Mwv1VWr st+yWhqvo/sBEF+S9A3jMr3/wvIib6U= X-Received: by 2002:a05:6000:4012:b0:385:f7d9:99f5 with SMTP id ffacd0b85a97d-38a224087b8mr37943617f8f.51.1735852692938; Thu, 02 Jan 2025 13:18:12 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c89e4ebsm39336728f8f.85.2025.01.02.13.18.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 Jan 2025 13:18:12 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , "Michael S. Tsirkin" , Richard Henderson , Paolo Bonzini , David Hildenbrand , Zhenwei Pi , Marcel Apfelbaum , "Gonglei (Arei)" , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Peter Xu , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Fam Zheng , Eduardo Habkost Subject: [PATCH v4 2/8] qdev: Make qdev_get_machine() not use container_get() Date: Thu, 2 Jan 2025 22:17:54 +0100 Message-ID: <20250102211800.79235-3-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250102211800.79235-1-philmd@linaro.org> References: <20250102211800.79235-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=philmd@linaro.org; helo=mail-wr1-x42b.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Peter Xu Currently, qdev_get_machine() has a slight misuse on container_get(), as the helper says "get a container" but in reality the goal is to get the machine object. It is still a "container" but not strictly. Note that it _may_ get a container (at "/machine") in our current unit test of test-qdev-global-props.c before all these changes, but it's probably unexpected and worked by accident. Switch to an explicit object_resolve_path_component(), with a side benefit that qdev_get_machine() can happen a lot, and we don't need to split the string ("/machine") every time. This also paves way for making the helper container_get() never try to return a non-container at all. Signed-off-by: Peter Xu Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20241121192202.4155849-9-peterx@redhat.com> Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/core/qdev.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 57c1d9df3a7..bc5b60212a7 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -818,7 +818,12 @@ Object *qdev_get_machine(void) static Object *dev; if (dev == NULL) { - dev = container_get(object_get_root(), "/machine"); + dev = object_resolve_path_component(object_get_root(), "machine"); + /* + * Any call to this function before machine is created is treated + * as a programming error as of now. + */ + assert(dev); } return dev;