All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lin Ma <lma@novell.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: pbonzini@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] object_del: Prevent removing an in-use memory backend object
Date: Mon, 23 Mar 2015 16:52:24 +0800	[thread overview]
Message-ID: <550FD448.2090906@novell.com> (raw)
In-Reply-To: <20150320111726.3727f305@nial.brq.redhat.com>


在 2015年03月20日 18:17, Igor Mammedov 写道:
> On Fri, 20 Mar 2015 12:14:58 +0800
> Lin Ma <lma@suse.com> wrote:
>
>> showing a memory device whose memdev is removed leads an assert:
>>
>> (qemu) object_add memory-backend-ram,id=ram0,size=128M
>> (qemu) device_add pc-dimm,id=d0,memdev=ram0
>> (qemu) object_del ram0
>> (qemu) info memory-devices
>> **
>> ERROR:qom/object.c:1274:object_get_canonical_path_component:\
>>                              assertion failed: (obj->parent != NULL)
>> Aborted
>>
>> The patch prevents removing an in-use mem backend and outputs an error msg.
>>
>> Signed-off-by: Lin Ma <lma@suse.com>
>> ---
>>   qmp.c | 14 ++++++++++++++
>>   1 file changed, 14 insertions(+)
>>
>> diff --git a/qmp.c b/qmp.c
>> index c479e77..0086e2d 100644
>> --- a/qmp.c
>> +++ b/qmp.c
>> @@ -704,6 +704,7 @@ void qmp_object_del(const char *id, Error **errp)
>>   {
>>       Object *container;
>>       Object *obj;
>> +    const char *typename;
>>   
>>       container = container_get(object_get_root(), "/objects");
>>       obj = object_resolve_path_component(container, id);
>> @@ -711,6 +712,19 @@ void qmp_object_del(const char *id, Error **errp)
>>           error_setg(errp, "object id not found");
>>           return;
>>       }
>> +
>> +    typename = object_class_get_name(object_class_get_parent(\
>> +                                        object_get_class(OBJECT(obj))));
>> +    if (strcmp(typename, TYPE_MEMORY_BACKEND) == 0 ) {
>> +        MemoryRegion *mr;
>> +        mr = host_memory_backend_get_memory(MEMORY_BACKEND(obj), errp);
>> +        if (memory_region_is_mapped(mr)) {
>> +            char *path = object_get_canonical_path_component(obj);
>> +            error_setg(errp, "memdev %s is in used.", path);
>> +            g_free(path);
>> +            return;
>> +        }
>> +    }
> How about making it more generic?
> i.e
>    if (!obj_class->can_be_deleted(obj))
>       error out
>
>>       object_unparent(obj);
>>   }
>>   
>
That makes sense, I couldn't agree more.
I am going to drop this patch and separate it to 2 patches. One for 
adding generic can_be_deleted
callback, The other for adding impl in hostmem-ram.c and hostmem-file.c

thanks,
Lin

  reply	other threads:[~2015-03-23  8:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-20  4:14 [Qemu-devel] [PATCH] object_del: Prevent removing an in-use memory backend object Lin Ma
2015-03-20 10:17 ` Igor Mammedov
2015-03-23  8:52   ` Lin Ma [this message]
2015-03-23  9:29   ` [Qemu-devel] 答复: " 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=550FD448.2090906@novell.com \
    --to=lma@novell.com \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.