qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 6/6] chardev: convert file backend to realize


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH 6/6] chardev: convert file backend to realize
Date: Tue, 16 Oct 2012 14:44:41 -0500
User-agent: Notmuch/0.13.2+93~ged93d79 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu)

Paolo Bonzini <address@hidden> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]