From patchwork Fri Dec 13 13:33:47 2024 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: 850130 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:2c4:b0:385:e875:8a9e with SMTP id o4csp1503224wry; Fri, 13 Dec 2024 05:36:16 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWqeY56KleevzSLUkpJRSYDg+9XKA++ThDxHW/5dXdwM8ijELsY0RJgWuQHSGzc1/6We9Dvqg==@linaro.org X-Google-Smtp-Source: AGHT+IHtwt9XXSMiuOrs2TmClrA7gfveGI2+/Y9GF4sWhkEpFvebhEWA04jRyC1JulCc8qbMf3t9 X-Received: by 2002:a05:6214:246a:b0:6d8:f7cf:a12 with SMTP id 6a1803df08f44-6dc969a86d8mr43950406d6.45.1734096976036; Fri, 13 Dec 2024 05:36:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734096976; cv=none; d=google.com; s=arc-20240605; b=gJh4xRG5+3Fa7z67ZL8XSzah7nFQjh8CcjWRUvpN1cnAu3BmQ5gSHHKSQsMGSjTRNx s76rQm9ujF6QiIKEQo0VhC6Vd/XtC7TzdRj6PW/6L/1V1O6ShjVD0vPKVlKFHQQa7P6m ukSFugalhlcxqVRJssV2WNCsvwPDPivD9vPdoCE1C/nSvvmqXBIjol4yIKUF104hXI8q iIXK65AMEk9hH2spXsWBwcJkHyYqX5BGcQGkjLd2Td1V7eUayUj9JXffzyArkUgbyam/ lWwUM8yf2sjwl/eA6MZ4dwBjehB21d+qqtb71Tfg+HrLSwULqAHD0SAbW4XXhl0KkUu5 aD8Q== 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=3yF4gTyIXghUKxGkr5yLxPBvl2lN3UWs2PgcMEYcsVo=; fh=5/bEEfneXpYiCSLu1RRtIdWOVpk1SgQYYFlk2zFRZHo=; b=Zz4ZcBwCtMyI0ajqjQ9YqVtY0sFF8vzxxyvC9izjsXFdeYEjzu0ed+97W3JJCQH1NG kkJ+rW+rvDX52lyvNbgRFGHepxTYou29ba62XltpuDg9j8w/ryS/4RUNDXTE2zVz5AO9 1YX1bDzUGGs3Y3yg9ZLWTSMzo9A2NYuTmOWB8hRGHypTLbJe+QHpgK8bZlWilFQhFeSH bkhSDKBjw41YKJ+XPtf+eQUA4gqOYUU34Y3DSzUP81Md24eyPpRt/HhwAzh0xjfwCVnJ zUqenVwdtTXJRqAan4gm7ufwZuVgmXy2i536Fq9uYx9wKAiSUMxlXdB28i+nXQ/mD3e6 VpXA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qz6cua3o; 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 6a1803df08f44-6dae15d3ad7si58601806d6.443.2024.12.13.05.36.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Dec 2024 05:36:16 -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=Qz6cua3o; 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 1tM5p4-0005f4-VG; Fri, 13 Dec 2024 08:35:15 -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 1tM5o0-0005AW-NY for qemu-devel@nongnu.org; Fri, 13 Dec 2024 08:34:13 -0500 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tM5ny-00015W-NG for qemu-devel@nongnu.org; Fri, 13 Dec 2024 08:34:08 -0500 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3862d16b4f5so1162860f8f.0 for ; Fri, 13 Dec 2024 05:34:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734096844; x=1734701644; 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=3yF4gTyIXghUKxGkr5yLxPBvl2lN3UWs2PgcMEYcsVo=; b=Qz6cua3o3GmLITMHIWaoM+dqq8LkublH2Ui8KZHaNkZOFBVG/oiJ3BVoBVeexanO0g o9mwRgf4s+rRjFufr+1g+xq8dVk2yci8waQm/POFqLfW8tXRFuhMtzbT31nAHLmRHvfd pAzY7xFwuSHqBe8VgPQC1XdpnbF6p9/6bIMkWAzC4xpM8QhMRbE/0TP53pnsLSxofAXU Gcxb/cEWQ3hU3q+BnU2zbaaHpWdbmxa5p0xLaxfyFO2sx9/Y7r9k4cuEX41FYKfaEyEd ogiksFdAwCr+WgiOge+jlEJrZjGvIXmOGQs+hv80jBQHCZ83Nczo7vPnNSLDLESfFi8b acww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734096844; x=1734701644; 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=3yF4gTyIXghUKxGkr5yLxPBvl2lN3UWs2PgcMEYcsVo=; b=St4hgbdYdkV4D3gpPdoAbyn5lYixI5FtiqoTzdu7cU5irnm7Rk4jfTf567S51Vxmmg tg0WTop5xJRJONLoePecHc+yYy7wGJZSpS3+FErO/NkAP4zThiVjKd5VpqoSi+XJ++VJ HF4D1iBwoVZz/7dUTUspOZbEvjlq8lOWxUIkZ0efEr3mXm/otq/+EJUgSsELbgRdHYA+ cZNBXgKr+ftSAAmix4cD6oFEKnc33oLpf2vFAU1Uf+vftRMEsGw/0HMyOIOOxb5jvibi yanSXirWSCCtkvws5TaQ0fmxuE9jqPnbgcgGOqStIKqBUlBxrukGIpyQ5qGNQP0yD1Sw CWlw== X-Gm-Message-State: AOJu0YwNkrLRFmQ2g9GZ6gdK5kMeh0N7C2ikkoV86GKBya/fUwsW8CS7 5hJT3L+T29P9ZdEK1OH9Waa5g+h8b49357v7hiFhRDUdKXLWxR4wNcFH4ziDpdIozStEDukxp98 o X-Gm-Gg: ASbGnct874FpCyxIUzEQZqf58LHCYfrf4GOP79UCkhw1vduYTngb9dsGBqvKk/9DnHU XMK8xlGok3ujFHK8b3pWW3rqPJfAzMxFQXIkEa1Npk7IVI0v4hKUTSiXFAkhYG/5YmW4QiKl0IL K4dDPPwxEQEp9hrXSed39o6G5WJokOjxHbtk9dmdOY2F/EX/NzRZd00C82Mmnap/TYCbzbB288T wtK9y+Zvmsmq/rZ0tVk4VQi2WWeA3/4UN5ZMZ9DuWK/kv/P6G3Msva4izeFgvC+CQoYR8tQDJKU Gvvugn46jA/eh2lMp7qXxHmRndfeVOLcGzgk X-Received: by 2002:a05:6000:491b:b0:386:3d27:b4f0 with SMTP id ffacd0b85a97d-38788805406mr6166037f8f.14.1734096844432; Fri, 13 Dec 2024 05:34:04 -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-38782521dfesm6969358f8f.107.2024.12.13.05.34.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 13 Dec 2024 05:34:04 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Gerd Hoffmann , =?utf-8?q?Daniel?= =?utf-8?q?_P_=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_?= =?utf-8?q?Mathieu-Daud=C3=A9?= Subject: [PATCH v2 2/7] hw/nvram/fw_cfg: Pass QOM parent to fw_cfg_add_file_from_generator() Date: Fri, 13 Dec 2024 14:33:47 +0100 Message-ID: <20241213133352.10915-3-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241213133352.10915-1-philmd@linaro.org> References: <20241213133352.10915-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=philmd@linaro.org; helo=mail-wr1-x431.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 Currently fw_cfg_add_file_from_generator() is restricted to command line created objects which reside in the '/objects' QOM container. In order to extend to other types of containers, pass the QOM parent by argument. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Daniel P. Berrangé --- include/hw/nvram/fw_cfg.h | 10 ++++++---- hw/nvram/fw_cfg.c | 11 ++++++----- system/vl.c | 3 ++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h index 14e68966c59..fcb06f18cc3 100644 --- a/include/hw/nvram/fw_cfg.h +++ b/include/hw/nvram/fw_cfg.h @@ -294,11 +294,12 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *filename, void *data, * fw_cfg_add_file_from_generator: * @s: fw_cfg device being modified * @filename: name of new fw_cfg file item - * @gen_id: name of object implementing FW_CFG_DATA_GENERATOR interface + * @part: name of object implementing FW_CFG_DATA_GENERATOR interface + * @parent: the object in which to resolve the @part * @errp: pointer to a NULL initialized error object * * Add a new NAMED fw_cfg item with the content generated from the - * @gen_id object. The data generated by the @gen_id object is copied + * @part object. The data generated by the @part object is copied * into the data structure of the fw_cfg device. * The next available (unused) selector key starting at FW_CFG_FILE_FIRST * will be used; also, a new entry will be added to the file directory @@ -307,8 +308,9 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *filename, void *data, * * Returns: %true on success, %false on error. */ -bool fw_cfg_add_file_from_generator(FWCfgState *s, const char *filename, - const char *gen_id, Error **errp); +bool fw_cfg_add_file_from_generator(FWCfgState *s, + Object *parent, const char *part, + const char *filename, Error **errp); /** * fw_cfg_add_extra_pci_roots: diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index fe3b86135a7..b94cd27bd85 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -1027,22 +1027,23 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *filename, return NULL; } -bool fw_cfg_add_file_from_generator(FWCfgState *s, const char *filename, - const char *gen_id, Error **errp) +bool fw_cfg_add_file_from_generator(FWCfgState *s, + Object *parent, const char *part, + const char *filename, Error **errp) { FWCfgDataGeneratorClass *klass; GByteArray *array; Object *obj; gsize size; - obj = object_resolve_path_component(object_get_objects_root(), gen_id); + obj = object_resolve_path_component(parent, part); if (!obj) { - error_setg(errp, "Cannot find object ID '%s'", gen_id); + error_setg(errp, "Cannot find object ID '%s'", part); return false; } if (!object_dynamic_cast(obj, TYPE_FW_CFG_DATA_GENERATOR_INTERFACE)) { error_setg(errp, "Object ID '%s' is not a '%s' subclass", - gen_id, TYPE_FW_CFG_DATA_GENERATOR_INTERFACE); + part, TYPE_FW_CFG_DATA_GENERATOR_INTERFACE); return false; } klass = FW_CFG_DATA_GENERATOR_GET_CLASS(obj); diff --git a/system/vl.c b/system/vl.c index f103532a9a1..4a370da624a 100644 --- a/system/vl.c +++ b/system/vl.c @@ -1184,7 +1184,8 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp) size = strlen(str); /* NUL terminator NOT included in fw_cfg blob */ buf = g_memdup(str, size); } else if (nonempty_str(gen_id)) { - if (!fw_cfg_add_file_from_generator(fw_cfg, name, gen_id, errp)) { + if (!fw_cfg_add_file_from_generator(fw_cfg, object_get_objects_root(), + gen_id, name, errp)) { return -1; } return 0;