From: Lin Ma <lma@suse.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: pbonzini@redhat.com, peter.crosthwaite@xilinx.com,
afaerber@suse.de, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v5 1/2] qom: Add can_be_deleted callback to UserCreatableClass
Date: Sat, 28 Mar 2015 01:53:28 +0800 [thread overview]
Message-ID: <55159918.7020502@suse.com> (raw)
In-Reply-To: <20150327182029.39d6392f@nial.brq.redhat.com>
在 2015年03月28日 01:20, Igor Mammedov 写道:
> On Sat, 28 Mar 2015 00:55:29 +0800
> Lin Ma <lma@suse.com> wrote:
>
>> If backends implement the can_be_deleted and it returns false,
>> Then the qmp_object_del won't delete the given backends.
>>
>> Signed-off-by: Lin Ma <lma@suse.com>
>> ---
>> include/qom/object_interfaces.h | 14 ++++++++++++++
>> qmp.c | 5 +++++
>> qom/object_interfaces.c | 14 ++++++++++++++
>> 3 files changed, 33 insertions(+)
>>
>> diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
>> index b792283..012b653 100644
>> --- a/include/qom/object_interfaces.h
>> +++ b/include/qom/object_interfaces.h
>> @@ -25,6 +25,8 @@ typedef struct UserCreatable {
>> * UserCreatableClass:
>> * @parent_class: the base class
>> * @complete: callback to be called after @obj's properties are set.
>> + * @can_be_deleted: callback to be called before an object is removed
>> + * to check if @obj can be removed safely.
>> *
>> * Interface is designed to work with -object/object-add/object_add
>> * commands.
>> @@ -47,6 +49,7 @@ typedef struct UserCreatableClass {
>>
>> /* <public> */
>> void (*complete)(UserCreatable *uc, Error **errp);
>> + bool (*can_be_deleted)(UserCreatable *uc, Error **errp);
>> } UserCreatableClass;
>>
>> /**
>> @@ -59,4 +62,15 @@ typedef struct UserCreatableClass {
>> * nothing.
>> */
>> void user_creatable_complete(Object *obj, Error **errp);
>> +
>> +/**
>> + * user_creatable_can_be_deleted:
>> + * @obj: the object whose can_be_deleted() method is called if defined
> s/obj/uc/
> s/defined/implemented/
>
>> + * @errp: if an error occurs, a pointer to an area to store the error
>> + *
>> + * Wrapper to call can_be_deleted() method if one of types it's inherited
>> + * from implements USER_CREATABLE interface, otherwise the call does
>> + * nothing.
> drop ", otherwise the call does nothing"
>
>> +bool user_creatable_can_be_deleted(Object *obj, Error **errp);
> [...]
>>
>> +bool user_creatable_can_be_deleted(Object *obj, Error **errp)
>> +{
>> +
>> + UserCreatableClass *ucc;
>> + UserCreatable *uc = USER_CREATABLE(obj);
> Function description doesn't match what it does, I mean part
> "otherwise the call does nothing."
>
> How about changing prototype to:
>
> bool user_creatable_can_be_deleted(UserCreatable *uc, Error **errp)
>
> and calling it in qmp.c like:
> user_creatable_can_be_deleted(USER_CREATABLE(obj), errp);
That makes sense.
But If so, Does prototype of user_creatable_complete need to be changed
as well by a new patch?
next prev parent reply other threads:[~2015-03-27 17:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-27 16:55 [Qemu-devel] [PATCH v5 0/2] Add generic can_be_deleted to UserCreatableClass Lin Ma
2015-03-27 16:55 ` [Qemu-devel] [PATCH v5 1/2] qom: Add can_be_deleted callback " Lin Ma
2015-03-27 17:20 ` Igor Mammedov
2015-03-27 17:53 ` Lin Ma [this message]
2015-03-30 12:02 ` Igor Mammedov
2015-03-27 16:55 ` [Qemu-devel] [PATCH v5 2/2] hostmem: Prevent removing an in-use memory backend Lin Ma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55159918.7020502@suse.com \
--to=lma@suse.com \
--cc=afaerber@suse.de \
--cc=imammedo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.crosthwaite@xilinx.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).