From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55080) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TO9RI-0005qY-4G for qemu-devel@nongnu.org; Tue, 16 Oct 2012 11:52:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TO9RA-0007bI-FD for qemu-devel@nongnu.org; Tue, 16 Oct 2012 11:52:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30180) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TO9RA-0007bB-6R for qemu-devel@nongnu.org; Tue, 16 Oct 2012 11:52:08 -0400 Message-ID: <507D82A4.1030203@redhat.com> Date: Tue, 16 Oct 2012 17:52:04 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1350329657-18665-1-git-send-email-aliguori@us.ibm.com> <1350329657-18665-7-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1350329657-18665-7-git-send-email-aliguori@us.ibm.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit 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: Anthony Liguori Cc: qemu-devel@nongnu.org, Andreas Faerber , Gerd Hoffmann 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... Paolo