From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:53818) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RW6w7-00077d-8q for qemu-devel@nongnu.org; Thu, 01 Dec 2011 08:44:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RW6w1-0002tj-M7 for qemu-devel@nongnu.org; Thu, 01 Dec 2011 08:44:27 -0500 Received: from mail-yx0-f173.google.com ([209.85.213.173]:57244) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RW6w1-0002tW-GA for qemu-devel@nongnu.org; Thu, 01 Dec 2011 08:44:21 -0500 Received: by yenq3 with SMTP id q3so2229469yen.4 for ; Thu, 01 Dec 2011 05:44:21 -0800 (PST) Message-ID: <4ED784B3.8060800@codemonkey.ws> Date: Thu, 01 Dec 2011 07:44:19 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <1322687028-29714-1-git-send-email-aliguori@us.ibm.com> <1322687028-29714-8-git-send-email-aliguori@us.ibm.com> <4ED76325.6080305@redhat.com> In-Reply-To: <4ED76325.6080305@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 07/18] qom: add link properties List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity 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, Avi Kivity wrote: > On 11/30/2011 11:03 PM, Anthony Liguori wrote: >> Links represent an ephemeral relationship between devices. They are meant to >> replace the qdev concept of busses by allowing more informal relationships >> between devices. > > So, links are equivalent to pointers? Yup. Once we have qom inheritance (next stage), we can have a link property and you'll be able to set it to an E1000State with the appropriate casting and error checking taking place. >> Links are fairly limited in their usefulness without implementing QOM-style >> subclassing and interfaces. >> >> >> +static void qdev_get_link_property(DeviceState *dev, Visitor *v, void *opaque, >> + const char *name, Error **errp) >> +{ >> + DeviceState **child = opaque; >> + gchar *path; >> + >> + if (*child) { >> + path = qdev_get_canonical_path(*child); >> + visit_type_str(v,&path, name, errp); >> + g_free(path); >> + } else { >> + path = (gchar *)""; > > If gchar != char, this is wrong. Also, you're converting a const > pointer into a non-const pointer, discarding type safety. I'll address this later in the thread. >> + visit_type_str(v,&path, name, errp); >> + } > > Shouldn't this be visit_type_link()? link isn't a primitive type for visitors. visit_type_link() would just call visit_type_str() so I don't think there's a ton of value in introducing the extra layer. The accessors are the only places that should be marshaling links. Regards, Anthony Liguori >