From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:57986) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RW6qo-0002Gf-BM for qemu-devel@nongnu.org; Thu, 01 Dec 2011 08:39:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RW6qi-0001Pk-G8 for qemu-devel@nongnu.org; Thu, 01 Dec 2011 08:38:58 -0500 Received: from mail-gy0-f173.google.com ([209.85.160.173]:39230) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RW6qi-0001Pg-Dj for qemu-devel@nongnu.org; Thu, 01 Dec 2011 08:38:52 -0500 Received: by ghbg19 with SMTP id g19so2345575ghb.4 for ; Thu, 01 Dec 2011 05:38:52 -0800 (PST) Message-ID: <4ED78369.8000009@codemonkey.ws> Date: Thu, 01 Dec 2011 07:38:49 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <1322687028-29714-1-git-send-email-aliguori@us.ibm.com> <1322687028-29714-16-git-send-email-aliguori@us.ibm.com> <20111201112139.GE31730@stefanha-thinkpad.localdomain> In-Reply-To: <20111201112139.GE31730@stefanha-thinkpad.localdomain> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 15/18] qom: optimize qdev_get_canonical_path using a parent link List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , Peter Maydell , Anthony Liguori , Stefan Hajnoczi , Jan Kiszka , qemu-devel@nongnu.org, Markus Armbruster , Luiz Capitulino On 12/01/2011 05:21 AM, Stefan Hajnoczi wrote: > On Wed, Nov 30, 2011 at 03:03:45PM -0600, Anthony Liguori wrote: >> @@ -1210,6 +1210,9 @@ void qdev_property_add_child(DeviceState *dev, const char *name, >> qdev_property_add(dev, name, type, qdev_get_child_property, >> NULL, NULL, child, errp); >> >> + g_assert(child->parent == NULL); >> + child->parent = dev; > > The implications are: > > 1. A DeviceState must be a child or the root. It is not okay to create > a DeviceState and inquire its canonical path before making it a child in > the graph. Correct. > > 2. A DeviceState can only be the child of one parent. Since > user-created devices are added to /peripheral or /peripheral-anon this > means that the /i440fx only has links to them, never a parent-child > relationship. Correct. /peripheral[-anon] are where user created devices live. Machine created devices live directly off of / Each "directory" ends up being a unique namespace. This ends up being a nice way to support compatibly since we have so many namespace today. I imagine, for instance, that we will end up with a /block directory too and that is where blockdev objects will live. > > Is this right? > >> + /* Do not, under any circumstance, use this parent link below anywhere >> + * outside of qdev.c. You have been warned. */ >> + DeviceState *parent; > > It would be nice to explain why parent is private to qdev.c. Composition is a unidirectional relationship. The parent pointer is there simply as an optimization. I'll make the comment a big scarier :-) Regards, Anthony Liguori