From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:56073) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOD5j-00085y-Jy for qemu-devel@nongnu.org; Tue, 16 Oct 2012 15:46:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOD5i-0004vY-Cb for qemu-devel@nongnu.org; Tue, 16 Oct 2012 15:46:15 -0400 Received: from e5.ny.us.ibm.com ([32.97.182.145]:49245) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOD5i-0004vS-8S for qemu-devel@nongnu.org; Tue, 16 Oct 2012 15:46:14 -0400 Received: from /spool/local by e5.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 16 Oct 2012 15:46:10 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 37B5138C80B5 for ; Tue, 16 Oct 2012 15:45:09 -0400 (EDT) Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q9GJj7ZS079034 for ; Tue, 16 Oct 2012 15:45:08 -0400 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q9GJiiZE004068 for ; Tue, 16 Oct 2012 13:44:44 -0600 From: Anthony Liguori In-Reply-To: <507D82A4.1030203@redhat.com> References: <1350329657-18665-1-git-send-email-aliguori@us.ibm.com> <1350329657-18665-7-git-send-email-aliguori@us.ibm.com> <507D82A4.1030203@redhat.com> Date: Tue, 16 Oct 2012 14:44:41 -0500 Message-ID: <87zk3myzfa.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH 6/6] chardev: convert file backend to realize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org, Andreas Faerber , Gerd Hoffmann Paolo Bonzini writes: > Il 15/10/2012 21:34, Anthony Liguori ha scritto: >> +static char *chardev_file_get_path(Object *obj, Error **errp) >> +{ >> + CharDriverState *chr = CHARDEV(obj); >> + FDCharDriver *s = chr->opaque; >> + >> + return s->path ? g_strdup(s->path) : g_strdup(""); >> +} >> + >> +static void chardev_file_set_path(Object *obj, const char *value, Error **errp) >> +{ >> + CharDriverState *chr = CHARDEV(obj); >> + FDCharDriver *s = chr->opaque; >> + >> + if (chr->realized) { >> + error_set(errp, QERR_PERMISSION_DENIED); >> + return; >> + } >> + >> + if (s->path) { >> + g_free(s->path); >> + } >> + >> + s->path = g_strdup(value); >> +} >> + >> +static void chardev_file_initfn(Object *obj) >> +{ >> + CharDriverState *chr = CHARDEV(obj); >> + >> + object_property_add_str(obj, "path", chardev_file_get_path, chardev_file_set_path, NULL); >> +#ifndef _WIN32 >> + chr->opaque = CHARDEV_FILE(obj); >> +#endif >> +} >> + > > IMHO this really really calls for pushing static properties and realized > up to Object... I agree actually. But this doesn't add anything to Object, this just adds a new set of properties that are implemented entirely in terms of the existing property infrastructure. What I don't want to do though is push the notion of "realize" to Object. Instead, we should have a mechanism to "lock" read/write properties so they no longer are mutable. This should not affect the object's state but rather the individual property state. IOW, we shouldn't be adding anything to Object to do this. Regards, Anthony Liguori > > Paolo