From nobody Tue Oct 28 12:15:19 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515076995403877.1968580150749; Thu, 4 Jan 2018 06:43:15 -0800 (PST) Received: from localhost ([::1]:39434 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eX6ji-00021F-Li for importer@patchew.org; Thu, 04 Jan 2018 09:43:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52380) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eX6hd-0000bn-Co for qemu-devel@nongnu.org; Thu, 04 Jan 2018 09:41:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eX6hZ-0002nD-HM for qemu-devel@nongnu.org; Thu, 04 Jan 2018 09:41:05 -0500 Received: from mail-qk0-x244.google.com ([2607:f8b0:400d:c09::244]:45318) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eX6hZ-0002mK-7w; Thu, 04 Jan 2018 09:41:01 -0500 Received: by mail-qk0-x244.google.com with SMTP id o126so2135327qke.12; Thu, 04 Jan 2018 06:41:01 -0800 (PST) Received: from x1.lan ([138.117.48.219]) by smtp.gmail.com with ESMTPSA id l188sm2223304qkd.36.2018.01.04.06.40.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jan 2018 06:40:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VckVE1NrM2CKq5LqdQMK+DG/tuT4iBPdy4x7DeuqZoY=; b=rnUJ2ykXMJtLHiX2tiAFHeLx5zwf8QBJssL+4Zp4aDwF4pD4hwY47LXlVW38dpKC+x 8tkQmXh4enqS7nJHAMHdxaMnWnhK1k0WJXj2yfsU+We8HFFRFS627IxmjBZNvIML5V7R z4g+Z+rAgeF61iMnNOx0pe7pdC04ZoHBxQRWfcKSKf/LA9XTzhvvZKcnb8IDgfeQc1Vw SZ7KJjW3M0blWsuUiXxQJl4nnNQ8VwPB/xtAbY023sj8CbGEfCsBzT0XuqUVBeHLUunX ZwTmwEqKCSXxJG59f6W8e9uZlQsFeW7d9e9dM7/WlgOijQjZf77o0HhrDDgs0E9l34Et b9eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=VckVE1NrM2CKq5LqdQMK+DG/tuT4iBPdy4x7DeuqZoY=; b=l4kCT1f8KAOrTb02i7naF0MmIv6z48ZcvqkfUZnE4n6hIulA0JVuK+MB/SdX8mKTt4 sM22SzHoFiT8E/xruBRPcUw9X6rgPobKA1yciBFaL+QGrVzvvz6U5SiLEj7rY85j+twU utRo/LJ1LuDyBaWOtVQclAPDugFw7e3UiequuaOAgqxiazMBsKqnnyTvpCTXwIv5g/2G /c0TD1MubyvAw4kMMH2JvfZC+A1AmOooI5DiX+bUEkZndEQhX7ZEn+hb5OX243GgdzsE KpOYGIj0/7TMOsIlq2Xsk/yLas73cV+3Us/NypQ334hiyPXWmVxPD8/njTr8VBnHyyAE 7Q5g== X-Gm-Message-State: AKGB3mKrXetFyP8XfpTz1R6WX+HMXOdl/vpKl3zghK+k5oN02+nL/Ia6 Vmm+Y5qPNG5qhw5NfOrcVH8= X-Google-Smtp-Source: ACJfBov6OV2AKz9lZ9pqw118dnsAf8p2v5SXNVec2mR17Aaj5c3VqWWRhlM4c5EDxWOJYkvsPaEP1Q== X-Received: by 10.55.128.196 with SMTP id b187mr6344263qkd.87.1515076860597; Thu, 04 Jan 2018 06:41:00 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Alistair Francis , "Edgar E . Iglesias" , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Igor Mammedov , Eduardo Habkost , Markus Armbruster , Sascha Silbe , Alexander Graf , Peter Crosthwaite Date: Thu, 4 Jan 2018 11:40:41 -0300 Message-Id: <20180104144046.30793-2-f4bug@amsat.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180104144046.30793-1-f4bug@amsat.org> References: <20180104144046.30793-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::244 Subject: [Qemu-devel] [RFC PATCH 1/6] qom: introduce TypeInfo name aliases X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, qemu-arm@nongnu.org, Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/qom/object.h | 3 +++ qom/object.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index dc73d59660..5d6e8795d4 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -428,6 +428,8 @@ struct Object * TypeInfo: * @name: The name of the type. * @parent: The name of the parent type. + * @aliases: A list of alias names for the type. This should point to a st= atic + * array that's terminated with a zero filled element. * @instance_size: The size of the object (derivative of #Object). If * @instance_size is 0, then the size of the object will be the size of = the * parent object. @@ -468,6 +470,7 @@ struct TypeInfo { const char *name; const char *parent; + const char **aliases; =20 size_t instance_size; void (*instance_init)(Object *obj); diff --git a/qom/object.c b/qom/object.c index c58c52d518..c532a8aa65 100644 --- a/qom/object.c +++ b/qom/object.c @@ -83,10 +83,15 @@ static GHashTable *type_table_get(void) =20 static bool enumerating_types; =20 -static void type_table_add(TypeImpl *ti) +static void type_table_add_with_key(TypeImpl *ti, const char *key_name) { assert(!enumerating_types); - g_hash_table_insert(type_table_get(), (void *)ti->name, ti); + g_hash_table_insert(type_table_get(), (void *)key_name, ti); +} + +static void type_table_add(TypeImpl *ti) +{ + type_table_add_with_key(ti, ti->name); } =20 static TypeImpl *type_table_lookup(const char *name) @@ -137,6 +142,15 @@ static TypeImpl *type_register_internal(const TypeInfo= *info) ti =3D type_new(info); =20 type_table_add(ti); + + if (info->aliases) { + int i; + + for (i =3D 0; info->aliases[i]; i++) { + type_table_add_with_key(ti, info->aliases[i]); + } + } + return ti; } =20 --=20 2.15.1