From patchwork Fri Dec 6 18:13:48 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: 847849 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c2:0:b0:385:e875:8a9e with SMTP id f2csp926833wrt; Fri, 6 Dec 2024 10:14:43 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUE/OynbWJMUGsSaPqxiUpiZDGolaPkarre4JCtn8s03wiJgFCyJ4J9+fIf5aHRmg8h2i21Hg==@linaro.org X-Google-Smtp-Source: AGHT+IHnW5CBrYnOTXP9DM7HCavo/8luMuPfLz3s2xnRrilXTPqSTGGWtOIIOx5999+OYIjI8gcW X-Received: by 2002:a05:620a:3905:b0:7b6:67e1:b4ff with SMTP id af79cd13be357-7b6bc996dd1mr771357385a.28.1733508883434; Fri, 06 Dec 2024 10:14:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733508883; cv=none; d=google.com; s=arc-20240605; b=A4fM+6mdhjrDE29k9oHOYoPjGpZzFxyeWiYYq5LUFLiy4jBFtNjD6QSOfK3djDuImQ z/Di6PhAZYMqaxsHFxR4yfJbc0sym1QQR9xNzMPOnGpT1MGKjGLC4RcR+UGPXr1wp1wx VPqqL7W2ak2tvK7h6loE4NZwy+rqIXTjYJGh5AugytI5ANG8XK25LaSLmZi5nfc2cyv7 3c0HMN41FCOz6sgV7ASYzIruqJvidWCzfFZMdj7Z05nLmgXk7qtW/BGGI0OEi1u598wi nZ83IBGG2bHAiOmckhpxeMNs1IGTXyHEyJaTcDet6m8NvbfN1PE1CJ+AV7iPEnk1Gmww tubQ== 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=jcfKXIJuNiuvzm2ydvBx89mK8MIYUVOg22CEhEE1H9M=; fh=3wK/0BWpYKKByqhpnDce4GYDJpf0QpS0zq5lyeSr+sc=; b=VtaEp2Y6Npt41FSj48Y6zhXUuxsu/1OvPPS9oUKnViYSPsO9Lv2xcqdukqV8vPjrEH zvkdnjkiLiWMx4ZFWMCFfJ96w9qCeoVnLF6yL+gPM5JNVKRIUTc26aRpJige8/K/yGdZ 5UGGJPu7tyxpGobMvLHw8sEFIelbNLmQgW/TyqWDwsWG06LwBzgJtmKUdRspur/1SQWL LZR6P7hxnLH3baGVO2c7ubwnQBWBRTXHA3CK4nm6b4e9Jlu0U4TQ+ik/uJ7fsfnchgfo jEt541urHjEb2G5nj1Pg+CNsdPeKE13HP+BumSJEuUgA9cBLmpK4DtUbAFnWx2HUWahi SkFw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zAuPiWqk; 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 af79cd13be357-7b6b5ad40b0si481300085a.705.2024.12.06.10.14.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Dec 2024 10:14:43 -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=zAuPiWqk; 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 1tJcqN-0001Mm-QN; Fri, 06 Dec 2024 13:14:23 -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 1tJcqM-0001ME-Ge for qemu-devel@nongnu.org; Fri, 06 Dec 2024 13:14:22 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tJcqK-0005PW-Id for qemu-devel@nongnu.org; Fri, 06 Dec 2024 13:14:22 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-434a83c6b01so16139105e9.0 for ; Fri, 06 Dec 2024 10:14:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733508859; x=1734113659; 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=jcfKXIJuNiuvzm2ydvBx89mK8MIYUVOg22CEhEE1H9M=; b=zAuPiWqkUAnLyuapXuXWEa131/B1BmQA9ITE/9cAbPclCeqTdqLr0A3RLUpiWrgV6T Fb2sOzPZ2BXs19DyNah3CcpAdYKxWiKJ70QRvjM/9/Q5caiHaKDle1gGtk/IkSqMt0+S L0ZrUX83W5uQGa9Xet8s4/bW5/tnX72fOi8WaYSPj+SyzewVOQ4IvXzcGEMt2iEjxDM3 xSpRVL7e8nS51i4ZcZ7NxUC47FSpbbctEzHnfDBde+Acv8lNEethhBiOa4183a+4IXEA H36W5jZMain9Gumq2PzDOQgKbhsH6x1DOXnPzoyyW6ALd5AsIpiLrxyeVeRMKl9w/1qn 0J5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733508859; x=1734113659; 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=jcfKXIJuNiuvzm2ydvBx89mK8MIYUVOg22CEhEE1H9M=; b=hC4gZ9V7FD1HBRbpzQlfxHlZ8xXJ7rarkD1jnDEV/bLYU3xvRYifSIIjlptrGrK1TN 95DEIo+zCYuM8kX29Hs/DQJVEuazM3ooKOfsnVubwryuhdHggArP0b5jInDFF3tcanEk pP123dTviUqgf4Y+xWGmGEOlmjQ4MolNNflpdIAJeapFKhyqhwu4zRBI+E3Rti4K1IQG OwtPuhitA5tiTYBiPxWcwOCVjE1WznmK1Jry5Qrdc1eDdfjz6+2RTgd12vUIkgcp/J3o Ma1D5SBoAYvKhNWkMb92KOxtH9L/LED4bVYraS5QR/A67ArDjMYT2EE5nVro3vPVE9cM 8YxA== X-Forwarded-Encrypted: i=1; AJvYcCWtMEuNLIjteSB9ig8QHZWxURMBKwFRQsjXMVnkDgrvjQ2OggVdbld9wIlWqwU5Z3zahgvJcyQvuoo5@nongnu.org X-Gm-Message-State: AOJu0Yw+TYtw/agraK1qJYgcKDkuwzqsREZhlAj9uMOnLCcH15CTx3n2 q+HGeQ3SmmdJKoYGOyx992njIjDjdJHBI9GpTwQQE+OKmcwqCI81bvFOYpK+f5Q= X-Gm-Gg: ASbGncuTEfqkGwiZ1sCids8e2zp2IDyFysRyhg5nz/Lv/TYbA4g4zGHdEf0YNpU8AT/ +31g7wkfEACUu0lpvN0Be5IVglcderoN9Hz6HyOHoM2JqeXIBnUfT1FJ8HQvu2MlYxhllgxI4QA vNMLe4ivMfpiiHzEo9G291DOQxiRh+JqtUKmH2cLG0Ra5F+SUD/C2UAL87G1vDLHIjQdjt8ES8/ n1/DIJbsU1APsk/QQh5Z0aWyPv3ovaZL7xmizcd6qOVF6svEiamEP+avxbzk9JnyV4= X-Received: by 2002:a05:600c:19c7:b0:434:a781:f5d2 with SMTP id 5b1f17b1804b1-434ddea7f36mr35413855e9.5.1733508857333; Fri, 06 Dec 2024 10:14:17 -0800 (PST) Received: from localhost.localdomain ([95.127.41.180]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-434d5272f99sm98988715e9.11.2024.12.06.10.14.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Dec 2024 10:14:15 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Jiahui Cen , qemu-devel@nongnu.org Cc: Gerd Hoffmann , Eduardo Habkost , Gustavo Romero , Paolo Bonzini , Marcel Apfelbaum , "Michael S. Tsirkin" , Richard Henderson , Zhao Liu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bernhard Beschow Subject: [PATCH 2/6] hw/nvram/fw_cfg: Pass QOM parent to fw_cfg_add_file_from_generator() Date: Fri, 6 Dec 2024 19:13:48 +0100 Message-ID: <20241206181352.6836-3-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206181352.6836-1-philmd@linaro.org> References: <20241206181352.6836-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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=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+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é --- 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;