From patchwork Thu Jan 2 21:17:55 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: 854751 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7968588wrq; Thu, 2 Jan 2025 13:19:12 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXnDePEH5Jg1RiTdLs+mFYu6yXUnBAr58J18DpjN2d+KlqjS//OTHjgkURwrwR4oKMsOUZdPQ==@linaro.org X-Google-Smtp-Source: AGHT+IGQfaNvCvzt6x19NLbqmZBTIzthXobmtRuuSzK4D1+GbA6dNwkjEvYG6jC6rBBNy0olliz1 X-Received: by 2002:ac8:7d12:0:b0:460:8e3b:6790 with SMTP id d75a77b69052e-46a4a9a34f7mr690687171cf.48.1735852752022; Thu, 02 Jan 2025 13:19:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735852752; cv=none; d=google.com; s=arc-20240605; b=TjYa7tuB2kFpDHSfLS+C7dvb8Szy9tka6CWUtX50V9IOBL9n315/L+HrW4mgHYJxDb gT0H4DTg9KCalw+lIh0P3amBqhZuSv60DWQQw6iB7U9nPsy0QIneAvsmZHE9BgeeIviA WTVdq/8x141ZtVhPCC4Cobjonsd4lbQKCt6Qq6231B4pnpahuiVC4diXVk9pX6KI2oSD jz7dBkrRpK/E0KZcxo2xKmEBvl2Z8OVKU3uKCRjt352txwixHjeVUpKpFRW0NxCalE5a dAkF+9wF9Si8j6jA0HbWtW6MRsby3pr7Qk8FmcqVhKffWK5ryhEudoa8rnyoE2bj4qfP z1bg== 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=424nUjnt0mSbCqT2Iy8fBR2D+25DbV9xd+ohVsIuqlU=; fh=Yr6y3Q7nw9Pkn2BMoDtN0XGcR8Ktn+gkbMNk1sAP+Hw=; b=BioCip5Q5FSNXysGBhmlrUpqs7xfANUcQGU9hd+D9oyP2b0V0/UH0eiyLe0dw0t75F HGwXOzL6nNizkF2BUAT2cWRk6EvoCa/IWBQEW+/XsELra+CrXsgX+PRtHQLzcpV2BY+r HPZo5L/I/AgwHSVqoZXammtnu27duv2vIZUY1/RrfVh6zgPd8IfMQd+nqajp6Foz21JM WtZ/XO4hjHxYAkLrE+UWtyQuND3xSlIqMCSJSDjkWUpQgrn92Hxh9j7UOu/OupAvhr6e qCYNc6I5rk/GRiURNq32cr0QchUJ5DPjvdtdraqf6HeJ4fVYy+JJDZNg2G6aWUOkff9a gIbw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="JUIiF/u3"; 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-46a3eb9a601si372571001cf.225.2025.01.02.13.19.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Jan 2025 13:19:12 -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="JUIiF/u3"; 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 1tTSaJ-00044c-4V; Thu, 02 Jan 2025 16:18:27 -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 1tTSaE-00041t-1z for qemu-devel@nongnu.org; Thu, 02 Jan 2025 16:18:24 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tTSaC-0001OQ-G0 for qemu-devel@nongnu.org; Thu, 02 Jan 2025 16:18:21 -0500 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4368a293339so79819405e9.3 for ; Thu, 02 Jan 2025 13:18:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735852698; x=1736457498; 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=424nUjnt0mSbCqT2Iy8fBR2D+25DbV9xd+ohVsIuqlU=; b=JUIiF/u3H/ziU1vcqi3gbUpIbiyRQ25D8v9fgvkGWb1QTSWOBVHSvvo9wVej+Jsu9K 6C1cwUNdsUuMltpwbvqi64jJZnr4tDL1gRKZgfYV69EaaeuorK9wKt7hbTphY0Qzwgs3 BXOilkUX7TB7XqlJ8Lhz1/l4IHX8qbHfntcRbOxSnWLxMYbAbNka0hRNuBdwSZWKCMDF RG4Gigq6kYlR1wqWjKcxwnK7KCXpjToVZng6dyS8jF45vXAvG/ZoBk8LysNgvXK5aRky tz3yEKQrZ/hci64ywPQAOC1O/2Bd0hh+qPcheKcJPHI+PZsECp4TNdeGuEDRL5xPsiLo 0QfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735852698; x=1736457498; 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=424nUjnt0mSbCqT2Iy8fBR2D+25DbV9xd+ohVsIuqlU=; b=b0/eLUYb51Z3HracUjalir2U3qlCDEN0lY8s+VFIzNO7KWcgp6/6J7XhP4rvaBM7XO xrYY1MlU43Y3/iVuiFiQEZoqe1YsLMJWlMvnAM33ufzuubN5Qnt8XsaEboDPuDvWNk7W jE/Xh5VZSJOCFB7PHtYH1G3AxXluVyitOnQfnMQnO3Mnvy88lrqK7ySCoXjz2z0MqDoz WikyEwrfcEphbQItvYStK3Fl2R28j8GwwoLkegr3KaexiX/nw910m3thAs4+4RizDvYK hEFbfy8sd2vTvMkrYk1BuLfVJ02b8XPtMAEbKJrDrCPUWWzmwF352OK3ovj0QRBBlTsM oSmw== X-Gm-Message-State: AOJu0Yzr0Yioomjkk+Bnh+4wyb5r+zMIr3zh6U9Bq+2cwzeQlaRBU+bO wUsn6yDNzfsvolAizU4kDOHVldQdC9HWgFjMaUGZ2jhp/cxVrXJuff+SJkPiN1bpviAghghrT9B +qTCh6Q== X-Gm-Gg: ASbGnct42nuBAvQvYyxFwcSjTtY6dhMmZJUrhAakxBQeMj+XR1MagzdlgCR4s4GMIvT seuTd5IEsE410xVeMmbjxIkBJ3slbT1Ywd9VpjsX0Kb8G6YykE7gYfpq6pClNw5OKFEdbBxXTfl WMdLZI5cp65579CC6VR6ssSYLoZvGKyFWH1hHCfvTFWI2Z8itOWxjIFVcx7IYi4DdBPOiuLxHgZ jPf15z65PoW6TDUiIsNVvXcrZ+lr78soTwPFuz0wIjeM4aRwGEocnwy0zvmON4Tzv+xOnGaCbg6 UCB7oX6E1r0YG3zFw1cSgJpoujKCF7Y= X-Received: by 2002:a05:600c:693:b0:434:f586:753c with SMTP id 5b1f17b1804b1-4366a0cf7f2mr341455805e9.7.1735852698527; Thu, 02 Jan 2025 13:18:18 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4366128a62asm459186485e9.44.2025.01.02.13.18.16 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 Jan 2025 13:18:17 -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 3/8] qdev: Add machine_get_container() Date: Thu, 2 Jan 2025 22:17:55 +0100 Message-ID: <20250102211800.79235-4-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::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.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 Add a helper to fetch machine containers. Add some sanity check around. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Peter Xu Message-ID: <20241121192202.4155849-10-peterx@redhat.com> Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- include/hw/qdev-core.h | 10 ++++++++++ hw/core/qdev.c | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index b83b1439968..2434065bad2 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -1037,6 +1037,16 @@ Object *qdev_get_machine(void); */ Object *qdev_create_fake_machine(void); +/** + * machine_get_container: + * @name: The name of container to lookup + * + * Get a container of the machine (QOM path "/machine/NAME"). + * + * Returns: the machine container object. + */ +Object *machine_get_container(const char *name); + /** * qdev_get_human_name() - Return a human-readable name for a device * @dev: The device. Must be a valid and non-NULL pointer. diff --git a/hw/core/qdev.c b/hw/core/qdev.c index bc5b60212a7..9973e029ffa 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -829,6 +829,17 @@ Object *qdev_get_machine(void) return dev; } +Object *machine_get_container(const char *name) +{ + Object *container, *machine; + + machine = qdev_get_machine(); + container = object_resolve_path_component(machine, name); + assert(object_dynamic_cast(container, TYPE_CONTAINER)); + + return container; +} + char *qdev_get_human_name(DeviceState *dev) { g_assert(dev != NULL);